forked from OpenIB/OpenIB
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdnsbls_bypass.php
65 lines (55 loc) · 2.47 KB
/
dnsbls_bypass.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
<?php
include 'inc/functions.php';
function outputError($errCode, $errString) {
http_response_code($errCode);
error ($errString);
return 0;
}
function getRequestMethod($r) {
$reqMethod = "NG";
if ($r === 'GET'){
$reqMethod = "GET";
}
if ($r === "POST"){
$reqMethod = "POST";
}
return $reqMethod;
}
$requestMethod = getRequestMethod($_SERVER['REQUEST_METHOD']);
if ($requestMethod === "NG"){
outputError (400, "Bad Request.");
}
if ($requestMethod === "GET"){
$captcha = generate_captcha($config['captcha']['extra']);
$html = "{$captcha['html']}<br/>
<input class='captcha_text' name='captcha_text' size='25' maxlength='6' autocomplete='off' type='text' autocorrect='off' autocapitalize='off' spellcheck='false'>
<input class='captcha_cookie' name='captcha_cookie' type='hidden' autocomplete='off' value='{$captcha['cookie']}'><br/>";
$body = Element("8chan/dnsbls.html", array("config" => $config, "ayah_html" => $html));
echo Element("page.html", array("config" => $config, "boardlist" => createBoardlist(), "body" => $body, "title" => _("Bypass DNSBL"), "subtitle" => _("Post even if blocked")));
}
if ($requestMethod === "POST"){
$resp = file_get_contents($config['captcha']['provider_check'] . "?" . http_build_query([
'mode' => 'check',
'text' => $_POST['captcha_text'],
'extra' => $config['captcha']['extra'],
'cookie' => $_POST['captcha_cookie']
]));
if ($resp === '1') {
$tor = checkDNSBL($_SERVER['REMOTE_ADDR']); // This actually needs to use an IP address, but doesnt store it anywhere
$identity = getIdentity();
if (!$tor) {
$query = prepare('INSERT INTO ``dnsbl_bypass`` VALUES(:ip, NOW(), 0) ON DUPLICATE KEY UPDATE `created`=NOW(),`uses`=0');
$query->bindValue(':ip', $identity);
$query->execute() or error(db_error($query));
}
$cookie = bin2hex(openssl_random_pseudo_bytes(16));
$query = prepare('INSERT INTO ``tor_cookies`` VALUES(:cookie, NOW(), 0)');
$query->bindValue(':cookie', $cookie);
$query->execute() or error(db_error($query));
setcookie("tor", $cookie, time()+60*60*3);
echo Element("page.html", array("config" => $config, "boardlist" => createBoardlist(), "body" => '', "title" => _("Success!"), "subtitle" => _("You may now go back and make your post.")));
} else {
$errorText = _('You failed the CAPTCHA') . _('. <a href="/dnsbls_bypass.php">Try again.</a> If it\'s not working, email admin@9san.ch for support.');
outputError (403, $errorText);
}
}