Help me with these problems

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

27 replies · 1,419 views · started 17 years ago · 1 min read

11 participants
kiLLeR-eyEd_14 Senior · 382 posts #1

Help me with these problems: In any profile, 2 IPs are detailed..I don't know why like that..Another one is when i posted an apostrophe, 3 slashes are added instead of only one..I have magic_quotes_gpc on and i also added an anti_injection function with mysql_real_escape_string, trim, strip_tags..I removed forbidden words like drop, update, etc..I just only need one function that can counter sql injection attack..

morse Senior · 364 posts #2

whats the point in having magic quotes on ? its a security issue slashes are added for the mysql_real_escape_string to escape the quotes as quotes are used for mysql injection 2 ips are detailed coz you have added a code to show ips twice, thats your coding issue, people here cant solve it until you give out the coding of the page exactly where two ips are listed, chances are that 1 will be hostname while other will be ip

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

amylee Principal · 1,092 posts #3
//protect against sql injections and remove $ sign
if( !get_magic_quotes_gpc() )
{
    if( is_array($_GET) )
    {
        while( list($k, $v) = each($_GET) )
        {
            if( is_array($_GET[$k]) )
            {
                while( list($k2, $v2) = each($_GET[$k]) )
                {
                    $_GET[$k][$k2] = addslashes($v2);
                }
                @reset($_GET[$k]);
            }
            else
            {
                $_GET[$k] = addslashes($v);
            }
        }
        @reset($_GET);
    }

    if( is_array($_POST) )
    {
        while( list($k, $v) = each($_POST) )
        {
            if( is_array($_POST[$k]) )
            {
                while( list($k2, $v2) = each($_POST[$k]) )
                {
                    $_POST[$k][$k2] = addslashes($v2);
                }
                @reset($_POST[$k]);
            }
            else
            {
                $_POST[$k] = addslashes($v);
            }
        }
        @reset($_POST);
kiLLeR-eyEd_14 Senior · 382 posts #4

amylee wrote:

//protect against sql injections and remove $ sign
if( !get_magic_quotes_gpc() )
{
    if( is_array($_GET) )
    {
        while( list($k, $v) = each($_GET) )
        {
            if( is_array($_GET[$k]) )
            {
                while( list($k2, $v2) = each($_GET[$k]) )
                {
                    $_GET[$k][$k2] = addslashes($v2);
                }
                @reset($_GET[$k]);
            }
            else
            {
                $_GET[$k] = addslashes($v);
            }
        }
        @reset($_GET);
    }

    if( is_array($_POST) )
    {
        while( list($k, $v) = each($_POST) )
        {
            if( is_array($_POST[$k]) )
            {
                while( list($k2, $v2) = each($_POST[$k]) )
                {
                    $_POST[$k][$k2] = addslashes($v2);
                }
                @reset($_POST[$k]);
            }
            else
            {
                $_POST[$k] = addslashes($v);
            }
        }
        @reset($_POST);

Amylee, is that realLy w0rking?c0z i'm already using that..I got it fr0m sweEt angel's p0st..I used it and rem0ve mysql_real_escape_string which i have added beFore..Yeh, it addslashes but don't kn0w if it realLy rem0ves $ sign.?

amylee Principal · 1,092 posts #6

its directly from my script and yeah it does it job

morse Senior · 364 posts #7

kiLLeR-eyEd_14 wrote: Does it realLy protects all submitTed f0rms?Like in sh0uTb0x and chat where i cAn't see addslashes there..I cAn Only seE adDslashes in pm and in my chatbot that's why i'm thinking if that realLy pr0tect all submited f0rms..

if you dont see slashes in your shouts and chats , iut means you can be easily hacked , recheck your entire coding , i guess you have missed many parts where you are supposed to block sql injection

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

Anshul Senior · 296 posts #8
if(!get_magic_quotes_gpc())
{
  $_GET = array_map('mysql_real_escape_string', $_GET); 
  $_POST = array_map('mysql_real_escape_string', $_POST); 
  $_COOKIE = array_map('mysql_real_escape_string', $_COOKIE);
}
else
{  
   $_GET = array_map('stripslashes', $_GET); 
   $_POST = array_map('stripslashes', $_POST); 
   $_COOKIE = array_map('stripslashes', $_COOKIE);
   $_GET = array_map('mysql_real_escape_string', $_GET); 
   $_POST = array_map('mysql_real_escape_string', $_POST); 
   $_COOKIE = array_map('mysql_real_escape_string', $_COOKIE);
}
Dj-marc Developer · 164 posts #9

Spook wrote:

if(!get_magic_quotes_gpc())
{
  $_GET = array_map('mysql_real_escape_string', $_GET); 
  $_POST = array_map('mysql_real_escape_string', $_POST); 
  $_COOKIE = array_map('mysql_real_escape_string', $_COOKIE);
}
else
{  
   $_GET = array_map('stripslashes', $_GET); 
   $_POST = array_map('stripslashes', $_POST); 
   $_COOKIE = array_map('stripslashes', $_COOKIE);
   $_GET = array_map('mysql_real_escape_string', $_GET); 
   $_POST = array_map('mysql_real_escape_string', $_POST); 
   $_COOKIE = array_map('mysql_real_escape_string', $_COOKIE);
}

does tis code do the same thing like what amylee's code does?

anderson Developer · 146 posts #10

As far as I know, function mysql_real_escape_string() cant work for escaping $ sign.

Wait...

Anshul Senior · 296 posts #13

kiLLeR-eyEd_14 wrote: My problem now is my registration page..I d0n't think i've got wr0ng c0dings in my register.php..It's w0rking bEf0re buT then 1time it got erRor..The next page sh0ws erRor buT registrati0n was sucCessful..CAn s0me1 telL me what cAuses this pr0blem?

dude dont the mess your text wid upper and lower case duh

mcKeny Developer · 130 posts #15

magic quotes will be disable soon...Why not verify all field? eg the function that check for illegal characters in the registration page? only allowed A-Z 1-9 space .? in input element... thats what i did with one of ma unfinished script http://mobispace.cogia.net works perfectly..

 ;||id=1--; 

😀 use your head its easy to black

R.M.C

PHP Adovocate B)

kiLLeR-eyEd_14 Senior · 382 posts #16

Yeh..It's already in my script..The thing i'm talking about is or the thing i just want to have is a more secured script to counter sql injection attacks..I'm not contented with magic_quotes or addslashes..When i tried using mysql_real_escape_string, i got errors that why i can't use that function..

metulj Super moderator Principal · 1,726 posts #17

kiLLeR-eyEd_14 wrote: SorRy duDe..I'm using m0bile that's why i cAn't av0id using upPer cAse..If i'm using a c0mpuTer, i wilL n0t go make hard typing with upPercAse..Lol

i use mobile A LOT !! so dont tell me you cant avoid capital letters... next time i'll just delete posts writen in aka LeeT text.. it's really annoying to read it, almost same annoyance like all written in capital letters

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ノ刀ノイリ!

something else Fellow · 2,296 posts #18

use stripslashes($string); on output (providing its not going back into database for something like a badly coded quote system)*:p

mcKeny Developer · 130 posts #19

kiLLeR-eyEd_14 wrote: Yeh..It's already in my script..The thing i'm talking about is or the thing i just want to have is a more secured script to counter sql injection attacks..I'm not contented with magic_quotes or addslashes..When i tried using mysql_real_escape_string, i got errors that why i can't use that function..

error??????

 $newstring = mysql_real_escape_string($string);
echo $newstring;

R.M.C

PHP Adovocate B)

kiLLeR-eyEd_14 Senior · 382 posts #20

metulj wrote: i use mobile A LOT !! so dont tell me you cant avoid capital letters... next time i'll just delete posts writen in aka LeeT text.. it's really annoying to read it, almost same annoyance like all written in capital letters

Then why don't you make strings converted into lower cases in outputs here..A user cannot avoid it and you were annoyed with it, so make a script that would convert upper cases into lower cases..

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