php fuzz

php mysql fuzz

上周因为一个注入,让我有研究了一下fuzz方面的东西,所以从网上找了几个脚本,另外写了个批量检测的php脚本,现在记录下来。

第一个是对mysql的fuzz,主要测试的是chr函数的255个特殊字符放到mysql语句中会不会起到作用,这个脚本是网上找的,原文来自于wooyun zone,可惜了zone里一堆好东西现在都不见了啊。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?php
error_reporting(0);
/* 连接选择数据库 */
$link = mysql_connect("localhost", "root", "root123")
or die("Could not connect : " . mysql_error());
print "Connected successfully<br/><br />";
mysql_select_db("mysql") or die("Could not select database");
/* 执行 SQL 查询 */
for($i=0;$i<255;$i++){
$fuzz=chr($i);
$query = "{$fuzz}SELECT{$fuzz}{$fuzz}password{$fuzz}from{$fuzz} mysql.user {$fuzz}limit {$fuzz}1";
//$query = "SELECT 1 from mysql.user --{$fuzz}xxxxx";
$result = mysql_query($query);
$array = mysql_fetch_array($result,MYSQL_ASSOC);
/* 在 HTML 中打印结果 */
if(mysql_error()==''){
echo urlencode(chr($i))." ---- ".chr($i)."<br/>";
echo $query."<br />";
print_r($array);
echo "<br /><br />";
mysql_free_result($result);
}
}
/* 释放资源 */
mysql_free_result($result);
/* 断开连接 */
mysql_close($link);
?>


php sql injection

第二个脚本是用来练注入的,需要配置下数据库

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?php
$conn = mysql_connect("localhost", "root", "root123");
if(!$conn)
{
echo "数据库联接错误";
exit;
}
if (!mysql_select_db("test"))
{
echo "选择数据库出错" . mysql_error();
exit;
}
$tempID=$_GET['id'];
if($tempID<=0 || !isset($tempID)) $tempID=1;
$sql = "SELECT * FROM php_product WHERE id =$tempID";
echo $sql.'<br>';
$result = mysql_query($sql);
if (!$result) {
echo "查询出错" . mysql_error();
exit;
}
if (mysql_num_rows($result) == 0) {
echo "没有查询结果";
exit;
}
while ($row = mysql_fetch_assoc($result)) {
echo 'ID:'.$row["id"].'<br>';
echo 'name:'.$row["name"].'<br>';
echo 'price:'.$row["price"].'<br>';
echo 'image:'.$row["img"].'<br>';
}
?>


php burp geturl

第三个脚本是自己写的,用来配合burp检测网站状态,也可用来批量执行exp等等,关键看自己怎么用了,很简单的东西,而且file_get_contents是有先天不足的,建议替换为其他函数

1
2
3
4
5
6
7
8
9
10
11
12
13
14
<?php
/*
$url = "http://".$_GET["u"];
*/
$url = $_GET["u"];
$ctx = stream_context_create(array(
'http' => array('timeout' => 50,
'proxy' => 'tcp://127.0.0.1:8080',
'request_fulluri' => True,)
)
);
$result = file_get_contents($url, false, $ctx);
echo $result;
?>

这只是初步的脚本,网上有更多好东西,度娘谷哥可以帮你。