Welcome our webmaster and SEO forum
Please enjoy the forum, contribute what you can, and wind up the Moderators!
+ Reply to Thread
Page 1 of 4 1 2 3 ... LastLast
Results 1 to 10 of 37

Thread: Hacker trap script

  1. #1
    Bagi Zoltán's Avatar
    Bagi Zoltán is offline Boss Cart consultant Bagi Zoltán has much to be proud of Bagi Zoltán has much to be proud of Bagi Zoltán has much to be proud of Bagi Zoltán has much to be proud of Bagi Zoltán has much to be proud of Bagi Zoltán has much to be proud of Bagi Zoltán has much to be proud of Bagi Zoltán has much to be proud of
    Join Date
    Feb 2007
    Location
    Veszprém, Hungary
    Posts
    1,225

    Default Hacker trap script

    I would like to declare that this is not a genuine post, so i already posted it on an other forum as well, but now i know that i should have post it here firstly.

    This script arsenal will help to fight against hacker, won't make your script more secure so if it is open for a certain attack this won't solve the programing bug, but will make the entrance more difficoult.

    Let's see what are the functions:
    • validate the Googlebot, the msnbot and the Yahoo! Slurp so when someone proxify the the site it won't cause content duplication,
    • make possible to ban certain user agents, IPs as well,
    • inspect the requested URL string so when someone would like to manipulate the mysql database via injection method the trap will reward it with a very elegant IP ban (this function must be modify in accordance of the website and the needs) ,

    This is the core code called security.php

    PHP Code:
      <?php
    $ua 
    $_SERVER['HTTP_USER_AGENT'];
    $webadress $_SERVER['REQUEST_URI'];
    $ip $_SERVER['REMOTE_ADDR'];
    $target file(dirname(__FILE__)."/ip-logfile.txt");
    $sqltarget file(dirname(__FILE__)."/sql-injection.txt");
    $ualist file(dirname(__FILE__)."/banned-ua.txt");
    $loc dirname(__FILE__);

    //if the visitor said to be a robot
    if(strstr($ua'msnbot') || stristr($ua'Googlebot') || stristr($ua'Yahoo! Slurp')){
    //we must validate it
    require "$loc/security-proxy-checker.php";
    }
    else{

    //visitors with banned user agents are not allowed to access
    foreach($ualist as $item){
    $item trim($item);
    if(
    stristr($ua$item)){
    require 
    "$loc/message.php";
    exit;}}
    //visitors with banned IPs are not allowed to access
    foreach($target as $item){
    $item trim($item);
    if(
    stristr($ip$item)){
    require 
    "$loc/message.php";
    exit;
    }}

    //let's inspect the requested URL string
    foreach($sqltarget as $sqlitem){
    $sqlitem trim($sqlitem);
    if(
    stristr($webadress$sqlitem)){
    require 
    "$loc/index.php";
    exit;}}}
    ?>
    As you may recognise the script uses txt files which stores the banned user agents / IPs and typical string particulars which might be used during the sql injection attack.

    Very important part of the solution is the index.php file with the following code
    PHP Code:
      <?php
    $ip 
    $_SERVER["REMOTE_ADDR"];
    $webadress $_SERVER['REQUEST_URI'];
    $loc dirname(__FILE__);
    $logfile "$loc/ip-logfile.txt";
    $urllogfile "$loc/requested-string.txt";
    $time date("F j, Y, g:i a"); 
    require 
    "$loc/message.php";
    //Let's start the statistic module
    //store the IP as first step
    $fp fopen($logfile'a');
    fputs($fp"$ip
    "
    );
    fclose($fp);
    $fpstring fopen($urllogfile'a');
    //Put the string and some very importent parameter into a control logfile so if somebody was banned without any reason we will have the chance to fix that
    fputs($fpstring"$ip requested this string $webadress this time $time
    "
    );
    fclose($fpstring);
    exit;
    ?>
    My favourite part of the whole thing is the message.php which stores my greetings to the attackers, very nice one so nothing rough.

    Attaching you may find the whole archived folder (with Hungarian comments in the files). In order to implement the trap all you need to do is to upload the files into an optional folder let's name it core for instance and place this code to the very front of the files you would like to protect.

    PHP Code:
    PHP Code:
    <?php require "/thisisthepathof/core/security.php"?>
    And one more thing. Don't forget to restict the crawl of the optional core folder where the files are stored in the robots.txt file, this may catch some extra bad guy.

    I warrant nothing but this works very well at my site. I regularly check the requested-string.txt to see if somebody had been banned accidentally. But i regularly smile on the catchings.
    Thanks

    ps. today i realized that at my Hungarian blog some very strange URLs has been restricted for instance /Databases/vicndatadata.mdb or /Reg/User_Reg.asp. I though that is something that i don't need it and since i know that WP is written in php and i use permalinks i completed my sql-injection.txt file with this two lines:
    .asp
    .mdb
    restricting the access of these certain file extensions, and my security logs become very busy since then
    I'm going to ask Cyrus to help me extend the protection covering leeching and xss attacks as well, but don't tell him, he knows nothing about my purpose
    Attached Files

  2. #2
    gkd_uk is offline Super Moderator gkd_uk has much to be proud of gkd_uk has much to be proud of gkd_uk has much to be proud of gkd_uk has much to be proud of gkd_uk has much to be proud of gkd_uk has much to be proud of gkd_uk has much to be proud of gkd_uk has much to be proud of gkd_uk has much to be proud of
    Join Date
    Mar 2007
    Location
    UK
    Posts
    2,550

  3. #3
    temi's Avatar
    temi is offline Facilitator temi is just really nice temi is just really nice temi is just really nice temi is just really nice temi is just really nice
    Join Date
    Jun 2003
    Location
    London, England.
    Posts
    10,304

    Default

    Thanks for sharing Bagi

    * Build a shopping cart for your business with eCommerce software UK
    * BossCart.com can build you a.
    Register your domain names at Velnet
    ::
    Add Eco sites to The Green Directory free of charge.
    Use LBS Free PHP Directory Script . Web Hosting Blog

  4. #4
    deluxdon's Avatar
    deluxdon is offline Senior Member deluxdon has a spectacular aura about deluxdon has a spectacular aura about deluxdon has a spectacular aura about
    Join Date
    Mar 2007
    Location
    www.wpblogpoint.com
    Posts
    869

    Default

    Useful post bagi. Thanks for sharing it with us.

    DON.

  5. #5
    Bagi Zoltán's Avatar
    Bagi Zoltán is offline Boss Cart consultant Bagi Zoltán has much to be proud of Bagi Zoltán has much to be proud of Bagi Zoltán has much to be proud of Bagi Zoltán has much to be proud of Bagi Zoltán has much to be proud of Bagi Zoltán has much to be proud of Bagi Zoltán has much to be proud of Bagi Zoltán has much to be proud of
    Join Date
    Feb 2007
    Location
    Veszprém, Hungary
    Posts
    1,225

    Default

    It is my pleasure to read your responses.

  6. #6
    Lovely is offline Senior Member Lovely is on a distinguished road
    Join Date
    Mar 2007
    Posts
    305

    Default

    It is a nice script Bagi Zoltán, thanks for sharing it. I wonder if there is any hacker and anti virus script that can work with server?

  7. #7
    espmartin's Avatar
    espmartin is offline Senior Member espmartin will become famous soon enough
    Join Date
    Jun 2007
    Location
    West Coast, USA (California)
    Posts
    625

    Default

    Bagi, you should begin a security consulting service! Serious!!!!

    I'll be your first client. PM me bro!!!

  8. #8
    Bagi Zoltán's Avatar
    Bagi Zoltán is offline Boss Cart consultant Bagi Zoltán has much to be proud of Bagi Zoltán has much to be proud of Bagi Zoltán has much to be proud of Bagi Zoltán has much to be proud of Bagi Zoltán has much to be proud of Bagi Zoltán has much to be proud of Bagi Zoltán has much to be proud of Bagi Zoltán has much to be proud of
    Join Date
    Feb 2007
    Location
    Veszprém, Hungary
    Posts
    1,225

    Default

    Lovely, sadly i don't know as much about how to identify viruses with php but sadly my toolkit is limited only on server side scripts. As far as i know viruses are not really able to catch via script, but secure gateways such as zorp, which identify the unnatural package transmissions.

    Martin, thank you for your kind words i am thinking on this, but i need to learn hacking as first. Of course i am thinking on ethical hacking, but you must know how to attack a script/server to know how to defend it, so it will be a long way and i am only at the startline at the monent. My sister work for an information security company called Kurt, i guess you have never heard about it, but there works one of the biggest hackers on the whole planet. He was disqualified from the hacker world champion because he used some tool which was not allowed I want him to be my mentor. Sweet dreams

    I would like to release only FREE defending scripts in the future which cover wider area of web based attacks that might be installaed easily for everyone.

  9. #9
    magyar is offline Banned magyar is on a distinguished road
    Join Date
    Jan 2008
    Posts
    5

    Default

    Very nice. Thank you.

  10. #10
    Bagi Zoltán's Avatar
    Bagi Zoltán is offline Boss Cart consultant Bagi Zoltán has much to be proud of Bagi Zoltán has much to be proud of Bagi Zoltán has much to be proud of Bagi Zoltán has much to be proud of Bagi Zoltán has much to be proud of Bagi Zoltán has much to be proud of Bagi Zoltán has much to be proud of Bagi Zoltán has much to be proud of
    Join Date
    Feb 2007
    Location
    Veszprém, Hungary
    Posts
    1,225

    Default

    This is a schame that you use our nation as user member and got banned. Next time you should choose something else when you go spammming.

+ Reply to Thread
Page 1 of 4 1 2 3 ... LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124