Coder Social home page Coder Social logo

ruedigergad / clj-net-pcap Goto Github PK

View Code? Open in Web Editor NEW
66.0 66.0 30.0 79.94 MB

A wrapper/facade/whatever to enable/ease the use of jNetPcap (a libpcap based packet sniffing lib) in Clojure

HTML 1.89% CSS 0.15% Shell 0.26% Clojure 4.00% Java 75.81% C 6.42% C++ 11.08% Gnuplot 0.11% TeX 0.21% Makefile 0.05%

clj-net-pcap's People

Contributors

ruedigergad avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

clj-net-pcap's Issues

Output statistics when shutting down.

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.

Improve DSL syntax

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))}]}

Regularly output statstical data to stderr

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.

Rename "InfiniteLoop" Class

Rename the class "InfiniteLoop" to something like "ProcessingLoop" which better gives away the intention.

Add command history and enable command editing.

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.

ExceptionInInitializerError

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 order of elements in BufferRecord

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.

Map is not printed correctly to stdout when HTTP RequestUrl is empty.

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"}}}

Work with Npcap

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?

Add simple examples

It would be a good idea to add some simple examples on how to use cljNetPcap.

help!!!

I want to compile the program myself, but the code is very confusing, which makes me unable to start. Please help me

Map is not printed correctly to stdout when HTTP Referer is empty.

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 more detailed longer help text to command line interface.

Commands such as:

  • "add-filter",
  • "gen-packet",
  • "send-packet",
  • or "set-dsl-transformation-fn"
    require complexer arguments.
    For providing better understandable help, we should try to provide longer and more detailed help texts.
    These help texts may also include examples.

Output statistics on signal

Yet another method for querying statistical data could be to output statistical data on request when a defined signal is received.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.