Skip to content

Commit

Permalink
Fixed remainning python2 to python3 regressions. (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ahmed Lotfy authored and wisepythagoras committed Jan 21, 2021
1 parent 56d5fd0 commit 439ddf1
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ sudo apt install tor lynx

# For Fedora
sudo yum install tor lynx

# For ArchLinux
sudo pacman -S tor torsocks lynx
```

By installing Tor we also get a program called `torsocks`; this program will be used to redirect traffic of common programs through the Tor network. For example, it can be run as follows:
Expand All @@ -27,7 +30,7 @@ torsocks curl -L http://httpbin.org/ip
# Etc...
```

### Required Python Modules
## Required Python 3 Modules

``` bash
pip install sklearn dpkt
Expand Down Expand Up @@ -59,6 +62,10 @@ Once the website has finished loading, the capture process needs to be killed, a

## Classifying Unknown Traffic

```bash
# python predict.py [packet to classify]
python predict.py xyz.pcap
```
Once the training is done, and the `classifier-nb.dmp` is created, the [predict.py](predict.py) script can be run with the pcap file as the sole argument. The script will load the classifier and attempt to identify which web page the traffic originated from.

It is worth noting that from each sample only the first 40 packets will be used to train a usable model and to run through the resulting classifier.
Expand All @@ -82,4 +89,3 @@ Traffic is never "clean", as the assumption was - for simplicity - in this resea
1. Wang, T. and Goldberg, I. (2017). Website Fingerprinting. [online] Cse.ust.hk. Available at: https://www.cse.ust.hk/~taow/wf/.
2. Wang, T. and Goldberg, I. (2017). Improved Website Fingerprinting on Tor. Cheriton School of Computer Science. Available at: http://www.cypherpunks.ca/~iang/pubs/webfingerprint-wpes.pdf
3. Wang, T. (2015). Website Fingerprinting: Attacks and Defenses. University of Waterloo. Available at: https://uwspace.uwaterloo.ca/bitstream/handle/10012/10123/Wang_Tao.pdf

5 changes: 2 additions & 3 deletions packet.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@
print("An argument is required")
exit(1)

f = open(sys.argv[1])
# f = open('data/jjay-w-tor-2nd.pcap')
f = open(sys.argv[1], 'rb')

pcap = dpkt.pcap.Reader(f)
open_time = 0;
open_time = 0

for ts, buf in pcap:
if open_time is 0:
Expand Down
2 changes: 1 addition & 1 deletion utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def read_pcap_file(file):
""" Read the pcap file and return the sizes of the packets. """

# Read the file.
fp = open(file)
fp = open(file, 'rb')

# Create the pcap object
pcap = dpkt.pcap.Reader(fp)
Expand Down

0 comments on commit 439ddf1

Please sign in to comment.