⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ec.c

📁 一个非常强大的库
💻 C
📖 第 1 页 / 共 2 页
字号:
#include "head.h"char info[] = "#------------------------------------------------------"	      "----------------------------------------------#\n|     "	      "                                      EyeCry v1.2      "	      "                                        |\n| |-|@|_|_0 "	      "2 /-||_|_ |\\|@^|^ \\//-||\\||)/-||_$!                 "	      "                                     |\n| Well, I think"	      ", this program must be named as \"DEATH\" or something "	      "in that way. It is VERY power-   |\n| full program, whi"	      "ch includes: packet creator + packet sender, packet sni"	      "ffer, portscanner. So, you |\n| can do almost everythin"	      "g with this one program. Only shortcoming of this softw"	      "are, that it can be  |\n| used by people, who are exper"	      "ts in net protocol level. But it doesn't matter for rea"	      "l net vandal,  |\n| is it? So, watch readme.txt for det"	      "ailed instructions.                                    "	      "         |\n| Params are:                              "	      "                                                       "	      "   |\n|  mkip - creates IP header                      "	      "                                                    |\n"              "|  mk_i - creates ICMP header                          "	      "                                              |\n|  mk_"	      "u - creates UDP header                                 "	      "                                        |\n|  mk_t - cr"	      "eates TCP header                                       "	      "                                  |\n|  mksm - fills pa"	      "cket with symbol                                       "	      "                            |\n|  snrp - sniffes packet"	      "s, but do not decodes anything                         "	      "                      |\n|  snip - sniffes packets, dec"	      "odes only IP header                                    "	      "                |\n|  snap - sniffes packets, decodes e"	      "verything                                              "	      "          |\n|  sdpk - sends packet                    "	      "                                                       "	      "    |\n|  scpr - scans ports                           "	      "                                                     | "	      "\n| Program author: Smolin Anton - [Attack-Defence Comp"	      "uter Technologies]-Rage-                        |\n| Ma"	      "il2: adctrage@bk.ru, aofgabriel@bk.ru                  "	      "                                          |\n|        a"	      "dctrage@2die4.com, aofgabriel@2die4.com                "	      "                                    |\n| Location: Russ"	      "ia, Omsk                                               "	      "                              |\n| Date: 22/06/2002 01:"	      "34 OMSST                                               "	      "                        |\n#---------------------------"	      "-------------------------------------------------------"	      "------------------#\n";int mkip(int n, char **optn){	char *pack;	FILE *pkfl;	struct iphdr *iphd;	if(n != 18){		eror:		fail("Usage: ./ec mkip <file> <size> <bord> <vers> <hd"		     "ln> <tofs> <tlen> <iden> <foff> <titl> <prot> <c"		     "hsm\n                    > ([chop]: <bord> <size"		     ">) <srip> <dsip>\n   Launch ./ec info to see mor"		     "e information");		return(-1);	}	if(!(pack = (char *)malloc(atoi(optn[3])))){		fail("Couldn't allocate memory");		return(-1);	}	fopen(optn[2], "a");	pkfl = fopen(optn[2], "r");	fread(pack, atoi(optn[3]), 1, pkfl);	fclose(pkfl);	iphd = (struct iphdr *)(pack + atoi(optn[4]));	iphd->version = atoi(optn[5]);	iphd->ihl = atoi(optn[6]);	iphd->tos = atoi(optn[7]);	iphd->tot_len = htons(atoi(optn[8]));	iphd->id = htons(atoi(optn[9]));	iphd->frag_off = htons(atoi(optn[10]));	iphd->ttl = atoi(optn[11]);	iphd->protocol = atoi(optn[12]);	iphd->check = 0;	iphd->saddr = inet_addr(optn[16]);	iphd->daddr = inet_addr(optn[17]);	if(strcmp(optn[13], "noch") == 0)		goto wrtf;	else if(strcmp(optn[13], "mkch") == 0)		iphd->check = chck((unsigned short *)(pack + atoi		                   (optn[14])), atoi(optn[15]));	else		goto eror;	wrtf:	pkfl = fopen(optn[2], "w");	fwrite(pack, atoi(optn[3]), 1, pkfl);	fclose(pkfl);	free(pack);	return(0);}int mk_i(int n, char **optn){	char *pack;	FILE *pkfl;	struct icmphdr *_ihd;	if(n != 15){		eror:		fail("Usage: ./ec mk_i <file> <size> <bord> <type> <co"		     "de> <chsm> ([chop]: <bord> <size>) <iden> <seqn>"		     " <g\n                    ate> <nous> <mtui>\n   "		     "Launch ./ec info to see more information");		return(-1);	}	if(!(pack = (char *)malloc(atoi(optn[3])))){		fail("Couldn't allocate memory");		return(-1);	}	fopen(optn[2], "a");	pkfl = fopen(optn[2], "r");	fread(pack, atoi(optn[3]), 1, pkfl);	fclose(pkfl);	_ihd = (struct icmphdr *)(pack + atoi(optn[4]));	_ihd->type = atoi(optn[5]);	_ihd->code = atoi(optn[6]);	_ihd->checksum = 0;	if(htons(atoi(optn[10])) != 0)		_ihd->un.echo.id = htons(atoi(optn[10]));	if(htons(atoi(optn[11])) != 0)		_ihd->un.echo.sequence = htons(atoi(optn[11]));	if(inet_addr(optn[12]) != 0)		_ihd->un.gateway = inet_addr(optn[12]);	if(htons(atoi(optn[13])) != 0)		_ihd->un.frag.__unused = htons(atoi(optn[13]));	if(htons(atoi(optn[14])) != 0)		_ihd->un.frag.mtu = htons(atoi(optn[14]));	if(strcmp(optn[7], "noch") == 0)		goto wrtf;	else if(strcmp(optn[7], "mkch") == 0)		_ihd->checksum = chck((unsigned short *)(pack + atoi		                      (optn[8])), atoi(optn[9]));	else		goto eror;	wrtf:	pkfl = fopen(optn[2], "w");	fwrite(pack, atoi(optn[3]), 1, pkfl);	fclose(pkfl);	free(pack);	return(0);}int mk_u(int n, char **optn){	char *pack;	char *psed;	FILE *pkfl;	struct udphdr *_uhd;	struct pshdr *pshd;	if(n != 16){		eror:		fail("Usage: ./ec mk_u <file> <size> <bord> <srpr> <ds"		     "pr> <lent> <chsm> ([chop]: <bord> <size> <srip> "		     "<ds\n                    ip> <zero> <prot> <tlen"		     ">)\n   Launch ./ec info to see more information "		     "");		return(-1);	}	if(!(pack = (char *)malloc(atoi(optn[3])))){		fail("Couldn't allocate memory");		return(-1);	}	fopen(optn[2], "a");	pkfl = fopen(optn[2], "r");	fread(pack, atoi(optn[3]), 1, pkfl);	fclose(pkfl);	_uhd = (struct udphdr *)(pack + atoi(optn[4]));	_uhd->source = htons(atoi(optn[5]));	_uhd->dest = htons(atoi(optn[6]));	_uhd->len = htons(atoi(optn[7]));	if(strcmp(optn[8], "noch") == 0)		goto wrtf;	else if(strcmp(optn[8], "mkch") == 0){		if(!(psed = (char *)malloc(pssz + atoi(optn[10])))){			fail("Couldn't allocate memory");			free(pack);			return(-1);		}		pshd = (struct pshdr *)psed;		pshd->saddr = inet_addr(optn[11]);		pshd->daddr = inet_addr(optn[12]);		pshd->zero = atoi(optn[13]);		pshd->protocol = atoi(optn[14]);		pshd->length = htons(atoi(optn[15]));		bcopy((char *)(pack + atoi(optn[9])), (char *)(psed +		      pssz), atoi(optn[10]));		_uhd->check = chck((unsigned short *)psed, pssz + atoi		                   (optn[10]));		free(psed);	}	else		goto eror;	wrtf:	pkfl = fopen(optn[2], "w");	fwrite(pack, atoi(optn[3]), 1, pkfl);	fclose(pkfl);	free(pack);	return(0);}int mk_t(int n, char **optn){	char *pack;	char *psed;	FILE *pkfl;	struct tcphdr *_thd;	struct pshdr *pshd;	if(n != 28){		eror:		fail("Usage: ./ec mk_t <file> <size> <bord> <srpr> <ds"		     "pr> <seqn> <aseq> <doff> <res1> <res2> <urgf> <a"		     "ckf\n                    > <pshf> <rstf> <synf> "		     "<finf> <wind> <chsm> ([chop]: <bord> <size> <sri"		     "p> <dsip> <\n                    zero> <prot> <t"		     "len>) <urgp>\n   Launch ./ec info to see more in"		     "formation");		return(-1);	}	if(!(pack = (char *)malloc(atoi(optn[3])))){		fail("Couldn't allocate memory");		return(-1);	}	fopen(optn[2], "a");	pkfl = fopen(optn[2], "r");	fread(pack, atoi(optn[3]), 1, pkfl);	fclose(pkfl);	_thd = (struct tcphdr *)(pack + atoi(optn[4]));	_thd->source = htons(atoi(optn[5]));	_thd->dest = htons(atoi(optn[6]));	_thd->seq = htonl(atoi(optn[7]));	_thd->ack_seq = htonl(atoi(optn[8]));	_thd->doff = atoi(optn[9]);	_thd->res1 = atoi(optn[10]);	_thd->res2 = atoi(optn[11]);	_thd->urg = atoi(optn[12]);	_thd->ack = atoi(optn[13]);	_thd->psh = atoi(optn[14]);	_thd->rst = atoi(optn[15]);	_thd->syn = atoi(optn[16]);	_thd->fin = atoi(optn[17]);	_thd->window = htons(atoi(optn[18]));	_thd->check = 0;	_thd->urg_ptr = htons(atoi(optn[27]));	if(strcmp(optn[19], "noch") == 0)		goto wrtf;	else if(strcmp(optn[19], "mkch") == 0){		if(!(psed = (char *)malloc(pssz + atoi(optn[21])))){			fail("Couldn't allocate memory");			free(pack);			return(-1);		}		pshd = (struct pshdr *)psed;		pshd->saddr = inet_addr(optn[22]);		pshd->daddr = inet_addr(optn[23]);		pshd->zero = atoi(optn[24]);		pshd->protocol = atoi(optn[25]);		pshd->length = htons(atoi(optn[26]));		bcopy((char *)(pack + atoi(optn[20])), (char *)(psed +		      pssz), atoi(optn[21]));		_thd->check = chck((unsigned short *)psed, pssz + atoi		                   (optn[21]));		free(psed);	}	else		goto eror;	wrtf:	pkfl = fopen(optn[2], "w");	fwrite(pack, atoi(optn[3]), 1, pkfl);	fclose(pkfl);	free(pack);	return(0);}int mksm(int n, char **optn){	char *pack;	FILE *pkfl;	if(n != 7){		fail("Usage: ./ec mksm <file> <size> <bord> <flsz> <sy"		     "mb>\n   Launch ./ec info to see more information"		     "");		return(-1);	}	if(!(pack = (char *)malloc(atoi(optn[3])))){		fail("Couldn't allocate memory");		return(-1);	}	fopen(optn[2], "a");	pkfl = fopen(optn[2], "r");	fread(pack, atoi(optn[3]), 1, pkfl);	fclose(pkfl);	memset(pack + atoi(optn[4]), atoi(optn[6]), atoi(optn[5]));	pkfl = fopen(optn[2], "w");	fwrite(pack, atoi(optn[3]), 1, pkfl);	fclose(pkfl);	free(pack);	return(0);}int snrp(int n, char **optn){	struct sockaddr sans;	int sasz = sizeof(sans);	int sock;	int bred;	char *pack;	FILE *logf;	int numb = 1;	if(n != 4){		fail("Usage: ./ec snrp <file> <size>\n   Launch ./ec i"		     "nfo to see more information");		return(-1);	}	if(!(pack = (char *)malloc(atoi(optn[3])))){		fail("Couldn't allocate memory");		return(-1);	}	if((sock = socket(17, 3, htons(0x0003))) == -1){		fail("Couldn't open socket");		free(pack);		return(-1);	}	while(bred != -1){		bred = recvfrom(sock, pack, atoi(optn[3]), 0, &sans,		                &sasz);		logf = fopen(optn[2], "a");		fprintf(logf, "[+] Packet number           < %d\n",		        numb);		fprintf(logf, " |\n");		fprintf(logf, "[+] Data                    <\n");		fwrite(pack, bred, 1, logf);		fprintf(logf, "\n\n");		fclose(logf);		numb++;	}	shutdown(sock, 1);	free(pack);	return(0);}int snip(int n, char **optn){	struct sockaddr sans;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -