forked from serafim/dos
1
0
Fork 0

Compare commits

..

21 Commits
my_msg ... dev

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
7 changed files with 1175 additions and 81 deletions

4
.gitignore vendored Normal file
View File

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

View File

@ -1,21 +0,0 @@
{
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"windowsSdkVersion": "10.0.19041.0",
"compilerPath": "cl.exe",
"cStandard": "c17",
"cppStandard": "c++17",
"intelliSenseMode": "windows-msvc-x64"
}
],
"version": 4
}

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 "$@"

View File

@ -1,58 +0,0 @@
#include <iostream>
#include <string>
#include <curl/curl.h>
#include <cctype>
using namespace std;
string telegram_id;
string bot_token;
int my_msg(const string& msg) {
cout << msg << endl;
CURL* curl = curl_easy_init();
if (!curl) return 6;
string escaped_msg = escape_json(msg);
string chat_id_field;
if (is_numeric(telegram_id)) {
chat_id_field = "\"chat_id\": " + telegram_id;
} else {
chat_id_field = "\"chat_id\": \"" + telegram_id + "\"";
}
string json_data = "{" + chat_id_field + ", \"text\": \"" + escaped_msg + "\"}";
struct curl_slist* headers = nullptr;
headers = curl_slist_append(headers, "Content-Type: application/json");
curl_easy_setopt(curl, CURLOPT_URL, ("https://api.telegram.org/bot" + bot_token + "/sendMessage").c_str());
curl_easy_setopt(curl, CURLOPT_POST, 1L);
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, json_data.c_str());
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(curl, CURLOPT_USERAGENT, "libcurl/7.68.0");
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, [](void*, size_t size, size_t nmemb, void*) -> size_t {
return size * nmemb;
});
CURLcode res = curl_easy_perform(curl);
long http_code = 0;
curl_easy_getinfo(curl, CURLINFO_RESPONSE_CODE, &http_code);
curl_slist_free_all(headers);
curl_easy_cleanup(curl);
if (res != CURLE_OK) return 5;
switch (http_code) {
case 200: return 0; // Успех
case 401: return 1; // Неверный токен
case 400: return 2; // Неверный chat_id
case 404: return 3; // Неверный URL (бот не найден)
default:
return 4; // Ошибка сервера (500)
}
}

1117
src/DosAtk.cpp Normal file

File diff suppressed because it is too large Load Diff