Files
dos/build.py
dr-wh0 bca0037807 bugfix: Решение проблемы с логированием, доработка лога и рефакторинг кода (#28)
1. Решает issue #26

2. Обновлённый формат логов:
```
drwho@ubuntu:~/PycharmProjects/dos$ cat /var/log/DosAtk
[2025-05-08 23:42:50.704] Starting DosAtk | Type: TCP SYN flood | Sent 1000 requests | Stopping DosAtk [2025-05-08 23:42:50.723]
[2025-05-08 23:43:07.943] Starting DosAtk | Type: UDP port scan | Sent 1000 requests | Stopping DosAtk [2025-05-08 23:43:07.957]
[2025-05-08 23:43:21.388] Starting DosAtk | Type: TCP SYN flood | Sent 1000 requests | Stopping DosAtk [2025-05-08 23:43:21.407]
[2025-05-08 23:43:35.619] Starting DosAtk | Type: UDP port scan | Sent 1000 requests | Stopping DosAtk [2025-05-08 23:43:35.637]
[2025-05-08 23:54:52.170] Starting DosAtk | Stopping DosAtk [2025-05-08 23:54:52.170]
[2025-05-08 23:55:45.017] Starting DosAtk | Type: TCP SYN flood | Sent 1000 requests | Stopping DosAtk [2025-05-08 23:55:45.037]

```
![image](/attachments/04c4de29-6903-440b-9926-710489deb5dd)

3. Использование scan-атаки:
```
drwho@ubuntu:~/PycharmProjects/dos$ sudo ./DosAtk -a scan -i 127.0.0.1
start my_check_params
Starting DosAtk at 2025-05-09 00:12:38.324
end my_check_params
start my_dns
end my_dns
start my_udp
end my_udp
start my_log
end my_log
start my_fin
Worked for 0.015 seconds
Sent 1000 requests (1000 ok, 0 failed)
DosAtk stopped at 2025-05-09 00:12:38.339
end my_fin
```
![image](/attachments/5ba46d05-00b5-4691-8a61-6d58f7a7824b)

4. Использование flood-атаки:
```
drwho@ubuntu:~/PycharmProjects/dos$ sudo ./DosAtk -a flood -i 127.0.0.1 -p 800
start my_check_params
Starting DosAtk at 2025-05-08 23:56:31.850
end my_check_params
start my_dns
end my_dns
start my_tcp_syn
end my_tcp_syn
start my_log
end my_log
start my_fin
Worked for 0.019 seconds
Sent 1000 requests (1000 ok, 0 failed)
DosAtk stopped at 2025-05-08 23:56:31.869
end my_fin
```
![image](/attachments/584eb9d3-88d3-4741-8dc2-a7579e79f536)

5. Небольшой рефакторинг кода, обновление в соответствии с актуальной блок-схемой

Reviewed-on: https://gitea.serafimdev.com/serafim/dos/pulls/28
Reviewed-by: serafim <simasuh@gmail.com>
Co-authored-by: dr-wh0 <79003667309@yandex.ru>
Co-committed-by: dr-wh0 <79003667309@yandex.ru>
2025-05-09 15:45:22 +03:00

21 lines
722 B
Python
Executable File
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env python3
import os
import sys
import subprocess
log_path = "/var/log/DosAtk"
if not os.path.exists(log_path):
if os.getuid() == 0: # Если уже root
os.system("mkdir -p /var/log && touch /var/log/DosAtk")
os.system("chmod 666 /var/log/DosAtk")
else:
os.system("sudo mkdir -p /var/log && sudo touch /var/log/DosAtk 2>/dev/null || true")
os.system("sudo chmod 666 /var/log/DosAtk 2>/dev/null || true")
# Компиляция
if subprocess.call(["g++", "src/DosAtk.cpp", "-o", "DosAtk", "-lcurl", "-lssl", "-lcrypto"]) != 0:
sys.exit(1)
# Запуск с аргументами
if len(sys.argv[1:]) > 0:
os.execvp("./DosAtk", ["./DosAtk"] + sys.argv[1:])