-
Notifications
You must be signed in to change notification settings - Fork 0
/
dnsdump.php
74 lines (65 loc) · 2.83 KB
/
dnsdump.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
<?php
/**
* @file
* File to download excel sheet from dnsdumpster.com.
*/
// Turn off all error reporting.
error_reporting(0);
// $domains is an array of domains.
$domains = ['google.com', 'facebook.com', 'linkedin.com', 'vivacanada.com'];
$copied_domains = [];
// let's read every domain...
foreach ($domains as $key => $domain) {
$file_path = 'dnsfiles/' . $domain . '.xlsx';
// Exist if DNS detail file already present for the domain.
if (!file_exists($file_path)) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://dnsdumpster.com/");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "csrfmiddlewaretoken=kbaoos7fElQ5I4aXaGFugUnO6mh6QmZe&targetip=" . $domain);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_ENCODING, 'gzip, deflate');
$headers = [];
$headers[] = "Authority: dnsdumpster.com";
$headers[] = "Pragma: no-cache";
$headers[] = "Cache-Control: no-cache";
$headers[] = "Origin: https://dnsdumpster.com";
$headers[] = "Upgrade-Insecure-Requests: 1";
$headers[] = "Content-Type: application/x-www-form-urlencoded";
$headers[] = "User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36";
$headers[] = "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8";
$headers[] = "Referer: https://dnsdumpster.com/";
$headers[] = "Accept-Encoding: gzip, deflate, br";
$headers[] = "Accept-Language: en-US,en;q=0.9,zh-CN;q=0.8,zh;q=0.7,ar;q=0.6";
$headers[] = "Cookie: csrftoken=kbaoos7fElQ5I4aXaGFugUnO6mh6QmZe; _ga=GA1.2.1239030569.1545929271; _gid=GA1.2.1857725251.1546416794; _gat=1";
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Error:' . curl_error($ch) . "\n";
}
else {
print "Copying {$domain} into dnsfiles directory.\n";
$dom = new DOMDocument();
$dom->loadHTML($result);
$nodes = $dom->getElementsByTagName('a');
// Loop through all the links available in curl response.
foreach ($nodes as $node) {
if (strpos($node->attributes->getNamedItem('href')->nodeValue, 'https://dnsdumpster.com/static/xls/') !== FALSE) {
// Get Excel file.
$con = file_get_contents($node->attributes->getNamedItem('href')->nodeValue);
$fp = fopen($file_path, 'w+');
fwrite($fp, $con);
fclose($fp);
$copied_domains[$key] = $domain;
}
}
curl_close($ch);
print "File-> " . ($key + 1) . ": Copied {$domain} into dnsfiles directory.\n\n";
}
}
}
if (!empty($copied_domains)) {
$not_copied = array_diff($domains, $copied_domains);
print "Data not found for following domains: \n";
print implode("\n", $not_copied) . "\n";
}