Block Tor users from entering your forum.

by Pirate - 19-06-2015, 10:25 PM
Contact: pirate@undoxable.net
Prime
Posts:
254
Joined:
Mar 2015
Likes:
7
Credits:
69
Reputation:
3
2 Years of Service
#1
OP
Posted: 19-06-2015, 10:25 PM
Here is a php plugin code that will block tor users from entering your forum:

Code:
<?php


if(!defined("IN_MYBB"))
{
    die("lol ur such a l33t haxxor!");
}
$plugins->add_hook("showthread_start", "tor_guard_block");
$plugins->add_hook("newreply_do_newreply_start", "tor_guard_block");
$plugins->add_hook("newthread_do_newthread_start", "tor_guard_block");
$plugins->add_hook("online_today_start", "tor_guard_block");
$plugins->add_hook("polls_start", "tor_guard_block");
$plugins->add_hook("pre_output_page", "tor_guard_block");
$plugins->add_hook("postbit", "tor_guard_block");
$plugins->add_hook("usercp_start", "tor_guard_block");
$plugins->add_hook("usercp_do_profile_start", "tor_guard_block");
$plugins->add_hook("usercp_profile_start", "tor_guard_block");
$plugins->add_hook("usercp_options_start", "tor_guard_block");
$plugins->add_hook("usercp_password", "tor_guard_block");
$plugins->add_hook("usercp_do_changename_start", "tor_guard_block");
$plugins->add_hook("member_do_register_start", "tor_guard_block");
$plugins->add_hook("member_lostpw", "tor_guard_block");
$plugins->add_hook("member_login", "tor_guard_block");
$plugins->add_hook("misc_start", "tor_guard_block");
$plugins->add_hook("private_start", "tor_guard_block");
$plugins->add_hook("reputation_start", "tor_guard_block");

function tor_block_info()
    {

    return array(
        "name"        => "TOR Block",
        "description"    => "Block TOR users from Accessing your Website",
        "author"        => "Pirate",
        "authorwebsite"    => "http://community.mybb.com/user-91538.html",
        "website"    =>  "http://community.mybb.com/user-91538.html",
        "version"        => "1.1",
        "compatibility"    => "18*"
        );
    }
    
    function tor_guard_install()
    {
        global $db, $lang;
        $lang->load("torblock");
    $new_setting_group = array(
    "name" => "torblock",
    "title" => $lang->settings_name,
    "disporder" => 1,
    "isdefault" => 0
    );
        $settings[] = array(
        "name" => "torblock_redirecturl",
        "title" => $lang->redirecturl,
        "optionscode" => "text",
        "disporder" => 1,
        "value" => denied.php,
        "gid" => $gid
    );
    }
    function tor_guard_is_installed()
{
    global $db;
    $query = $db->simple_select("settinggroups", "*", "name='torblock'");
    if($db->num_rows($query))
    {
        return TRUE;
    }
    return FALSE;
}
function tor_guard_activate()
{
    global $db, $mybb;
}

function tor_guard_deactivate()
{
    global $mybb, $db, $cache;
}

function tor_guard_uninstall()
{
$query = $db->simple_select("settinggroups", "gid", "name='torblock'");
    $gid = $db->fetch_field($query, "gid");
    if(!$gid) {
        return;
    }
    $db->delete_query("settinggroups", "name='torblock'");
    $db->delete_query("settings", "gid=$gid");
    rebuild_settings();
}
function tor_guard_block()
{
    global $mybb;
    
    
    $torExitNodes = file_get_contents("https://www.dan.me.uk/tornodes");
    
    $ip = $_SERVER['REMOTE_ADDR'];
        
    if (strpos($torExitNodes, $ip) == true) {
     die('$settings['value']');
}
}
?>
King of Leaks!
Prime
Posts:
226
Joined:
Jan 2015
Likes:
21
Credits:
163
Reputation:
13
2 Years of Service
#2
Posted: 19-06-2015, 10:46 PM
So uhm, where would I put this?

