Skip to content

Commit

Permalink
No commit message
Browse files Browse the repository at this point in the history
  • Loading branch information
CIC committed May 31, 2018
1 parent a26aae2 commit 21790da
Show file tree
Hide file tree
Showing 18 changed files with 459 additions and 148 deletions.
8 changes: 8 additions & 0 deletions README.md
Expand Up @@ -32,12 +32,20 @@ Go to the extracted directory,enter the 'bin' folder
### linux
Open a terminal and run this command
```
//For GUI:
sudo ./CICFlowMeter
//For Command line:
./cfm "inputFolder" "outputFolder"
```
### windows
Lanunch the Comand Prompt and run this command
```
//for GUI:
CICFlowMeter.bat
//for Commond line:
cfm.bat "inputFolder" "outputFolder"
```

## Get started
Expand Down
76 changes: 76 additions & 0 deletions ReadMe.txt
@@ -0,0 +1,76 @@
# Intro
The CICFlowMeter is an open source tool that generates Biflows from pcap files, and extracts features from these flows.

CICFlowMeter is a network traffic flow generator available from here . It can be used to generate bidirectional flows, where the first packet determines the forward (source to destination) and backward (destination to source) directions, hence the statistical time-related features can be calculated separately in the forward and backward directions. Additional functionalities include, selecting features from the list of existing features, adding new features, and controlling the duration of flow timeout.

NOTE: TCP flows are usually terminated upon connection teardown (by FIN packet) while UDP flows are terminated by a flow timeout. The flow timeout value can be assigned arbitrarily by the individual scheme e.g., 600 seconds for both TCP and UDP.

For citation in your works and also understanding CICFlowMeter (formerly ISCXFlowMeter) completely, you can find below published paper:
Gerard Drapper Gil, Arash Habibi Lashkari, Mohammad Mamun, Ali A. Ghorbani, "Characterization of Encrypted and VPN Traffic Using Time-Related Features", In Proceedings of the 2nd International Conference on Information Systems Security and Privacy(ICISSP 2016) , pages 407-414, Rome , Italy


----------------------------------------

# Installation and executing:

Extract CICFlowMeterV3.zip

___Note: The only prerequisite is that "libpcap" library or WinPcap on windows systems, be pre-installed___


For Linux

> $ sudo apt-get install libpcap-dev


For windows
> download [winpcap](<https://www.winpcap.org/install/default.htm>)

## executing
Go to the extracted directory,enter the 'bin' folder

### linux
Open a terminal and run this command
```
//For GUI:
sudo ./CICFlowMeter

//For Command line:
./cfm "inputFolder" "outputFolder"
```
### windows
Lanunch the Comand Prompt and run this command
```
//for GUI:
CICFlowMeter.bat

//for Commond line:
cfm.bat "inputFolder" "outputFolder"
```

## Get started
for offline
```
1.Select the folder that include your PCAP files
2.Select the folder that you would like to save you CSV files
3.Click OK button
```

for realtime
```
1 CLick Load button to find the list of network interfaces
2 Select the interface you would like to monitor
3 Click start button and wait for a while
4 Click stop button to stop the process and save the csv in same applcation folder/data/daily
```

--------------------------------------------------------------

Contact us at A.Habibi.L@unb.ca if there are any problems.


For citation in your works and also understanding CICFlowMeter (formerly ISCXFlowMeter) completely, you can find below published papers:

Arash Habibi Lashkari, Gerard Draper-Gil, Mohammad Saiful Islam Mamun and Ali A. Ghorbani, "Characterization of Tor Traffic Using Time Based Features", In the proceeding of the 3rd International Conference on Information System Security and Privacy, SCITEPRESS, Porto, Portugal, 2017

Gerard Drapper Gil, Arash Habibi Lashkari, Mohammad Mamun, Ali A. Ghorbani, "Characterization of Encrypted and VPN Traffic Using Time-Related Features", In Proceedings of the 2nd International Conference on Information Systems Security and Privacy(ICISSP 2016) , pages 407-414, Rome , Italy
36 changes: 26 additions & 10 deletions build.gradle
Expand Up @@ -3,18 +3,19 @@ apply plugin: 'maven'
apply plugin: 'application'

group = 'cic.unb.ca'
version = '3.0'
description = """CICFlowMeterV3"""
version = '4.0'
description = """CICFlowMeterV4"""

sourceCompatibility = 1.8
targetCompatibility = 1.8

repositories {
mavenLocal()
mavenCentral()
maven { url "https://clojars.org/repo" }
}
dependencies {
compile group: 'log4j', name: 'log4j', version:'1.2.17'
compile group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.11.0'
compile group: 'org.slf4j', name: 'slf4j-log4j12', version:'1.7.25'
compile group: 'org.jnetpcap', name: 'jnetpcap', version:'1.4.1'
compile group: 'junit', name: 'junit', version:'4.12'
Expand Down Expand Up @@ -105,18 +106,32 @@ task execute(type: JavaExec) {
}
}

/*task exedebug(type: JavaExec) {
debug = true
main = "cic.cs.unb.ca.ifm.App"

task exeCMD(type: JavaExec){
main = "cic.cs.unb.ca.ifm.Cmd" //main class
classpath = sourceSets.main.runtimeClasspath
String osName = System.getProperty('os.name').toLowerCase()
if(osName.contains('windows')){
jvmArgs '-Djava.library.path=jnetpcap/win/jnetpcap-1.4.r1425'
}else{
jvmArgs '-Djava.library.path=jnetpcap/linux/jnetpcap-1.4.r1425'
}
jvmArgs '-Xdebug', '-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005'
}*/
//args = ["/home/yzhang29/0a/Capture/", "/home/yzhang29/0a/Capture/out/"]
}


