forked from Tuhinshubhra/RED_HAWK
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rhawk.php
484 lines (452 loc) · 18.5 KB
/
rhawk.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
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
<?php
error_reporting(0);
$blue = "\e[34m";
$lblue = "\e[36m";
$cln = "\e[0m";
$green = "\e[92m";
$fgreen = "\e[32m";
$red = "\e[91m";
$bold = "\e[1m";
echo"\n\e[91m
---------------------------------------------------------------------------
██████╗ ███████╗██████╗ ██╗ ██╗ █████╗ ██╗ ██╗██╗ ██╗
██╔══██╗██╔════╝██╔══██╗ ██║ ██║██╔══██╗██║ ██║██║ ██╔╝
██████╔╝█████╗ ██║ ██║ ███████║███████║██║ █╗ ██║█████╔╝
██╔══██╗██╔══╝ ██║ ██║ ██╔══██║██╔══██║██║███╗██║██╔═██╗
██║ ██║███████╗██████╔╝ ██║ ██║██║ ██║╚███╔███╔╝██║ ██╗
╚═╝ ╚═╝╚══════╝╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚══╝╚══╝ ╚═╝ ╚═╝
$bold
All In One Tool For Info Gathering, SQL Vulnerability Scannig and Crawling
$fgreen
---------------------------------------------------------------------------
[+] Coded By - R3D#@X0R_2H1N A.K.A Tuhinshubhra
$lblue [+] Version - 1.1.0
---------------------------------------------------------------------------
\n";
thephuckinstart :
echo "\n\e[0m".$blue."Enter Your Choice (help/fix/domain) : $green";
$ip=trim(fgets(STDIN,1024));
if ($ip == "help"){
echo"\n\n[+] RED HAWK Help Screen [+] \n\n";
echo $bold.$lblue."Commands\n";
echo "========\n";
echo $fgreen."[1] help:$cln View The Help Menu\n";
echo $bold.$fgreen."[2] fix:$cln Installs All Required Modules (Suggested If You Are Running The Tool For The First Time)\n";
echo $bold.$fgreen."[3] URL:$cln Enter The Domain Name Which You Want To Scan (Format:www.sample.com / sample.com)\n";
goto thephuckinstart;
}
elseif ($ip == "fix") {
echo "\e[91m\e[1m[+] RED HAWK FiX MENU [+]\n$cln";
echo "\e[32m[+] Installing Required Modules ...\n";
echo "\e[32m[+] Installing cURL ...\e[0m";
system ("sudo apt-get -qq --assume-yes install php-curl");
echo "\n\e[32m[i]$bold cURL Installed Successfully!\e[0m";
echo "\n\e[32m[+] Installing php-xml ...\e[0m";
system ("sudo apt-get -qq --assume-yes install php-xml");
echo "\n\e[32m[i]$bold php-XML Installed Successfully!\e[0m";
echo "\n\e[32m[+] Setting Things Up ...\n\e[0m";
echo "\e[32m[#]$bold JOB FINISHED SUCCESSFULLY! Starting RED HAWK ...\n\e[0m";
goto thephuckinstart;
}
elseif (strpos($ip,'://') !== false){ echo "Enter URL Without Http/Https\n"; goto thephuckinstart ;}
elseif (strpos($ip,'.') == false ) { echo "Enter A Valid URL\n"; goto thephuckinstart ;}
else
{
echo "\nDo The Website Have HTTPS Enabled ?\n";
echo $bold."1. No \n2. Yes";
echo $cln."\nInput Choice (1/2): ";
$ipsl = trim(fgets(STDIN,1024));
if ($ipsl == "2") {
$ipsl = "https://";
}
else {
$ipsl = "http://";
}
echo"\n$cln"."$lblue"."[+] Scanning Begins ... \n";
echo"$blue"."[i] Scanning Site:\e[92m $ipsl"."$ip \n";
echo "\n\n";
//----------------------------------------------------------//
// Basic Scans
//----------------------------------------------------------//
echo "\n$bold"."$lblue"."B A S I C I N F O \n";
echo "====================\n";
echo"\n\e[0m";
//website ip
$wip = gethostbyname($ip);
echo"\n$blue"."[+] IP address: ";
echo "\e[92m";
echo $wip ."\n\e[0m";
//detect webserver
$urlws = $ipsl.$ip;
$wsheaders = get_headers($urlws, 1);
echo"$blue"."[+] Web Server: ";
$ws = $wsheaders['Server'];
if ($ws == ""){echo "\e[91mCould Not Detect\e[0m";}
else { echo "\e[92m$ws \e[0m";}
echo"\n";
//detect CMS
$cmsurl = $ipsl.$ip;
$cmssc = file_get_contents($cmsurl);
if (strpos($cmssc,'/wp-content/') !== false){$tcms="\e[92mWordPress";}else{
if (strpos($cmssc,'Joomla') !== false){$tcms="\e[92mJoomla";}else{
$drpurl= $ipsl.$ip."/misc/drupal.js";
$drpsc = file_get_contents($drpurl);
if (strpos($drpsc,'Drupal') !== false){$tcms= "\e[92mDrupal";}else{
if (strpos($cmssc,'/skin/frontend/') !== false){$tcms="\e[92mMagento";}else{
$tcms="\e[91mCould Not Detect";
}}}}
echo "$blue"."[+] CMS: $tcms \e[0m";
//detect cloudflare
echo"\n$blue"."[+] Cloudflare: ";
$urlhh= "http://api.hackertarget.com/httpheaders/?q=". $ip;
$resulthh = file_get_contents ($urlhh);
if (strpos($resulthh,'cloudflare') !== false){
echo "\e[91mDetected\n\e[0m";
}
else {
echo "\e[92mNot Detected\n\e[0m";
}
//detect robots.txt
echo"$blue"."[+] Robots File: ";
$rbturl = $ipsl.$ip."/robots.txt";
$rbthandle = curl_init($rbturl);
curl_setopt($rbthandle, CURLOPT_RETURNTRANSFER, TRUE);
$rbtresponse = curl_exec($rbthandle);
$rbthttpCode = curl_getinfo($rbthandle, CURLINFO_HTTP_CODE);
if($rbthttpCode == 200) {
$rbtcontent = file_get_contents($rbturl);
if ($rbtcontent == ""){
echo "Found But Empty!";
}
else{
echo $green."Found $cln \n";
echo $blue ."\n -------------[ contents ]---------------- $cln \n";
echo $rbtcontent;
echo "\n-----------[end of contents]-------------";
}
}
else
{
echo $red."Could NOT Find robots.txt! $cln \n";
}
//The scans starts here
echo "\n\n$cln";
echo "\n\n$bold".$lblue."W H O I S L O O K U P\n";
echo "========================";
echo"\n\n$cln";
$urlwhois= "http://api.hackertarget.com/whois/?q=". $ip;
$resultwhois = file_get_contents ($urlwhois);
echo"\t";
echo $resultwhois ;
echo"\n\n$cln";
echo"\n\n$bold".$lblue."G E O I P L O O K U P\n";
echo "=========================";
echo"\n\n$cln";
$urlgip= "http://api.hackertarget.com/geoip/?q=". $ip;
$resultgip = file_get_contents ($urlgip);
echo $resultgip ;
echo "\n\n$cln";
echo "\n\n$bold".$lblue."H T T P H E A D E R S\n";
echo "=======================";
echo"\n\n$cln";
echo $resulthh ;
echo "\n\n";
echo "\n\n$bold".$lblue."D N S L O O K U P\n";
echo "===================";
echo"\n\n$cln";
$urldlup= "http://api.hackertarget.com/dnslookup/?q=". $ip;
$resultdlup = file_get_contents ($urldlup);
echo $resultdlup ;
echo "\n\n";
echo "\n\n$bold".$lblue."S U B N E T C A L C U L A T I O N\n";
echo "====================================";
echo"\n\n$cln";
$urlscal= "http://api.hackertarget.com/subnetcalc/?q=". $ip;
$resultscal = file_get_contents ($urlscal);
echo $resultscal ;
echo "\n\n";
echo "\n\n$bold".$lblue."N M A P P O R T S C A N\n";
echo "============================";
echo"\n\n$cln";
$urlnmap= "http://api.hackertarget.com/nmap/?q=". $ip;
$resultnmap = file_get_contents ($urlnmap);
echo $resultnmap ;
echo "\n";
//----------------------------------------------------------//
// Subdomains Finder
//---------------------------------------------------------//
echo "\n\n$bold".$lblue."S U B - D O M A I N F I N D E R\n";
echo "==================================";
echo"\n\n";
$urlsd= "http://api.hackertarget.com/hostsearch/?q=". $ip;
$resultsd = file_get_contents ($urlsd);
$subdomains = explode("\n", $resultsd);
$sdcount = count($subdomains);
$sdcount = $sdcount - 1;
echo "\n$blue"."[i] Total Subdomains Found :$cln ".$green .$sdcount."\n\n$cln";
foreach ($subdomains as $subdomain) {
//echo ;
echo "[+] Subdomain:$cln $fgreen".(str_replace(",","\n\e[0m[-] IP:$cln $fgreen",$subdomain));
echo "\n\n$cln";
}
echo "\n\n";
//----------------------------------------------------------//
// Reverse IP scan
//----------------------------------------------------------//
echo "\n\n$bold".$lblue."R E V E R S E I P L O O K U P\n";
echo "==================================";
echo"\n\n";
$sth = 'http://domains.yougetsignal.com/domains.php';
$ch = curl_init($sth);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1 ); curl_setopt($ch, CURLOPT_POSTFIELDS, "remoteAddress=$ip&ket=");
curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_POST, 1);
$resp = curl_exec($ch); $resp = str_replace("[","", str_replace("]","", str_replace("\"\"","", str_replace(", ,",",", str_replace("{","", str_replace("{","", str_replace("}","", str_replace(", ",",", str_replace(", ",",", str_replace("'","", str_replace("'","", str_replace(":",",", str_replace('"','', $resp ) ) ) ) ) ) ) ) ) ))));
$array = explode(",,", $resp);
unset($array[0]);
echo "\n$blue"."[i] Total Sites Found On This Server :$cln ".$green .count($array)."\n\n$cln";
foreach($array as $izox) {
// echo"\n";
echo "\n$blue"."[#]$cln ".$fgreen.$izox.$cln;
echo"\n$blue"."[-] CMS:$cln $green";
$cmsurl = $ipsl.$izox;
$cmssc = file_get_contents($cmsurl);
if (strpos($cmssc,'/wp-content/') !== false){$tcms="WordPress";}else{
if (strpos($cmssc,'Joomla') !== false){$tcms="Joomla";}else{
$drpurl= $ipsl.$ip."/misc/drupal.js";
$drpsc = file_get_contents($drpurl);
if (strpos($drpsc,'Drupal') !== false){$tcms= "Drupal";}else{
if (strpos($cmssc,'/skin/frontend/') !== false){$tcms="Magento";}else{
$tcms=$red."Could Not Detect$cln ";
}}}}
echo $tcms ."\n";
}
//----------------------------------------------------------//
// SQL
//----------------------------------------------------------//
echo "\n\n";
echo "\n\n$bold".$lblue."S Q L V U L N E R A B I L I T Y S C A N N E R\n";
echo "===================================================$cln";
echo"\n";
$lulzurl = $ipsl.$ip;
$html = file_get_contents($lulzurl);
$dom = new DOMDocument;
@$dom->loadHTML($html);
$links = $dom->getElementsByTagName('a');
$vlnk = 0;
foreach ($links as $link){
$lol= $link->getAttribute('href');
if( strpos( $lol, '?' ) !== false ){
echo"\n$blue [#] ".$fgreen .$lol ."\n$cln";
echo$blue." [-] Searching For SQL Errors: ";
$sqllist = file_get_contents('sqlerrors.ini');
$sqlist = explode(',', $sqllist);
if (strpos($lol, '://') !== false){
$sqlurl = $lol ."'";
}
else{
$sqlurl = $ipsl.$ip."/".$lol."'";
}
$sqlsc = file_get_contents($sqlurl);
$sqlvn = "$red Not Found";
foreach($sqlist as $sqli){
if (strpos($sqlsc, $sqli) !== false) $sqlvn ="$green Found!";
}
echo $sqlvn;
echo"\n$cln";
echo "\n";
$vlnk++ ;
}
}
echo"\n\n$blue [+] URL(s) With Parameter(s):".$green.$vlnk;
echo"\n\n";
//----------------------------------------------------------//
// Crawler
//----------------------------------------------------------//
echo"\n\n$bold".$lblue."C R A W L E R \n";
echo "=============";
echo"\n\n";
echo "\nCrawling Types & Descriptions:$cln";
echo "\n\n$bold"."69:$cln This is the lite version of tge crawler, This will show you the files which returns the http code '200'. This is time efficient and less messy.\n";
echo "\n$bold"."420:$cln This is a little advance one it will show you all the list of files with their http code other then the badboy 404. This is a little messier but informative \n\n";
csel :
echo "Select Crawler Type (69/420): ";
$ctype = trim(fgets(STDIN,1024));
if ($ctype == "420"){
echo"\n\t -[ A D V A N C E C R A W L I N G ]-\n";
echo"\n\n";
echo"\n Loading Crawler File ....\n";
if (file_exists("crawl/admin.ini")){
echo"\n[-] Admin Crawler File Found! Scanning For Admin Pannel [-]\n";
$crawllnk = file_get_contents("crawl/admin.ini");
//$crawls = array($crawllnk);
$crawls = explode(',', $crawllnk);
echo"\nURLs Loaded: ".count($crawls) ."\n\n";
foreach ($crawls as $crawl){
$url = $ipsl.$ip ."/".$crawl;
$handle = curl_init($url);
curl_setopt($handle, CURLOPT_RETURNTRANSFER, TRUE);
/* Get the HTML or whatever is linked in $url. */
$response = curl_exec($handle);
/* Check for 404 (file not found). */ $httpCode = curl_getinfo($handle, CURLINFO_HTTP_CODE);
if($httpCode == 200) {
echo"\n\n [ • ] $url : ";
echo "Found!";
}
elseif($httpCode == 404) {
//do nothing
}
else{
echo"\n\n [ • ] $url : ";
echo "HTTP Response: " .$httpCode;
}
curl_close($handle);
}
}
else{
echo"\n File Not Found, Aborting Crawl ....\n";
}
if (file_exists("crawl/backup.ini")){
echo"\n[-] Backup Crawler File Found! Scanning For Site Backups [-]\n";
$crawllnk = file_get_contents("crawl/backup.ini");
//$crawls = array($crawllnk);
$crawls = explode(',', $crawllnk);
echo"\nURLs Loaded: ".count($crawls) ."\n\n";
foreach ($crawls as $crawl){
$url = $ipsl.$ip ."/".$crawl;
$handle = curl_init($url);
curl_setopt($handle, CURLOPT_RETURNTRANSFER, TRUE);
/* Get the HTML or whatever is linked in $url. */
$response = curl_exec($handle);
/* Check for 404 (file not found). */ $httpCode = curl_getinfo($handle, CURLINFO_HTTP_CODE);
if($httpCode == 200) {
echo"\n\n [ • ] $url : ";
echo "Found!";
}
elseif($httpCode == 404) {
//do nothing
}
else{
echo"\n\n [ • ] $url : ";
echo "HTTP Response: " .$httpCode;
}
curl_close($handle);
}
}
else{
echo"\n File Not Found, Aborting Crawl ....\n";
}
if (file_exists("crawl/others.ini")){
echo"\n[-] General Crawler File Found! Crawling The Site [-]\n";
$crawllnk = file_get_contents("crawl/others.ini");
//$crawls = array($crawllnk);
$crawls = explode(',', $crawllnk);
echo"\nURLs Loaded: ".count($crawls) ."\n\n";
foreach ($crawls as $crawl){
$url = $ipsl.$ip ."/".$crawl;
$handle = curl_init($url);
curl_setopt($handle, CURLOPT_RETURNTRANSFER, TRUE);
/* Get the HTML or whatever is linked in $url. */
$response = curl_exec($handle);
/* Check for 404 (file not found). */ $httpCode = curl_getinfo($handle, CURLINFO_HTTP_CODE);
if($httpCode == 200) {
echo"\n\n [ • ] $url : ";
echo "Found!";
}
elseif($httpCode == 404) {
//do nothing
}
else{
echo"\n\n [ • ] $url : ";
echo "HTTP Response: " .$httpCode;
}
curl_close($handle);
}
}
else{
echo"\n File Not Found, Aborting Crawl ....\n";
}
}
elseif ($ctype == "69"){
echo"\n\t -[ B A S I C C R A W L I N G ]-\n";
echo"\n\n";
echo"\n Loading Crawler File ....\n";
if (file_exists("crawl/admin.ini")){
echo"\n[-] Admin Crawler File Found! Scanning For Admin Pannel [-]\n";
$crawllnk = file_get_contents("crawl/admin.ini");
//$crawls = array($crawllnk);
$crawls = explode(',', $crawllnk);
echo"\nURLs Loaded: ".count($crawls) ."\n\n";
foreach ($crawls as $crawl){
$url = $ipsl.$ip ."/".$crawl;
$handle = curl_init($url);
curl_setopt($handle, CURLOPT_RETURNTRANSFER, TRUE);
$response = curl_exec($handle);
$httpCode = curl_getinfo($handle, CURLINFO_HTTP_CODE);
if($httpCode == 200) {
echo"\n\n [ • ] $url : ";
echo "Found!";
}
elseif($httpCode == 404) {
//do nothing
}
else {
echo ".";
}
curl_close($handle);
}
}
else{
echo"\n File Not Found, Aborting Crawl ....\n";
}
if (file_exists("crawl/backup.ini")){
echo"\n[-] Backup Crawler File Found! Scanning For Site Backups [-]\n";
$crawllnk = file_get_contents("crawl/backup.ini");
$crawls = explode(',', $crawllnk);
echo"\nURLs Loaded: ".count($crawls) ."\n\n";
foreach ($crawls as $crawl){
$url = $ipsl.$ip ."/".$crawl;
$handle = curl_init($url);
curl_setopt($handle, CURLOPT_RETURNTRANSFER, TRUE);
$response = curl_exec($handle);
$httpCode = curl_getinfo($handle, CURLINFO_HTTP_CODE);
if($httpCode == 200) {
echo"\n\n [ • ] $url : ";
echo "Found!";
}
elseif($httpCode == 404) {
//do nothing
}
curl_close($handle);
}
}
else{
echo"\n File Not Found, Aborting Crawl ....\n";
}
if (file_exists("crawl/others.ini")){
echo"\n[-] General Crawler File Found! Crawling The Site [-]\n";
$crawllnk = file_get_contents("crawl/others.ini");
$crawls = explode(',', $crawllnk);
echo"\nURLs Loaded: ".count($crawls) ."\n\n";
foreach ($crawls as $crawl){
$url = $ipsl.$ip ."/".$crawl;
$handle = curl_init($url);
curl_setopt($handle, CURLOPT_RETURNTRANSFER, TRUE);
$response = curl_exec($handle);
$httpCode = curl_getinfo($handle, CURLINFO_HTTP_CODE);
if($httpCode == 200) {
echo"\n\n [ • ] $url : ";
echo "Found!";
}
elseif($httpCode == 404) {
//do nothing
}
curl_close($handle);
}
}
else{
echo"\n File Not Found, Aborting Crawl ....\n";
}
}
else { goto csel ;}
}
?>