Istifadəçi |
2012-05-09 05:27 GMT |
|
|
|
Pr0grammer |
|
Mesaj Sayı : 1677 |
Mövzu Sayı : |
Rep Ver : |
Rep Sayı : 62 |
Indi Saytda : |
Cinsiyyət : Oğlan |
|
Şəhər : KARABAKH IS AZERBAIJAN! |
Ölkə : |
Məslək : |
Yaş : |
Mesaj : |
|
Bu secure olmaq əvəzinə tam vulnerable skriptdir Azsecurity.
Bunu hansı hosta atsanız 2x2 pwn olacaq tezliklə.
Verdiyin skriptdə fixdən danışmalı heç nə yoxdur ümumiyyətlə.
///////////////////////////////////////////////////////////////////////////////////////////////////////
[url]http://192.168.0.15/learn/work/prob.php?id=-9999999999999999999995+UnIoN+sElEcT+repeat(benchmark(1000000000000000,md5(repeat(md5(now()),100000))),1000000000000),2,3,4+from+makale--[/url]
[url]http://192.168.0.15/learn/work/prob.php?id=(select+benchmark(10000000000000000000,sha1(md5(now()))))--[/url]
[url]http://192.168.0.15/learn/work/prob.php?id=benchmark(10000000000000000000,sha1(md5(now())))--[/url]
///////////////////////////////////////////////////////////////////////////////////////////////////////
Problemi əyani olmaq sübüt etmək üçün: at localhosta yoxla yuxarıdakı kimi:
Kod: <?php
$mhost='192.168.0.1';
$mdbuser='xaxa';
$mpass='xaxa';
$mdb='xaxa';
$handle=@mysql_connect($mhost,$mdb,$mpass) or die('Qosula Bilmirem!');
$selectdb=@mysql_selectdb($mdb) or die('Sece Bilmirem Database-i');
// By AzSecurity...
$sef = $_GET["sef"];
$id = $_GET["id"];
$vt_kontrol=mysql_fetch_assoc(mysql_query("SELECT * FROM makale WHERE id=$id AND sef='$sef'"));
if(!$vt_kontrol){
die(var_dump($vt_kontrol));//false
echo "
<center><h1>Yemedin Getdin! <br>
</h1></center>
" ;
}
else{
echo $vt_kontrol["baslik"];
die(var_dump($vt_kontrol));//true-da
}
?>
mysql> show tables \g
+----------------+
| Tables_in_xaxa |
+----------------+
| makale |
+----------------+
1 row in set (0.00 sec)
mysql> explain makale \g
+--------+---------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+--------+---------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| baslik | text | NO | | NULL | |
| sef | int(11) | NO | | NULL | |
| metn | text | YES | | NULL | |
+--------+---------+------+-----+---------+----------------+
4 rows in set (0.02 sec)
mysql> show create table makale \g
+--------+-----------------------------------------------------------------------
---------------------------------------------------------------------------------
| Table | Create Table
+--------+-----------------------------------------------------------------------
---------------------------------------------------------------------------------
| makale | CREATE TABLE `makale` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`baslik` text NOT NULL,
`sef` int(11) NOT NULL,
`metn` text,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=latin1 |
+--------+-----------------------------------------------------------------------
---------------------------------------------------------------------------------
1 row in set (0.00 sec)
mysql> show create table makale \G
*************************** 1. row ***************************
Table: makale
Create Table: CREATE TABLE `makale` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`baslik` text NOT NULL,
`sef` int(11) NOT NULL,
`metn` text,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=latin1
1 row in set (0.00 sec)
mysql>
Fixinə qaldıqda
type casting:
$sef = (int)$_GET["sef"];
$id =(int) $_GET["id"];
yaxud ctype_digit() -lə yoxlamaq.
Kod: <?php
$mhost='192.168.0.1';
$mdbuser='xaxa';
$mpass='xaxa';
$mdb='xaxa';
$handle=@mysql_connect($mhost,$mdb,$mpass) or die('Qosula Bilmirem!');
$selectdb=@mysql_selectdb($mdb) or die('Sece Bilmirem Database-i');
if(isset($_GET['sef']) && isset($_GET['id']))//yoxla hemise inisialize olub ya yox?
{
// By AzSecurity...
$sef = mysql_real_escape_string((int)$_GET["sef"]);// her ehtimal ucun mysql_real_escape_string() de yerindedir.
$id =mysql_real_escape_string((int)$_GET["id"]);
$vt_kontrol=mysql_fetch_assoc(mysql_query("SELECT * FROM makale WHERE id='$id' AND sef='$sef'"));
if(!$vt_kontrol){
//die(mysql_error());//false
echo "
<center><h1>Yemedin Getdin! <br>
</h1></center>
" ;
}
else{
echo $vt_kontrol["baslik"];
//die(var_dump($vt_kontrol));//true-da
}
}
?>
Ümumiyyətlə isə:red-hatz.org da sırf $_GET requestdən gələn bu tipli "payload"-ın qarşısını almaq üçün:
Orda Anti sql injection adlı mövzu var idi öz əlavəmi etmişdim ora da baxa bilərsən.
[url]http://192.168.0.15/learn/work/prob.php?id=1&sef=-9999999999999999999995+UnIoN+sElEcT+repeat(benchmark(1000000000000000,md5(repeat(md5(now()),100000))),1000000000000),2,3,4+from+makale--[/url]
və s.
|
Anti-armenia.ORG |
|