[Winpcap-users] Sending packet

Deston High mqx at low-axs.net
Tue Dec 6 21:52:49 GMT 2005


According your previous post you capture data and want to "block" (in 
this case: reset) the connection.
Well, when you capture the data, use pkt_data (see: pcap_next_ex()) and 
modify the flag bits and send the modified packet.
Might it help if you insert the data in a header structure of both ip 
and tcp protocol.

for ethernet it could look like this:

typedef struct HEADER
{
    struct
    {
       ...
    } IPHEADER;
    struct
    {
       ...
    } TCPHEADER;

} HERDER;

...
initial pcap...
set filter...
...
while (pcap_next_ex(handle,&header,&pkt_data) > 0)
{
    HEADER *iptcpheader = (HEADER*)(pkt_data+etherheaderlen);
    iptcpheader->tcpheader.th_flag = 4;
    ...
    pcap_sendpacket(handler,pkt_data,sizeof(iptcpheader)+etherheaderlen);
}
...

very snipped example!

hope it gives an idea how to do that.

might helpful: http://de.wikipedia.org/wiki/TCP-Header
there are some other good sites explaining the header with examples how 
the header-struct looks like.

D. High


cinias at o2.pl wrote:

> Hi Everyone,
>  
> Does enybody know how I can send a TCP Packet with RST flag?
>  
> Marcin
>
>------------------------------------------------------------------------
>
>_______________________________________________
>Winpcap-users mailing list
>Winpcap-users at winpcap.org
>https://www.winpcap.org/mailman/listinfo/winpcap-users
>  
>



More information about the Winpcap-users mailing list