Skip to content

Commit 3061f24

Browse files
committed
init project
1 parent e11c00d commit 3061f24

File tree

108 files changed

+7501
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

108 files changed

+7501
-0
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
### Version 0.7.1
2+
3+
- Migrate project from [CICFlowMeter Mk.6](https://github.com/Tomahawkd/CICFlowMeter-Mk.6)

README.md

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
# JFlowInspector
2+
JFlowInspector is a tool to inspect network traffic, identify network flows and extract preset
3+
features to CSV file.
4+
5+
## History
6+
Inspired by [CICFlowMeter](https://github.com/ahlashkari/CICFlowMeter), the project originally
7+
is forked to [CICFlowMeter Mk.6](https://github.com/Tomahawkd/CICFlowMeter-Mk.6). After a massive
8+
code refactor, CICFlowMeter Mk.6 is able to use to extract more features, not only the TCP features
9+
but also HTTP features.
10+
11+
To read HTTP data from TCP stream, CICFlowMeter Mk.6 is refactored again to add the ability to
12+
reassemble the HTTP data from several TCP segments. However, the TCP reorder and reassembly slows
13+
down the whole inspecting procedure significantly.
14+
15+
The third code refactor comes with multi-threading and a faster pcap file parser. This is the
16+
current CICFlowMeter Mk.6. For now, it is way different from the original CICFlowMeter, and
17+
I'm tend to provide more features for CICFlowMeter Mk.6. Therefore, the original CICFlowMeter Mk.6
18+
project is migrate to a new repository, which here is the place for the new generation of the
19+
CICFlowMeter and CICFlowMeter Mk.6.
20+
21+
## Prerequisite
22+
1. Java 8
23+
2. jnetpcap native library and use `-Djava.library.path` to link native library with jar.
24+
25+
Note:
26+
Highly recommended allocating JFlowInspector with larger memory using `-Xmx` if you are about to
27+
processing large number of network flows.
28+
My configuration is allocating 4G of the memory (`-Xmx4G`)
29+
30+
## Build
31+
Clone the code and its submodule and use maven to create jar.
32+
33+
Note:
34+
1. The repo is only tested on Windows platform.
35+
2. The native library is acquired from the original CICFlowMeter repo.
36+
3. For more information about jnetpcap, please follow the [link](https://sourceforge.net/projects/jnetpcap/).
37+
4. The tool will generate tons of logs while running, use `--quiet` to stop this.
38+
39+
## Commandline Help
40+
```
41+
Usage: <main class> [options] Pcap file or directory.
42+
Options:
43+
-a, --act_time
44+
Setting timeout interval for an activity.
45+
Default: 5000000
46+
-c, --continue
47+
Indicate the files in input dir are continuous.
48+
Default: false
49+
--debug
50+
Show debug output (sets logLevel to DEBUG)
51+
Default: false
52+
-q, --flow_queue
53+
Set the queue length waiting for flow process
54+
Default: 256
55+
-t, --flow_thread
56+
Set the thread count to process flows
57+
Default: 5
58+
-f, --flow_time
59+
Setting timeout interval for a flow.
60+
Default: 120000000
61+
-h, --help
62+
Prints usage for all the existing commands.
63+
-m, --mode
64+
Mode selection.
65+
Default: DEFAULT
66+
Possible Values: [DEFAULT, SAMPLING, FULL, ONLINE]
67+
-n, --no
68+
Ignores specific feature (use as -no <feature1>,<feature2>)
69+
Default: []
70+
--noassemble
71+
Disable TCP Reassembing
72+
Default: false
73+
--old
74+
Use Jnetpcap Parser which is stable but slow.
75+
Default: false
76+
-1, --one_file
77+
Output only one file.
78+
Default: false
79+
--quiet
80+
No output (sets logLevel to NONE)
81+
Default: false
82+
* -o, -output
83+
Output directory.
84+
```
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
package io.tomahawkd.jflowinspector;
2+
3+
import io.tomahawkd.config.ConfigManager;
4+
import io.tomahawkd.config.commandline.CommandlineConfig;
5+
import io.tomahawkd.config.commandline.CommandlineConfigSource;
6+
import io.tomahawkd.config.sources.SourceManager;
7+
import io.tomahawkd.config.util.ClassManager;
8+
import io.tomahawkd.jflowinspector.config.CommandlineDelegate;
9+
import io.tomahawkd.jflowinspector.execute.Executor;
10+
import io.tomahawkd.jflowinspector.execute.WithMode;
11+
import io.tomahawkd.jflowinspector.util.Utils;
12+
import org.apache.commons.lang3.ArrayUtils;
13+
import org.apache.logging.log4j.LogManager;
14+
import org.apache.logging.log4j.Logger;
15+
16+
import java.lang.reflect.InvocationTargetException;
17+
import java.util.Objects;
18+
19+
public class Main {
20+
21+
public static final Logger logger = LogManager.getLogger(Main.class);
22+
23+
public static void main(String[] args) {
24+
SourceManager sourceManager = SourceManager.get();
25+
ConfigManager configManager = ConfigManager.get();
26+
27+
sourceManager.getSource(CommandlineConfigSource.class).setData(args);
28+
configManager.parse();
29+
30+
CommandlineDelegate delegate = configManager.getDelegateByType(CommandlineDelegate.class);
31+
assert delegate != null;
32+
if (delegate.isHelp()) {
33+
System.out.println(Objects.requireNonNull(configManager.getConfig(CommandlineConfig.class)).usage());
34+
return;
35+
}
36+
logger.debug("Commandline parse complete.");
37+
logger.debug(delegate.debugString());
38+
System.out.println(delegate.debugString());
39+
System.out.println(Utils.DividingLine);
40+
41+
42+
Class<? extends Executor> executorClass = ClassManager.createManager(null)
43+
.loadClassesWithAnnotation(Executor.class, null, WithMode.class)
44+
.stream()
45+
.filter(c -> ArrayUtils.contains(c.getAnnotation(WithMode.class).value(), delegate.getMode()))
46+
.findFirst().orElse(null);
47+
48+
if (executorClass == null) {
49+
logger.fatal("Executor not found.");
50+
return;
51+
}
52+
53+
try {
54+
Executor executor = executorClass.getDeclaredConstructor().newInstance();
55+
executor.execute(delegate);
56+
} catch (InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
57+
logger.fatal("Cannot create executor {}", executorClass.getName(), e);
58+
e.printStackTrace();
59+
} catch (Exception e) {
60+
logger.fatal("Unexpect exception.", e);
61+
e.printStackTrace();
62+
}
63+
}
64+
}

0 commit comments

Comments
 (0)