Skip to content

Commit

Permalink
Final
Browse files Browse the repository at this point in the history
  • Loading branch information
AlirezaDehlaghi committed Sep 19, 2022
1 parent d897ea0 commit 07192fc
Show file tree
Hide file tree
Showing 38 changed files with 2,330 additions and 1,476 deletions.
3 changes: 3 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions .idea/ICSSIM.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/inspectionProfiles/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 0 additions & 30 deletions deployments/Other test Dockers/attacker-docker/Dockerfile

This file was deleted.

17 changes: 0 additions & 17 deletions deployments/Other test Dockers/digital-twin/Dockerfile

This file was deleted.

8 changes: 0 additions & 8 deletions deployments/Other test Dockers/digital-twin/start.sh

This file was deleted.

11 changes: 0 additions & 11 deletions deployments/Other test Dockers/other/Dockerfile

This file was deleted.

41 changes: 0 additions & 41 deletions deployments/Other test Dockers/seba-docker/Dockerfile

This file was deleted.

5 changes: 5 additions & 0 deletions deployments/attacker-machine.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

sudo docker container attach attacker-machine



5 changes: 0 additions & 5 deletions deployments/attacker2.sh

This file was deleted.

8 changes: 4 additions & 4 deletions deployments/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ services:

networks:
wnet:
ipv4_address: 192.168.0.41
ipv4_address: 192.168.0.42

attacker2:
build: attacker-docker/.
Expand All @@ -122,15 +122,15 @@ services:
privileged: true
tty: true
working_dir: /src
entrypoint: ["./start.sh", "Attacker.py"]
container_name: attacker2
entrypoint: ["./start.sh", "AttackerMachine.py"]
container_name: attacker-machine
volumes:
- ../src:/src
- "/etc/timezone:/etc/timezone:ro"
- "/etc/localtime:/etc/localtime:ro"
networks:
wnet:
ipv4_address: 192.168.0.42
ipv4_address: 192.168.0.41


networks:
Expand Down
46 changes: 28 additions & 18 deletions src/Attacker.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import os
import subprocess
import sys
from datetime import datetime
from datetime import datetime, timedelta
from time import sleep

from scapy.arch import get_if_addr
Expand All @@ -29,30 +29,33 @@ def _before_start(self):
os.makedirs(self.__log_path)

self.__log_attack_summary = self.setup_logger(
"log_summary",
"attacker_summary",
logging.Formatter('%(message)s'),
file_dir= self.__log_path,
file_ext='.csv'
)

self.__log_attack_summary.info("{},{},{},{},{},{},{}".format("Attack",
self.__log_attack_summary.info("{},{},{},{},{},{},{},{}".format("attack",
"startStamp",
"endStamp",
"startTime",
"endTime",
"attackerMAC",
"attackerIP",
"description"
)
)

self.__attack_list = ['scan-ettercap',
'scan-ping',
'scan-nmap',
'scan-scapy',
'mitm-scapy',
'mitm-ettercap',
'ddos',
'replay-scapy']
self.__attack_list = {'scan-ettercap': 'ip-scan',
'scan-ping': 'ip-scan',
'scan-nmap': 'port-scan',
'scan-scapy': 'ip-scan',
'mitm-scapy': 'mitm',
'mitm-ettercap': 'mitm',
'ddos': 'ddos',
'replay-scapy': 'replay'}

self.__attack_cnt = len(self.__attack_list)

pass

Expand All @@ -66,23 +69,26 @@ def __get_menu_line(self, template, number, text):
def _logic(self):
menu = "\n"
menu += self.__get_menu_line('{} to {} press {} \n', 0, 'clear')
for i in range(len(self.__attack_list)):
menu += self.__get_menu_line('{} To apply the {} attack press {} \n', i + 1, self.__attack_list[i])
i = 0
for attack in self.__attack_list.keys():
i += 1
menu += self.__get_menu_line('{} To apply the {} attack press {} \n', i , attack)
self.report(menu)

try:
attack_name = int(input('your choice (1 to {}): '.format(len(self.__attack_list))))
attack_name = int(input('your choice (1 to {}): '.format(self.__attack_cnt)))

if int(attack_name) == 0:
os.system('clear')
return

if 0 < attack_name <= len(self.__attack_list):
attack_name = self.__attack_list[attack_name-1]
if 0 < attack_name <= self.__attack_cnt:
attack_name = list(self.__attack_list.keys())[attack_name-1]
attack_short_name = self.__attack_list[attack_name]


attack_path = os.path.join(self.__attack_path, str(attack_name) + ".sh")
print(os.path.isfile(attack_path))

if not os.path.isfile(attack_path):
raise ValueError('command {} does not exist'.format(attack_path))

Expand All @@ -92,13 +98,17 @@ def _logic(self):
subprocess.run([attack_path, self.__log_path, log_file])
end_time = datetime.now()

self.__log_attack_summary.info("{},{},{},{},{},{},{}".format(attack_name,
if attack_name == 'ddos':
start_time = start_time + timedelta(seconds=5)

self.__log_attack_summary.info("{},{},{},{},{},{},{},{}".format(attack_short_name,
start_time.timestamp(),
end_time.timestamp(),
start_time,
end_time,
self.MAC,
self.IP,
attack_name,
)
)

Expand Down
Loading

0 comments on commit 07192fc

Please sign in to comment.