Ban may require multiple IP addresses in config.php

More
17 years 8 months ago #513 by Pete
The other solution I was thinking about was to get the visitors Mac Address (since the mac address never changes using a function like this:
Code:
<?php function returnMacAddress() { // WARNING: the commands 'which' and 'arp' should be executable // by the apache user; on most linux boxes the default configuration // should work fine // Get the arp executable path $location = `which arp`; $location = rtrim($location); // Execute the arp command and store the output in $arpTable $arpTable = `$location -n`; // Split the output so every line is an entry of the $arpSplitted array $arpSplitted = split("\n",$arpTable); // Get the remote ip address (the ip address of the client, the browser) $remoteIp = $GLOBALS['REMOTE_ADDR']; $remoteIp = str_replace(".", "\\.", $remoteIp); // Cicle the array to find the match with the remote ip address foreach ($arpSplitted as $value) { // Split every arp line, this is done in case the format of the arp // command output is a bit different than expected $valueSplitted = split(" ",$value); foreach ($valueSplitted as $spLine) { if (preg_match("/$remoteIp/",$spLine)) { $ipFound = true; } // The ip address has been found, now rescan all the string // to get the mac address if ($ipFound) { // Rescan all the string, in case the mac address, in the string // returned by arp, comes before the ip address // (you know, Murphy's laws) reset($valueSplitted); foreach ($valueSplitted as $spLine) { if (preg_match("/[0-9a-f][0-9a-f][:-]". "[0-9a-f][0-9a-f][:-]". "[0-9a-f][0-9a-f][:-]". "[0-9a-f][0-9a-f][:-]". "[0-9a-f][0-9a-f][:-]". "[0-9a-f][0-9a-f]/i",$spLine)) { return $spLine; } } } $ipFound = false; } } return false; } echo returnMacAddress(); ?>

But the problem with this method is that since the Mac Address is not part of the TCP/IP, it never gets past the local router / switch / firewall. This would work for local users on the same network, but not for Web Visitors, so this idea won't work either. :(

DigiOz Webmaster
www.digioz.com

Please Log in or Create an account to join the conversation.

More
17 years 8 months ago #515 by Norman
Hi Pete,

Thanks for your ideas so far; it looks like a difficult one to crack.

I was thinking of something a simpler but it might not be very practicable.

Ask the users to always use the same Username when writing a message. Provide all users with a four digit (or whatever number you choose) ID. Ask the users to keep the ID confidential. When a user attempts to write a message, a check should be done to see if the Username and ID match. The Username/ID pair could be stored in a text file. A potential user (for write access) would need to communicate via some other means (email) in order to obtain an ID. If you need to ban a user, then the Username/ID could be removed from the text file or commented out.

This of course have nothing to do with IP Adresses, Host Names, MAC Addresses, etc.

What do you think?

Thanks, Norman

Please Log in or Create an account to join the conversation.

More
17 years 8 months ago #517 by Pete
Well, that would basically be a user registeration system of sorts. Of course we could do something like that. Not too many guestbooks require users that want to leave comments to register before posting. In my opinion it would take away from the flexibility of having a guestbook.

It is certainly easy to create and implement though. You would then be facing similar problems as what phpbb forum users face, which is bots that have the user signup and activation process automated, which bypass the whole process, including the built in image verification! :shock: Which means you would have to keep banning new usernames each time someone submits a spam!

DigiOz Webmaster
www.digioz.com

Please Log in or Create an account to join the conversation.

More
17 years 8 months ago #520 by Norman
OK, I did not think it was that practicable and I agree that not being able to leave a comment without first registering is not in the 'spirit' of a guestbook. I just do not have any other ideas right now.

Thanks, Norman

Please Log in or Create an account to join the conversation.

More
16 years 7 months ago #856 by Whimpy
I have added regular expression support to the banned_ip list. This might not be perfect, but it works for me since most spam seems to come from countries like Latvia or China or other countries where I don't know anyone who would want to add a legitimate entry to my guestbook ;-)

This is my modification to ban.php:
Code:
foreach($banned_ip as $banned) { $banned = str_replace('.', '\.', $banned); $ip = $_SERVER['REMOTE_ADDR']; if(preg_match("/^$banned$/",$ip)) { print "<h1 align=center><font color=red>You have been banned!</font></h1><br>"; include("footer.php"); exit(); } }

You can then block (for example) a complete subnet in config.php:
Code:
$banned_ip[] = '192.168.1.\d+';

Please Log in or Create an account to join the conversation.

More
16 years 7 months ago #882 by Pete

Whimpy wrote: I have added regular expression support to the banned_ip list. This might not be perfect, but it works for me since most spam seems to come from countries like Latvia or China or other countries where I don't know anyone who would want to add a legitimate entry to my guestbook ;-)

This is my modification to ban.php:

Code:
foreach($banned_ip as $banned) { $banned = str_replace('.', '\.', $banned); $ip = $_SERVER['REMOTE_ADDR']; if(preg_match("/^$banned$/",$ip)) { print "<h1 align=center><font color=red>You have been banned!</font></h1><br>"; include("footer.php"); exit(); } }

You can then block (for example) a complete subnet in config.php:
Code:
$banned_ip[] = '192.168.1.\d+';


Excellent idea! We will most likely implement this in the next release of the DigiOz Guestbook. :)

DigiOz Webmaster
www.digioz.com

Please Log in or Create an account to join the conversation.

Time to create page: 0.129 seconds
Powered by Kunena Forum