Jump to content

mysql injection


ch1zra

Recommended Posts

elem, imam ovo :

$cxn=@mysql_connect("$host","$user","$pass") or die ($diemsg);

@mysql_select_db("$dbname",$cxn);

sve je jelda definisano, ali neki lik me je iscimao, i kao baci oko na ovo :

http://ch1zra.com/mirc/index.php?display=S...t+all+1,2,3,4--

i tu izlista neke sitne pizdarijice (nisam se nikad interesovao oko injectiona, pa ne znam sta tacno izlistava, kontam da je broj kolona u datoj tabeli, and so on).

elem, ja koliko sam uspeo da izgooglam, @mysql_connect i @mysql_select_db bi trebalo da resi taj problem, ali avaj.. nije :P

dakle, jel imate ideju neku sta da radim ? :)

nije da drzim neke bitne podatke i tim tabelama, al svejedno, zelim da ne moze niko da mi madjija tu.

Ko je nub ne budi mu drug.

I mean you harm.

Link to comment
Share on other sites

svaki upit u bazu ciji su delovi user-generated moras da provlacis kroz f-jy

mysql_real_escape_string
da bi se osigurao od haka. Ta funkcija je sigurna zastita od zloupotrebe. Mysql injection nastaje kada se radi neociscen upit u bazu. Recimo da imas kod kojim vrsis selekciju na osnovu nekog korisnickog odabira:
$id = $_GET['id']

$result = mysql_query("SELECT * FROM admin WHERE id = $id");
ovaj upit je nesiguran zato sto ja umesto id-a u GET mogu da stavim sledeci kod recimo : 1; DROP TABLE admin i da se tebi izvrsi sledeci query:
$result = mysql_query("SELECT * FROM admin WHERE id =1; DROP TABLE admin");

The people can always be brought to the bidding of the leaders. That is easy. All you have to do is tell them they are being attacked and denounce the pacifists for lack of patriotism and exposing the country to danger. It works the same way in any country.

Link to comment
Share on other sites

ok... i dalje me nesto jebucka :D

ako moze mali heads up samo, gde i kako da ubacim escape ?

$diemsg = "An error occurred while trying to retrieve data. Please try again later.";

$cxn=@mysql_connect("$host","$user","$pass") or die ($diemsg);

@mysql_select_db("$dbname",$cxn);


$SnippetID = $_GET['SnippetID'];

if (isset($SnippetID)) {

	$query = "select * from snippets where id = " . $SnippetID;

	$result = mysql_query($query) or die ("Can't find requested snippet.");

	while ($row = mysql_fetch_assoc($result)) {

	extract($row);

	echo "<div class=\"top\">";

	echo "<div align=\"right\" style=\"color: #000000\">..:: \$snippets >> " . $snipname . "</div>";

	$cnt = str_replace(" />",">",html_entity_decode($description, ENT_QUOTES));

	echo "<div class=\"down\">";

	echo $cnt;

	echo "<br><br>";

	echo "<form name=\"snippet\" action=\"none\"><textarea name=\"snippet\" readonly style=\"color:#000000;background-color:#CCCCCC;\" onClick=\"java script:this.form.snippet.focus();this.form.snippet.select();\" cols=\"70\" rows=\"10\">" . $snip . "</textarea></form>";

	echo "<hr width=\"600\"><div align=\"right\"><a href=\"index.php?display=Snippets\">Back to all \$snippets</a></div></div></div>";

	}

}
//edit malo seljacka varijanta, al uspeo sam nesto da odradim.. ubacio sam :
if (isset($SnippetID))  {

if (!ctype_alnum($SnippetID)) {

	die("bad user input, gtfo!");

}

Edited by ch1zra

Ko je nub ne budi mu drug.

I mean you harm.

Link to comment
Share on other sites

umesto:

$SnippetID = $_GET['SnippetID'];
ubaci:
$SnippetID = mysql_real_escape_string($_GET['SnippetID']);

The people can always be brought to the bidding of the leaders. That is easy. All you have to do is tell them they are being attacked and denounce the pacifists for lack of patriotism and exposing the country to danger. It works the same way in any country.

Link to comment
Share on other sites

^ slazem se, ali dosta (besplatnih) hostova nema novi mysql, ili nema ukljucen mysqli

The people can always be brought to the bidding of the leaders. That is easy. All you have to do is tell them they are being attacked and denounce the pacifists for lack of patriotism and exposing the country to danger. It works the same way in any country.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...