Results 1 to 9 of 9
Like Tree4Likes
  • 4 Post By ozziemale31

Thread: stop sqli now and protect your site

  1. #1
    Senior Member ozziemale31's Avatar
    Join Date
    Jan 2007
    Location
    Sydney Australia
    Posts
    817
    Thanks
    27
    Thanked 265 Times in 90 Posts
    Rep Power
    0

    Default stop sqli now and protect your site

    ok so u wana make your script secure against sql injection ive made this possible to ban the hacker directly from the server
    first add this to your htaccess page rename my url to yours
    Code:
    Options -Indexes
    ErrorDocument 402 http://mobilezonez.net/?err
    ErrorDocument 403 http://mobilezonez.net/?err
    ErrorDocument 404 http://mobilezonez.net/?err
    ErrorDocument 500 http://mobilezonez.net/?err
    
    RewriteEngine On
    RewriteCond %{QUERY_STRING} (\"|%22).*(\>|%3E|<|%3C).* [NC]
    RewriteRule ^(.*)$ logs.php [NC]
    RewriteCond %{QUERY_STRING} (\<|%3C).*script.*(\>|%3E) [NC]
    RewriteRule ^(.*)$ logs.php [NC]
    RewriteCond %{QUERY_STRING} (javascript:).*(\;).* [NC]
    RewriteRule ^(.*)$ logs.php [NC]
    RewriteCond %{QUERY_STRING} (\;|\’|\"|\%22).*(union|select|insert|drop|update|validated|md5|1|5|perm|1 FROM ibwf_users|benchmark|or|and|if).* [NC]
    RewriteRule ^(.*)$ logs.php [NC]
    RewriteRule (,|;|<|>|’|`) /logs.php [NC]
    
    
    RemoveHandler .phtml .php3 .php4 .php5 .php6 .phps .cgi .pl .asp .aspx .shtml .shtm .fcgi .fpl .jsp .py
    AddType application/x-httpd-php-source .phtml .php3 .php4 .php5 .php6 .phps .cgi .pl .asp .aspx .shtml .shtm .fcgi .fpl .jsp .py
    
    php_flag display_errors 0
    php_value error_reporting 7
    php_value register_globals 0
    php_flag session.use_trans_sid off
    php_value magic_quotes_gpc 0
    php_value magic_quotes_runtime 0
    php_value magic_quotes_sybase 0
    php_value allow_url_fopen 0
    php_value arg_separator.output "&amp;"
    AddDefaultCharset UTF-8
    
    <IfModule mod_expires.c>
      ExpiresActive On
      ExpiresDefault A1209600
      <FilesMatch \.php$>
        ExpiresActive Off
      </FilesMatch>
    </IfModule>
    
    
    RewriteCond %{REQUEST_METHOD} ^TRACE
    RewriteCond %{HTTP:range} !(^bytes=[^,]+(,[^,]+){0,4}$|^$)
    RewriteRule .* - [F]
    
    RewriteCond %{HTTP_USER_AGENT} libwww [NC,OR]
    RewriteCond %{QUERY_STRING} ^(.*)=http [NC]
    RewriteRule ^(.*)$ – [F,L]
    make sure your htaccess page is chmodded to 666 to allow rewrite
    now make a logs.php page for your server

    Code:
    <?php
    /*
    ////////////////////////////////////////
    //       mobilezonez sql inject trap //
    //              by                          //
    //       Ozziemale aka Rampage     //
    ///////////////////////////////// //////
    */
    
    $r= $_SERVER['REQUEST_URI'];
    $q= $_SERVER['QUERY_STRING'];
    $i= $_SERVER['REMOTE_ADDR'];
    $u= $_SERVER['HTTP_USER_AGENT'];
    $i = "deny from $REMOTE_ADDR\n" ;
    $banip = '.htaccess';
    $fp = fopen($banip, "a");
    $write = fputs($fp, $i);
    fclose($fp);
    
    $ref = $_SERVER['HTTP_REFERER'];
    $phone=$_SERVER['HTTP_USER_AGENT'];
    $forwarder_ip = @htmlspecialchars(getenv('HTTP_X_FORWARDED_FOR'));
    $sydnNew_Time = time() + (24 * 60 * 60);
    $sydn=date("H:i",$sydnNew_Time);
    $time = date("F jS Y,");
    $iplog = "Time:$time-$sydn ::Browser:$r :: Ip-$i ::Referer:$ref ::Attempt: $r - $q - $i - $u";
               $fp=@fopen("iplog.txt","a+");
               @fputs($fp,"$iplog \r\n");
               @fclose($fp);
    $mess = $r . ' | ' . $q . ' | ' . $i . ' | ' .$u;
    mail("admin@mobilezonez.net","bad request",$mess,"from:hacker@mobilezonez.net");
    echo "Bye Bye Mother ****er!!!";
    ?>
    now make a page called iplog.txt

    chmod it to 777
    and we are done this will block sql injection logg the attempt email it to you then write the log onto a text file then ban the ip from your server...
    thus stopping them in their tracks. hope you all enjoy this code i made
    dont forget to say thanks
    Last edited by ozziemale31; 24-01-12 at 09:56.
    metulj, arnage, coder4u and 1 others like this.







    Dont Ask Me Dumb Questions.Or you'l get a Dumb Answer..


  2. The Following 11 Users Say Thank You to ozziemale31 For This Useful Post:

    ACIDCORE (24-01-12), coder4u (24-01-12), exhamination (24-01-12), gokturk (16-06-12), mahipat (24-01-12), metulj (24-01-12), mirror (25-01-12), mysterio (24-01-12), razor (24-01-12), shushant (29-01-12), woody (24-01-12)

  3. #2
    Senior Member ozziemale31's Avatar
    Join Date
    Jan 2007
    Location
    Sydney Australia
    Posts
    817
    Thanks
    27
    Thanked 265 Times in 90 Posts
    Rep Power
    0

    Default

    for those who end up with a 500 misconfiguration error
    use this version

    Code:
    RewriteEngine On
    RewriteCond %{QUERY_STRING} (\"|%22).*(\>|%3E|<|%3C).* [NC]
    RewriteRule ^(.*)$ logs.php [NC]
    RewriteCond %{QUERY_STRING} (\<|%3C).*script.*(\>|%3E) [NC]
    RewriteRule ^(.*)$ logs.php [NC]
    RewriteCond %{QUERY_STRING} (javascript:).*(\;).* [NC]
    RewriteRule ^(.*)$ logs.php [NC]
    RewriteCond %{QUERY_STRING} (\;|\’|\"|\%22).*(union|select|insert|drop|update|perm|validated|md5|benchmark|or|and|if).* [NC]
    RewriteRule ^(.*)$ logs.php [NC]
    RewriteRule (,|;|<|>|’|`) /logs.php [NC]
    
    RemoveHandler .phtml .php3 .php4 .php5 .php6 .phps .cgi .pl .asp .aspx .shtml .shtm .fcgi .fpl .jsp .py
    AddType application/x-httpd-php-source .phtml .php3 .php4 .php5 .php6 .phps .cgi .pl .asp .aspx .shtml .shtm .fcgi .fpl .jsp .py
    
    php_flag display_errors 0
    php_value error_reporting 7
    php_value register_globals 0
    php_flag session.use_trans_sid off
    php_value magic_quotes_gpc 0
    php_value magic_quotes_runtime 0
    php_value magic_quotes_sybase 0
    php_value allow_url_fopen 0
    php_value arg_separator.output "&amp;"
    AddDefaultCharset UTF-8
    
    <IfModule mod_expires.c>
      ExpiresActive On
      ExpiresDefault A1209600
      <FilesMatch \.php$>
        ExpiresActive Off
      </FilesMatch>
    </IfModule>
    
    
    RewriteCond %{REQUEST_METHOD} ^TRACE
    RewriteCond %{HTTP:range} !(^bytes=[^,]+(,[^,]+){0,4}$|^$)
    RewriteRule .* - [F]
    
    RewriteCond %{HTTP_USER_AGENT} libwww [NC,OR]
    RewriteCond %{QUERY_STRING} ^(.*)=http [NC]
    RewriteRule ^(.*)$ – [F,L]







    Dont Ask Me Dumb Questions.Or you'l get a Dumb Answer..


  4. #3
    Junior Member
    Join Date
    Sep 2011
    Posts
    2
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Default

    this now working bro i think you should test it and add it to the htaccess for does using the scriptand make it possible to download

  5. #4
    Senior Member analyzer's Avatar
    Join Date
    Mar 2011
    Posts
    101
    Thanks
    4
    Thanked 3 Times in 3 Posts
    Rep Power
    3

    Default

    This code was made for lava script, but will work also for other script if this script work

  6. #5
    Senior Member
    Join Date
    Mar 2010
    Posts
    147
    Thanks
    7
    Thanked 51 Times in 15 Posts
    Rep Power
    4

    Default

    this is not for sql injection, its for xss

    [Only registered and activated users can see links. Click Here To Register...]
    Applications, Games, Wallpapers, Ringtones, Videos, Themes, Screensaver and More!!!

  7. #6
    Junior Member ionutz's Avatar
    Join Date
    Feb 2012
    Posts
    15
    Thanks
    1
    Thanked 3 Times in 2 Posts
    Rep Power
    0

    Default

    Thank you for acetate given code

  8. #7
    Senior Member CreativityKills's Avatar
    Join Date
    May 2009
    Location
    Lagos
    Posts
    844
    Thanks
    0
    Thanked 106 Times in 62 Posts
    Rep Power
    4

    Default

    I honestly don't understand why people go through much stress over this whole injection thing, I've learnt enough to know there is no way to inject cleanly written codes. The php function coupled with good filter practices effectively contains injection.

  9. #8
    Senior Member
    Join Date
    Jul 2008
    Posts
    364
    Thanks
    124
    Thanked 32 Times in 31 Posts
    Rep Power
    0

    Default

    Quote Originally Posted by CreativityKills [Only registered and activated users can see links. Click Here To Register...]
    I honestly don't understand why people go through much stress over this whole injection thing, I've learnt enough to know there is no way to inject cleanly written codes. The php function coupled with good filter practices effectively contains injection.
    True words. However these codes might give a sense of security for people who have just set up a site out of free available script
    tinyurl.com/earnbymobile
    Easy earning for Indians
    ---------------------
    Alternative mobile advertising network .. Minimum 100 USD pay / NET15 pay cycle, Good Brand, Best targeting for Android
    goo.gl/6vub3

  10. #9
    Senior Member CreativityKills's Avatar
    Join Date
    May 2009
    Location
    Lagos
    Posts
    844
    Thanks
    0
    Thanked 106 Times in 62 Posts
    Rep Power
    4

    Default

    Yeah good point bro

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Scan And protect your site from Sql Injection!!
    By Head in forum Scripts Forum
    Replies: 0
    Last Post: 19-10-11, 03:36
  2. How to stop dis in subdomain site
    By iykzy4luv in forum Coding Forum
    Replies: 4
    Last Post: 08-04-11, 07:35
  3. Simple way to protect ur site fr4 session hack.
    By KiLLeR_mAcHInE in forum Tutorials
    Replies: 27
    Last Post: 10-12-10, 17:37
  4. protect
    By dominik92r in forum Coding Forum
    Replies: 8
    Last Post: 16-02-10, 04:31

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
  •  

SEO by vBSEO

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19