Just make a PHP file and upload it?
We are!
Posts:
1,044
Joined:
Jan 2015
Likes:
108
Credits:
1,882
Reputation:
25
2 Years of Service
#3
Posted: 19-06-2015, 10:54 PM
(19-06-2015, 10:46 PM)Maximum Wrote: So uhm, where would I put this?

Just make a PHP file and upload it?

Make a file called "tor_guard.php" and upload to Plugins.
King of Leaks!
Prime
Posts:
226
Joined:
Jan 2015
Likes:
21
Credits:
163
Reputation:
13
2 Years of Service
#4
Posted: 19-06-2015, 11:11 PM
(19-06-2015, 10:54 PM)akay Wrote:
(19-06-2015, 10:46 PM)Maximum Wrote: So uhm, where would I put this?

Just make a PHP file and upload it?

Make a file called "tor_guard.php" and upload to Plugins.

Thank you Sir Akay.
Novice
Posts:
48
Joined:
Jun 2015
Likes:
2
Credits:
23
Reputation:
0
2 Years of Service
#5
Posted: 19-06-2015, 11:38 PM
Very cool. This could easily be adapted to non nulledbb sites as well. I only skimmed through it.. only thing I would suggest would be to file cache $torExitNodes so that you aren't make a new call to the 3rd party site on every page load, and update the file occasionally
YouR JuSt G4Y
Posts:
879
Joined:
Feb 2015
Likes:
32
Credits:
317
Reputation:
3
2 Years of Service
#6
Posted: 22-06-2015, 02:01 AM
ERROR!

Parse error: syntax error, unexpected 'value' (T_STRING) in /home/hqforumx/public_html/inc/plugins/tor_guard.php on line 102
We are!
Posts:
1,044
Joined:
Jan 2015
Likes:
108
Credits:
1,882
Reputation:
25
2 Years of Service
#7
Posted: 22-06-2015, 07:20 AM
(22-06-2015, 02:01 AM)Mr_Joker Wrote: ERROR!

Parse error: syntax error, unexpected 'value' (T_STRING) in /home/hqforumx/public_html/inc/plugins/tor_guard.php on line 102

PHP Code:
"value" => denied.php,

 if (
strpos($torExitNodes$ip) == true) {
     die(
'$settings['value']');


I think he forgot to upload denied.php.
ᶠᵃᵈʸ'ˢ ʷᵃᶦᶠᵘ
Posts:
542
Joined:
Jan 2015
Likes:
65
Credits:
501
Reputation:
37
2 Years of Service
#8
Posted: 22-06-2015, 01:35 PM
(22-06-2015, 07:20 AM)akay Wrote:
(22-06-2015, 02:01 AM)Mr_Joker Wrote: ERROR!

Parse error: syntax error, unexpected 'value' (T_STRING) in /home/hqforumx/public_html/inc/plugins/tor_guard.php on line 102

PHP Code:
"value" => denied.php,

 if (
strpos($torExitNodes$ip) == true) {
     die(
'$settings['value']');


I think he forgot to upload denied.php.

denied.php should be wrapped in quotation marks. 10/10 would not use OP's code.
Faded is cute Heart
لا إله إلا الله‎
Posts:
6,326
Joined:
Jan 2015
Likes:
298
Credits:
268
Reputation:
162
2 Years of Service
#9
Posted: 22-06-2015, 01:46 PM
What about using deny and using all those reverse IP's Tor uses like umm deny from [IP] ?
| Monopoly- Best forever .. | MGK - ;) | Addicted | Senpai | Nyan | Sensei | H | fdigl |
[Image: gZD4Fba.png]

Closed Account
Posts:
26
Joined:
Jun 2015
Likes:
0
Credits:
29
Reputation:
0
2 Years of Service
#10
Posted: 23-06-2015, 10:46 AM
thank you for your sharing Smile
The last reply on this thread is older than a month. Please do not unnecessarily bump it.
Register an account or login to reply
Create an account
Create a free account today and start posting right away. It only takes a few seconds.
Login
Log into an existing account.
1 Guest(s)