Git Product home page Git Product logo

ip-spoofing-and-detection's Introduction

1. IP Spoofing simultaion carried out using scapy and observed in Wireshark

Open the terminal, Install scapy using pip

>>> pip install scapy

Create a basic packet with src and destination IP address, ttl(time to live), protocol to be used etc.

>>> x = IP(ttl=64)
>>> x.src = "192.36.151.40"
>>> x.dst = "183.81.159.136"
>>> x = x/TCP()/"Test-Packet Recieved"
>>> x
<IP  frag=0 ttl=64 proto=tcp src=192.36.151.40 dst=183.81.159.136 |<TCP  |<Raw  load='Test-Packet Recieved'

Open wireshark and connect to the same network to which sender is connected to. Open the Network and apply the filter as follows:

ip.dst == 183.81.159.136

Press Start capturing button and then send the packets as below with count set to how many packets to be sent:

>>> send(x, count=10)

Captured packets

You can add more information to the packet to mimic a real-world data.

2. Detection using both Logistic Regression and Neural Network

2.1 Dataset:

The dataset DDoS SDN dataset is downloaded from kaggle.

The dataset contains a total of 1,04,345 training examples.

contains 3 categorial and 19 numerical features, a total of 22 features.

Dataset preview

contains a label column: 0 refers benign packet and 1 refers malignant IP packet.

The data is pre-processed and split into training (0.80) and testing (0.20) using pandas and sklearn library respectively.

2.2 Model training:

Logistic Regression Model:

Install Required libraries using pip

pip install numpy pandas sklearn

The logisticRegression class in sklearn.linear_model is used to create an instance of the model. This model is trained with max_iters(total no. of iterations to be run to train the model) is set to 10000.

Neural Networks Model:

Install the tensorflow library using below command

pip install tensorflow

Model contains two hidden layers each having 10 units and a third output layer having one unit.

"Adam" and "BinaryCrossentropy" is used as optimizer and loss function respectively.

15 Epochs with a default batch_size of 32 is set while training the model.

2.3 Model Evaluation:

An accuracy of 70.16 % is achieved by using Logistic Regression.

An accuracy of 98.96 % is achieved by using NN model.

Both the jupyter source files are uploaded in the src directory.

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.