HTB - Omni
Zweilosec's writeup on the easy-difficulty machine Omni from https://hackthebox.eu
Overview

Short description to include any strange things to be dealt with
Useful Skills and Tools
Useful thing 1
description with generic example
Useful thing 2
description with generic example
Enumeration
Nmap scan
I started my enumeration with an nmap scan of 10.10.10.204. The options I regularly use are: -p-, which is a shortcut which tells nmap to scan all ports, -sC is the equivalent to --script=default and runs a collection of nmap enumeration scripts against the target, -sV does a service scan, and -oA <name> saves the output with a filename of <name>.
There were a few standard Windows ports such as 135 - RPC, 3895 - Windows Remote Management, as well as a web server hosted on port 8080. There were also a few ports in the 29000 range that I did not recognize, including one that was identified by nmap as ARCserve Discovery.
I started out my enumeration with the web server on port 8080.


"Windows Device Portal" - Needs credentials to log in
You can login to the Windows Device Portal using the default Administrator credentials (User name: Administrator, Password: p@ssw0rd).
unfortunately the owners have changed the default password
https://www.thomasmaurer.ch/2015/06/how-to-connect-to-windows-10-iot-core-via-powershell/
denied again...I need to find the password to continue
https://www.zdnet.com/article/new-exploit-lets-attackers-take-control-of-windows-iot-core-devices/
There aren't a lot of useful files that have known locations on a windows machine so I tried to grab the hosts file in C:\Windows\System32\drivers\etc\
Next I had to try running commands to see what privileges I actually had
First I ran the set command, which returned a list of the local environment variables
Next I ran the same command to see if there was any difference in using the --as_logged_on_user flag. I noticed that there seemed to be a user called "DefaultAccount" logged in
My context seems to be running commands as System, so this should be a quick and easy win...right? (failed to notice this was still "logged on user")
A little bit of testing shows that I can run PowerShell
wget as an alias is not configured...this may be a limited version of PowerShell
so maybe I am not running as System as thought, since I was unable to write to the System32 folder (the folder I was in by default.)
Since I could not write to the current folder, I simply made a temp directory and uploaded my nc.exe there
After uploading netcat to the temp folder I created I sent a reverse shell back to my machine
Initial Foothold
Road to User
Ok...so my shell is a little shaky...and whoami is not installed
Since I couldn't use whoami I used ls env: to once again check the environment variables to see who I was. I seemed to be the user omni$.
I was able to enter the Administrator folder and use type to get the contents of the root.txt flag, but it did not contain the contents I expected. It seemed to be a PowerShell credential object written to a file.
I tried importing the credential information to see if I could directly use it, but it gave me a an error message stating that an "Error occurred during a cryptographic operation."
AFter doing some reading, it looked like I needed to find a key
sshd? interesting
In the folder C:\Data\Users\app I found the user.txt flag, but it was also encrypted the same way as the root.txt.
haha so this file is locked so that it is owned by Administrator, but also so NT AUTHORITY\SYSTEM cannot read it...very odd
The iot-admin.xml file was another PowerShell credential file
I still needed a key to decode these as well it seems
After poking around in the user folders for a little bit and finding nothing useful, I decided to see what programs were installed. There was only PowerShell with a limited set of modules installed.
After searching through the files here I found nothing useful. There was also nothing interesting in netstat or services
Finding user creds
After searching for a long time and not finding anything I started searching the user directories and Program Files for hidden files
There were many many hidden files in the users directories, most of them were desktop.ini files and random config files in appdata. However, in the program files directory there was only one hidden file, and it contained some very useful information
It looked like this batch script contained the passwords for both the app user and administrator!
https://davidhamann.de/2019/12/08/running-command-different-user-powershell/
powershell.exe -c "$user='WORKGROUP\John'; $pass='password123'; try { Invoke-Command -ScriptBlock { Get-Content C:\Users\John\Desktop\secret.txt } -ComputerName Server123 -Credential (New-Object System.Management.Automation.PSCredential $user,(ConvertTo-SecureString $pass -AsPlainText -Force)) } catch { echo $_.Exception.Message }" 2>&1
hmm it seems like I cannot run commands as another user. I need to find a way to login as the other two users
I tried logging in with WinRM but got an error. Looking at my nmap output again I remembered that there was that web portal I saw earlier
Port 8080 - Web Portal

Logged in using app's credentials.

Web portal for managing the IOT device

Apps running on the device

Running Processes

Found another password in the AllJoyn SoftAP settings

Device performance monitor

Was able to run commands directly in the portal. Using the command set I was able to list all of the currently set environment variables, including the current user context I was running in.
User.txt

Since I was running as app and could execute arbitrary commands I tried again to see if I could decrypt the user.txt flag.
I was able to successfully decrypt the flag!
Further Enumeration

next I cleared my cookies for the site, closed and reopened the browser, then logged in as administrator to see if the same process could be done for the root.txt

Now that I was the administrator user I could read the hardening.txt file which contained the steps the Administrator had taken to hard the machine. I thought it was strange that this file would be locked so only the admin could read it, though it was is the app user's folder.
I still wasn't able to decode iot-admin.xml for some reason
Root.txt

I was able to get the root flag though!

Thanks to egre55 for... [something interesting or useful about this machine.]
If you like this content and would like to see more, please consider buying me a coffee!
Last updated
Was this helpful?