2

Will I'm working on project using JnetPcap API,I was able to list to run the ClassicPcapExample successfully

public class ClassicPcapExample {

/**
 * Main startup method
 * 
 * @param args
 *          ignored
 */
public static void main(String[] args) {
    List<PcapIf> alldevs = new ArrayList<PcapIf>(); // Will be filled with NICs
    StringBuilder errbuf = new StringBuilder(); // For any error msgs

    /***************************************************************************
     * First get a list of devices on this system
     **************************************************************************/
    int r = Pcap.findAllDevs(alldevs, errbuf);
    if (r == Pcap.NOT_OK || alldevs.isEmpty()) {
        System.err.printf("Can't read list of devices, error is %s", errbuf
            .toString());
        return;
    }

    System.out.println("Network devices found:");

    int i = 0;
    for (PcapIf device : alldevs) {
        String description =
            (device.getDescription() != null) ? device.getDescription()
                : "No description available";
        System.out.printf("#%d: %s [%s]\n", i++, device.getName(), description);
    }

    PcapIf device = alldevs.get(0); // We know we have atleast 1 device
    System.out
        .printf("\nChoosing '%s' on your behalf:\n",
            (device.getDescription() != null) ? device.getDescription()
                : device.getName());

    /***************************************************************************
     * Second we open up the selected device
     **************************************************************************/
    int snaplen = 64 * 1024;           // Capture all packets, no trucation
    int flags = Pcap.MODE_PROMISCUOUS; // capture all packets
    int timeout = 10 * 1000;           // 10 seconds in millis
    Pcap pcap =
        Pcap.openLive(device.getName(), snaplen, flags, timeout, errbuf);

    if (pcap == null) {
        System.err.printf("Error while opening device for capture: "
            + errbuf.toString());
        return;
    }

the problem I m having now , is my wireless interface is not listed among the interfaces , so I can sniff HTTP Packets .

Here is the Output of this program :

        Network devices found:
#0: \Device\NPF_{273EF1C6-92B4-446F-9D88-553E18695A27} [VMware Virtual Ethernet Adapter]
#1: \Device\NPF_{C69FC3BE-1E6C-415B-9AAC-36D4654C7AD8} [Microsoft]
#2: \Device\NPF_{46AC6814-0644-4B81-BAC9-70FEB2002E07} [VMware Virtual Ethernet Adapter]
#3: \Device\NPF_{037F3BF4-B510-4A1D-90C0-1014FB3974F7} [Microsoft]
#4: \Device\NPF_{CA7D4FF0-B88B-4D0D-BBDC-A1923AF8D4B3} [Realtek PCIe GBE Family Controller]
#5: \Device\NPF_{3E2983E7-11F8-415A-BC81-E1B99CA8B092} [Microsoft]

Choosing 'VMware Virtual Ethernet Adapter' on your behalf:
Sam Ben
  • 229
  • 1
  • 5
  • 11
  • try modifying PcapIf device = alldevs.get(0); by entering different values in alldevs.get(#number of the device as shown in console) – chyupa Apr 08 '14 at 11:30

1 Answers1

2

jnetpcap didn't list your wireless interface as "wireless" like wireshark does.

It's listed as Microsoft instead, so your interface is one of the Microsoft devices in that list.

Let only your wireless access the net, then try the sniffer on each one until you find which is the wireless interface.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
chaos
  • 21
  • 5