SlideShare a Scribd company logo
Packet Filtering using JPCAP

import java.net.*;
import java.io.*;
import jpcap.JpcapCaptor;
import jpcap.JpcapSender;
import jpcap.NetworkInterface;
import jpcap.NetworkInterfaceAddress;
import jpcap.packet.*;

class Main
{
       /* variables */
       JpcapCaptor captor;
       NetworkInterface[] list;
       String str,info;
       int x, choice;

public static void main(String args[])
{
        new Main();
}

public Main()
{

       /* first fetch available interfaces to listen on */
        list = JpcapCaptor.getDeviceList();
       System.out.println("Available interfaces: ");

       for(x=0; x<list.length; x++)
       {
              System.out.println(x+" -> "+list[x].description);
       }
       System.out.println("-------------------------n");
       choice = Integer.parseInt(getInput("Choose interface (0,1..): "));
       System.out.println("Listening on interface -> "+list[choice].description);
       System.out.println("-------------------------n");

       /*Setup device listener */
       try
       {
              captor=JpcapCaptor.openDevice(list[choice], 65535, false, 20);

                /* listen for TCP/IP only */
                captor.setFilter("ip and tcp", true);
}
      catch(IOException ioe) { ioe.printStackTrace(); }


      /* start listening for packets */
      while (true)
      {
               Packet info = captor.getPacket();
               if(info != null)
               System.out.println(info);
      }
}

/* get user input */
public static String getInput(String q)
{
        String input = "";
        System.out.print(q);
        BufferedReader bufferedreader = new BufferedReader(new
        InputStreamReader(System.in));
        try
        {
                input = bufferedreader.readLine();
        }
        catch(IOException ioexception)
        {
        }
        return input;
        }
} /*end class*/
OUTPUT:
C:Packet CapturingjSniff>javac Main.java

