-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathphpwndb.php
246 lines (224 loc) · 13.9 KB
/
phpwndb.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
<?php
/*
██████╗ ██╗ ██╗██████╗ ██╗ ██╗███╗ ██╗██████╗ ██████╗
██╔══██╗██║ ██║██╔══██╗██║ ██║████╗ ██║██╔══██╗██╔══██╗
██████╔╝███████║██████╔╝██║ █╗ ██║██╔██╗ ██║██║ ██║██████╔╝
██╔═══╝ ██╔══██║██╔═══╝ ██║███╗██║██║╚██╗██║██║ ██║██╔══██╗
██║ ██║ ██║██║ ╚███╔███╔╝██║ ╚████║██████╔╝██████╔╝
╚═╝ ╚═╝ ╚═╝╚═╝ ╚══╝╚══╝ ╚═╝ ╚═══╝╚═════╝ ╚═════╝
PHPwnDB v1.0
Search credentials leaked on pwndb database with variation.
PHPwnDB is an adaptation of tools like pwndb.py in PHP for using it simply via a web browser.
PHPwnDB permits search based on domain.tld, username, firstname lastname permutations and the use of wildcard.
Results can be filtered to produce instant wordlists read-to-use through hashs cracker tools or Burp Intruder.
PHPwnDB can be very usefull during security assessments or Bug Bounty, when firstname lastname or email of the
web-developer / maintainer / webmaster / author of the web application is discovered in footer, CSS file or HTML comment.
By providing this information to PHPwnDB, a list of potential credentials already leaked by the past can be quickly tested against the web-app.
@Author : Yann CAM (@ycam / asafety.fr) - https://github.com/yanncam/phpwndb/
*/
echo "<h1>PHPwnDB</h1>";
echo "<table width='100%'><tr>";
echo "<td>";
echo " <form action='?method=firstlastname' method='post'>
<textarea cols='60' rows='10' name='search' placeholder='firstname lastname OR lastname firstname (like bill gates to check billgates, gatesbill, bgates, gbill, bill.gates, bill-gates, bill_gates, gates.bill, gates-bill, gates_bill and with wildcard-suffix on 2 chars like gatesbill13 or bgates37) '>" . ((isset($_GET["method"], $_POST["search"]) && $_GET["method"]==="firstlastname") ? trim(strval($_POST["search"])) : "") . "</textarea><br />
<input type='submit' value='Search variation first/last name (take ~5min)' />
</form>";
echo "</td>";
echo "<td>";
echo " <form action='?method=username' method='post'>
<textarea cols='60' rows='10' name='search' placeholder='username OR [email protected] (use _ as wildcard like bgates____ for bgates1337)'>" . ((isset($_GET["method"], $_POST["search"]) && $_GET["method"]==="username") ? trim(strval($_POST["search"])) : "") . "</textarea><br />
<input type='submit' value='Search user/mail list' />
</form>";
echo "</td>";
echo "<td>";
echo " <form action='?method=domain' method='post'>
<textarea cols='60' rows='10' name='search' placeholder='Target.com'>" . ((isset($_GET["method"], $_POST["search"]) && $_GET["method"]==="domain") ? trim(strval($_POST["search"])) : "") . "</textarea><br />
<input type='submit' value='Search domains leaks' />
</form>";
echo "</td>";
echo "</tr></table>";
function searchOnTorPwndb($luser, $domain = ""){
$url = 'http://pwndb2am4tzkvold.onion';
$postRequest = array(
"submitform" => "em",
"luser" => $luser,
"domain" => $domain,
"luseropr" => "1",
"domainopr" => "0",
);
$ch = curl_init($url);
// curl_setopt($ch, CURLOPT_PROXYTYPE, 7);
curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5_HOSTNAME);
curl_setopt($ch, CURLOPT_PROXY, 'socks5h://127.0.0.1:9050');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postRequest);
$output = curl_exec($ch);
if(curl_errno($ch)){
throw new Exception(curl_error($ch));
}
return extractPwnDbEntries($output);
}
function extractPwnDbEntries($output){
$entries = array();
$pattern = "'<pre>(.*?)</pre>'si";
if(preg_match($pattern, $output, $match)){
$data = explode("Array", $match[1]);
foreach($data as $entry){
if(strpos($entry, "id")){
$luser = trim(str_replace("[luser] => ", "", explode("\n", $entry)[3]));
$domain = trim(str_replace("[domain] => ", "", explode("\n", $entry)[4]));
$passwd = trim(str_replace("[password] => ", "", explode("\n", $entry)[5]));
$entries[] = array("username" => $luser, "domain" => $domain, "password" => $passwd);
}
}
}
return $entries;
}
function generateVariationFirstLastName($input){
$variations = array();
$separators = array("_");
$padding = array("_", "__");
$parts = explode(" ", $input);
foreach($parts AS &$part)
$part = strtolower(trim($part));
$variations[] = $parts[0] . $parts[1];
$variations[] = $parts[1] . $parts[0];
$variations[] = $parts[0][0] . $parts[1];
$variations[] = $parts[1][0] . $parts[0];
foreach($separators AS $separator){
$variations[] = $parts[0] . $separator . $parts[1];
$variations[] = $parts[1] . $separator . $parts[0];
$variations[] = $parts[0][0] . $separator . $parts[1];
$variations[] = $parts[1][0] . $separator . $parts[0];
}
$variationsBase = $variations;
foreach($variationsBase AS $variationBase){
foreach($padding AS $pad){
$variations[] = $variationBase . $pad;
}
}
return array_unique($variations);
}
function clearDiacritics($input){
$replace = array(
'ъ'=>'-', 'Ь'=>'-', 'Ъ'=>'-', 'ь'=>'-',
'Ă'=>'A', 'Ą'=>'A', 'À'=>'A', 'Ã'=>'A', 'Á'=>'A', 'Æ'=>'A', 'Â'=>'A', 'Å'=>'A', 'Ä'=>'Ae',
'Þ'=>'B',
'Ć'=>'C', 'ץ'=>'C', 'Ç'=>'C',
'È'=>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'ו'=>'v', 'В'=>'v',
'ש'=>'w', 'ŵ'=>'w', 'Ŵ'=>'w',
'ы'=>'y', 'ŷ'=>'y', 'ý'=>'y', 'ÿ'=>'y', 'Ÿ'=>'y', 'Ŷ'=>'y',
'Ы'=>'y', 'ž'=>'z', 'З'=>'z', 'з'=>'z', 'ź'=>'z', 'ז'=>'z', 'ż'=>'z', 'ſ'=>'z', 'Ж'=>'zh', 'ж'=>'zh'
);
return strtr($input, $replace);
}
$entries = array();
if(isset($_GET["method"], $_POST["search"])){
$begin = time();
$inputs = explode("\n", strval($_POST["search"]));
foreach($inputs AS $input){
switch(strval($_GET["method"])){
case "firstlastname":
$input = clearDiacritics($input);
$variations = generateVariationFirstLastName(trim($input));
//print_r($variations);
foreach($variations AS $variation){
$entries = array_merge($entries, searchOnTorPwndb(trim($variation)));
}
break;
case "username":
$entries = array_merge($entries, searchOnTorPwndb(trim($input)));
break;
case "domain":
$entries = array_merge($entries, searchOnTorPwndb("", trim($input)));
break;
}
}
$end = time();
echo "<h2>" . (count($entries)-1). " leaks found in " . ($end-$begin) . " seconds</h2>";
echo "<script> var results = [";
foreach($entries AS $entry){
if($entry["username"] === "donate" && $entry["domain"] === "btc.thx"){
// ignore donation entry in results, but don't hesitate to donate ! ;)
} else {
echo '{"username": "'.$entry["username"].'", "domain": "'.$entry["domain"].'", "password": "'.base64_encode($entry["password"]).'"},';
}
}
echo "];</script>";
echo "<script>";
?>
function displayResults(){
var cbUsername = document.getElementById('cbUsername').checked == 1;
var cbDomain = document.getElementById('cbDomain').checked == 1;
var cbPassword = document.getElementById('cbPassword').checked == 1;
var sepUsernameDomain = document.getElementById('sepUsernameDomain').value;
var sepIdentityPassword = document.getElementById('sepIdentityPassword').value;
document.getElementById('results').value = '';
if(cbUsername && !cbDomain && !cbPassword)
results.forEach(entry => document.getElementById('results').value += entry['username']+"\n");
if(!cbUsername && cbDomain && !cbPassword)
results.forEach(entry => document.getElementById('results').value += entry['domain']+"\n");
if(!cbUsername && !cbDomain && cbPassword)
results.forEach(entry => document.getElementById('results').value += atob(entry['password'])+"\n");
if(cbUsername && cbDomain && !cbPassword)
results.forEach(entry => document.getElementById('results').value += entry['username']+sepUsernameDomain+entry['domain']+"\n");
if(cbUsername && !cbDomain && cbPassword)
results.forEach(entry => document.getElementById('results').value += entry['username']+sepIdentityPassword+atob(entry['password'])+"\n");
if(!cbUsername && cbDomain && cbPassword)
results.forEach(entry => document.getElementById('results').value += entry['domain']+sepIdentityPassword+atob(entry['password'])+"\n");
if(cbUsername && cbDomain && cbPassword)
results.forEach(entry => document.getElementById('results').value += entry['username']+sepUsernameDomain+entry['domain']+sepIdentityPassword+atob(entry['password'])+"\n");
}
<?php
echo "</script>";
echo "<input id='cbUsername' type='checkbox' onclick='displayResults();' checked='checked' />Username";
echo "<select id='sepUsernameDomain' onchange='displayResults();'><option value='@'>@</option><option value=';'>;</option><option value=','>,</option></select>";
echo "<input id='cbDomain' type='checkbox' onclick='displayResults();' checked='checked' />Domain";
echo "<select id='sepIdentityPassword' onchange='displayResults();'><option value=':'>:</option><option value=';'>;</option><option value='='>=</option><option value=','>,</option></select>";
echo "<input id='cbPassword' type='checkbox' onclick='displayResults();' checked='checked' />Password";
echo "<input type='button' value='Copy results' onclick='document.getElementById(\"results\").select();document.execCommand(\"copy\");' />";
echo "<br />";
echo "<textarea id='results' readonly cols='150' rows='30'>";
foreach($entries AS $entry){
if($entry["username"] === "donate" && $entry["domain"] === "btc.thx"){
// ignore donation entry in results, but don't hesitate to donate ! ;)
} else {
echo $entry["username"]."@".$entry["domain"] . ":" . $entry["password"] . "\n";
}
}
echo "</textarea>";
}
?>