0x0A-HackTheBox-Base

Recon

Nmap

0x0A-HackTheBox-Base
目标开放了 2280 端口。

查看一下网页。

0x0A-HackTheBox-Base
有个 login 页面。

我先尝试了一下 sql injection,但是没有成功,无法登录。

截取了请求,也没有什么特别的。
0x0A-HackTheBox-Base

Dirbuster

0x0A-HackTheBox-Base
很快找到了换个 /login 目录是可以访问的。
0x0A-HackTheBox-Base
重点是 config.php.swp 两个文件。但是 config.php 没有什么内容,看一下 .swp

我尝试 vi -r login.php.sqp,但是无法恢复。

扩展阅读
VIM Recovery Mode

直接 vi 打开之后,是个乱码。
0x0A-HackTheBox-Base
0x0A-HackTheBox-Base
但是下面有字符串,那就用 strings 看一下。

0x0A-HackTheBox-Base
这里看到了比较用户名密码的登录逻辑。

那么问题肯定在这里,只是我还不知道。

搜索一下 php strcmp exlpots
0x0A-HackTheBox-Base
很多 bypass,那这个肯定就是有漏洞可以利用了。

扩展阅读
PHP String Comparison Vulnerability
Bypass PHP Strcmp
PHP Type Juggling

这个漏洞是 type juggling 这个语言特征造成的。大家阅读一下文档,php 应该用 === 比较相等,而不应该用 ==

Bypass PHP == Operator

0x0A-HackTheBox-Base
在第二篇文章中能找到我想要的答案。也就是说,给这个 strcmp 方法一个对象,或者一个数组,那么结果会返回 0,也就能绕过登录逻辑。
0x0A-HackTheBox-Base
0x0A-HackTheBox-Base

我用了 admin 结果还是 admin 登录。

看了下源码这是写死的

0x0A-HackTheBox-Base

Foothold

php 文件上传测试

0x0A-HackTheBox-Base

0x0A-HackTheBox-Base
上传成功,没有限制。

下面就是常规套路了,上传 reverse shell,连接本地。

0x0A-HackTheBox-Base
修改 ip 和端口,上传,然后本地监听 9903端口,找到 /uploads 目录执行。

0x0A-HackTheBox-Base
找不到文件。

0x0A-HackTheBox-Base

Directory Enumeration

dirsearch 找一下上传目录。
0x0A-HackTheBox-Base

没有结果。

dirbuster

0x0A-HackTheBox-Base
也没有结果。再换 gobuster。也没有结果。

我现在特别喜欢 dirbuster,因为可以右键直接在浏览器打开。
我换回 dirbuster,然后换了一个 /dirb/big.txt 的字典,就有结果出来了。

0x0A-HackTheBox-Base
上传目录是 /_uploaded/

0x0A-HackTheBox-Base
0x0A-HackTheBox-Base

Privilege Escalation

0x0A-HackTheBox-Base
/etc/passwd 显示有一个用户名 john

config.php 中有一个登录信息。
0x0A-HackTheBox-Base
没有用户叫 admin ,显然不会直接给我 root 的密码,所以一定是 john 的。

0x0A-HackTheBox-Base
0x0A-HackTheBox-Base

我登录到一个 linux 用户账户之后,前几个个命令一定是 idcat /etc/passwdsudo -l (如果有密码的话)。

现在我有 john 的密码,看一下他的 sudo 权限。

0x0A-HackTheBox-Base
之前在一篇文章中看到 sudo -l -l,试了一下,好像多一点点内容。

线索来了,find 命令可以使用。

find 可以配合 exec 执行命令。

0x0A-HackTheBox-Base

就找一下当前目录的文件就好了,然后执行 /bin/bash,获得 root shell

I’m in…


个人博客地址 ????