
Enumeration
We start with running nmap on the target to see what is running.
nmap -sC -sV -T 4 <target ip>
Starting Nmap 7.93 ( https://nmap.org ) at 2023-02-20 16:27 GMT
Stats: 0:00:00 elapsed; 0 hosts completed (0 up), 0 undergoing Script Pre-Scan
NSE Timing: About 0.00% done
WARNING: Service 10.10.96.67:5000 had already soft-matched rtsp, but now soft-matched sip; ignoring second value
WARNING: Service 10.10.96.67:80 had already soft-matched rtsp, but now soft-matched sip; ignoring second value
Nmap scan report for 10.10.96.67
Host is up (0.033s latency).
Not shown: 997 closed tcp ports (conn-refused)
PORT STATE SERVICE VERSION
22/tcp open ssh OpenSSH 8.2p1 Ubuntu 4ubuntu0.5 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey:
| 3072 753a85da4c79ab329dbb3486e2b0f9d6 (RSA)
| 256 60a68b3edac21e6987adb7a637db2793 (ECDSA)
|_ 256 723233926e17948b751872c82e7123f5 (ED25519)
80/tcp open rtsp
| fingerprint-strings:
| FourOhFourRequest:
| HTTP/1.0 404 NOT FOUND
| Content-Type: text/html; charset=utf-8
| Content-Length: 232
| <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
| <title>404 Not Found</title>
| <h1>Not Found</h1>
| <p>The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.</p>
| GetRequest:
| HTTP/1.0 200 OK
| Content-Type: text/html; charset=utf-8
| Content-Length: 2660
| <!DOCTYPE html>
| <html lang="en">
| <head>
| <meta charset="utf-8" />
| <meta
| name="viewport"
| content="width=device-width, initial-scale=1, shrink-to-fit=no"
| <link
| rel="stylesheet"
| href="./static/codemirror.min.css"/>
| <link
| rel="stylesheet"
| href="./static/bootstrap.min.css"/>
| <title>MD2PDF</title>
| </head>
| <body>
| <!-- Navigation -->
| <nav class="navbar navbar-expand-md navbar-dark bg-dark">
| <div class="container">
| class="navbar-brand" href="/"><span class="">MD2PDF</span></a>
| </div>
| </nav>
| <!-- Page Content -->
| <div class="container">
| <div class="">
| <div class="card mt-4">
| <textarea class="form-control" name="md" id="md"></textarea>
| </div>
| <div class="mt-3
| HTTPOptions:
| HTTP/1.0 200 OK
| Content-Type: text/html; charset=utf-8
| Allow: GET, HEAD, OPTIONS
| Content-Length: 0
| RTSPRequest:
| RTSP/1.0 200 OK
| Content-Type: text/html; charset=utf-8
| Allow: GET, HEAD, OPTIONS
|_ Content-Length: 0
|_rtsp-methods: ERROR: Script execution failed (use -d to debug)
|_http-title: MD2PDF
5000/tcp open rtsp
| fingerprint-strings:
| FourOhFourRequest:
| HTTP/1.0 404 NOT FOUND
| Content-Type: text/html; charset=utf-8
| Content-Length: 232
| <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
| <title>404 Not Found</title>
| <h1>Not Found</h1>
| <p>The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.</p>
| GetRequest:
| HTTP/1.0 200 OK
| Content-Type: text/html; charset=utf-8
| Content-Length: 2624
| <!DOCTYPE html>
| <html lang="en">
| <head>
| <meta charset="utf-8" />
| <meta
| name="viewport"
| content="width=device-width, initial-scale=1, shrink-to-fit=no"
| <link
| rel="stylesheet"
| href="./assets/codemirror.min.css"/>
| <link
| rel="stylesheet"
| href="./assets/bootstrap.min.css"/>
| <title>MD2PDF</title>
| </head>
| <body>
| <!-- Navigation -->
| <nav class="navbar navbar-expand-md navbar-dark bg-dark">
| <div class="container">
| class="navbar-brand" href="/"><span class="">MD2PDF</span></a>
| </div>
| </nav>
| <!-- Page Content -->
| <div class="container">
| <div class="">
| <div class="card mt-4">
| <textarea class="form-control" name="md" id="md"></textarea>
| </div>
| <div class="mt-3
| HTTPOptions:
| HTTP/1.0 200 OK
| Content-Type: text/html; charset=utf-8
| Allow: HEAD, OPTIONS, GET
| Content-Length: 0
| RTSPRequest:
| RTSP/1.0 200 OK
| Content-Type: text/html; charset=utf-8
| Allow: HEAD, OPTIONS, GET
|_ Content-Length: 0
|_rtsp-methods: ERROR: Script execution failed (use -d to debug)
<snip>------------<snip>
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 22.26 seconds
Stats: 0:00:00 elapsed; 0 hosts completed (0 up), 0 undergoing Script Pre-Scan
NSE Timing: About 0.00% done
WARNING: Service 10.10.96.67:5000 had already soft-matched rtsp, but now soft-matched sip; ignoring second value
WARNING: Service 10.10.96.67:80 had already soft-matched rtsp, but now soft-matched sip; ignoring second value
Nmap scan report for 10.10.96.67
Host is up (0.033s latency).
Not shown: 997 closed tcp ports (conn-refused)
PORT STATE SERVICE VERSION
22/tcp open ssh OpenSSH 8.2p1 Ubuntu 4ubuntu0.5 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey:
| 3072 753a85da4c79ab329dbb3486e2b0f9d6 (RSA)
| 256 60a68b3edac21e6987adb7a637db2793 (ECDSA)
|_ 256 723233926e17948b751872c82e7123f5 (ED25519)
80/tcp open rtsp
| fingerprint-strings:
| FourOhFourRequest:
| HTTP/1.0 404 NOT FOUND
| Content-Type: text/html; charset=utf-8
| Content-Length: 232
| <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
| <title>404 Not Found</title>
| <h1>Not Found</h1>
| <p>The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.</p>
| GetRequest:
| HTTP/1.0 200 OK
| Content-Type: text/html; charset=utf-8
| Content-Length: 2660
| <!DOCTYPE html>
| <html lang="en">
| <head>
| <meta charset="utf-8" />
| <meta
| name="viewport"
| content="width=device-width, initial-scale=1, shrink-to-fit=no"
| <link
| rel="stylesheet"
| href="./static/codemirror.min.css"/>
| <link
| rel="stylesheet"
| href="./static/bootstrap.min.css"/>
| <title>MD2PDF</title>
| </head>
| <body>
| <!-- Navigation -->
| <nav class="navbar navbar-expand-md navbar-dark bg-dark">
| <div class="container">
| class="navbar-brand" href="/"><span class="">MD2PDF</span></a>
| </div>
| </nav>
| <!-- Page Content -->
| <div class="container">
| <div class="">
| <div class="card mt-4">
| <textarea class="form-control" name="md" id="md"></textarea>
| </div>
| <div class="mt-3
| HTTPOptions:
| HTTP/1.0 200 OK
| Content-Type: text/html; charset=utf-8
| Allow: GET, HEAD, OPTIONS
| Content-Length: 0
| RTSPRequest:
| RTSP/1.0 200 OK
| Content-Type: text/html; charset=utf-8
| Allow: GET, HEAD, OPTIONS
|_ Content-Length: 0
|_rtsp-methods: ERROR: Script execution failed (use -d to debug)
|_http-title: MD2PDF
5000/tcp open rtsp
| fingerprint-strings:
| FourOhFourRequest:
| HTTP/1.0 404 NOT FOUND
| Content-Type: text/html; charset=utf-8
| Content-Length: 232
| <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
| <title>404 Not Found</title>
| <h1>Not Found</h1>
| <p>The requested URL was not found on the server. If you entered the URL manually please check your spelling and try again.</p>
| GetRequest:
| HTTP/1.0 200 OK
| Content-Type: text/html; charset=utf-8
| Content-Length: 2624
| <!DOCTYPE html>
| <html lang="en">
| <head>
| <meta charset="utf-8" />
| <meta
| name="viewport"
| content="width=device-width, initial-scale=1, shrink-to-fit=no"
| <link
| rel="stylesheet"
| href="./assets/codemirror.min.css"/>
| <link
| rel="stylesheet"
| href="./assets/bootstrap.min.css"/>
| <title>MD2PDF</title>
| </head>
| <body>
| <!-- Navigation -->
| <nav class="navbar navbar-expand-md navbar-dark bg-dark">
| <div class="container">
| class="navbar-brand" href="/"><span class="">MD2PDF</span></a>
| </div>
| </nav>
| <!-- Page Content -->
| <div class="container">
| <div class="">
| <div class="card mt-4">
| <textarea class="form-control" name="md" id="md"></textarea>
| </div>
| <div class="mt-3
| HTTPOptions:
| HTTP/1.0 200 OK
| Content-Type: text/html; charset=utf-8
| Allow: HEAD, OPTIONS, GET
| Content-Length: 0
| RTSPRequest:
| RTSP/1.0 200 OK
| Content-Type: text/html; charset=utf-8
| Allow: HEAD, OPTIONS, GET
|_ Content-Length: 0
|_rtsp-methods: ERROR: Script execution failed (use -d to debug)
<snip>------------<snip>
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 22.26 seconds
We have port 22 open, port 80 and port 5000. We will go straight to port 80 and further our enumeration.
The server is hosting a Markdown to PDF converter. Let's convert something and see what is being used on the back end.

It is using wkhtmltopdf 0.12.5 to convert the MD. Researching exploits and vulnerabilities for this version brings us to file inclusion!
Let's find out what directories are on the server using gobuster.
└─$ gobuster dir --url http://10.10.96.67/ -w /usr/share/dirbuster/wordlists/directory-list-2.3-small.txt
===============================================================
Gobuster v3.4
by OJ Reeves (@TheColonial) & Christian Mehlmauer (@firefart)
===============================================================
[+] Url: http://10.10.96.67/
[+] Method: GET
[+] Threads: 10
[+] Wordlist: /usr/share/dirbuster/wordlists/directory-list-2.3-small.txt
[+] Negative Status codes: 404
[+] User Agent: gobuster/3.4
[+] Timeout: 10s
===============================================================
2023/02/20 17:10:11 Starting gobuster in directory enumeration mode
===============================================================
/admin (Status: 403) [Size: 166]
/convert (Status: 405) [Size: 178]
Progress: 87615 / 87665 (99.94%)
===============================================================
2023/02/20 17:18:37 Finished
===============================================================
===============================================================
Gobuster v3.4
by OJ Reeves (@TheColonial) & Christian Mehlmauer (@firefart)
===============================================================
[+] Url: http://10.10.96.67/
[+] Method: GET
[+] Threads: 10
[+] Wordlist: /usr/share/dirbuster/wordlists/directory-list-2.3-small.txt
[+] Negative Status codes: 404
[+] User Agent: gobuster/3.4
[+] Timeout: 10s
===============================================================
2023/02/20 17:10:11 Starting gobuster in directory enumeration mode
===============================================================
/admin (Status: 403) [Size: 166]
/convert (Status: 405) [Size: 178]
Progress: 87615 / 87665 (99.94%)
===============================================================
2023/02/20 17:18:37 Finished
===============================================================
Interesting, there is an admin and convert page.
Exploitation
We want to try and have this admin page included within the conversion. Let's first test and see if there is input sanitization happening.


We seem to be able to use html tags fine, let's try using an iframe and include the admin page. Unfortunately I forgot to screenshot the result of this but it didn't work! Remembering we had port 5000 open we adjust slightly.
