Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Send a packet

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >

Share

Shulou(Shulou.com)06/01 Report--

# include "stdafx.h"

# include

# include

# include

Void main (int argc, char * * argv)

{

Pcap_t * fp

Char errbuf[PCAP _ ERRBUF_SIZE]

U_char packet [100]

Int i

Pcap_if_t * alldevs

Pcap_if_t * d

Int inum

Int jung0

/ * get the list of devices * /

If (pcap_findalldevs_ex (PCAP_SRC_IF_STRING, NULL, & alldevs, errbuf) =-1)

{

Fprintf (stderr, "Error in pcap_findalldevs:% s\ n", errbuf)

Exit (1)

}

/ * print list * /

For (dudes alldevs; d; dudes-> next)

{

Printf ("d. S", + + j, d-> name)

If (d-> description)

Printf ("(% s)\ n", d-> description)

Else

Printf ("(No description available)\ n")

}

If (jacks 0)

{

Printf ("\ nNo interfaces found! Make sure WinPcap is installed.\ n")

Return

}

Printf ("Enter the interface number (1M% d):", j)

Scanf ("d", & inum)

If (inum

< 1 || inum >

j)

{

Printf ("\ nInterface number out of range.\ n")

/ * release device list * /

Pcap_freealldevs (alldevs)

Return

}

/ * Jump to selected device * /

For (d=alldevs, juni0; j

< inum-1 ;d=d->

Next, jacks +)

/ * Open the output device * /

If ((fp= pcap_open (d-> name, / / device name)

100, / / part to be captured (only the first 100 bytes are captured)

PCAP_OPENFLAG_PROMISCUOUS, / / hybrid mode

1000, / / read timeout

NULL, / / remote machine verification

Errbuf / / error buffering

)) = = NULL)

{

Fprintf (stderr, "\ nUnable to open the adapter.% s is not supported by WinPcap\ n", argv [1])

Return

}

Pcap_freealldevs (alldevs)

/ * suppose that on Ethernet, the destination address of MAC is set to 1: 1 * /

Packet [0] = 255

Packet [1] = 255

Packet [2] = 255

Packet [3] = 255

Packet [4] = 255

Packet [5] = 255

/ * set the MAC source address to 2 * /

Packet [6] = 10

Packet [7] = 10

Packet [8] = 10

Packet [9] = 10

Packet [10] = 10

Packet [11] = 10

Packet [12] = 96

Packet [13] = 00

/ * fill in the rest * /

For (iTunes 14)

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Network Security

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report