-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDomainMultiplier.php
More file actions
221 lines (190 loc) · 5.71 KB
/
DomainMultiplier.php
File metadata and controls
221 lines (190 loc) · 5.71 KB
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
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
<?php
/*
** Domain Multiplier v1.0
** Utilizado para multiplicar lista de domínios.
** Coded by Constantine - 07/2015 - https://github.com/jessesilva
** Shadow Network: https://github.com/Shadow-Network
*/
error_reporting(0);
/*
** Inicializa aplicação.
*/
if (($application = new Application()) != null && $application->status() === true) {
$application->startup();
$application->close();
} else
die("Error to create class Application.\n");
/*
** Classe de controle da aplicação.
*/
class Application {
private $flag;
private $domainList;
private $outputFullURLFile;
private $outputDomainFile;
private $counter;
private $step;
/* Inicializa classe. */
public function __construct() {
$this->zeroClass();
$this->flag = true;
}
/* Retorna estado da classe. */
public function status() {
return $this->flag;
}
/* Núcleo da classe. */
public function startup() {
if ($_SERVER['argc'] != 2)
$this->showBanner();
if (!file_exists($_SERVER['argv'][1])) {
print " File not exists: {$_SERVER['argv'][1]}\n";
$this->close();
}
if ($this->check($_SERVER['argv'][1]) === false)
die(" Invalid argument.\n");
$this->domainList = $_SERVER['argv'][1];
$this->outputFullURLFile = "{$_SERVER['argv'][1]}-full_url.txt";
$this->outputDomainFile = "{$_SERVER['argv'][1]}-domain.txt";
if (($fp = fopen($this->domainList, 'r')) !== false) {
while (!feof($fp)) {
$IPv4 = gethostbyname(str_replace(array("\n", "\r"), '', fgets($fp)));
if ($this->check($IPv4) === true)
$this->bing("ip:{$IPv4}");
}
fclose($fp);
}
}
/*
** Faz busca em todas páginas do Bing.
** @param $dork Query de busca.
*/
private function bing($dork) {
for ($page = 0; ; $page++) {
if (($sock = fsockopen('www.bing.com', 80, $e, $err, 3)) === false)
continue;
$header = "GET /search?q={$dork}&first={$page}1&FORM=PERE HTTP/1.1\r\n";
$header .= "User-Agent: Mozilla/5.0 (Windows NT 6.1; Trident/7.0; SLCC2; ";
$header .= ".NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; ";
$header .= "Media Center PC 6.0; .NET4.0C; .NET4.0E; rv:11.0) like Gecko\r\n";
$header .= "Host: www.bing.com\r\n";
$header .= "Connection: close\r\n\r\n";
fputs($sock, $header);
$response = "";
while (!feof($sock))
$response .= fread($sock, 8192);
fclose($sock);
if ($this->check($response) === true) {
preg_match_all('!https?://\S+!', $response, $matches);
$urls = $matches[0];
for ($index = 0; $this->check($urls[$index]) === true; $index++) {
$url = explode("://", $urls[$index]);
$url = explode("\"", $url[1]);
$url = explode("/", $url[0]);
if ($this->filter($url[0]) === true) {
$this->showInformation($url[0]);
$this->save($urls[$index], $url[0]);
}
}
} else
break;
if (!strstr($response, 'class="sb_pagN"'))
break;
}
}
/* Encerra aplicação. */
public function close() {
$this->zeroClass();
if ($_SERVER['argc'] == 2)
die("\n Application finished.\n");
exit();
}
/*
** Verifica se existem dados em variável.
** @param $buffer Dados a serem analisados.
** @return Se existirem dados retorna 'true', caso contrário 'false'.
*/
private function check($buffer) {
if ($buffer) {
if (!empty($buffer))
if (strlen($buffer) > 0)
if ($buffer != "")
return true;
}
return false;
}
/* Zera atributos da classe. */
private function zeroClass() {
$this->flag = false;
$this->domainList = null;
$this->outputFullURLFile = null;
$this->outputDomainFile = null;
$this->counter = 0;
$this->step = 0;
}
/*
** Exibe informações no terminal.
** @param $buffer Dados a serem exibidos.
*/
private function showInformation($buffer) {
if ($this->step == 0) {
print "\n Starting...\n\n";
$this->step = 1;
}
print " [{$this->counter}] -> {$buffer} extracted!\n";
$this->counter++;
}
/*
** Verifica se URL não está na blacklist.
** @param $buffer Dados a serem salvos.
** @return Se for uma URL válida retorna 'true', caso contrário 'false'.
*/
private function filter($buffer) {
if ($this->check($buffer) === false)
return false;
$strings = array(
"microsoft.com", "msn.com", "w3.org", "live.com", "microsofttranslator.com",
"sandyclough.com", "bingj.com", "http://\"+_d.domain+\"/\"", "google.com", null);
for ($index = 0; $strings[$index] !== null; $index++)
if (strstr($buffer, $strings[$index]))
return false;
$status = false;
if (($fp = fopen($this->outputDomainFile, 'r')) !== false) {
while (!feof($fp)) {
if (strstr(fgets($fp), $buffer)) {
$status = true; break;
}
}
fclose($fp);
}
if ($status === true)
return false;
return true;
}
/*
** Salva dados em arquivos de saída.
** @param $fullUrl URL completa.
** @param $domain Domínio.
*/
private function save($fullUrl, $domain) {
$fullUrlContent = explode("\"", $fullUrl);
if (($fp = fopen($this->outputFullURLFile, 'a+')) !== false) {
fwrite($fp, $fullUrlContent[0] . "\n");
fclose($fp);
}
if (($fp = fopen($this->outputDomainFile, 'a+')) !== false) {
fwrite($fp, $domain . "\n");
fclose($fp);
}
}
/* Exibe banner da aplicação. */
private function showBanner() {
print "\n Domain Multiplier - 07/2015 - Greatz for L1sbeth\n\n";
print " Use: php {$_SERVER['argv'][0]} list_of_domains.txt\n\n";
print " Output files: \n";
print " -> list_of_domains-full_url.txt = Full URL.\n";
print " -> list_of_domains-domain.txt = Domain.\n\n";
$this->close();
}
}
?>