1.8.x

Block Tor users from entering your forum.

Submitted by Pirate, , Thread ID: 4928

Thread Closed
19-06-2015, 10:25 PM
#1
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']');
}
}
?>

RE: Block Tor users from entering your forum.

#2
So uhm, where would I put this?

Just make a PHP file and upload it?

RE: Block Tor users from entering your forum.

#3
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.

RE: Block Tor users from entering your forum.

#4
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.

RE: Block Tor users from entering your forum.

#5
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

RE: Block Tor users from entering your forum.

#6
ERROR!

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

RE: Block Tor users from entering your forum.

#7
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.

RE: Block Tor users from entering your forum.

#8
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.
[Image: ZtDsXXv.png]

RE: Block Tor users from entering your forum.

#9
What about using deny and using all those reverse IP's Tor uses like umm deny from [IP] ?
| A | v4hl| Addicted | Senpai | Sui | Sensei | H | fdigl |


RE: Block Tor users from entering your forum.

#10
thank you for your sharing Smile

Users browsing this thread: 1 Guest(s)