ruedigergad / clj-net-pcap Goto Github PK
View Code? Open in Web Editor NEWA wrapper/facade/whatever to enable/ease the use of jNetPcap (a libpcap based packet sniffing lib) in Clojure
A wrapper/facade/whatever to enable/ease the use of jNetPcap (a libpcap based packet sniffing lib) in Clojure
Can I compile this on mac and generate .dylib file?
Currently, it is not possible to get statistical data from jNetPcap.
First step would be to print out statistical data when the example stand-alone application exits.
Fix issue wrt extracting the native libs: owner, deletion on shutdown, multiple processes, etc.
Merge open issues from cljNetPcap: https://github.com/ruedigergad/cljNetPcap/issues
The current DSL syntax is quite verbose.
A potential improvement could be to use Clojure-like expressions in the DSL, e.g.:
{:type :json-str
:rules [{"name" (int16 0)}
{"ts" (timestamp 0)}
{"ip-src" (ipv4-address :ipv4-src)}]}
This could also be used for including the scaling and centering, e.g.:
{:type :json-str
:rules [{"ts" (timestamp 0)}
{"src-port" (/ (int16 :udp-src) 65535)}]}
These are just some first examples but the potential could also be extended further such that the scaling factors could be, e.g., automatically calculated based on the extraction function, e.g.:
{:type :json-str
:rules [{"ts" (timestamp 0)}
{"src-port" (normalize (int16 :udp-src))}]}
It should be possible to dump "raw" data to a file.
The format should be the standard pcap format.
As another alternative/enhancement it should be possible to output statistical data in regular intervals.
In order to not interfer with other output one option could be to write this to stderr.
Currently, the documentation is pretty rudimentary. This should be improved.
Rename the class "InfiniteLoop" to something like "ProcessingLoop" which better gives away the intention.
Right now, the cursor/arrow keys do not work properly.
These keys could be used for implementing a command line history (up/down) and for editing commands (left/right).
This would ease the usage of the interactive command line prompt.
I'm trying to use the the clojars version 1.3.1 and I get the following exception. Any thoughts on what I might need to change? I'm on OSX with Java 7.
Exception in thread "main" java.lang.ExceptionInInitializerError
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:266)
at clojure.lang.RT.loadClassForName(RT.java:2098)
at clojure.lang.RT.load(RT.java:430)
at clojure.lang.RT.load(RT.java:411)
at clojure.core$load$fn__5018.invoke(core.clj:5530)
at clojure.core$load.doInvoke(core.clj:5529)
at clojure.lang.RestFn.invoke(RestFn.java:408)
at clojure.core$load_one.invoke(core.clj:5336)
at clojure.core$load_lib$fn__4967.invoke(core.clj:5375)
at clojure.core$load_lib.doInvoke(core.clj:5374)
at clojure.lang.RestFn.applyTo(RestFn.java:142)
at clojure.core$apply.invoke(core.clj:619)
at clojure.core$load_libs.doInvoke(core.clj:5413)
at clojure.lang.RestFn.applyTo(RestFn.java:137)
at clojure.core$apply.invoke(core.clj:621)
at clojure.core$use.doInvoke(core.clj:5507)
at clojure.lang.RestFn.invoke(RestFn.java:421)
at clj_net_pcap.pcap$loading__4784__auto__.invoke(pcap.clj:20)
at clj_net_pcap.pcap__init.load(Unknown Source)
at clj_net_pcap.pcap__init.(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:266)
at clojure.lang.RT.loadClassForName(RT.java:2098)
at clojure.lang.RT.load(RT.java:430)
at clojure.lang.RT.load(RT.java:411)
at clojure.core$load$fn__5018.invoke(core.clj:5530)
at clojure.core$load.doInvoke(core.clj:5529)
at clojure.lang.RestFn.invoke(RestFn.java:408)
at clojure.core$load_one.invoke(core.clj:5336)
at clojure.core$load_lib$fn__4967.invoke(core.clj:5375)
at clojure.core$load_lib.doInvoke(core.clj:5374)
at clojure.lang.RestFn.applyTo(RestFn.java:142)
at clojure.core$apply.invoke(core.clj:619)
at clojure.core$load_libs.doInvoke(core.clj:5413)
at clojure.lang.RestFn.applyTo(RestFn.java:137)
at clojure.core$apply.invoke(core.clj:621)
at clojure.core$use.doInvoke(core.clj:5507)
at clojure.lang.RestFn.invoke(RestFn.java:408)
at wificap.core$eval7$loading__4910__auto____8.invoke(core.clj:1)
at wificap.core$eval7.invoke(core.clj:1)
at clojure.lang.Compiler.eval(Compiler.java:6619)
at clojure.lang.Compiler.eval(Compiler.java:6608)
at clojure.lang.Compiler.load(Compiler.java:7064)
at clojure.lang.RT.loadResourceScript(RT.java:370)
at clojure.lang.RT.loadResourceScript(RT.java:361)
at clojure.lang.RT.load(RT.java:440)
at clojure.lang.RT.load(RT.java:411)
at clojure.core$load$fn__5018.invoke(core.clj:5530)
at clojure.core$load.doInvoke(core.clj:5529)
at clojure.lang.RestFn.invoke(RestFn.java:408)
at clojure.core$load_one.invoke(core.clj:5336)
at clojure.core$load_lib$fn__4967.invoke(core.clj:5375)
at clojure.core$load_lib.doInvoke(core.clj:5374)
at clojure.lang.RestFn.applyTo(RestFn.java:142)
at clojure.core$apply.invoke(core.clj:619)
at clojure.core$load_libs.doInvoke(core.clj:5413)
at clojure.lang.RestFn.applyTo(RestFn.java:137)
at clojure.core$apply.invoke(core.clj:619)
at clojure.core$require.doInvoke(core.clj:5496)
at clojure.lang.RestFn.invoke(RestFn.java:408)
at user$eval3.invoke(NO_SOURCE_FILE:1)
at clojure.lang.Compiler.eval(Compiler.java:6619)
at clojure.lang.Compiler.eval(Compiler.java:6608)
at clojure.lang.Compiler.eval(Compiler.java:6582)
at clojure.core$eval.invoke(core.clj:2852)
at clojure.main$eval_opt.invoke(main.clj:308)
at clojure.main$initialize.invoke(main.clj:327)
at clojure.main$null_opt.invoke(main.clj:362)
at clojure.main$main.doInvoke(main.clj:440)
at clojure.lang.RestFn.invoke(RestFn.java:421)
at clojure.lang.Var.invoke(Var.java:419)
at clojure.lang.AFn.applyToHelper(AFn.java:163)
at clojure.lang.Var.applyTo(Var.java:532)
at clojure.main.main(main.java:37)
Caused by: java.lang.NullPointerException
at clj_net_pcap.native$copy_resource_to_file.invoke(native.clj:81)
at clj_net_pcap.native$extract_native_lib.invoke(native.clj:90)
at clj_net_pcap.native$extract_native_libs.invoke(native.clj:108)
at clj_net_pcap.native$extract_and_load_native_libs.invoke(native.clj:12
2)
at clj_net_pcap.native__init.load(Unknown Source)
at clj_net_pcap.native__init.(Unknown Source)
... 75 more
(ns wificap.core
(:use
clj-net-pcap.pcap
)
(:gen-class))
(defn -main
"I don't do a whole lot ... yet."
[& args]
;; work around dangerous default behaviour in Clojure
(alter-var-root #'*read-eval* (constantly false))
(println "Hello, World!" (get-devices)))
Change the order of elements in the BufferRecord defrecord to match the layout of the pcap format.
This makes the BufferRecord easier to use and helps to avoid mistakes due to a messed up order.
Sample output below:
{"sniffer.header.parsed" {"PcapHeader" {"timestampInNanos" 1345332080195344000, "wirelen" 631},
"DataLinkLayer"
{"index" 0,
"destination" "00:04:0E:3D:B0:86",
"source" "74:DE:2B:08:78:09",
"next" 2},
"NetworkLayer"
{"index" 1,
"destination" "62.146.26.38",
"source" "192.168.0.198",
"id" 39936,
"tos" 0,
"ttl" 64,
"next" 4},
"Tcp"
{"index" 2,
"destination" 80,
"source" 58118,
"ack" 87556976,
"seq" 2360073644,
"flags" #{"PSH" "ACK"},
"next" 13},
"Http"
{"index" 3,
"RequestUrl"
"Referer"
"RequestMethod" "GET",
"RequestVersion" "HTTP/1.1"}}}
I have Windows 10/64. When I install winpcap then jnetpcap work well. But when I install npcap 0.99 with winpcap api compatible mode I get error
UnexpectedException: Unexpected exception[CompletionException: java.lang.ExceptionInInitializerError]
Is jnetpcap work with npcap?
Currently, the following commands are not yet mentioned in the short help:
It would be a good idea to add some simple examples on how to use cljNetPcap.
Certain options require the "-r" option for working properly.
For these cases, "-r" should be implicit.
Additionally, the help text should mention this in order to avoid confusion.
I want to compile the program myself, but the code is very confusing, which makes me unable to start. Please help me
Sample output showing the issue:
{"PcapHeader" {"timestampInNanos" 1345332080314336000, "wirelen" 574},
"DataLinkLayer"
{"index" 0,
"destination" "00:04:0E:3D:B0:86",
"source" "74:DE:2B:08:78:09",
"next" 2},
"NetworkLayer"
{"index" 1,
"destination" "62.146.26.38",
"source" "192.168.0.198",
"id" 39943,
"tos" 0,
"ttl" 64,
"next" 4},
"Tcp"
{"index" 2,
"destination" 80,
"source" 58118,
"ack" 87565262,
"seq" 2360074209,
"flags" #{"PSH" "ACK"},
"next" 13},
"Http"
{"index" 3,
"RequestUrl" "/css/top.b64-DtuWNk.css",
"Referer"
"RequestMethod" "GET",
"RequestVersion" "HTTP/1.1"}}
Add ICMP Echo id and sequence number to output map.
Commands such as:
Yet another method for querying statistical data could be to output statistical data on request when a defined signal is received.
Add an option for scaling numerical values that are to be extracted via DSL statements.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.