using namespace std;
bool IsDebugging( )
{
if ( IsDebuggerPresent( ) || IsDebuggerPresentPEB( ) || CheckRemoteDebuggerPresentAPI( )
|| NtQueryInformationProcess_ProcessDebugPort( ) || NtQueryInformationProcess_ProcessDebugFlags( ) || NtQueryInformationProcess_ProcessDebugObject( )
|| NtSetInformationThread_ThreadHideFromDebugger( ) || CloseHandle_InvalideHandle( ) || UnhandledExcepFilterTest( )
|| HardwareBreakpoints( ) || SoftwareBreakpoints( ) || Interrupt_3( ) || MemoryBreakpoints_PageGuard( )
|| NtQueryObject_ObjectTypeInformation( ) || SetHandleInformatiom_ProtectedHandle( ) )
return true;
return false;
}
bool IsAnalysing( )
{
auto m_fnIsRemoteSession = [ ] ( ) -> bool
{
const int m_iSessionMetrics = GetSystemMetrics( SM_REMOTESESSION );
return m_iSessionMetrics != 0;
};
string m_szProcesses[ ] =
{
_xor_("ollydbg.exe"), // OllyDebug debugger
_xor_("ProcessHacker.exe"), // Process Hacker
_xor_("tcpview.exe"), // Part of Sysinternals Suite
_xor_("autoruns.exe"), // Part of Sysinternals Suite
_xor_("autorunsc.exe"), // Part of Sysinternals Suite
_xor_("filemon.exe"), // Part of Sysinternals Suite
_xor_("procmon.exe"), // Part of Sysinternals Suite
_xor_("regmon.exe"), // Part of Sysinternals Suite
_xor_("procexp.exe"), // Part of Sysinternals Suite
_xor_("idaq.exe"), // IDA Pro Interactive Disassembler
_xor_("ida.exe"), // IDA Pro Interactive Dissasembler
_xor_( "idaq64.exe"), // IDA Pro Interactive Disassembler
_xor_("ImmunityDebugger.exe"), // ImmunityDebugger
_xor_("Wireshark.exe"), // Wireshark packet sniffer
_xor_("dumpcap.exe"), // Network traffic dump tool
_xor_("HookExplorer.exe"), // Find various types of runtime hooks
_xor_("ImportREC.exe"), // Import Reconstructor
_xor_("PETools.exe"), // PE Tool
_xor_("LordPE.exe"), // LordPE
_xor_("dumpcap.exe"), // Network traffic dump tool
_xor_("SysInspector.exe"), // ESET SysInspector
_xor_("proc_analyzer.exe"), // Part of SysAnalyzer iDefense
_xor_("sysAnalyzer.exe"), // Part of SysAnalyzer iDefense
_xor_("sniff_hit.exe"), // Part of SysAnalyzer iDefense
_xor_("windbg.exe"), // Microsoft WinDbg
_xor_("joeboxcontrol.exe"), // Part of Joe Sandbox
_xor_("joeboxserver.exe"), // Part of Joe Sandbox
_xor_("x32dbg.exe"), // x32dbg
_xor_("x64dbg.exe"), // x64dbg
_xor_("x96dbg.exe"), // x64dbg part
_xor_("ida64.exe"),
_xor_("httpdebugger.exe"),
_xor_("cheatengine-x86_64.exe")
};
utils util;
WORD m_iLength = sizeof( m_szProcesses ) / sizeof( m_szProcesses[ 0 ] );
for ( int i = 0; i < m_iLength; i++ )
{
if (util.GetProcIDFromName( m_szProcesses[ i ].c_str( ) ) )
return true;
}
return ( m_fnIsRemoteSession());
}
void HandleUserActivity( )
{
if ( IsDebugging( ) || IsAnalysing( ) )
{
ErasePEHeaderFromMemory( );
HANDLE m_hProcess = LI_FN( OpenProcess )( PROCESS_QUERY_INFORMATION | PROCESS_TERMINATE, 0, GetCurrentProcessId( ) );
TerminateProcess( m_hProcess, 0 );
}
}
bool isflex() {
if (IsDebugging() || IsAnalysing()) {
return true;
}
return false;
}