task cmdScript(type: CreateStartScripts) {
mainClassName = "cic.cs.unb.ca.ifm.Cmd"
applicationName = "cfm"
outputDir = new File(project.buildDir, 'scripts')
classpath = jar.outputs.files + project.configurations.runtime
defaultJvmOpts = ["-Djava.library.path=../lib/native"]
}

applicationDistribution.into("bin") {
from(cmdScript)
fileMode = 0755
}


// The Application Plugin
Expand All @@ -135,6 +150,7 @@ applicationDistribution.from("jnetpcap/win/jnetpcap-1.4.r1425") {
applicationDistribution.from('LICENSE.txt'){
into('')
}
applicationDistribution.from('README.md'){
applicationDistribution.from('ReadMe.txt'){
into('')
}
rename("ReadMe.txt","README.md")
}
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
@@ -1,4 +1,4 @@
#Wed Mar 07 10:36:46 AST 2018
#Fri May 25 10:05:01 ADT 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
Expand Down
14 changes: 7 additions & 7 deletions pom.xml
Expand Up @@ -2,15 +2,15 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>cic.unb.ca</groupId>
<artifactId>SimpleFlowMeterV3</artifactId>
<artifactId>SimpleFlowMeterV4</artifactId>
<version>0.0.4-SNAPSHOT</version>
<name>SimpleFlowMeterV3</name>
<name>SimpleFlowMeterV4</name>

<dependencies>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.11.0</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
Expand Down Expand Up @@ -113,7 +113,7 @@
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<finalName>CICFlowMeterV2-${project.version}</finalName>
<finalName>CICFlowMeterV4-${project.version}</finalName>
<appendAssemblyId>false</appendAssemblyId>
</configuration>
<id>build-CICFlowMeter</id>
Expand Down Expand Up @@ -151,4 +151,4 @@

</build>

</project>
</project>
12 changes: 8 additions & 4 deletions src/main/java/cic/cs/unb/ca/flow/ui/FlowMonitorPane.java
Expand Up @@ -14,7 +14,7 @@
import org.jnetpcap.PcapIf;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import swing.common.InsertCsvRow;
import cic.cs.unb.ca.jnetpcap.worker.InsertCsvRow;
import swing.common.InsertTableRow;
import swing.common.JTable2CSVWorker;
import swing.common.TextFileFilter;
Expand Down Expand Up @@ -71,6 +71,10 @@ private void init() {
csvWriterThread = Executors.newSingleThreadExecutor();
}

public void destory() {
csvWriterThread.shutdown();
}

private JPanel initCenterPane(){
JPanel pane = new JPanel();
pane.setLayout(new BorderLayout(0, 0));
Expand All @@ -90,7 +94,7 @@ private JPanel initFlowPane() {
pane.setLayout(new BorderLayout(0, 5));
pane.setBorder(BorderFactory.createLineBorder(new Color(0x555555)));

initTableBtnPane();//pane.add(initTableBtnPane(), BorderLayout.NORTH);
//pane.add(initTableBtnPane(), BorderLayout.NORTH);
pane.add(initTablePane(), BorderLayout.CENTER);
pane.add(initStatusPane(), BorderLayout.SOUTH);

Expand Down Expand Up @@ -282,7 +286,7 @@ private void loadPcapIfs() {
lblStatus.validate();

} catch (InterruptedException | ExecutionException e) {
e.printStackTrace();
logger.debug(e.getMessage());
}
break;
}
Expand Down Expand Up @@ -323,7 +327,7 @@ private void startTrafficFlow() {
logger.info("Pcap stop listening");

}catch (InterruptedException | ExecutionException e) {
e.printStackTrace();
logger.debug(e.getMessage());
}
break;
}
Expand Down
40 changes: 37 additions & 3 deletions src/main/java/cic/cs/unb/ca/flow/ui/FlowOfflinePane.java
@@ -1,17 +1,25 @@
package cic.cs.unb.ca.flow.ui;

import cic.cs.unb.ca.flow.FlowMgr;
import cic.cs.unb.ca.jnetpcap.BasicFlow;
import cic.cs.unb.ca.jnetpcap.FlowFeature;
import cic.cs.unb.ca.jnetpcap.worker.ReadPcapFileWorker;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import cic.cs.unb.ca.jnetpcap.worker.InsertCsvRow;
import swing.common.PcapFileFilter;

import javax.swing.*;
import javax.swing.border.Border;
import javax.swing.border.EmptyBorder;
import java.awt.*;
import java.io.File;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Vector;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class FlowOfflinePane extends JPanel{
protected static final Logger logger = LoggerFactory.getLogger(FlowOfflinePane.class);
Expand All @@ -34,6 +42,8 @@ public class FlowOfflinePane extends JPanel{
private JProgressBar fileProgress;
private JProgressBar fileCntProgress;

private ExecutorService csvWriterThread;

public FlowOfflinePane() {

init();
Expand All @@ -49,6 +59,12 @@ private void init(){
fileChooser = new JFileChooser(new File("."));
pcapChooserFilter = new PcapFileFilter();
fileChooser.setFileFilter(pcapChooserFilter);
csvWriterThread = Executors.newSingleThreadExecutor();

}

public void destroy() {
csvWriterThread.shutdown();
}

private JPanel initOutPane(){
Expand Down Expand Up @@ -307,15 +323,15 @@ private long getComboParameter(JComboBox<Long> param,Vector<Long> paramEle) thro
}

private void startReadPcap(){
File in;
final File in;
int cmbInIndex = cmbInput.getSelectedIndex();
if (cmbInIndex < 0) {
in = new File((String) cmbInput.getEditor().getItem());
}else{
in = cmbInputEle.get(cmbInIndex);
}

File out;
final File out;
int cmbOutIndex = cmbOutput.getSelectedIndex();
if (cmbOutIndex < 0) {
out = new File((String) cmbOutput.getEditor().getItem());
Expand All @@ -333,6 +349,8 @@ private void startReadPcap(){
flowTimeout = getComboParameter(param1, param1Ele);
activityTimeout = getComboParameter(param2, param2Ele);

Map<String, Long> flowCnt = new HashMap<>();

ReadPcapFileWorker worker = new ReadPcapFileWorker(in, out.getPath(), flowTimeout, activityTimeout);
worker.addPropertyChangeListener(evt -> {
ReadPcapFileWorker task = (ReadPcapFileWorker) evt.getSource();
Expand All @@ -353,6 +371,7 @@ private void startReadPcap(){
break;
case DONE:
progressBox.setVisible(false);
flowCnt.clear();
break;
}
} else if (ReadPcapFileWorker.PROPERTY_FILE_CNT.equalsIgnoreCase(evt.getPropertyName())) {
Expand All @@ -366,7 +385,22 @@ private void startReadPcap(){

} else if (ReadPcapFileWorker.PROPERTY_CUR_FILE.equalsIgnoreCase(evt.getPropertyName())) {
fileProgress.setIndeterminate(true);
fileProgress.setString((String) evt.getNewValue());
String curFile = (String) evt.getNewValue();
fileProgress.setString(curFile);
flowCnt.put(curFile, 0L);
} else if (ReadPcapFileWorker.PROPERTY_FLOW.equalsIgnoreCase(evt.getPropertyName())) {

String fileName = (String) evt.getOldValue();
BasicFlow flow = (BasicFlow) evt.getNewValue();

flowCnt.put(fileName, flowCnt.get(fileName) + 1);

String msg = String.format("%d flows on Reading %s",flowCnt.get(fileName),fileName);
fileProgress.setString(msg);

//write flows to csv file
String header = FlowFeature.getHeader();
csvWriterThread.execute(new InsertCsvRow(header, flow.dumpFlowBasedFeaturesEx(), out.getPath(), fileName+FlowMgr.FLOW_SUFFIX));
}
});
worker.execute();
Expand Down
7 changes: 4 additions & 3 deletions src/main/java/cic/cs/unb/ca/ifm/App.java
Expand Up @@ -3,11 +3,12 @@
import cic.cs.unb.ca.flow.FlowMgr;
import cic.cs.unb.ca.guava.GuavaMgr;
import cic.cs.unb.ca.ifm.ui.MainFrame;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.awt.*;

public class App {

public static final Logger logger = LoggerFactory.getLogger(App.class);
public static void init() {
FlowMgr.getInstance().init();
GuavaMgr.getInstance().init();
Expand Down Expand Up @@ -35,7 +36,7 @@ public static void main(String[] args) {
init();
new MainFrame();
} catch (Exception e) {
e.printStackTrace();
logger.debug(e.getMessage());
}
});
}
Expand Down

0 comments on commit 21790da

Please sign in to comment.