一、Mysql UTF-8编码
搭建环境
创建一个.php文件
<?php
$mysqli = new mysqli("localhost", "root", "123456", "security");
/* check connection */
if ($mysqli->connect_errno) {
printf("Connect failed: %s\n", $mysqli->connect_error);
exit();
}
$mysqli->query("set names utf8");
username = addslashes(_GET['username']);
if ($username === 'admin') {
die('Permission denied!');
}
/* Select queries return a resultset */
sql = "SELECT \* FROM \`table1\` WHERE username='{username}'";
if ($result = $mysqli->query( $sql )) {
printf("Select returned %d rows.\n", $result->num_rows);
while ($row = $result->fetch_array(MYSQLI_ASSOC))
{
var_dump($row);
}
/* free result set */
$result->close();
} else {
var_dump($mysqli->error);
}
$mysqli->close();
在数据库中创建一张表


表中插入数据


这样环境就搭好了, 然后访问网页

当username=admin时就会被拒绝,但是当username≠admin时,又查询不了数据库


所以要想查询到数据库,就必须让username=admin,但是username=admin又会被拒绝,所以我们需要传递一个admin并带有字符的,让程序认为他不是admin,但是又可以让MySQL把那个字符放弃删除。

经过尝试发现%c2可以绕过,但是为什么呢?
这是因为%c2是一个特殊字符,MySQL在转换字符集的过程为,utf-8---->utf-8--->latin 1,但是在这个案例中实际上是utf-8---->utf-8--->utf-8,而latin 1只支持英文,因此在转换的过程中就抛出了错误,导致查出了username=admin的结果。
二、无字母数字webshell
首先在Ubuntu下的/usr/local/nginx/html中,创建一个web.php

访问网页

然后下一个上传文件的html文件


最后随便创建一个txt文件,编写内容

现在,使用burp suite进行抓包


发送到repeater下边


然后将红框内的数据放到web.php下


这里改为POST

然后就可以写get传参

但是 由于这里是get传参,要遵循url编码,所以要将空格,问号, @,分号进行转换

提交

在Linux下的/tmp中可以看到生成了一个临时文件

为进一步验证,可以在web.php下添加sleep,然后再次提交

然后再去查看这个临时文件是否存在
