Lavalair Sql Injection Blocker

Started on the old forum in March 2009 · view the original in the archive · old links redirect here

41 replies · 7,140 views · started 17 years ago · 1 min read

TL;DR · summary of 41 replies
  • -subzero suggested using magic_quotes_gpc = On in php.ini to prevent a lot of problems related to SQL injection.
  • -Anderson recommended validating all input fields and using mysql_real_escape_string for preventing SQL injections, as it is specifically made for that purpose by the PHP team.
  • -The thread did not conclude with a specific fix or code approach for blocking SQL Injection completely.

Written automatically from the replies by a language model on our own server. It can be wrong; the posts below are the source.

31 participants
newbie14 Junior · 22 posts #21

re

ini_set("display_errors", "0"); if(!get_magic_quotes_gpc()) { $_GET = array_map('trim', $_GET); $_POST = array_map('trim', $_POST); $_COOKIE = array_map('trim', $_COOKIE);

$_GET = array_map('addslashes', $_GET); $_POST = array_map('addslashes', $_POST); $_COOKIE = array_map('addslashes', $_COOKIE); }

its true prevent sql inject?

kiss Senior · 294 posts #22
function clean($str)
{
$str = @trim($str);
if(get_magic_quotes_gpc())
{
$str = stripslashes($str);
}
return mysql_real_escape_string($str);
}

Easy and very usefull: $test = clean($_REQUEST['test']); $test = clean($_POST['test']); $test = clean($_GET['test']);

www.inbuzunar.mobi -Your mobile portal pocket

Ponick Developer · 216 posts #23

Post this in your core.Php

function check_injection()
  {
    $badchars = array("DROP", "SELECT", "UPDATE", "DELETE", "DELETE" , "UNION", "WHERE", "FROM");
  
    foreach($_REQUEST  as $value)
    {
      if(in_array(strtoupper($value), $badchars))
      {
      $logfile= 'log/log.txt'; //chmod 777
$IP = $_SERVER['REMOTE_ADDR'];
$logdetails= date("F j, Y, g:i a") . ': ' . '<a href=http://dnsstuff.com/tools/city.ch?ip='.$_SERVER['REMOTE_ADDR'].' target=_blank>'.$_SERVER['REMOTE_ADDR'].'</a>';
$fp = fopen($logfile, "r+");
fwrite($fp, $logdetails, strlen($logdetails));
fclose($fp);

       header('Location:http://go-to-hell.com');

      }
      else
      {
        $check = preg_split("//", $value, -1, PREG_SPLIT_OFFSET_CAPTURE);
        foreach($check as $char)
        {
         if(in_array(strtoupper($char), $badchars))
          {
      $logfile= 'log/log.txt';
$IP = $_SERVER['REMOTE_ADDR'];
$logdetails= date("F j, Y, g:i a") . ': ' . '<a href=http://dnsstuff.com/tools/city.ch?ip='.$_SERVER['REMOTE_ADDR'].' target=_blank>'.$_SERVER['REMOTE_ADDR'].'</a>';
$fp = fopen($logfile, "r+");
fwrite($fp, $logdetails, strlen($logdetails));
fclose($fp);

            header('Location:http://go-to-hell.com');
     }
    }
   }
  }
  } 

hehehe. . .

/* I don't know everything hehe */

Find me on facebook

kiLLeR-eyEd_14 Senior · 382 posts #24
function safe($text)
{
$safe = stripslashes($text);
if(function_exists("mysql_real_escape_string"))
{
$safe = mysql_real_escape_string($safe);
}else if(function_exists("mysql_escape_string"))
{
$safe = mysql_escape_string($safe);
}
return $safe;
}

use: $str = safe($_POST['str']); $str = safe($_GET['str']);

kenxyz Junior · 13 posts #25

Where do i use d script

murshid7 Junior · 22 posts #26

how to stop sql blocking when some one comes and makes a external link to avatar, forum posts. how to stop that?

Mysterio Lead · 630 posts #27

murshid7 wrote: how to stop sql blocking when some one comes and makes a external link to avatar, forum posts. how to stop that?

try to make something like go.php, so when someone adds a link, it will loose everything in there, then redirect to the desired url.

mysterio.al - programming is a functional art

metulj Super moderator Principal · 1,726 posts #28

jsyguy23 wrote: $uid=mysql_real_escape_string( $_GET["uid"] );

