HackTheBox-OpenKeyS
- IP: 10.10.10.199
- Name: OpenKeyS
- Difficulty: Medium
0x01 信息收集
nmap
- 22 ssh openssh8.1
- 80 http openbsd httpd
攻击面很小?
dirt busting
1 | /images (Status: 301) |
http
Index.php
includes/
.swp文件是vi/vim的临时文件,然后这里有个极小的细节,不是对vim很了解的人一定不知道的细节。*vi/vim的恢复文件.swp
里面有该文件的所有者的用户名,和路径信息**。
将swp文件下载到本地,看看内容。
用vim恢复文件。
1 | vim -r auth.php.swp |
从这个函数,又看到了一个目录,并且知道了这里存在命令执行,但是应该不存在绕过。。
escapeshellcmd() escapes any characters in a string that might be used to trick a shell command into executing arbitrary commands. This function should be used to make sure that any data coming from user input is escaped before this data is passed to the exec() or system() functions, or to the backtick operator.
Following characters are preceded by a backslash:
&#;
|*?~<>^()[]{}$`,\x0A
and\xFF
.'
and"
are escaped only if they are not paired. On Windows, all these characters plus%
and!
are preceded by a caret (^
).
然后往下看。
这个函数,有将_REQUEST
中的username
赋予给_SESSION
的username
。
REUQUEST的值怎么获得呢,可以通过Cookie,GET,POST来获得
An associative array that by default contains the contents of $_GET, $_POST and $_COOKIE.
Auth_helpers
1 | wget http://openkeys.htb/auth_helpers/check_auth |
1 | check_auth: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter /usr/libexec/ld.so, for OpenBSD, not stripped |
差点就在这里陷入兔子洞了
0x02 获取立足点
通过阅读这篇文章和这篇文章我们可以知道OpenBSD上有几个登陆绕过漏洞和本地提权的漏洞,然后登陆绕过可以用ssh去探测是否存在。
1 | ssh -v -F /dev/null -o PreferredAuthentications=keyboard-interactive -o KbdInteractiveDevices=bsdauth -l -sresponse:passwd openkeys.htb |
如果一直是挂起的状态的话,就说明受到影响。因为服务端的ssh服务此时正在等待接受响应获取用户名和密码,而-sresponse:passwd被当作是一个参数了。
POST以下内容,还要携带Cookie字段;username=jennifer。
为什么要带个username的cookie的参数?因为如果不携带的话,request就会从post那里获取username变量,但是显然的没有-schallenge
这个用户。虽然成功绕过,但是并不能干什么。而我们从.swp
文件中知道了一个用户名,所以就携带进去获取该用户的sshkey。
1 | username=-schallenge&password=1 |
修复格式,并给权限(600/400)。
0x03 提权-Root
这个版本的系统受到多个提权漏洞的影响,因为没有当前用户的密码,也不是auth组用户所以选择使用CVE-2019-19520。
下载这个exp
S/Key Password
要输入一个密码,就输入Your Password is:xxxx 那个密码。之后就提权成功了。