View Full Version : Miscellaneous Hacks - Ban IP's In vBulletin Options Easily
Simon Lloyd
08-07-2011, 10:00 PM
What this mod does
With this simple mod you can enter a list of IP's that you want to ban (redirect) one per line, when trying to access your site the user of the IP will be redirected to an obscure google page with a 301 permanent redirect.
What this mod won't do
With this mod you cannot ban partial ranged IP's laid out like this 2.23.123 - 2.23.130
How to install
Simply go to Admincp>Manage Products and import product-baniparray.xml
Please mark as installed if you use this!
Version History
v1.0.1
Made it possible to use partial IP addresses
v1.0.2
Added custom redirect message box
Added custom redirect url box
Added IP Range boxes for banning IP's that fall within range
Ranged IP's parsed during checks
vbeta added for test purposes 9/08/2011
Beta has email notification ability, this beta is for those of you that wish to test it and feed back!
Checked range block working only against my IP range, please report any bugs!
Simon Lloyd
08-08-2011, 12:34 AM
**Reserved**
Boofo
08-08-2011, 12:54 AM
Looks good but not quite what I am looking for. I need to be able to ban IP ranges (as in the other thread), not just complete IPs.
Simon Lloyd
08-08-2011, 01:00 AM
Looks good but not quite what I am looking for. I need to be able to ban IP ranges (as in the other thread), not just complete IPs.Well surely it's best to use vBulletins built in one for that?
Boofo
08-08-2011, 01:34 AM
True, but you can also block full IPs with that, too. Plus, it kind of defeats the purpose of my question in the other thread. ;)
Simon Lloyd
08-08-2011, 02:06 AM
Ah!, my fault i didn't read the thread fully, and for your question i just read....array of ip's not realising it was for partial or blocks of ip's.
It's going to take quiet a bit i would imagine but i'll look in to it :)
Boofo
08-08-2011, 02:12 AM
You should be able to use his outline.
Simon Lloyd
08-08-2011, 02:56 AM
You can now use partial ip's, i'm working on an addition where you can block from xx.xx.xxx.xx - xx.xxx.xx.x.
It's 5am here so i guess i'll finish it later today :)
Boofo
08-08-2011, 03:05 AM
Another option would be to have a setting for the redirect page so it is configurable. As well as a notification of some sort.
Simon Lloyd
08-08-2011, 03:08 AM
Don't want much do you? :) i'll look in to that too, i'm off home to bed in a couple of hours, so i won't start work on it again until around 7:30pm GMT
Boofo
08-08-2011, 03:13 AM
well, you might as well add something to this that would make it a better option to use than the one in vb. ;)
BirdOPrey5
08-08-2011, 11:52 AM
Would this work with IPv6 addresses?
nhawk
08-08-2011, 12:02 PM
Here's a little snippet of code for IPv4 addresses that I use in several private mods.
$ip = explode('.',IPADDRESS);
$ipaddress = 16777216 * $ip[0] + 65536 * $ip[1] + 256 * $ip[2] + $ip[3];
You should be able to figure out how to compare a range of numbers with that.
IPv6 is very similar.
Simon Lloyd
08-08-2011, 04:51 PM
Would this work with IPv6 addresses?To answer this simply, if you entered x12.35p.6-51?54e in the list then anything matching that will be redirected, if you enter x12 then anything that contains x12 will be redirected.
Here's a little snippet of code for IPv4 addresses that I use in several private mods.
$ip = explode('.',IPADDRESS);
$ipaddress = 16777216 * $ip[0] + 65536 * $ip[1] + 256 * $ip[2] + $ip[3];
You should be able to figure out how to compare a range of numbers with that.
IPv6 is very similar.I really have no idea what an IPv4 or 6 is, the mod, as it stands does not use regular expressions to check the entire octet hut instead goes for a simple match, there are enhancements coming soon with this mod but (until i understand it myself) for now it will remain simply as a match.
Simon Lloyd
08-08-2011, 10:46 PM
Product update - new enhancements
Simon Lloyd
08-09-2011, 12:11 AM
Beta product added for test purposes, it has email notification facility, if you use this version please feed back.
Simon Lloyd
08-09-2011, 12:52 AM
Beta re-uploaded due to a typo!
nhawk
08-09-2011, 10:12 AM
I really have no idea what an IPv4 or 6 is, the mod, as it stands does not use regular expressions to check the entire octet hut instead goes for a simple match, there are enhancements coming soon with this mod but (until i understand it myself) for now it will remain simply as a match.
The code I gave you converts the IPv4 ip address (xxx.xxx.xxx.xxx) to it's true numeric value. Hence it can then be used in a < > comparison.
IPv6 can be done in a similar way, but it uses hexadecimal values and will result in an insanely large number. ;)
Boofo
08-09-2011, 10:15 AM
This will also work for IPv4:
// Checks for valid IP Address since some proxies will send invalid user
// agent strings.
//
// usage: if (!isValidIPv4($ipaddress))
function isValidIPv4($addr) {
$octs = explode('.',$addr);
if (count($octs) != 4) return false;
foreach ($octs as $oct) {
if (!ctype_digit($oct)) return false;
$oct = intval($oct);
if ($oct < 0 || $oct > 255) return false;
}
return true;
}
lmsol
08-21-2011, 01:41 PM
I noticed that I have had a lot of Japanese ips sitting in my "who's online". I found this product and thought it would be a good idea to ban these ips.
I have installed. I re-logged into my forum and still see these ips on my "who's online" list.
How do I know if these ips are now banned?
Thanks guys
Simon Lloyd
08-21-2011, 02:05 PM
Lol!, the ban is a redirect, firstly the session timeout set in you vbulletin options has to pass before anyone goes missing off the who's online, secondly the bot/spider/person has to visit another url before they get redirected if their session hasn't timed out.
Give it time and they will disappear :)
P>S please mark as installed!
lmsol
08-21-2011, 02:16 PM
Sorry. I clearly have the Sunday morning sleepies.
I have marked as installed. Thanks :)
ChiNa
07-21-2012, 05:06 PM
I remember you helped me with the Quick-Editor and then the Similar thread.. Thank you very much for your help. I wish there was more like you in vBulletin. And I am sure there is. Everyone have been amzingly helpfull to me. (Newbie)
ChiNa
09-29-2012, 02:01 PM
VOTED: Excellent, and INSTALLED!
I Forgot something..
I Just Installed this one, I have little question! Do you think that a proxy-Ban, or Proxy Detection option could be added in this product! Or maybe in your next release!
Maybe close to the Product called (Proxy to Real IP)......
Simon Lloyd
09-29-2012, 02:49 PM
Thats not the intention of this mod, there is a mod that prevents proxy use and there's one that helps display the users real ip (by Paul M) if the proxy provides it, as far as i know this mod doesn't conflict with any of those so you can use it in conjunction. :)
ram94401
06-15-2013, 06:52 PM
Thanks! Installed. How do I verify that this mod is working as intended? I can't block my IP obviously.
Simon Lloyd
06-15-2013, 07:02 PM
You can ban your own ip :), when you find it works go to your /includes/config.php and right under <? php add define('DISABLE_HOOKS', true); then access your admincp of the forum and remove your ip, once done comment out the line you added in config.php by adding // in front of it so its there for future use (it disables all plugins).
ram94401
06-15-2013, 11:49 PM
Thanks. I used Chrome and Firefox. In Chrome, I went admin panel and banned my IP and kept open admin panel screen. In Firefox, I tested the redirect. It worked ok. Then, I went back to Chrome and removed my IP from ban list. After a minute, I tested in Firefox. I was able to see the forum instead of getting redirected. It worked great! I do not see "Message to Redirected users" though. In fact, that's what I wanted. I do not want to show some courteous message to spammers.
Overall, it worked as advertised! Nominating for the mod of month. Great Job!
Simon Lloyd
06-16-2013, 05:58 AM
Glad it's what you wanted, check out my other mod https://vborg.vbsupport.ru/showthread.php?t=264932 to keep bad bots away and reduce your bandwidth :)
ram94401
06-16-2013, 03:59 PM
Thanks. Quick question. Under "List IPs" box, instruction says "You may use full or partial IP's in the list". What is the format for partial IP? Should I enter
xx.xx.xx.* or just xx.xx.xx.
Thank you.
Simon Lloyd
06-16-2013, 04:58 PM
no need for .* or .
If you enter 88.123.11 then it will ban:
88.123.11.1
88.123.11.2
88.123.11..3 ......etc
If you enter 88 then it will ban every ip that has 88 in it so in this case you'd need to add an extra qualifier so 88.123 will ban every ip that has that in it, addind a dot5 after it like 88.123. will ensure that only ips's with another paremeter after the las t dot will be banned.
Hope that clears it up for you.
ram94401
06-16-2013, 11:37 PM
It does. Thanks again.
sverdios
07-24-2013, 09:47 AM
any chance, for example, if one user try to logging with a banned ip automatic ban the user?
Simon Lloyd
07-24-2013, 02:41 PM
if a user attempts to login with a banned ip either with my system of vbulletins then they wont be able to load the site.
sverdios
07-24-2013, 05:43 PM
if a user attempts to login with a banned ip either with my system of vbulletins then they wont be able to load the site.
yes i know, but the user can change you ip and access then, for example I acces to vbulletin from my dedicated server, this ip are banned, but i can access normally from my pc. any chance to move this user to banned group? or some log register what user try to logging from banned ip?
Simon Lloyd
07-25-2013, 08:49 AM
You are talking about 2 different things!any chance to move this user to banned group? and or some log register what user try to logging from banned ip?the second part is an easy thing to do, the first is a little harder. If I have time at some point i'll add those things.
Dan49
07-31-2013, 05:13 AM
Hi Simon,
I installed this mod. Added a few IPs to the list. Then one of my legit users got blocked. I spent a lot of time with him trying to pin point the problem, as his IP is not on the list. I narrowed it down by removing a few IPs from the list at a time, until I found which one affected him.
I had 222. on the list which blocked 203.59.222.162.
What I concluded is that 222. does not only block the beginning numbers, it blocks any occurrence of those numbers in the IP.
Is this what you wanted this mod to do? Let me know if this the case, then I must uninstall it as it's unpredictable which IPs it will ban.
Dan49
07-31-2013, 05:16 AM
Never mind, I just saw you answered this a few posts above. Looks like I understood correctly. It's too dangerous to put only 3 numbers on the list. But I think I can still make it work, adding at least one more ###. behind it.
Dan49
08-04-2013, 02:56 AM
Simon,
I want to make sure I'm using block range of IPs feature correctly. If I set
Start IP: 202.46.48.36
End IP: 202.46.63.165
will it block these IPs?
202.46.48.77
202.46.57.138
202.46.62.142
Simon Lloyd
08-04-2013, 05:31 PM
To be honest its been a long while since I used or did any development on this mod, my first instinct is to say no because those ip's are fully qualified ip's you'd need to enter them like
202.46.48
202.46.63
I cant remember what instructions I gave in the mod. My wifes due to have a big op so I wont have time to test or look at this for at least a week - sorry!
Dan49
08-04-2013, 05:53 PM
Thank you.
Good luck with the op.
The normal vb ban IP option will remove all of them safely without affecting any unforeseen IPs by using 202.46.
But I much prefer to have these IPs redirected as opposed to sitting in who's online. So I will wait for your response on this. I'll bump this thread in 2 weeks.
Dan49
08-21-2013, 04:36 PM
Hi Simon,
I'd like to know if it's possible with your mod to block/redirect:
202.46.48.77
202.46.57.138
202.46.62.142
using 202.46. so it will block all the above. But will not block the following:
103.202.46.
or
103.01.202.46
In other words function the same way as the native VB IP ban, except with redirect.
Dan49
09-09-2013, 02:08 AM
Simon, please look into this if you get a chance. The vietnamese bots are killing me. Every IP I block they come back with different ones.
Simon Lloyd
09-09-2013, 01:43 PM
I've not had time yet but if you're having problems you can sort that right now by following this tutorial and adding partial ip's to your .htaccess file http://supportcenter.verio.com/KB/questions.php?questionid=504
FirstDz
12-11-2013, 12:19 AM
Thank you !!
BadgerDog
01-05-2015, 12:03 PM
Has anyone started having a recent problem with this mod blocking this user agent?
Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36
I'm starting to get complaints from users trying to register who are using Chrome?
Thanks for any feedback ... :)
Regards,
Doug
ozzy47
01-05-2015, 01:09 PM
This mod is for IP's not useragents. So if you disable this mod, the problem you are having goes away?
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.