diff --git a/Python/filegenerator.py b/Python/filegenerator.py index 3c55602..da44edb 100644 --- a/Python/filegenerator.py +++ b/Python/filegenerator.py @@ -18,8 +18,8 @@ def __init__(self, make_log, make_summary, self.makeSummary = make_summary self.makeAnimation = make_animation # File Name to be used - self.logFileName = "log-{0}.csv".format(str(sessionId)) - self.summaryFileName = "summary-{0}.csv".format(str(sessionId)) + self.logFileName = "logs\log-{0}.csv".format(str(sessionId)) + self.summaryFileName = "summaries\summary-{0}.csv".format(str(sessionId)) # names of the output files self.logName = log_name self.summaryName = summary_name diff --git a/cleanup.bat b/cleanup.bat index 7dc45eb..3ef374d 100644 --- a/cleanup.bat +++ b/cleanup.bat @@ -1,2 +1,4 @@ @echo off -del *.csv \ No newline at end of file +del *.csv +del logs\log-*.csv +del summaries\summary-*.csv \ No newline at end of file diff --git a/readme.md b/readme.md index 56ee7f9..013dc33 100644 --- a/readme.md +++ b/readme.md @@ -16,7 +16,13 @@ Follow these steps to get started: pip install flask ``` -3. Execute the following commands to run flask: +3. If it is your first time to run the server, you should create some folders: +```bat +mkdir logs +mkdir summaries +``` + +4. Execute the following commands to run flask: ```bat set FLASK_APP=pserver set FLASK_ENV=development @@ -24,7 +30,7 @@ python -m flask run ``` Alternatively, you may double-click `run_server.bat` file in lieu of manually typing these commands. -4. In certain circumstances, your system might be configuring the `*.js` files with incorrect treatings. Locate registry key `HKEY_CLASSES_ROOT\.js` and edit the key value `Content Type` to be `text/javascript`.
+5. In certain circumstances, your system might be configuring the `*.js` files with incorrect treatings. Locate registry key `HKEY_CLASSES_ROOT\.js` and edit the key value `Content Type` to be `text/javascript`.
Please note that you are all set if key value `Content Type` does not exist in `HKEY_CLASSES_ROOT\.js` key at all: just leave the registry as is. Usually, things are problematic if the value of `Content Type` equals to `text/plain`. ### Option 2: Get Started on Windows with WSL @@ -43,76 +49,28 @@ https://www.digitalocean.com/community/tutorials/how-to-install-python-3-and-set Link: https://www.digitalocean.com/community/tutorials/how-to-make-a-web-application-using-flask-in-python-3 1) You only need to follow step 1 to install flask. -2) Copy and paste and then run the below two commands. ***You have to do this everytime you open up a new terminal***:\ -export FLASK_APP=pserver\ +2) Copy and paste and then run the below two commands. ***You have to do this everytime you open up a new terminal***: +```bash +export FLASK_APP=pserver export FLASK_ENV=development +``` ### To run the server: 1) Navigate to the top of this repo -2) Run the following\ +2) If it is your first time to run the server, then run +```bat +mkdir summaries +mkdir logs +``` + +3) Run the following +```bat flask run +``` -## Get Started for Localized Animator -There is a localized animator project written in `Visual Basic .NET 2010`. This sub-project is in initial stage.
-To run the project, you should install `.NET Framework 4.0`: https://dotnet.microsoft.com/download/dotnet-framework/net40
-To make changes to the project, you should install `Visual Studio 2010` or higher. Make sure you have installed `VB.NET`. - -## Algorithm and Pseudocode -The high level design is to make eight classes of objects: The `Attacker`, `Server`, `Router`, `Packets`, `Connection Object`, `DDD Controller`, `DDD Mapper` and `Client`.
-In the high level design, there are eight classes of objects - -1. `Attacker` class includes:
- - `init` - For defining the object specific data.
- - Data includes:
- - clientIP: client's IP, used for generating spoofed packetsDropped
- - serverIP: IP of server used for SYN-ACK Flood
- - curTime: Tracks the current time of the simulation
- - counterPacketsSent:Counter for the summary file
- - connectionToServer: stores the connectionObject connecting the attacker to the server
- - packetsSent: counter for logging purposes
- - packetsReceived: counter for logging purposes (currently unused but it makes it easier for the log file to operate)
- - packetsDropped: counter for packets dropped (currently unused but it makes it easier for the log file to operate)
- - packetsGenerated: Counter for number of packets generated (dw - in the case of a dumb attacker it ends up being the same as packetsSent, but I was adding this variable to all classes for consistency and symmetry in the summary file)
- - fileGen: File management object
- - packetIDPrefix: Used for packet IDs as a prefix so that we're not using the IPs
- - ipAddress: IP address of attacker
- - packetSize: The size of the packets sent by the attacker
- - sendRate: The rate at which the attacker sents data (MB/ms)
- - transmissionDelay: How long it takes to send a packet onto a connection
- - sendingPacket: The packet that is currently being sent
- - timeToNextIteration: Time inbetween iterations
- - `processPackets()` - Checks if a packet is being sent or not. If no packet is being sent then it creates a new packet and starts sending it
- - `sendPackets()` - Checks if packet's transmission delay has been satisfied. If it has, then it sends it to the correct connection.
- - `generateSYN` - Generates a new syn packet.
- - `updateTime` - Updates the current time for the object and runs necessary functions.
-2. Server -3. Router -4. Packets -5. Connection Object -6. DDD Controller -7. DDD Mapper -8. Client - - -2. The ddd controller is to be determined**
- -3. The `Packet`class is defined as follows:
- - `constructor` - Creating new instances of the Packet object.
- - Data includes: x and y coordinates for simulation, src and dst IP, and src and dst Port.
- - `setSrcPort(newSrcPort)` - Sets new src port.
- - `setSrcIp(newSrcIp)` - Sets new src IP.
- - `setDstPort(newDstPort)` - Sets new dst port.
- - `setDstIp(newDstIp)` - Sets new dst IP.
- - `setX(newX)` - Sets the x coordinate of this packet.
- - `setY(newY)` - Sets the y coordinate of this packet.
- - `getX()` - Returns the x coordinate of this packet.
- - `getY()` - Returns the y coordinate of this packet.
- - `getSrcPort()` - Returns the src port.
- - `getSrcIp()` - Returns the src IP.
- - `getDstPort()` - Returns the dst port.
- - `getDstIp()` - Returns the dst IP.
- -4.Have to include info here about main and canvas** +## Summary and Log Files +For each session, the backend would generate a summary file and a log file. They will be separately placed in two directories: `logs` and `summaries`.
+There is also a `cleanup.bat`. If you would like to delete all summaries and logs for previous sessions, run it.
## License This project is under NCSA License. For more information, view the [license](license.txt). \ No newline at end of file diff --git a/run_server.bat b/run_server.bat index c16e31a..8afd09a 100644 --- a/run_server.bat +++ b/run_server.bat @@ -1,4 +1,7 @@ @echo off set FLASK_APP=pserver set FLASK_ENV=development -python -m flask run \ No newline at end of file +mkdir logs > NUL +mkdir summaries > NUL +python -m flask run +pause. \ No newline at end of file