this

$uid = mysql_escape_string(strip_tags(htmlspecialchars($_GET['uid'])));

could be a lot better 😊

It's better to keep your mouth shut and give the impression that you're stupid, than to open it and remove all doubt. ⓣⓗⓔ ⓠⓤⓘⓔⓣⓔⓡ ⓨⓞⓤ ⓑⓔ©ⓞⓜⓔ, ⓣⓗⓔ ⓜⓞⓡⓔ ⓨⓞⓤ ⓐⓡⓔ ⓐⓑⓛⓔ ⓣⓞ ⓗⓔⓐⓡ ! ιη тнєσяу, тнє ρяα¢тι¢є ιѕ α яєѕυℓт σƒ тнє тнєσяу, вυт ιη ρяα¢тι¢є ιѕ тнє σρρσѕιтє.

キノgんイノ刀g 4 ア乇ムc乇 ノ丂 レノズ乇 キucズノ刀g 4 √ノ尺gノ刀ノイリ!

paramound Junior · 18 posts #30

remove all forms of request password, or forgotten password to avoid the send me the password hacking method

manavworld Developer · 118 posts #31

Mysterio3 wrote: try to make something like go.php, so when someone adds a link, it will loose everything in there, then redirect to the desired url.

you said make like this go.php when hacker cames with external link via fourm,picture,avtar links, but my question is that go.php for wot? U mean we have need to rename gallery.php or core.php or wot. Can u explain about it, than newbie user can undrstand easly about all function

ranzit2 Developer · 187 posts #32

manavworld wrote: you said make like this go.php when hacker cames with external link via fourm,picture,avtar links, but my question is that go.php for wot? U mean we have need to rename gallery.php or core.php or wot. Can u explain about it, than newbie user can undrstand easly about all function

its for the links,posted by users.like http://site.com should be go.php?site=http://site.com in go.php make header location the site value. for images dnt allow direct images..pass images through php file

she is beautifull than php.and i love her more than php.

manavworld Developer · 118 posts #33

ranzit2 wrote: its for the links,posted by users.like http://site.com should be go.php?site=http://site.com in go.php make header location the site value. for images dnt allow direct images..pass images through php file

ahh ok sir, i will remove link of avtar, iam undrstand w0t u said, thank budy, realy thankful to u

paramound Junior · 18 posts #35

nice job bro. Just make sure you don't request a password link to your site or that will be the easiest way to a green horn in hacking to hack you

manavworld Developer · 118 posts #36

Plz help me, wht code i can add at .htaccess file, plz can u post here full code than i can easly copy>>post, i wil be very-very thankful to u.

manavworld Developer · 118 posts #37

ozziemale31 wrote: to protect your file share folders from php pages being uploaded make a htaccess page and put in it the following

IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti*

<Limit GET POST>
order deny,allow
deny from all
allow from all
</Limit>

<Limit PUT DELETE>
order deny,allow
deny from all
</Limit>

<Files images>
deny from all
</Files>

<Files *.php>
deny from all
</Files>

<Files *.php.*>
deny from all
</Files>

<Files *.php.php.*>
deny from all
</Files>

when a php page is uploaded in that directory and the hacker goes to open it they end up with a nice 403 error page not found even though their script to hack may be there lol thanks to gum for that lil trick

brother i hv already updated (magic_quotes in my core.php coding, now i can update this code in my .htaccess file?..ok...and one more question....<Files *.php> deny from all </Files>

<Files .php.> deny from all </Files> ..its ur code, hv we need to replace anythng? Plz ur litle teach make me secure, plz help me brother...i wil thankful to u.

raymark Junior · 23 posts #38

My site was still hacked 🙁

KiLLeR_mAcHInE Developer · 128 posts #40

My site was also hacked till today i never know who hacked it

:-):-):-):-) any probs PM me ??? :-):-):-):-):-) c yA

Write your reply now; next you create a free account (or sign in) and it is posted right away. Sign in to reply.

Similar topics

Keyboard shortcuts

g f
Go to forums
g h
Go to your feed
g m
Go to messages
r
Reply (in a topic)
/
Search
j
Next post
k
Previous post
?
This list
Ctrl/⌘ + Enter
Send what you are writing
Ctrl/⌘ + B / I
Bold / italic while writing
Esc
Close