Questions tagged [pcap4j]

A Java library for capturing, crafting, and sending packets.

A Java library for capturing, crafting, and sending packets.

28 questions
6
votes
1 answer

Read Packet Content using pcap4j

I have my below code which can captures packets from the interface using pcap4j but I am not sure how can I print the request and the response data present in the packet. For example, if I make a REST call from a postman then I want to trace the…
arpit joshi
  • 1,987
  • 8
  • 36
  • 62
6
votes
1 answer

BPF expression to capture only arp-reply packets

Is there a BPF expression that would only capture arp-reply packets? Currently, I am using Pcap4J and the following BPF expression: arp and dst host host and ether dst mac where host is the IP address of my device and mac is the MAC address of my…
rolling_codes
  • 15,174
  • 22
  • 76
  • 112
4
votes
1 answer

How to capture the domain in pcap4j?

I'm working in a Java (Android) project, the main idea is to capture urls and block the access to dangerous pages, so to obtain the urls that the user access I'm using pcap4j library as follows: IpV4Packet ipV4Packet = packet.get…
3
votes
1 answer

Simulate an HTTP/2 stream with pcap4j

I'm trying to capture the unencrypted bytes of a TLS connection and record them into a cap file for analysis of the HTTP/2 traffic. There are a lot of assumptions I am making that this is even possible. But I'm willing to fudge almost everything…
Yuri Schimke
  • 12,435
  • 3
  • 35
  • 69
2
votes
1 answer

Issue capturing packets from pcap file using JNetPcap

I'm using JNetPcap to capture packets from a pcap file in Java. The code works fine sometimes, but other times it doesn't capture any packets even though the pcap file is full of packets. Here's my code: import org.jnetpcap.Pcap; import…
elnino17
  • 31
  • 1
2
votes
1 answer

Winpcap with jnetpcap and Windows 10

According to WinPcap website, they don't support Windows 10 but latest release of famous network analyzer, Wireshark (2.6.6) which can run on Windows 10 still uses WinPcap in its installation. On the other hand, they warn you about WinPcap usage on…
2
votes
0 answers

Store Java raw InputStream data as PCAP to view in Wireshark

I'm trying to build a transparent proxy in Java with the ability to record data that passed through to be viewed later in wireshark. I was able to get the proxy working correctly with this snippet private static final int BUFFER_SIZE =…
ggfpc
  • 86
  • 8
1
vote
0 answers

How i can calcul bandwith by uisng pcap4j

I am having issues with the pcap4j library. I want to calculate the bandwidth using a pcap file and I have tried many codes but I have not been successful. One of the codes I have used is: import org.pcap4j.core.PcapHandle; import…
elnino17
  • 31
  • 1
1
vote
1 answer

Cannot read TcpPacket in pcap4j

I am trying to use pcap4j to get TcpPackets from loopback address. I can read packets successfully but I cannot convert them to TcpPackets: public class Main { public static void main(String[] args) throws Exception { …
adragomir
  • 457
  • 4
  • 16
  • 33
1
vote
1 answer

Pcap4J Error:java.lang.ClassNotFoundException: org.pcap4j.util.NifSelector while trying to run my code to list out the available interfaces

I'm currently trying to run a Java code through Maven to make a packet sniffing tool. Currently I'm running a simple code to select all the currently available network interfaces using NifSelector but im running into a the following error ->…
need_to_know_now
  • 328
  • 1
  • 2
  • 13
1
vote
1 answer

How can I stop thread containing blocking operation?

I'm working on a packet sniffer but I'm getting trouble about the way to stop a thread (without deprecated methods) containing a blocking method. The concerned method is the loop() one from pcap4j library. As it is a blocking method, I put it into…
GoldenBolt
  • 51
  • 8
1
vote
1 answer

Pcap4j TCP packets being dropped after showing on Wireshark

For educational purposes I'm trying to perform a SYN flood attack on a Ubuntu 18.04 VM. I have enabled bridge mode in my VM settings and set up a web server (10.0.0.10) I can reach on my host pc (10.0.0.3) and vice versa with pings. Pinging from…
Arjen
  • 11
  • 4
1
vote
2 answers

properties file exists, but still getting "WARN No appenders could be found"

I'm using the pcap4j library in my application and when I run it I get: log4j:WARN No appenders could be found for logger (org.pcap4j.core.NativeMappings). log4j:WARN Please initialize the log4j system properly. log4j:WARN See…
tom
  • 2,137
  • 2
  • 27
  • 51
1
vote
1 answer

Decrypting HTTPS packets using pcap4J

In Java I'm using pcap4J to capture network traffic of another application running on my computer. The code I'm using to do this is the following: import org.pcap4j.core.*; import org.pcap4j.packet.Packet; import org.pcap4j.util.NifSelector; import…
BullyWiiPlaza
  • 17,329
  • 10
  • 113
  • 185
0
votes
0 answers

pcap4j sendPacket The target IP cannot capture the corresponding message

pcap4j sendPacket The target IP cannot capture the corresponding message. PcapHandle pcapHandle = Pcaps.openOffline("D:\\GTP.pcap"); PcapNetworkInterface device = Pcaps.getDevByName("\\Device\\NPF_{32B17C2A-F521-4721-90CA-C57DF0024F01}"); …
1
2