Forum     

Go Back   Digit Technology Discussion Forum > Community > Tutorials
Register FAQ Calendar Mark Forums Read

Tutorials This section offers tutorials and How to's on just about anything related to computers and IT. Note: All tutorials are courtesy the posters and not verified by Digit

Closed Thread
 
LinkBack Thread Tools Display Modes
Old 11-03-2005, 05:29 PM   #1 (permalink)
sunnydiv
Guest
 
Posts: n/a
Default mysql attack, prevention

i made this following code, to hope it will protect from mysql injection
tell me if u find a bug or something

function remove_bad($value)
{
$value = addslashes($value);
$value = strip_tags($value);

echo ereg_replace("select", "nselectn", $value);
echo ereg_replace("delete", "ndeleten", $value);
echo ereg_replace("drop", "ndropn", $value);
echo ereg_replace("update", "nupdaten", $value);
echo ereg_replace("where", "nwheren", $value);

return $value;
}

reverse. hopefully you know, how this is going to work


function add_bad($value)
{
echo ereg_replace("nselectn", "select", $value);
echo ereg_replace("ndeleten", "delete", $value);
echo ereg_replace("ndropn", "drop", $value);
echo ereg_replace("nupdaten", "update", $value);
echo ereg_replace("nwheren", "where", $value);
$value = stripslashes($value);

return $value;
}


source, mysite http://www.rokda.info/forum/sutra14.html#14
 
Advertisements. Register and be a member of the community to get rid of them.
Advertisement

Old 11-03-2005, 08:23 PM   #2 (permalink)
In The Zone
 
Join Date: Feb 2005
Location: Anonymous
Posts: 204
Default

Are u sure you made the code by yourself ??
I think i saw it in packetstorm
h4xbox is offline  
Old 11-03-2005, 09:59 PM   #3 (permalink)
sunnydiv
Guest
 
Posts: n/a
Default

what dude

lame

i made it dude, there is nothing in it

i doubt they used the same technique

there r many many combinations one can use
 
Old 12-03-2005, 09:38 AM   #4 (permalink)
In The Zone
 
Join Date: Feb 2005
Location: Anonymous
Posts: 204
Default

I dunno anything abt hacking / scripts ... You are genius
h4xbox is offline  
Old 12-03-2005, 11:47 AM   #5 (permalink)
Right Off the Assembly Line
 
Join Date: Jul 2004
Posts: 13
Default hmm

Try this

I made this as someone had reported XSS vurnebilities in my S/w . This will strip everything and will not also allow incorrect entries though the forms ( more of a quick fix ) . Youll have to decode appropiately while displaying .

Code:
<?php
/*This will strip html from every variable unless it contains the word text ( introtext ) */
/* also this will conver all ' and " into text due to problems with sqlite and others */

function dbencode($str)
	{
	$str = addslashes($str);
	$str = str_replace(array("\r","\n","\\","'","\""),array("[CR]","[NL]","[ES]","[SQ]","[DQ]"), $str);
	return $str;
	}
	
function dbdecode($str)
	{
	$str = str_replace(array("[CR]","[NL]","[ES]","[SQ]","[DQ]"),array("\r","\n","\\","'","\""), $str);
	return stripslashes($str);
	}
	
function check_var($var,$val)
{
if(!defined( "_VALID_LM_ADMIN") && !strstr($var,'text'))
{
$val=utf8_decode($val);
$val=strip_tags($val);
}
if(is_array($val))return $val;
return dbencode($val);
}

foreach($_POST as $postvar => $postval){ ${$postvar} = check_var($postvar,$postval); }
foreach($_GET as $getvar => $getval){ ${$getvar} = check_var($getvar,$getval); }

?>
__________________
Vikas Patial
-----------------------------------------------------
http://www.ngcoders.com
http://www.roboticsindia.com
ngcoders is offline  
Closed Thread

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +5.5. The time now is 01:17 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.

Search Engine Optimization by vBSEO 3.3.2