C:Packet CapturingjSniff>java Main
Available interfaces:
0 -> MS Tunnel Interface Driver
1 -> Realtek 10/100/1000 Ethernet NIC
(Microsoft's Packet Scheduler)
-------------------------

Choose interface (0,1..): 1
Listening on interface -> Realtek 10/100/1000 Ethernet NIC
        (Microsoft's Packet Scheduler)
-------------------------

1319000427:719763 /172.10.0.81->/172.10.0.132 protocol(6) priority(0) hop(128)
 offset(0) ident(2203) TCP 445 > 1140 seq(2709085387) win(64592) ack 1006552375
 P
1319000427:720418 /172.10.0.132->/172.10.0.81 protocol(6) priority(0) hop(128)
 offset(0) ident(714) TCP 1140 > 445 seq(1006552375) win(64567) ack 2709085526
P
1319000427:721224 /172.10.0.81->/172.10.0.132 protocol(6) priority(0) hop(128)
 offset(0) ident(2204) TCP 445 > 1140 seq(2709085526) win(64452) ack 1006552515
 P
1319000427:721667 /172.10.0.132->/172.10.0.81 protocol(6) priority(0) hop(128)
 offset(0) ident(715) TCP 1140 > 445 seq(1006552515) win(64516) ack 2709085577
P
1319000427:721972 /172.10.0.81->/172.10.0.132 protocol(6) priority(0) hop(128)
 offset(0) ident(2205) TCP 445 > 1140 seq(2709085577) win(64389) ack 1006552578
 P
1319000427:722751 /172.10.0.132->/172.10.0.81 protocol(6) priority(0) hop(128)
 offset(0) ident(716) TCP 1140 > 445 seq(1006552578) win(64384) ack 2709085709
P
1319000427:930959 /172.10.0.81->/172.10.0.132 protocol(6) priority(0) hop(128)
 offset(0) ident(2206) TCP 445 > 1140 seq(2709085709) win(65535) ack 1006553370
ALGORITHM:

JPCAP
Jpcap can be used to develop many kinds of network applications, including (but not
limited to):

   •   network and protocol analyzers
   •   network monitors
   •   traffic loggers
   •   traffic generators
   •   user-level bridges and routers
   •   network intrusion detection systems (NIDS)
   •   network scanners
   •   security tools

Jpcap captures and sends packets independently from the host protocols (e.g., TCP/IP).
This means that Jpcap does not (cannot) block, filter or manipulate the traffic generated
by other programs on the same machine: it simply "sniffs" the packets that transit on the
wire. Therefore, it does not provide the appropriate support for applications like traffic
shapers, QoS schedulers and personal firewalls.

1. Obtain the list of network interfaces

To capture packets from a network, obtain the list of network interfaces.
JpcapCaptor.getDeviceList()
It returns an array of NetworkInterface objects.
A NetworkInterface object contains some information about the corresponding network
interface, such as its name, description, IP and MAC addresses, and datatlink name and
description.


2. Open a network interface

Choose which network interface to captuer packets from, open the interface by
using JpcapCaptor.openDevice() method.

JpcapCaptor.openDevice()
The following piece of code illustrates how to open an network interface

Name:                         Purpose
NetworkInterface intrface     Network interface that you want to open.
int snaplen                   Max number of bytes to capture at once.
boolean promics               True if you want to open the interface in promiscuous
                              mode, and otherwise false.
In promiscuous mode, you can capture packets every
                               packet from the wire
                               In non-promiscuous mode, you can only capture packets
                               send and received by your host.
int to_ms                      Set a capture timeout value in milliseconds.


3. Capture packets from the network interface

There are two major approaches to capture packets using a JpcapCaptor instance: using a
callback method, and capturing packets one-by-one.

Capturing packets one-by-one

capture packets using the JpcapCaptor.getPacket() method.

getPacket() method simply returns a captured packet.
getPacket() method multiple times to capture consecutive packets.

4. Set capturing filter

In Jpcap, you can set a filter so that Jpcap doesn't capture unwanted packets. For
example, if you only want to capture TCP/IPv4 packets, you can set a filter as following:

The filter expression "ip and tcp" means to to "keep only the packets that are both IPv4
and TCP and deliver them to the application".

By properly setting a filter, you can reduce the number of packets to examine, and thus
can improve the performance of your application.
Ad

More Related Content

What's hot (20)

Effective Threat Hunting with Tactical Threat Intelligence
Effective Threat Hunting with Tactical Threat IntelligenceEffective Threat Hunting with Tactical Threat Intelligence
Effective Threat Hunting with Tactical Threat Intelligence
Dhruv Majumdar
 
CCNA Security - Chapter 1
CCNA Security - Chapter 1CCNA Security - Chapter 1
CCNA Security - Chapter 1
Irsandi Hasan
 
Owasp top 10 vulnerabilities
Owasp top 10 vulnerabilitiesOwasp top 10 vulnerabilities
Owasp top 10 vulnerabilities
OWASP Delhi
 
Linux privilege escalation 101
Linux privilege escalation 101Linux privilege escalation 101
Linux privilege escalation 101
Rashid feroz
 
Xss ppt
Xss pptXss ppt
Xss ppt
penetration Tester
 
Sql injection with sqlmap
Sql injection with sqlmapSql injection with sqlmap
Sql injection with sqlmap
Herman Duarte
 
Alphorm.com Formation Hacking et sécurité 2020 ( 2of4) : Les techniques d'OSI...
Alphorm.com Formation Hacking et sécurité 2020 ( 2of4) : Les techniques d'OSI...Alphorm.com Formation Hacking et sécurité 2020 ( 2of4) : Les techniques d'OSI...
Alphorm.com Formation Hacking et sécurité 2020 ( 2of4) : Les techniques d'OSI...
Alphorm
 
Crowdstrike .pptx
Crowdstrike .pptxCrowdstrike .pptx
Crowdstrike .pptx
uthayakumar174828
 
Web Application Security and Awareness
Web Application Security and AwarenessWeb Application Security and Awareness
Web Application Security and Awareness
Abdul Rahman Sherzad
 
Alphorm.com Formation Hacking et Sécurité 2020 (1/3) : Méthodologies de Pente...
Alphorm.com Formation Hacking et Sécurité 2020 (1/3) : Méthodologies de Pente...Alphorm.com Formation Hacking et Sécurité 2020 (1/3) : Méthodologies de Pente...
Alphorm.com Formation Hacking et Sécurité 2020 (1/3) : Méthodologies de Pente...
Alphorm
 
security misconfigurations
security misconfigurationssecurity misconfigurations
security misconfigurations
Megha Sahu
 
Threat Hunting
Threat HuntingThreat Hunting
Threat Hunting
Splunk
 
Sensibilisation à la sécurité
Sensibilisation à la sécurité Sensibilisation à la sécurité
Sensibilisation à la sécurité
Thibault Tim
 
SQL INJECTION
SQL INJECTIONSQL INJECTION
SQL INJECTION
Anoop T
 
Alphorm.com Formation Analyse de Malware 1/2 : Le guide complet
Alphorm.com Formation Analyse de Malware 1/2 : Le guide completAlphorm.com Formation Analyse de Malware 1/2 : Le guide complet
Alphorm.com Formation Analyse de Malware 1/2 : Le guide complet
Alphorm
 
CCNA Security 02- fundamentals of network security
CCNA Security 02-  fundamentals of network securityCCNA Security 02-  fundamentals of network security
CCNA Security 02- fundamentals of network security
Ahmed Habib
 
Cyber Attack Methodologies
Cyber Attack MethodologiesCyber Attack Methodologies
Cyber Attack Methodologies
Geeks Anonymes
 
Hunting for Credentials Dumping in Windows Environment
Hunting for Credentials Dumping in Windows EnvironmentHunting for Credentials Dumping in Windows Environment
Hunting for Credentials Dumping in Windows Environment
Teymur Kheirkhabarov
 
The role of big data, artificial intelligence and machine learning in cyber i...
The role of big data, artificial intelligence and machine learning in cyber i...The role of big data, artificial intelligence and machine learning in cyber i...
The role of big data, artificial intelligence and machine learning in cyber i...
Aladdin Dandis
 
Endpoint Detection & Response - FireEye
Endpoint Detection & Response - FireEyeEndpoint Detection & Response - FireEye
Endpoint Detection & Response - FireEye
Prime Infoserv
 
Effective Threat Hunting with Tactical Threat Intelligence
Effective Threat Hunting with Tactical Threat IntelligenceEffective Threat Hunting with Tactical Threat Intelligence
Effective Threat Hunting with Tactical Threat Intelligence
Dhruv Majumdar
 
CCNA Security - Chapter 1
CCNA Security - Chapter 1CCNA Security - Chapter 1
CCNA Security - Chapter 1
Irsandi Hasan
 
Owasp top 10 vulnerabilities
Owasp top 10 vulnerabilitiesOwasp top 10 vulnerabilities
Owasp top 10 vulnerabilities
OWASP Delhi
 
Linux privilege escalation 101
Linux privilege escalation 101Linux privilege escalation 101
Linux privilege escalation 101
Rashid feroz
 
Sql injection with sqlmap
Sql injection with sqlmapSql injection with sqlmap
Sql injection with sqlmap
Herman Duarte
 
Alphorm.com Formation Hacking et sécurité 2020 ( 2of4) : Les techniques d'OSI...
Alphorm.com Formation Hacking et sécurité 2020 ( 2of4) : Les techniques d'OSI...Alphorm.com Formation Hacking et sécurité 2020 ( 2of4) : Les techniques d'OSI...
Alphorm.com Formation Hacking et sécurité 2020 ( 2of4) : Les techniques d'OSI...
Alphorm
 
Web Application Security and Awareness
Web Application Security and AwarenessWeb Application Security and Awareness
Web Application Security and Awareness
Abdul Rahman Sherzad
 
Alphorm.com Formation Hacking et Sécurité 2020 (1/3) : Méthodologies de Pente...
Alphorm.com Formation Hacking et Sécurité 2020 (1/3) : Méthodologies de Pente...Alphorm.com Formation Hacking et Sécurité 2020 (1/3) : Méthodologies de Pente...
Alphorm.com Formation Hacking et Sécurité 2020 (1/3) : Méthodologies de Pente...
Alphorm
 
security misconfigurations
security misconfigurationssecurity misconfigurations
security misconfigurations
Megha Sahu
 
Threat Hunting
Threat HuntingThreat Hunting
Threat Hunting
Splunk
 
Sensibilisation à la sécurité
Sensibilisation à la sécurité Sensibilisation à la sécurité
Sensibilisation à la sécurité
Thibault Tim
 
SQL INJECTION
SQL INJECTIONSQL INJECTION
SQL INJECTION
Anoop T
 
Alphorm.com Formation Analyse de Malware 1/2 : Le guide complet
Alphorm.com Formation Analyse de Malware 1/2 : Le guide completAlphorm.com Formation Analyse de Malware 1/2 : Le guide complet
Alphorm.com Formation Analyse de Malware 1/2 : Le guide complet
Alphorm
 
CCNA Security 02- fundamentals of network security
CCNA Security 02-  fundamentals of network securityCCNA Security 02-  fundamentals of network security
CCNA Security 02- fundamentals of network security
Ahmed Habib
 
Cyber Attack Methodologies
Cyber Attack MethodologiesCyber Attack Methodologies
Cyber Attack Methodologies
Geeks Anonymes
 
Hunting for Credentials Dumping in Windows Environment
Hunting for Credentials Dumping in Windows EnvironmentHunting for Credentials Dumping in Windows Environment
Hunting for Credentials Dumping in Windows Environment
Teymur Kheirkhabarov
 
The role of big data, artificial intelligence and machine learning in cyber i...
The role of big data, artificial intelligence and machine learning in cyber i...The role of big data, artificial intelligence and machine learning in cyber i...
The role of big data, artificial intelligence and machine learning in cyber i...
Aladdin Dandis
 
Endpoint Detection & Response - FireEye
Endpoint Detection & Response - FireEyeEndpoint Detection & Response - FireEye
Endpoint Detection & Response - FireEye
Prime Infoserv
 

Similar to Packet filtering using jpcap (20)

TCP IP
TCP IPTCP IP
TCP IP
hivasu
 
Wireshark.ethereal
Wireshark.etherealWireshark.ethereal
Wireshark.ethereal
gh02
 
Ipc
IpcIpc
Ipc
deepakittude
 
#2 (UDP)
#2 (UDP)#2 (UDP)
#2 (UDP)
Ghadeer AlHasan
 
Geep networking stack-linuxkernel
Geep networking stack-linuxkernelGeep networking stack-linuxkernel
Geep networking stack-linuxkernel
Kiran Divekar
 
Java Socket Programming
Java Socket ProgrammingJava Socket Programming
Java Socket Programming
Vipin Yadav
 
Capturing NIC and Kernel TX and RX Timestamps for Packets in Go
Capturing NIC and Kernel TX and RX Timestamps for Packets in GoCapturing NIC and Kernel TX and RX Timestamps for Packets in Go
Capturing NIC and Kernel TX and RX Timestamps for Packets in Go
ScyllaDB
 
Traffic monitoring
Traffic monitoringTraffic monitoring
Traffic monitoring
Radu Galbenu
 
ikh331-06-distributed-programming
ikh331-06-distributed-programmingikh331-06-distributed-programming
ikh331-06-distributed-programming
Anung Ariwibowo
 
Pemrograman Jaringan
Pemrograman JaringanPemrograman Jaringan
Pemrograman Jaringan
belajarkomputer
 
Socket System Calls
Socket System CallsSocket System Calls
Socket System Calls
Avinash Varma Kalidindi
 
Udp Programming
Udp ProgrammingUdp Programming
Udp Programming
leminhvuong
 
Udp Programming
Udp ProgrammingUdp Programming
Udp Programming
phanleson
 
Cs423 raw sockets_bw
Cs423 raw sockets_bwCs423 raw sockets_bw
Cs423 raw sockets_bw
jktjpc
 
Unit 8 Java
Unit 8 JavaUnit 8 Java
Unit 8 Java
arnold 7490
 
Workshop Wireshark
Workshop Wireshark Workshop Wireshark
Workshop Wireshark
Fabio Rosa
 
Network Programming: Data Plane Development Kit (DPDK)
Network Programming: Data Plane Development Kit (DPDK)Network Programming: Data Plane Development Kit (DPDK)
Network Programming: Data Plane Development Kit (DPDK)
Andriy Berestovskyy
 
#1 (TCPvs. UDP)
#1 (TCPvs. UDP)#1 (TCPvs. UDP)
#1 (TCPvs. UDP)
Ghadeer AlHasan
 
Socket Programming it-slideshares.blogspot.com
Socket  Programming it-slideshares.blogspot.comSocket  Programming it-slideshares.blogspot.com
Socket Programming it-slideshares.blogspot.com
phanleson
 
Cassandra 2.1 boot camp, Overview
Cassandra 2.1 boot camp, OverviewCassandra 2.1 boot camp, Overview
Cassandra 2.1 boot camp, Overview
Joshua McKenzie
 
TCP IP
TCP IPTCP IP
TCP IP
hivasu
 
Wireshark.ethereal
Wireshark.etherealWireshark.ethereal
Wireshark.ethereal
gh02
 
Geep networking stack-linuxkernel
Geep networking stack-linuxkernelGeep networking stack-linuxkernel
Geep networking stack-linuxkernel
Kiran Divekar
 
Java Socket Programming
Java Socket ProgrammingJava Socket Programming
Java Socket Programming
Vipin Yadav
 
Capturing NIC and Kernel TX and RX Timestamps for Packets in Go
Capturing NIC and Kernel TX and RX Timestamps for Packets in GoCapturing NIC and Kernel TX and RX Timestamps for Packets in Go
Capturing NIC and Kernel TX and RX Timestamps for Packets in Go
ScyllaDB
 
Traffic monitoring
Traffic monitoringTraffic monitoring
Traffic monitoring
Radu Galbenu
 
ikh331-06-distributed-programming
ikh331-06-distributed-programmingikh331-06-distributed-programming
ikh331-06-distributed-programming
Anung Ariwibowo
 
Udp Programming
Udp ProgrammingUdp Programming
Udp Programming
phanleson
 
Cs423 raw sockets_bw
Cs423 raw sockets_bwCs423 raw sockets_bw
Cs423 raw sockets_bw
jktjpc
 
Workshop Wireshark
Workshop Wireshark Workshop Wireshark
Workshop Wireshark
Fabio Rosa
 
Network Programming: Data Plane Development Kit (DPDK)
Network Programming: Data Plane Development Kit (DPDK)Network Programming: Data Plane Development Kit (DPDK)
Network Programming: Data Plane Development Kit (DPDK)
Andriy Berestovskyy
 
Socket Programming it-slideshares.blogspot.com
Socket  Programming it-slideshares.blogspot.comSocket  Programming it-slideshares.blogspot.com
Socket Programming it-slideshares.blogspot.com
phanleson
 
Cassandra 2.1 boot camp, Overview
Cassandra 2.1 boot camp, OverviewCassandra 2.1 boot camp, Overview
Cassandra 2.1 boot camp, Overview
Joshua McKenzie
 
Ad

More from Elanthendral Mariappan (8)

Ad-HOc presentation
Ad-HOc presentationAd-HOc presentation
Ad-HOc presentation
Elanthendral Mariappan
 
Image+processing
Image+processingImage+processing
Image+processing
Elanthendral Mariappan
 
Ex11 mini project
Ex11 mini projectEx11 mini project
Ex11 mini project
Elanthendral Mariappan
 
Ex3 lisp likelist in java
Ex3 lisp likelist in javaEx3 lisp likelist in java
Ex3 lisp likelist in java
Elanthendral Mariappan
 
Cybercrimes
CybercrimesCybercrimes
Cybercrimes
Elanthendral Mariappan
 
Routing security in ad hoc wireless network
Routing security in ad hoc wireless networkRouting security in ad hoc wireless network
Routing security in ad hoc wireless network
Elanthendral Mariappan
 
Autonomic computer
Autonomic computerAutonomic computer
Autonomic computer
Elanthendral Mariappan
 
Autonomic computer
Autonomic computerAutonomic computer
Autonomic computer
Elanthendral Mariappan
 
Ad

Recently uploaded (20)

Kit-Works Team Study_아직도 Dockefile.pdf_김성호
Kit-Works Team Study_아직도 Dockefile.pdf_김성호Kit-Works Team Study_아직도 Dockefile.pdf_김성호
Kit-Works Team Study_아직도 Dockefile.pdf_김성호
Wonjun Hwang
 
The No-Code Way to Build a Marketing Team with One AI Agent (Download the n8n...
The No-Code Way to Build a Marketing Team with One AI Agent (Download the n8n...The No-Code Way to Build a Marketing Team with One AI Agent (Download the n8n...
The No-Code Way to Build a Marketing Team with One AI Agent (Download the n8n...
SOFTTECHHUB
 
RTP Over QUIC: An Interesting Opportunity Or Wasted Time?
RTP Over QUIC: An Interesting Opportunity Or Wasted Time?RTP Over QUIC: An Interesting Opportunity Or Wasted Time?
RTP Over QUIC: An Interesting Opportunity Or Wasted Time?
Lorenzo Miniero
 
Dark Dynamism: drones, dark factories and deurbanization
Dark Dynamism: drones, dark factories and deurbanizationDark Dynamism: drones, dark factories and deurbanization
Dark Dynamism: drones, dark factories and deurbanization
Jakub Šimek
 
GDG Cloud Southlake #42: Suresh Mathew: Autonomous Resource Optimization: How...
GDG Cloud Southlake #42: Suresh Mathew: Autonomous Resource Optimization: How...GDG Cloud Southlake #42: Suresh Mathew: Autonomous Resource Optimization: How...
GDG Cloud Southlake #42: Suresh Mathew: Autonomous Resource Optimization: How...
James Anderson
 
Zilliz Cloud Monthly Technical Review: May 2025
Zilliz Cloud Monthly Technical Review: May 2025Zilliz Cloud Monthly Technical Review: May 2025
Zilliz Cloud Monthly Technical Review: May 2025
Zilliz
 
AI-proof your career by Olivier Vroom and David WIlliamson
AI-proof your career by Olivier Vroom and David WIlliamsonAI-proof your career by Olivier Vroom and David WIlliamson
AI-proof your career by Olivier Vroom and David WIlliamson
UXPA Boston
 
Challenges in Migrating Imperative Deep Learning Programs to Graph Execution:...
Challenges in Migrating Imperative Deep Learning Programs to Graph Execution:...Challenges in Migrating Imperative Deep Learning Programs to Graph Execution:...
Challenges in Migrating Imperative Deep Learning Programs to Graph Execution:...
Raffi Khatchadourian
 
Kit-Works Team Study_팀스터디_김한솔_nuqs_20250509.pdf
Kit-Works Team Study_팀스터디_김한솔_nuqs_20250509.pdfKit-Works Team Study_팀스터디_김한솔_nuqs_20250509.pdf
Kit-Works Team Study_팀스터디_김한솔_nuqs_20250509.pdf
Wonjun Hwang
 
Build With AI - In Person Session Slides.pdf
Build With AI - In Person Session Slides.pdfBuild With AI - In Person Session Slides.pdf
Build With AI - In Person Session Slides.pdf
Google Developer Group - Harare
 
UiPath Automation Suite – Cas d'usage d'une NGO internationale basée à Genève
UiPath Automation Suite – Cas d'usage d'une NGO internationale basée à GenèveUiPath Automation Suite – Cas d'usage d'une NGO internationale basée à Genève
UiPath Automation Suite – Cas d'usage d'une NGO internationale basée à Genève
UiPathCommunity
 
AI x Accessibility UXPA by Stew Smith and Olivier Vroom
AI x Accessibility UXPA by Stew Smith and Olivier VroomAI x Accessibility UXPA by Stew Smith and Olivier Vroom
AI x Accessibility UXPA by Stew Smith and Olivier Vroom
UXPA Boston
 
Limecraft Webinar - 2025.3 release, featuring Content Delivery, Graphic Conte...
Limecraft Webinar - 2025.3 release, featuring Content Delivery, Graphic Conte...Limecraft Webinar - 2025.3 release, featuring Content Delivery, Graphic Conte...
Limecraft Webinar - 2025.3 release, featuring Content Delivery, Graphic Conte...
Maarten Verwaest
 
fennec fox optimization algorithm for optimal solution
fennec fox optimization algorithm for optimal solutionfennec fox optimization algorithm for optimal solution
fennec fox optimization algorithm for optimal solution
shallal2
 
DevOpsDays SLC - Platform Engineers are Product Managers.pptx
DevOpsDays SLC - Platform Engineers are Product Managers.pptxDevOpsDays SLC - Platform Engineers are Product Managers.pptx
DevOpsDays SLC - Platform Engineers are Product Managers.pptx
Justin Reock
 
Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...
Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...
Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...
Markus Eisele
 
Com fer un pla de gestió de dades amb l'eiNa DMP (en anglès)
Com fer un pla de gestió de dades amb l'eiNa DMP (en anglès)Com fer un pla de gestió de dades amb l'eiNa DMP (en anglès)
Com fer un pla de gestió de dades amb l'eiNa DMP (en anglès)
CSUC - Consorci de Serveis Universitaris de Catalunya
 
Crazy Incentives and How They Kill Security. How Do You Turn the Wheel?
Crazy Incentives and How They Kill Security. How Do You Turn the Wheel?Crazy Incentives and How They Kill Security. How Do You Turn the Wheel?
Crazy Incentives and How They Kill Security. How Do You Turn the Wheel?
Christian Folini
 
Smart Investments Leveraging Agentic AI for Real Estate Success.pptx
Smart Investments Leveraging Agentic AI for Real Estate Success.pptxSmart Investments Leveraging Agentic AI for Real Estate Success.pptx
Smart Investments Leveraging Agentic AI for Real Estate Success.pptx
Seasia Infotech
 
Reimagine How You and Your Team Work with Microsoft 365 Copilot.pptx
Reimagine How You and Your Team Work with Microsoft 365 Copilot.pptxReimagine How You and Your Team Work with Microsoft 365 Copilot.pptx
Reimagine How You and Your Team Work with Microsoft 365 Copilot.pptx
John Moore
 
Kit-Works Team Study_아직도 Dockefile.pdf_김성호
Kit-Works Team Study_아직도 Dockefile.pdf_김성호Kit-Works Team Study_아직도 Dockefile.pdf_김성호
Kit-Works Team Study_아직도 Dockefile.pdf_김성호
Wonjun Hwang
 
The No-Code Way to Build a Marketing Team with One AI Agent (Download the n8n...
The No-Code Way to Build a Marketing Team with One AI Agent (Download the n8n...The No-Code Way to Build a Marketing Team with One AI Agent (Download the n8n...
The No-Code Way to Build a Marketing Team with One AI Agent (Download the n8n...
SOFTTECHHUB
 
RTP Over QUIC: An Interesting Opportunity Or Wasted Time?
RTP Over QUIC: An Interesting Opportunity Or Wasted Time?RTP Over QUIC: An Interesting Opportunity Or Wasted Time?
RTP Over QUIC: An Interesting Opportunity Or Wasted Time?
Lorenzo Miniero
 
Dark Dynamism: drones, dark factories and deurbanization
Dark Dynamism: drones, dark factories and deurbanizationDark Dynamism: drones, dark factories and deurbanization
Dark Dynamism: drones, dark factories and deurbanization
Jakub Šimek
 
GDG Cloud Southlake #42: Suresh Mathew: Autonomous Resource Optimization: How...
GDG Cloud Southlake #42: Suresh Mathew: Autonomous Resource Optimization: How...GDG Cloud Southlake #42: Suresh Mathew: Autonomous Resource Optimization: How...
GDG Cloud Southlake #42: Suresh Mathew: Autonomous Resource Optimization: How...
James Anderson
 
Zilliz Cloud Monthly Technical Review: May 2025
Zilliz Cloud Monthly Technical Review: May 2025Zilliz Cloud Monthly Technical Review: May 2025
Zilliz Cloud Monthly Technical Review: May 2025
Zilliz
 
AI-proof your career by Olivier Vroom and David WIlliamson
AI-proof your career by Olivier Vroom and David WIlliamsonAI-proof your career by Olivier Vroom and David WIlliamson
AI-proof your career by Olivier Vroom and David WIlliamson
UXPA Boston
 
Challenges in Migrating Imperative Deep Learning Programs to Graph Execution:...
Challenges in Migrating Imperative Deep Learning Programs to Graph Execution:...Challenges in Migrating Imperative Deep Learning Programs to Graph Execution:...
Challenges in Migrating Imperative Deep Learning Programs to Graph Execution:...
Raffi Khatchadourian
 
Kit-Works Team Study_팀스터디_김한솔_nuqs_20250509.pdf
Kit-Works Team Study_팀스터디_김한솔_nuqs_20250509.pdfKit-Works Team Study_팀스터디_김한솔_nuqs_20250509.pdf
Kit-Works Team Study_팀스터디_김한솔_nuqs_20250509.pdf
Wonjun Hwang
 
UiPath Automation Suite – Cas d'usage d'une NGO internationale basée à Genève
UiPath Automation Suite – Cas d'usage d'une NGO internationale basée à GenèveUiPath Automation Suite – Cas d'usage d'une NGO internationale basée à Genève
UiPath Automation Suite – Cas d'usage d'une NGO internationale basée à Genève
UiPathCommunity
 
AI x Accessibility UXPA by Stew Smith and Olivier Vroom
AI x Accessibility UXPA by Stew Smith and Olivier VroomAI x Accessibility UXPA by Stew Smith and Olivier Vroom
AI x Accessibility UXPA by Stew Smith and Olivier Vroom
UXPA Boston
 
Limecraft Webinar - 2025.3 release, featuring Content Delivery, Graphic Conte...
Limecraft Webinar - 2025.3 release, featuring Content Delivery, Graphic Conte...Limecraft Webinar - 2025.3 release, featuring Content Delivery, Graphic Conte...
Limecraft Webinar - 2025.3 release, featuring Content Delivery, Graphic Conte...
Maarten Verwaest
 
fennec fox optimization algorithm for optimal solution
fennec fox optimization algorithm for optimal solutionfennec fox optimization algorithm for optimal solution
fennec fox optimization algorithm for optimal solution
shallal2
 
DevOpsDays SLC - Platform Engineers are Product Managers.pptx
DevOpsDays SLC - Platform Engineers are Product Managers.pptxDevOpsDays SLC - Platform Engineers are Product Managers.pptx
DevOpsDays SLC - Platform Engineers are Product Managers.pptx
Justin Reock
 
Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...
Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...
Enterprise Integration Is Dead! Long Live AI-Driven Integration with Apache C...
Markus Eisele
 
Crazy Incentives and How They Kill Security. How Do You Turn the Wheel?
Crazy Incentives and How They Kill Security. How Do You Turn the Wheel?Crazy Incentives and How They Kill Security. How Do You Turn the Wheel?
Crazy Incentives and How They Kill Security. How Do You Turn the Wheel?
Christian Folini
 
Smart Investments Leveraging Agentic AI for Real Estate Success.pptx
Smart Investments Leveraging Agentic AI for Real Estate Success.pptxSmart Investments Leveraging Agentic AI for Real Estate Success.pptx
Smart Investments Leveraging Agentic AI for Real Estate Success.pptx
Seasia Infotech
 
Reimagine How You and Your Team Work with Microsoft 365 Copilot.pptx
Reimagine How You and Your Team Work with Microsoft 365 Copilot.pptxReimagine How You and Your Team Work with Microsoft 365 Copilot.pptx
Reimagine How You and Your Team Work with Microsoft 365 Copilot.pptx
John Moore
 

Packet filtering using jpcap

  • 1. Packet Filtering using JPCAP import java.net.*; import java.io.*; import jpcap.JpcapCaptor; import jpcap.JpcapSender; import jpcap.NetworkInterface; import jpcap.NetworkInterfaceAddress; import jpcap.packet.*; class Main { /* variables */ JpcapCaptor captor; NetworkInterface[] list; String str,info; int x, choice; public static void main(String args[]) { new Main(); } public Main() { /* first fetch available interfaces to listen on */ list = JpcapCaptor.getDeviceList(); System.out.println("Available interfaces: "); for(x=0; x<list.length; x++) { System.out.println(x+" -> "+list[x].description); } System.out.println("-------------------------n"); choice = Integer.parseInt(getInput("Choose interface (0,1..): ")); System.out.println("Listening on interface -> "+list[choice].description); System.out.println("-------------------------n"); /*Setup device listener */ try { captor=JpcapCaptor.openDevice(list[choice], 65535, false, 20); /* listen for TCP/IP only */ captor.setFilter("ip and tcp", true);
  • 2. } catch(IOException ioe) { ioe.printStackTrace(); } /* start listening for packets */ while (true) { Packet info = captor.getPacket(); if(info != null) System.out.println(info); } } /* get user input */ public static String getInput(String q) { String input = ""; System.out.print(q); BufferedReader bufferedreader = new BufferedReader(new InputStreamReader(System.in)); try { input = bufferedreader.readLine(); } catch(IOException ioexception) { } return input; } } /*end class*/
  • 3. OUTPUT: C:Packet CapturingjSniff>javac Main.java C:Packet CapturingjSniff>java Main Available interfaces: 0 -> MS Tunnel Interface Driver 1 -> Realtek 10/100/1000 Ethernet NIC (Microsoft's Packet Scheduler) ------------------------- Choose interface (0,1..): 1 Listening on interface -> Realtek 10/100/1000 Ethernet NIC (Microsoft's Packet Scheduler) ------------------------- 1319000427:719763 /172.10.0.81->/172.10.0.132 protocol(6) priority(0) hop(128) offset(0) ident(2203) TCP 445 > 1140 seq(2709085387) win(64592) ack 1006552375 P 1319000427:720418 /172.10.0.132->/172.10.0.81 protocol(6) priority(0) hop(128) offset(0) ident(714) TCP 1140 > 445 seq(1006552375) win(64567) ack 2709085526 P 1319000427:721224 /172.10.0.81->/172.10.0.132 protocol(6) priority(0) hop(128) offset(0) ident(2204) TCP 445 > 1140 seq(2709085526) win(64452) ack 1006552515 P 1319000427:721667 /172.10.0.132->/172.10.0.81 protocol(6) priority(0) hop(128) offset(0) ident(715) TCP 1140 > 445 seq(1006552515) win(64516) ack 2709085577 P 1319000427:721972 /172.10.0.81->/172.10.0.132 protocol(6) priority(0) hop(128) offset(0) ident(2205) TCP 445 > 1140 seq(2709085577) win(64389) ack 1006552578 P 1319000427:722751 /172.10.0.132->/172.10.0.81 protocol(6) priority(0) hop(128) offset(0) ident(716) TCP 1140 > 445 seq(1006552578) win(64384) ack 2709085709 P 1319000427:930959 /172.10.0.81->/172.10.0.132 protocol(6) priority(0) hop(128) offset(0) ident(2206) TCP 445 > 1140 seq(2709085709) win(65535) ack 1006553370
  • 4. ALGORITHM: JPCAP Jpcap can be used to develop many kinds of network applications, including (but not limited to): • network and protocol analyzers • network monitors • traffic loggers • traffic generators • user-level bridges and routers • network intrusion detection systems (NIDS) • network scanners • security tools Jpcap captures and sends packets independently from the host protocols (e.g., TCP/IP). This means that Jpcap does not (cannot) block, filter or manipulate the traffic generated by other programs on the same machine: it simply "sniffs" the packets that transit on the wire. Therefore, it does not provide the appropriate support for applications like traffic shapers, QoS schedulers and personal firewalls. 1. Obtain the list of network interfaces To capture packets from a network, obtain the list of network interfaces. JpcapCaptor.getDeviceList() It returns an array of NetworkInterface objects. A NetworkInterface object contains some information about the corresponding network interface, such as its name, description, IP and MAC addresses, and datatlink name and description. 2. Open a network interface Choose which network interface to captuer packets from, open the interface by using JpcapCaptor.openDevice() method. JpcapCaptor.openDevice() The following piece of code illustrates how to open an network interface Name: Purpose NetworkInterface intrface Network interface that you want to open. int snaplen Max number of bytes to capture at once. boolean promics True if you want to open the interface in promiscuous mode, and otherwise false.
  • 5. In promiscuous mode, you can capture packets every packet from the wire In non-promiscuous mode, you can only capture packets send and received by your host. int to_ms Set a capture timeout value in milliseconds. 3. Capture packets from the network interface There are two major approaches to capture packets using a JpcapCaptor instance: using a callback method, and capturing packets one-by-one. Capturing packets one-by-one capture packets using the JpcapCaptor.getPacket() method. getPacket() method simply returns a captured packet. getPacket() method multiple times to capture consecutive packets. 4. Set capturing filter In Jpcap, you can set a filter so that Jpcap doesn't capture unwanted packets. For example, if you only want to capture TCP/IPv4 packets, you can set a filter as following: The filter expression "ip and tcp" means to to "keep only the packets that are both IPv4 and TCP and deliver them to the application". By properly setting a filter, you can reduce the number of packets to examine, and thus can improve the performance of your application.
  翻译: