- Notifications
You must be signed in to change notification settings - Fork14
Use pcap4j to detect a mac address of remote host
License
gaoxingliang/mac-address-detector-java
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Use pcap4j to detect a mac address of remote host
I searched the whole website, and I found no solution provided to detect a mac address of remote host under same subnetwork.
So I created this project.
I used pcap4j to send and filtering packets.and for a IPv4 address, I used arp protocol related function to extract the mac address.and for a IPv6 address, I used ndp (neighbor discovery) protocol related function to extract the mac address.
- pcap4j 1.7.3
- libpcap. (ready for use version files has been uploaded into libpcapfiles)
gradle:
implementation group:'io.gitee.gaoxingliang', name:'mac-address-detector-java', version:'0.0.1'
mvn:
<dependency> <groupId>io.gitee.gaoxingliang</groupId> <artifactId>mac-address-detector-java</artifactId> <version>0.0.1</version></dependency>
and use it, see fullTest:
MacAddressaddress =MacAddressHelper.getInstance() .getMacAddress(Inet4Address.getByName("192.168.110.100"));
the pre-built dep files are underlibpcapfiles
directory.
on linux, you can load the libpcap directly without install anything
java -Dorg.pcap4j.core.pcapLibName=libpcap.so YourProgram
On windows, the npcap is required to be installed. (no reboot required)
java -Dorg.pcap4j.core.pcapLibName=wpcap.dll -Dorg.pcap4j.core.packetLibName=Packet.dll YourProgram
release the lib to mvn repo. and renaming the package.
Add a func to do packet dump by using pcap4j.After build the jar, call the main class PacketDump.java -Dorg.pcap4j.core.pcapLibName=libpcap.so -cp .:networkutils-all-0.2.jar PacketDump "udp"
About
Use pcap4j to detect a mac address of remote host
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.