Jump to content

Archived

This topic is now archived and is closed to further replies.

cardoso

How do I fight this forum hacker? How to get his ip info?

Recommended Posts

Hi All,  I have a community site that I've created as a hobby.... over the past month os so, there's been this guy/girl who has made it their mission to enter loads of crap on my site.  At first it was only 2 or 3 a day... yesterday it was 160.

So I implimented one of those "captcha" thing to make it harder... that only helped for a few hours.  Then I started filtering the content in my sql statement... that's getting to be more work then it's worth... he/she has far too many words for me to keep up.  Now I decided to capture and write to the DB the user's info based on ip... so I get the following:
$ip = $_SERVER['REMOTE_ADDR'];
$hostname = gethostbyaddr($_SERVER['REMOTE_ADDR']);
$referrer_page = $_SERVER['HTTP_REFERER'];
$requested_page = $_SERVER['REQUEST_URI'];
$AllUserInfo = "----IP:".$ip."----HOSTNAME:".$hostname."----REFERRER PAGE:".$referrer_page."----REQUESTED PAGE:".$requested_page;

But that did not work...  I get a NULL value... he's somehow blocking that information.

Can someone help?  This is a free site I've created out of the love for my community and this person is making it so hard for me to want to continue.

Thanks for any help you might throw my way.

Nelson Cardoso

Share this post


Link to post
Share on other sites
You could only allow posts where $_SERVER['REMOTE_ADDR'] is available - that way you could back trace.

Even if they spoof an ip address you will get another measure of how they are circumventing your system - and then prevent that.

Share this post


Link to post
Share on other sites
Good call!!!  I've already implimented your idea.  I'm a bit of a newbie with sql so I hadn't thought of that.

Thank you soooooooooo much.

Nelson Cardoso

Share this post


Link to post
Share on other sites
Did yu create the forum yourself, if you did then it sounds like you have an exploit in your code which the hacker is using to spam your forum.

Share this post


Link to post
Share on other sites
Hi wildteen88... any gotcha's that I should look out for?  Any "recommends" for solutions?

Thanks for replying to my email

Nelson

Share this post


Link to post
Share on other sites
ToonMariner, not sure if you're still following this thread... can you help with one more thing (or anyone else)?

I added what another snippet to my if statement before my insert code:
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "malta_add") && ($_SERVER['REMOTE_ADDR'] != "")) {.......

I added the:  && ($_SERVER['REMOTE_ADDR'] != "")

This was to try to avoid the hacker from even submitting if the ip was empty.  But it didn't work because he was able to submit... and when I look at the database, no value was captured in my "user ip" field.  Have I written this wrong?  Shouldn't that addition have stopped a post if there was no value for $_SERVER['REMOTE_ADDR'?

Thanks a million!!

Nelson

Share this post


Link to post
Share on other sites
[quote]
I added what another snippet to my if statement before my insert code:
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "malta_add") && ($_SERVER['REMOTE_ADDR'] != "")) {.......

Have I written this wrong?  Shouldn't that addition have stopped a post if there was no value for $_SERVER['REMOTE_ADDR']
[/quote]

You could try this:
[code]
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "malta_add") && (!$_SERVER['REMOTE_ADDR'])) {.......
[/code]

I think this should work if $_SERVER['REMOTE_ADDR'] is empty.

Rich

Share this post


Link to post
Share on other sites
Wow!!!  This forum is fantastic!!!  You people have been a great help....

HuggieBear... the only change I made was "I took out the '!'"... because I want them to submit if there is an ip address.

You got me 99% over that hurdle (I have to do some thinking for myself)... thanks so much!

Take care.
Nelson

Share this post


Link to post
Share on other sites
[quote author=ToonMariner link=topic=106238.msg424647#msg424647 date=1156944767]

Even if they spoof an ip address you will get another measure of how they are circumventing your system - and then prevent that.
[/quote]

I agree.

here is a very good article that describes various methods of [url=http://www.developerfusion.co.uk/show/4656/]insertion[/url] and how to prevent them. Here is one that is just good [url=http://www.developerfusion.co.uk/show/5381/]general reading[/url]. I found these to be very infomative and think that they should be standard reading for all.

The most improtant thing is to sanitize the user imputed data. Use something like [url=http://us3.php.net/manual/en/function.mysql-real-escape-string.php]mysql_real_escape_string[/url] and maybe [url=http://us3.php.net/manual/en/function.preg-match.php]preg_match[/url], to pervent unwanted caricatrues.

The reason that the ip field is empty is most likely that they are bypassing that field. What I would do is have a time stamp that for each post(You may already have that). I would then create a table (called something like `hits`)and a script that would  record the ip of every person that enters my site along with the referrer and timestamp.

Then when the unwanted posts are placed then you could search the `hits` table by the timestamp in the post. And there we go. You should now have the ip of the person that is posting these posts.

They may also be posting from out side your site. So another thing that I would do is do something like this

[code=php:0]
if (!$_SERVER['HTTP_REFERER'] !== 'http://yoursite.com/the_posting_page.php')
   header("HTTP/1.1 404 Not Found");
}
[/code]

Or maybe a acess denied error. I would stick with the the 404.

Good luck,
Tom


Share this post


Link to post
Share on other sites
[quote]
HuggieBear... the only change I made was "I took out the '!'"... because I want them to submit if there is an ip address.

You got me 99% over that hurdle (I have to do some thinking for myself)... thanks so much!
[/quote]

Sorry about the '!' I misread the code...  :o

Glad you picked up on it though  :)

Share this post


Link to post
Share on other sites
also, just to clear up that you bug isn't actually somewhere else, is this person's the ONLY person that your db is not getting their ip address? In other words, is your db storing other people's ip addresses just fine?

Share this post


Link to post
Share on other sites
Another thing that I would do is put size limits on all of my text fields , something like 20, and maybe pass all of the fields that are going to be placed in database through [url=http://us3.php.net/manual/en/function.htmlentities.php]htmlentities[/url]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.