-
Notifications
You must be signed in to change notification settings - Fork 262
/
scanner.php
executable file
·82 lines (72 loc) · 1.86 KB
/
scanner.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
<?php
// --- INTRODUCTION ---
// PHP HOSTS SCANNER
// ONLY WORK WITH PHP-CLI
// REQUIREMENTS: PHP 5 AND DNSUTILS (DEB) OR BIND-UTILS (RHEL)
// --- HOW TO USE ---
// RUN WITH COMMAND "php unblock.php yourfile.txt"
// CHANGE "yourfile.txt" WITH YOUR FILE
// --- INFO ---
// SPLIT TXT FILE TO 100000 LINES EACH FILE
// BECAUSE MORE THAN IT MAKE TIMEOUT
// --- COPYRIGHT ---
// PALGUNO WICAKSONO
// 2019
// ALL RIGHTS RESERVED
function domaintoip($host, $timeout = 1) {
$query = `nslookup -timeout=$timeout -retry=1 $host`;
if(preg_match('/\nAddress: (.*)\n/', $query, $matches))
return trim($matches[1]);
}
function count_line($file) {
set_time_limit(3600);
ini_set('memory_limit', '-1');
$arr = file($file, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
$c = ( false === $arr) ? 0 : count($arr);
return $c;
}
if(empty($argv[1]){
echo "use command php scanner.php listdomainyangingindiunblock.txt";
die();
}
$file = $argv[1];
$t = -microtime(1);
$alllines = count_line($file);
if($alllines > 100000){
echo "SPLIT YOUR FILE TO 100000 LINES OR IT WILL MAKE TIMEOUT \r\n";
die();
}else{
$lines = count_line($file);
$filenamee = 'hosts-'.$file;
$line = 0;
while($lines>0){
$spl = new SplFileObject($file);
$spl->seek($line);
$domain = $spl->current();
$hias = strtoupper($domain);
$ip = domaintoip($domain);
if(!(empty($ip))){
$hostsfile = new SplFileObject($filenamee, 'a');
//$hostsfile = fopen("hosts","a");
$newhosts = '
# ['.trim(strtoupper($domain)).']
'.$ip.' '.$domain;
echo "
[+] ======= UNBLOCKING DOMAIN ======= [+]
DOMAIN : $hias
IP : $ip
LINE : $line / $alllines
[+] ============ SUCCESS ============ [+]";
$hostsfile->fwrite($newhosts);
$line++;
$lines--;
}else{
$line++;
$lines--;
$alllines--;
}
}
}
echo "Done Unblocking \r\n";
exit();
?>