break;
and at last, here is the code of my TCPRST function :
I don't know if it is better to use LIBNET_LINK (with
libnet_build_ethernet) as it is done in my code or LIBNET_RAW4 mode (and
not use libnet_build_ethernet)
//Tcp reset function ******************************************
static int TCPRST(u_long saddr, u_long daddr, u_short sport, u_short
dport, int t_seq, int t_ack)
{
int c;
libnet_t *l;
libnet_ptag_t ip_tag, tcp_tag,eth_tag;
fprintf(stderr, "seq : %x, ack : %x ", t_seq, t_ack);
l = libnet_init(LIBNET_LINK,dev,errlbuf);
if (l == NULL)
{
fprintf(stderr, "libnet_init failed: %s\n", errlbuf);
exit(EXIT_FAILURE);
}
tcp_tag = libnet_build_tcp(sport,dport,t_seq,t_ack,0x14,5555,0,
0,LIBNET_TCP_H,NULL,0,l,0);
if (tcp_tag == -1)
{
fprintf(stderr,"libnet_build_tcp failed: %s\n", libnet_geterror
(l));
goto bad;
}
//fprintf(stderr,"build_tcp ok\n");
ip_tag = libnet_build_ipv4(LIBNET_IPV4_H + LIBNET_TCP_H,
0xF4/*IPTOS_LOWDELAY*/,
rand() & 0xFFFF,
0,64,IPPROTO_TCP,0,saddr,daddr,NULL,0,l,0);
if (ip_tag == -1)
{
fprintf(stderr,"libnet_build_ipv4 failed: %s\n",
libnet_geterror(l));
goto bad;
}
//fprintf(stderr,"build_ipv4 ok\n");
eth_tag =
libnet_build_ethernet(ether_dest,ether_src,htons(t),NULL,0,l,0);
if (eth_tag == -1)
{
fprintf(stderr,"libnet_build_ethernet failed: %s\n",
libnet_geterror(l));
goto bad;
}
//fprintf(stderr,"build_ethernet ok\n");
c = libnet_write(l);
if (c == -1)
{
fprintf(stderr,"libnet_write failed: %s\n",libnet_geterror(l));
goto bad;
}
else fprintf(stderr,"Wrote %d byte(s) TCP packet; check the
wire.\n",c);
libnet_destroy(l);
return (EXIT_SUCCESS);
bad:
libnet_destroy(l);
return(EXIT_FAILURE);
}
THANKS IN ADVANCE, at least for reading until here.
To unsubscribe, e-mail: libnet-unsubscribe@securityfocus.com
For additional commands, e-mail: libnet-help@securityfocus.com
Received on Wed Apr 16 08:16:24 2003