forked from serafim/dos
1
0
Fork 0

Compare commits

..

21 Commits

Author SHA1 Message Date
serafim c726a91fc2 fix: ip validation #29 (#30)
Co-authored-by: root <root@simasuh.fvds.ru>
Reviewed-on: https://gitea.serafimdev.com/serafim/dos/pulls/30
2025-05-11 16:17:58 +03:00
dr-wh0 abb6b7f06d FIX: Решение проблемы отправки сообщения в Telegram (#31)
### Решает issue #27

Теперь в Telegram отправляется сообщение при ошибке записи в лог, пример сообщения:

```
ОШИБКА ЗАПИСИ В ЛОГ: Не удалось открыть лог-файл!

ЛОГ:
[2025-05-11 13:13:25.481] Starting DosAtk | Type: TCP SYN flood | Failed to create tcp syn raw-socket | Stopping DosAtk [2025-05-11 13:13:25.481]
```

Reviewed-on: https://gitea.serafimdev.com/serafim/dos/pulls/31
Reviewed-by: serafim <simasuh@gmail.com>
Co-authored-by: dr-wh0 <79003667309@yandex.ru>
Co-committed-by: dr-wh0 <79003667309@yandex.ru>
2025-05-11 16:16:31 +03:00
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
serafim 8cfe964c89 fix: log and msg core dumped #22 (#25)
Co-authored-by: root <root@simasuh.fvds.ru>
Reviewed-on: https://gitea.serafimdev.com/serafim/dos/pulls/25
2025-05-02 20:13:29 +03:00
serafim de3085f043 fix: timer #23 (#24)
Co-authored-by: root <root@simasuh.fvds.ru>
Reviewed-on: https://gitea.serafimdev.com/serafim/dos/pulls/24
2025-05-02 19:39:59 +03:00
Serafim 89a828c3fc fix: docs: add missing lib 2025-04-28 22:57:50 +03:00
Serafim 7048d35b8b docs: add missing lib 2025-04-28 22:55:17 +03:00
dr-wh0 b7ed1b6a94 Refactor README.md (#21)
Reviewed-on: https://gitea.serafimdev.com/serafim/dos/pulls/21
Reviewed-by: serafim <simasuh@gmail.com>
Co-authored-by: dr-wh0 <79003667309@yandex.ru>
Co-committed-by: dr-wh0 <79003667309@yandex.ru>
2025-04-28 22:36:51 +03:00
dr-wh0 9ee7ea7847 Добавление my_log() и скрипта build.py (#19)
Стратегия ротации логов:
Когда размер лога достигает 10мб - создаётся новый лог.

build.py действует аналогично build.sh, плюс создаёт файл логов изначально, если запуск впервые.

Co-authored-by: Serafim <simasuh@gmail.com>
Reviewed-on: https://gitea.serafimdev.com/serafim/dos/pulls/19
Reviewed-by: serafim <simasuh@gmail.com>
Co-authored-by: dr-wh0 <79003667309@yandex.ru>
Co-committed-by: dr-wh0 <79003667309@yandex.ru>
2025-04-28 21:59:32 +03:00
oct 39768fda38 my_udp (#18)
my_udp

Co-authored-by: Serafim <simasuh@gmail.com>
Reviewed-on: https://gitea.serafimdev.com/serafim/dos/pulls/18
Co-authored-by: oct <m0odyplus@yandex.ru>
Co-committed-by: oct <m0odyplus@yandex.ru>
2025-04-28 21:28:35 +03:00
Serafim fcf58646ec Revert "my_udp (#16)" (#20)
This reverts commit 472eff7962.

Reviewed-on: https://gitea.serafimdev.com/serafim/dos/pulls/20
Co-authored-by: Serafim <simasuh@gmail.com>
Co-committed-by: Serafim <simasuh@gmail.com>
2025-04-28 21:19:57 +03:00
Serafim 472eff7962 my_udp (#16)
Reviewed-on: https://gitea.serafimdev.com/serafim/dos/pulls/16
Co-authored-by: Serafim <simasuh@gmail.com>
Co-committed-by: Serafim <simasuh@gmail.com>
2025-04-26 19:23:34 +03:00
nekitmilk 58fa2072a4 nekitmilk_compile_dev (#14)
Co-authored-by: tieshagr <tieshagr@student.21>
Reviewed-on: https://gitea.serafimdev.com/serafim/dos/pulls/14
Reviewed-by: serafim <simasuh@gmail.com>
Co-authored-by: nekitmilk <ya.nikita1317@gmail.com>
Co-committed-by: nekitmilk <ya.nikita1317@gmail.com>
2025-04-17 16:18:15 +03:00
Павел Овчинников d2daab9650 delete check_sum function and moved its logic inside tcp_syn (#13)
Reviewed-on: https://gitea.serafimdev.com/serafim/dos/pulls/13
Reviewed-by: dr-wh0 <79003667309@yandex.ru>
Co-authored-by: Urmipie <pablonepikasso8000@gmail.com>
Co-committed-by: Urmipie <pablonepikasso8000@gmail.com>
2025-04-08 01:48:15 +03:00
nekitmilk 27d94f1199 nekitmilk_my_dns (#11)
Co-authored-by: tieshagr <tieshagr@student.21>
Co-authored-by: Serafim <simasuh@gmail.com>
Reviewed-on: https://gitea.serafimdev.com/serafim/dos/pulls/11
Reviewed-by: serafim <simasuh@gmail.com>
Co-authored-by: nekitmilk <ya.nikita1317@gmail.com>
Co-committed-by: nekitmilk <ya.nikita1317@gmail.com>
2025-04-03 17:40:48 +03:00
Serafim 7e0804f272 style: return status codes, titles (#12)
Reviewed-on: https://gitea.serafimdev.com/serafim/dos/pulls/12
Co-authored-by: Serafim <simasuh@gmail.com>
Co-committed-by: Serafim <simasuh@gmail.com>
2025-04-03 15:47:06 +03:00
Павел Овчинников 59d747188f TCP SYN attacks (#10)
Reviewed-on: https://gitea.serafimdev.com/serafim/dos/pulls/8
Reviewed-on: https://gitea.serafimdev.com/serafim/dos/pulls/10
Reviewed-by: serafim <simasuh@gmail.com>
Co-authored-by: Urmipie <pablonepikasso8000@gmail.com>
Co-committed-by: Urmipie <pablonepikasso8000@gmail.com>
2025-04-03 00:53:29 +03:00
Serafim 43092ad1f4 style/improve-code-style (#7)
Reviewed-on: https://gitea.serafimdev.com/serafim/dos/pulls/7
Reviewed-by: dr-wh0 <79003667309@yandex.ru>
Co-authored-by: Serafim <simasuh@gmail.com>
Co-committed-by: Serafim <simasuh@gmail.com>
2025-04-03 00:23:50 +03:00
EgorALX 4c173756a0 Комментарии, status вынесен в глобалбную переменную (#6)
Co-authored-by: AleksanovED <AleksanovED@loodsen.ru>
Co-authored-by: dr-wh0 <79003667309@yandex.ru>
Reviewed-on: https://gitea.serafimdev.com/serafim/dos/pulls/6
Reviewed-by: serafim <simasuh@gmail.com>
Co-authored-by: EgorALX <alexanoffegor@yandex.ru>
Co-committed-by: EgorALX <alexanoffegor@yandex.ru>
2025-03-26 13:58:24 +03:00
serafim 556af1f1a7 dev_nekitmilk_refactoring (#5)
Co-authored-by: tieshagr <tieshagr@student.21>
Co-authored-by: oct <m0odyplus@yandex.ru>
Reviewed-on: https://gitea.serafimdev.com/serafim/dos/pulls/5
Reviewed-by: dr-wh0 <79003667309@yandex.ru>
Co-authored-by: serafim <simasuh@gmail.com>
Co-committed-by: serafim <simasuh@gmail.com>
2025-03-24 23:45:04 +03:00
serafim fd8c226de9 Начинаем за упокой, чтобы закончить за здравие (#4)
Co-authored-by: tieshagr <tieshagr@student.21>
Co-authored-by: root <root@simasuh.fvds.ru>
Reviewed-on: https://gitea.serafimdev.com/serafim/dos/pulls/4
2025-03-09 23:07:22 +03:00
9 changed files with 1175 additions and 201 deletions

4
.gitignore vendored Normal file
View File

@ -0,0 +1,4 @@
.vscode
src/test.cpp
test
DosAtk

View File

@ -1,10 +1,37 @@
# Как жить?
Регаемся на данном сайте, форкаем либу, пушим в свой форк и создаём merge request.
Либо просим у Серафима контрибьютора и сразу делаем ветку где надо (так даже лучше, не придётся мучаться с мержем из форка)
```
git clone https://gitea.serafimdev.com/serafim/dos # Клонируем репозиторий
git clone https://gitea.serafimdev.com/serafim/dos # Клонируем репозиторий (замените на свой форк!)
git checkout -b my_dns # Создаём ветку для реализации модуля my_dns
git add * # Добавляем написанный код в комит
git commit -m 'Написал код' # Комитим в локальную ветку
git push origin my_dns # Пушим свою ветку в репозиторий
# Теперь в интерфейсе https://gitea.serafimdev.com/serafim/dos создаём пул реквест и пишем мне в тг
```
```
# Компиляция
Для компиляции: `./build.py` (после компиляции запускает файл), либо ручками: `g++ src/DosAtk.cpp -o DosAtk -lcurl -lssl -lcrypto`
Если ошибка отсутствия заголовочных файлов, то нужно установить:
```
sudo apt-get install libcurl4-openssl-dev
sudo apt-get install libssl-dev
sudo apt-get install python3
sudo apt-get install nlohmann-json3-dev
```
# Запуск
Пример запуска:
```
sudo ./DosAtk -a flood -i 127.0.0.1 -p 800 # запуск заранее скомпилированной программы
sudo ./build.py -a flood -i 127.0.0.1 -p 800 # скомипилирует и запустит программу
```
Запускается только на Линухе!

21
build.py Executable file
View File

@ -0,0 +1,21 @@
#!/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:])

4
build.sh Executable file
View File

@ -0,0 +1,4 @@
#!/bin/sh
set -e # if compilation fail next command will not be executed, so older version of programm will not be launched
g++ src/DosAtk.cpp -o DosAtk -lcurl -lssl -lcrypto
./DosAtk "$@"

1117
src/DosAtk.cpp Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,14 +0,0 @@
CXX = g++
CXXFLAGS = -Iinclude/
all: dos
# Сюда дописывать файлики для компиляции
dos:
$(CXX) $(CXXFLAGS) ./main.cpp ./my_check_params.cpp -o dos
rebuild:
rm -f ./dos && make dos
clean:
rm -f ./dos

View File

@ -1,46 +0,0 @@
#include "my_check_params.hpp"
Options opts;
using namespace std;
// Компиляция из директории вызвать команду make my_app
// Запуск: ./my_app [флаги и аргументы к ним] (начать можно с флага --help)
int main(int argc, char *argv[]) {
int error = my_check_params(argc, argv);
if (error > 0)
{
if (opts.attack_type == "flood") {
cout << "type attack: " << opts.attack_type << "\n";
cout << "domain: " << opts.domain << "\n";
cout << "ip: " << opts.ip << "\n";
cout << "port: " << opts.port << "\n";
cout << "log file path: " << opts.log_file << "\n";
}
else if (opts.attack_type == "scan") {
cout << "type attack: " << opts.attack_type << "\n";
cout << "domain: " << opts.domain << "\n";
cout << "ip: " << opts.ip << "\n";
cout << "log file path: " << opts.log_file << "\n";
}
if (!opts.telegram_id.empty()) {
cout << "telegram_id: " << opts.telegram_id << "\n";
}
if (!opts.telegram_token.empty()) {
cout << "telegram_token: " << opts.telegram_token << "\n";
}
}
else {
cout << "err code:" << error << "\n";
}
return 0;
}

View File

@ -1,117 +0,0 @@
#include "my_check_params.hpp"
// Гарантируется наличие минимума нужных аргументов для flood и scan
// Гарантируется, что после работы парсера мы получим только валидный тип атаки
// Добавить:
// 1. Валидацию IP, port
// Статус коды:
// 2 - Атака флуд, все нужные опции есть
// 1 - Атака порт скан, все нужные опции есть
// 0 - нужна помощь
// -1 - пользователь не ввел тип атаки или ввел неверный тип атаки
// -10 - Пользователь выбрал тип атаки порт сканнинг, но не ввел нужные параметры
// -20 - Пользователь выбрал тип атаки флуд, но не ввел нужные параметры
// -100 - неизвестная ошибка
// -101 - неизвестная опция или потерян аргумент, следует предложить вызвать флаг помощи
// -600 - пользователь ввел токен, но не id или наоборот
// Какие-то еще коды?
int my_check_params(int argc, char** argv) {
int status = -100;
// Короткие опции (с двоеточием для параметров)
const char* short_options = "a:d:i:p:l:t:b:h";
// Длинные опции
const struct option long_options[] = {
{"attack", required_argument, NULL, 'a'},
{"domain", required_argument, NULL, 'd'},
{"ip", required_argument, NULL, 'i'},
{"port", required_argument, NULL, 'p'},
{"log", required_argument, NULL, 'l'},
{"telegram", required_argument, NULL, 't'},
{"token", required_argument, NULL, 'b'},
{"help", no_argument, NULL, 'h'},
{NULL, 0, NULL, 0}
};
int opt;
while ((opt = getopt_long(argc, argv, short_options, long_options, NULL)) != -1) {
switch (opt) {
case 'a':
opts.attack_type = optarg;
break;
case 'd':
opts.domain = optarg;
break;
case 'i':
opts.ip = optarg;
break;
case 'p':
opts.port = optarg;
break;
case 'l':
opts.log_file = optarg;
break;
case 't':
opts.telegram_id = optarg;
break;
case 'b':
opts.telegram_token = optarg;
break;
case 'h':
// std::cout << "Usage: " << argv[0] << " [options]\n"
// << "Required:\n"
// << " -a, --attack TYPE Type of attack (scan|flood)\n"
// << " -d, --domain DOMAIN Target domain\n"
// << " -i, --ip IP Target IP\n"
// << " -p, --port PORT Port. Required only for flood type!\n"
// << "Optional:\n"
// << " -l, --log FILE Log file\n"
// << " -t, --telegram ID Telegram ID\n"
// << " -b, --token TOKEN Telegram bot token\n";
status = 0;
break;
case '?':
// std::cerr << "Unknown option!\n.--help for info\n";
status = -101;
break;
default:
status = -100;
break;
}
}
// Проверка обязательных параметров
if (status != 0 && status != -101)
{
if (opts.attack_type != "flood" && opts.attack_type != "scan") {
// std::cerr << "Error: Missing required parameters!\n--help for more info\n";
status = -1;
}
else if (opts.attack_type == "scan" && (opts.domain.empty() || opts.ip.empty())) {
// std::cerr << "Error: Missing required parameters!\n--help for more info\n";
status = -10;
}
else if (opts.attack_type == "flood" && (opts.domain.empty() || opts.ip.empty() || opts.port.empty())) {
// std::cerr << "Error: Missing required parameters!\n--help for more info\n";
status = -20;
}
else if ((!opts.telegram_id.empty() && opts.telegram_token.empty()) || (opts.telegram_id.empty() && !opts.telegram_token.empty())) {
status = -600;
}
else if (opts.attack_type == "scan" && !opts.domain.empty() && !opts.ip.empty()) {
// std::cerr << "Error: Missing required parameters!\n--help for more info\n";
status = 1;
}
else if (opts.attack_type == "flood" && !opts.domain.empty() && !opts.ip.empty() && !opts.port.empty()) {
// std::cerr << "Error: Missing required parameters!\n--help for more info\n";
status = 2;
}
// Какие-то еще коды?
}
return status;
}

View File

@ -1,22 +0,0 @@
#pragma once
#include <iostream>
#include <string>
#include <unistd.h>
#include <getopt.h> // Для struct option
struct Options {
std::string attack_type; // Обязательный параметр
std::string domain; // Обязательный параметр
std::string ip; // Обязательный параметр
std::string port; // Обязательный параметр (не обязательный для скана)
std::string log_file = "/var/logs/DosAtk"; // Значение по умолчанию, не обязательный
std::string telegram_id; // Не обязательный параметр
std::string telegram_token; // Не обязательный параметр
};
extern Options opts; // Теперь это глобальная переменная, где она должна определяться?
// Прототип функции парсинга
int my_check_params(int argc, char** argv);