C:/fscan/HTTPCore/HTTP.h File Reference

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  _data
 This struct stores information to an HTTP request or response. Both HTTP Headers and HTTP body data are stored under this struct. More...
struct  _request
 This struct handles information related to and http response and includes information about client request, server response, url, server version .returned by an HTTP Server. More...

Defines

#define HTTP_STATUS_CONTINUE   100
 OK to continue with request.
#define HTTP_STATUS_SWITCH_PROTOCOLS   101
 server has switched protocols in upgrade header
#define HTTP_STATUS_OK   200
 request completed
#define HTTP_STATUS_CREATED   201
 object created, reason = new URI
#define HTTP_STATUS_ACCEPTED   202
 async completion (TBS)
#define HTTP_STATUS_PARTIAL   203
 partial completion
#define HTTP_STATUS_NO_CONTENT   204
 no info to return
#define HTTP_STATUS_RESET_CONTENT   205
 request completed, but clear form
#define HTTP_STATUS_PARTIAL_CONTENT   206
 partial GET furfilled
#define HTTP_STATUS_AMBIGUOUS   300
 server couldn't decide what to return
#define HTTP_STATUS_MOVED   301
 object permanently moved
#define HTTP_STATUS_REDIRECT   302
 object temporarily moved
#define HTTP_STATUS_REDIRECT_METHOD   303
 redirection w/ new access method
#define HTTP_STATUS_NOT_MODIFIED   304
 if-modified-since was not modified
#define HTTP_STATUS_USE_PROXY   305
 redirection to proxy, location header specifies proxy to use
#define HTTP_STATUS_REDIRECT_KEEP_VERB   307
 HTTP/1.1: keep same verb.
#define HTTP_STATUS_BAD_REQUEST   400
 invalid syntax
#define HTTP_STATUS_DENIED   401
 access denied
#define HTTP_STATUS_PAYMENT_REQ   402
 payment required
#define HTTP_STATUS_FORBIDDEN   403
 request forbidden
#define HTTP_STATUS_NOT_FOUND   404
 object not found
#define HTTP_STATUS_BAD_METHOD   405
 method is not allowed
#define HTTP_STATUS_NONE_ACCEPTABLE   406
 no response acceptable to client found
#define HTTP_STATUS_PROXY_AUTH_REQ   407
 proxy authentication required
#define HTTP_STATUS_REQUEST_TIMEOUT   408
 server timed out waiting for request
#define HTTP_STATUS_CONFLICT   409
 user should resubmit with more info
#define HTTP_STATUS_GONE   410
 the resource is no longer available
#define HTTP_STATUS_LENGTH_REQUIRED   411
 the server refused to accept request w/o a length
#define HTTP_STATUS_PRECOND_FAILED   412
 precondition given in request failed
#define HTTP_STATUS_REQUEST_TOO_LARGE   413
 request entity was too large
#define HTTP_STATUS_URI_TOO_LONG   414
 request URI too long
#define HTTP_STATUS_UNSUPPORTED_MEDIA   415
 unsupported media type
#define HTTP_STATUS_SERVER_ERROR   500
 internal server error
#define HTTP_STATUS_NOT_SUPPORTED   501
 required not supported
#define HTTP_STATUS_BAD_GATEWAY   502
 error response received from gateway
#define HTTP_STATUS_SERVICE_UNAVAIL   503
 temporarily overloaded
#define HTTP_STATUS_GATEWAY_TIMEOUT   504
 timed out waiting for gateway
#define HTTP_STATUS_VERSION_NOT_SUP   505
 HTTP version not supported.
#define HTTP_STATUS_FIRST   HTTP_STATUS_CONTINUE
#define HTTP_STATUS_LAST   HTTP_STATUS_VERSION_NOT_SUP
#define NO_AUTH   0
#define BASIC_AUTH   1
#define DIGEST_AUTH   2
#define NTLM_AUTH   4
#define NEGOTIATE_AUTH   8
#define UNKNOWN_AUTH   16
#define MAX_POST_LENGHT   4096
#define MAX_DOWNLOAD_SIZE   MAX_POST_LENGHT*20
#define OPT_HTTP_PROXY_HOST   0x00
#define OPT_HTTP_PROXY_PORT   0x01
#define OPT_HTTP_PROXY_USER   0x02
#define OPT_HTTP_PROXY_PASS   0x04
#define OPT_HTTP_HEADER   0x08
#define OPT_HTTP_COOKIE   0x10
#define OPT_HTTP_USERAGENT   0x20
#define OPT_HTTP_PROTOCOL   0x40
#define OPT_HTTP_MAXSPEED_DOWNLOAD   0x80
#define HTTP_REQUEST_CURRENT   1
#define HTTP_REQUEST_ALL   0

Typedefs

typedef struct _data HTTP_DATA
typedef struct _dataPHTTP_DATA
typedef struct _request REQUEST
typedef struct _requestPREQUEST
typedef void * HTTPHANDLE

Functions

int InitHTTPApi (void)
 Initializes the HTTP Core. You must call InitHTTPApi before interacting with HTTP functions.
void CloseHTTPApi (void)
 This function is used to stop working with HTTP Core. Previous call to InitHTTPApi() is required.
int SetHTTPAPIConfig (int opt, char *parameter)
 This function is used to set global configuration options for each connection.
char * GetHTTPAPIConfig (int opt)
 This function retrieves the current global configuration.
HTTPHANDLE InitHTTPConnectionHandle (char *hostname, int port, int ssl)
 This function returns a pseudo-Handle needed to stablish an HTTP connection. This information is managed internally by the HTTP Core. Only one call is required for handling each remote host.
int SetHTTPConfig (HTTPHANDLE HTTPHandle, int opt, char *parameter)
 This function Allows users to change some HTTP request parameters.
char * GetHTTPConfig (HTTPHANDLE HTTPHandle, int opt)
 This function allows users to retrieve HTTP Configuration parameters.
void CloseHTTPConnectionHandle (HTTPHANDLE HTTPHandle)
 This function destroys an HTTP Handle.
PREQUEST SendHttpRequest (HTTPHANDLE HTTPHandle, char *Vhost, char *HTTPMethod, char *url, char *Postdata, char *lpUsername, char *lpPassword, int AuthMethod)
 This function is used by the user to send a request against a webserver.
PREQUEST SendRawHttpRequest (HTTPHANDLE HTTPHandle, char *headers, char *postdata)
 This function is used by the user to send an special crafted HTTP Request against a webserver.
void * FreeRequest (PREQUEST request)
 This function destroys a _request struct returned by SendHttpRequest() and free reserved memory.
int CancelHttpRequest (HTTPHANDLE HTTPHandle, int what)
 This function is used to disconnect a currently stablished connection.
char * GetHeaderValue (char *headers, char *value, int n)
 This function is used to get a header returned by the HTTP server by using the header name.
char * GetHeaderValueByID (char *headers, unsigned int id)
 This function is used to get a header returned by the HTTP server.
PHTTP_DATA RemoveHeader (PHTTP_DATA request, char *Header)
 This function Searches a PHTTP_DATA structure for specific headers and if found , the header is removed.
PHTTP_DATA AddHeader (PHTTP_DATA request, char *Header)
 This function adds a header to the request.


Detailed Description

Fast HTTP Auth Scanner - HTTP Engine. This include file contains all needed information to manage the HTTP interface from the user side.
Author:
Andres Tarasco Acuna - http://www.tarasco.org

Definition in file HTTP.h.


Define Documentation

#define BASIC_AUTH   1

Definition at line 144 of file HTTP.h.

Referenced by IschallengeSupported(), and SendHttpRequest().

#define DIGEST_AUTH   2

Definition at line 145 of file HTTP.h.

Referenced by IschallengeSupported(), ParseReturnedBuffer(), and SendHttpRequest().

#define HTTP_REQUEST_ALL   0

Definition at line 173 of file HTTP.h.

#define HTTP_REQUEST_CURRENT   1

Definition at line 172 of file HTTP.h.

#define HTTP_STATUS_ACCEPTED   202

async completion (TBS)

Definition at line 20 of file HTTP.h.

#define HTTP_STATUS_AMBIGUOUS   300

server couldn't decide what to return

Definition at line 30 of file HTTP.h.

#define HTTP_STATUS_BAD_GATEWAY   502

error response received from gateway

Definition at line 80 of file HTTP.h.

#define HTTP_STATUS_BAD_METHOD   405

method is not allowed

Definition at line 54 of file HTTP.h.

#define HTTP_STATUS_BAD_REQUEST   400

invalid syntax

Definition at line 44 of file HTTP.h.

#define HTTP_STATUS_CONFLICT   409

user should resubmit with more info

Definition at line 62 of file HTTP.h.

#define HTTP_STATUS_CONTINUE   100

OK to continue with request.

Definition at line 12 of file HTTP.h.

#define HTTP_STATUS_CREATED   201

object created, reason = new URI

Definition at line 18 of file HTTP.h.

#define HTTP_STATUS_DENIED   401

access denied

Definition at line 46 of file HTTP.h.

#define HTTP_STATUS_FIRST   HTTP_STATUS_CONTINUE

Definition at line 87 of file HTTP.h.

#define HTTP_STATUS_FORBIDDEN   403

request forbidden

Definition at line 50 of file HTTP.h.

#define HTTP_STATUS_GATEWAY_TIMEOUT   504

timed out waiting for gateway

Definition at line 84 of file HTTP.h.

#define HTTP_STATUS_GONE   410

the resource is no longer available

Definition at line 64 of file HTTP.h.

#define HTTP_STATUS_LAST   HTTP_STATUS_VERSION_NOT_SUP

Definition at line 88 of file HTTP.h.

#define HTTP_STATUS_LENGTH_REQUIRED   411

the server refused to accept request w/o a length

Definition at line 66 of file HTTP.h.

#define HTTP_STATUS_MOVED   301

object permanently moved

Definition at line 32 of file HTTP.h.

#define HTTP_STATUS_NO_CONTENT   204

no info to return

Definition at line 24 of file HTTP.h.

#define HTTP_STATUS_NONE_ACCEPTABLE   406

no response acceptable to client found

Definition at line 56 of file HTTP.h.

#define HTTP_STATUS_NOT_FOUND   404

object not found

Definition at line 52 of file HTTP.h.

#define HTTP_STATUS_NOT_MODIFIED   304

if-modified-since was not modified

Definition at line 38 of file HTTP.h.

#define HTTP_STATUS_NOT_SUPPORTED   501

required not supported

Definition at line 78 of file HTTP.h.

#define HTTP_STATUS_OK   200

request completed

Definition at line 16 of file HTTP.h.

#define HTTP_STATUS_PARTIAL   203

partial completion

Definition at line 22 of file HTTP.h.

#define HTTP_STATUS_PARTIAL_CONTENT   206

partial GET furfilled

Definition at line 28 of file HTTP.h.

#define HTTP_STATUS_PAYMENT_REQ   402

payment required

Definition at line 48 of file HTTP.h.

#define HTTP_STATUS_PRECOND_FAILED   412

precondition given in request failed

Definition at line 68 of file HTTP.h.

#define HTTP_STATUS_PROXY_AUTH_REQ   407

proxy authentication required

Definition at line 58 of file HTTP.h.

#define HTTP_STATUS_REDIRECT   302

object temporarily moved

Definition at line 34 of file HTTP.h.

#define HTTP_STATUS_REDIRECT_KEEP_VERB   307

HTTP/1.1: keep same verb.

Definition at line 42 of file HTTP.h.

#define HTTP_STATUS_REDIRECT_METHOD   303

redirection w/ new access method

Definition at line 36 of file HTTP.h.

#define HTTP_STATUS_REQUEST_TIMEOUT   408

server timed out waiting for request

Definition at line 60 of file HTTP.h.

#define HTTP_STATUS_REQUEST_TOO_LARGE   413

request entity was too large

Definition at line 70 of file HTTP.h.

#define HTTP_STATUS_RESET_CONTENT   205

request completed, but clear form

Definition at line 26 of file HTTP.h.

#define HTTP_STATUS_SERVER_ERROR   500

internal server error

Definition at line 76 of file HTTP.h.

#define HTTP_STATUS_SERVICE_UNAVAIL   503

temporarily overloaded

Definition at line 82 of file HTTP.h.

#define HTTP_STATUS_SWITCH_PROTOCOLS   101

server has switched protocols in upgrade header

Definition at line 14 of file HTTP.h.

#define HTTP_STATUS_UNSUPPORTED_MEDIA   415

unsupported media type

Definition at line 74 of file HTTP.h.

#define HTTP_STATUS_URI_TOO_LONG   414

request URI too long

Definition at line 72 of file HTTP.h.

#define HTTP_STATUS_USE_PROXY   305

redirection to proxy, location header specifies proxy to use

Definition at line 40 of file HTTP.h.

#define HTTP_STATUS_VERSION_NOT_SUP   505

HTTP version not supported.

Definition at line 86 of file HTTP.h.

#define MAX_DOWNLOAD_SIZE   MAX_POST_LENGHT*20

Definition at line 151 of file HTTP.h.

#define MAX_POST_LENGHT   4096

Definition at line 150 of file HTTP.h.

Referenced by SendHttpRequest().

#define NEGOTIATE_AUTH   8

Definition at line 147 of file HTTP.h.

Referenced by IschallengeSupported(), and SendHttpRequest().

#define NO_AUTH   0

Definition at line 143 of file HTTP.h.

#define NTLM_AUTH   4

Definition at line 146 of file HTTP.h.

Referenced by IschallengeSupported(), and SendHttpRequest().

#define OPT_HTTP_COOKIE   0x10

Definition at line 160 of file HTTP.h.

Referenced by GetHTTPConfig(), and SetHTTPConfig().

#define OPT_HTTP_HEADER   0x08

Definition at line 159 of file HTTP.h.

Referenced by GetHTTPConfig(), and SetHTTPConfig().

#define OPT_HTTP_MAXSPEED_DOWNLOAD   0x80

Definition at line 163 of file HTTP.h.

Referenced by GetHTTPConfig(), and SetHTTPConfig().

#define OPT_HTTP_PROTOCOL   0x40

Definition at line 162 of file HTTP.h.

Referenced by GetHTTPConfig(), and SetHTTPConfig().

#define OPT_HTTP_PROXY_HOST   0x00

Definition at line 154 of file HTTP.h.

Referenced by GetHTTPConfig(), and SetHTTPConfig().

#define OPT_HTTP_PROXY_PASS   0x04

Definition at line 157 of file HTTP.h.

Referenced by GetHTTPConfig(), and SetHTTPConfig().

#define OPT_HTTP_PROXY_PORT   0x01

Definition at line 155 of file HTTP.h.

Referenced by GetHTTPConfig(), and SetHTTPConfig().

#define OPT_HTTP_PROXY_USER   0x02

Definition at line 156 of file HTTP.h.

Referenced by GetHTTPConfig(), and SetHTTPConfig().

#define OPT_HTTP_USERAGENT   0x20

Definition at line 161 of file HTTP.h.

Referenced by GetHTTPConfig(), and SetHTTPConfig().

#define UNKNOWN_AUTH   16

Definition at line 148 of file HTTP.h.

Referenced by IschallengeSupported().


Typedef Documentation

typedef struct _data HTTP_DATA

typedef void * HTTPHANDLE

For the user, this pseudo-handle returned by InitHTTPConnectionHandle() is just a pointer.

Definition at line 139 of file HTTP.h.

typedef struct _data * PHTTP_DATA

typedef struct _request * PREQUEST

typedef struct _request REQUEST


Function Documentation

PHTTP_DATA AddHeader ( PHTTP_DATA  request,
char *  Header 
)

This function adds a header to the request.

Parameters:
request PHTTP_DATA pointer to the headers
Header Null terminated pointer to the string that is going to be added.
Note:
Headers MUST contain \r\n at the end

Definition at line 658 of file HTTP.cpp.

References _data::Header, and _data::HeaderSize.

int CancelHttpRequest ( HTTPHANDLE  HTTPHandle,
int  what 
)

This function is used to disconnect a currently stablished connection.

Parameters:
HTTPHandle Handle of the remote connection.
what Cancel only the current request HTTP_REQUEST_CURRENT or blocks all connections against the remote HTTP host with HTTP_REQUEST_ALL.
Note:
This function is needed to cancel requests like example a CONNECT call sent against a remote HTTP proxy server by SendRawHttpRequest()

Definition at line 1136 of file HTTP.cpp.

References HTTPCoreCancelHTTPRequest().

Here is the call graph for this function:

void CloseHTTPApi ( void   ) 

This function is used to stop working with HTTP Core. Previous call to InitHTTPApi() is required.

Definition at line 55 of file HTTP.cpp.

References CloseHTTPApiCore(), and CloseHTTPConnectionHandle().

Here is the call graph for this function:

void CloseHTTPConnectionHandle ( HTTPHANDLE  HTTPHandle  ) 

This function destroys an HTTP Handle.

Parameters:
HTTPHandle Pointer to the Handle returned by InitHTTPConnectionHandle(). This value cant be NULL
Note:
Be sure to close the connection handle to avoid memory leaks

Definition at line 382 of file HTTP.cpp.

References UserAgent.

Referenced by CloseHTTPApi().

void* FreeRequest ( PREQUEST  data  ) 

This function destroys a _request struct returned by SendHttpRequest() and free reserved memory.

Parameters:
data Pointer to a _request struct
Returns:
FreeRequest() This function always returns a NULL pointer
Note:
Be sure to close the _request struct to avoid memory leaks

Definition at line 714 of file HTTP.cpp.

References FreeHTTPData(), _request::request, _request::response, and _request::server.

Referenced by SendHttpRequest().

Here is the call graph for this function:

char* GetHeaderValue ( char *  headers,
char *  value,
int  n 
)

This function is used to get a header returned by the HTTP server by using the header name.

Parameters:
headers Pointer to an string containing the headers returned by The server. You should use request->header here
value pointer to an string containing the search header. Example char *value = "Location:"
n Number of matching headers to be searched.
Returns:
GetHeaderValue() returns a Pointer to a string ended by '\0' that contains the header provided by the remote HTTP server. This function returns NULL if the header is not found.
Note:
spaces at the beginning of the return value are removed.

The returned buffer does not contain the ending "\r\n". Is user task to free the memory allocated by this function. Example:

        struct _request *data;
        ...
        char *buffer=GetHeaderValue(data->response->header,"Location:",0);
        if (buffer)
        {
                printf("[+] Found redirect to: %s\n",buffer);
                free(buffer);
        }

Definition at line 551 of file HTTP.cpp.

References strnicmp.

Referenced by GetServerVersion(), IschallengeSupported(), ParseReturnedBuffer(), ReadHTTPResponseData(), and SendHttpRequest().

char* GetHeaderValueByID ( char *  headers,
unsigned int  id 
)

This function is used to get a header returned by the HTTP server.

Parameters:
headers Pointer to an string containing the headers returned by The server. You should use request->header here
id Header id referecence for matching the header. For example id 0 is the first header (usually like "GET /resource HTTP/1.0\r\n")
Returns:
GetHeaderValueByID() returns a Pointer to a string ended by '\0' that contains the header provided by the remote HTTP server. This function returns NULL if there are less headers than the value specified by the id parameter.
Note:
The returned buffer does not contain the ending "\r\n". Is user task to free the memory allocated by this function. Example:
        struct _request *data;
        char *buffer=NULL;
        int id=0;
        ...
        while (1)
        {
                buffer=GetHeaderValue(data->response->header,"Location:",id);
                if (buffer != NULL)
                {
                        printf("Header[%3.3i]: %s\n",id,buffer);
                        free(buffer);
                        id++;
                } else {
                        break;
                }
        }

Definition at line 617 of file HTTP.cpp.

References HEADER_ID_NOT_FOUND.

char* GetHTTPAPIConfig ( int  opt  ) 

This function retrieves the current global configuration.

/param opt This value indicates the kind of data that is going to be retrieved. Valid options are OPT_HTTP_PROXY_HOST, OPT_HTTP_PROXY_PORT, OPT_HTTP_PROXY_USER,OPT_HTTP_PROXY_PASS, OPT_HTTP_PROXY_HEADER, OPT_HTTP_COOKIE, OPT_HTTP_USERAGENT, OPT_HTTP_PROXY_PROTOCOL /return Pointer to the option data.

Definition at line 86 of file HTTP.cpp.

References GetHTTPConfig().

Here is the call graph for this function:

char* GetHTTPConfig ( HTTPHANDLE  HTTPHandle,
int  opt 
)

This function allows users to retrieve HTTP Configuration parameters.

Parameters:
HTTPHandle pointer to a handle returned by a previous call to InitHTTPConnectionHandle()
opt this value indicates the kind of data that is going to be modified. Valid options are OPT_HTTP_PROXY_HOST, OPT_HTTP_PROXY_PORT, OPT_HTTP_PROXY_USER,OPT_HTTP_PROXY_PASS, OPT_HTTP_PROXY_HEADER, OPT_HTTP_COOKIE, OPT_HTTP_USERAGENT, OPT_HTTP_PROXY_PROTOCOL
Returns:
NULL terminated pointer to specific parameter string.

Definition at line 164 of file HTTP.cpp.

References _hhandle::AdditionalHeader, _hhandle::Cookie, _hhandle::lpProxyPassword, _hhandle::lpProxyUserName, OPT_HTTP_COOKIE, OPT_HTTP_HEADER, OPT_HTTP_MAXSPEED_DOWNLOAD, OPT_HTTP_PROTOCOL, OPT_HTTP_PROXY_HOST, OPT_HTTP_PROXY_PASS, OPT_HTTP_PROXY_PORT, OPT_HTTP_PROXY_USER, OPT_HTTP_USERAGENT, _hhandle::ProxyHost, _hhandle::ProxyPort, and _hhandle::UserAgent.

Referenced by GetHTTPAPIConfig().

int InitHTTPApi ( void   ) 

Initializes the HTTP Core. You must call InitHTTPApi before interacting with HTTP functions.

Returns:
This functions returns 1 Initialization succes. Value 2 means that the API is already initialized and 0 that there is a critical error.

Definition at line 42 of file HTTP.cpp.

References InitHTTPApiCore().

Here is the call graph for this function:

HTTPHANDLE InitHTTPConnectionHandle ( char *  hostname,
int  port,
int  ssl 
)

This function returns a pseudo-Handle needed to stablish an HTTP connection. This information is managed internally by the HTTP Core. Only one call is required for handling each remote host.

Parameters:
hostname Pointer to the remote hostname. This value can be either an ip address or a hostname
port TCP port for the remote HTTP Server.
ssl Boolean parameter (values 1 or 0 ) to identify if the remote http server port requires an HTTPS connection
Note:
This function does not stablish HTTP Connections, only internal data is initialized. Call SetHTTPConfig() for more features.

The configuration for this handle is inherit from global options defined at SetHTTPAPIConfig().

 HTTPHANDLE connection=InitHTTPConnectionHandle("mail.google.com",443,1);
 if (connection)
 {
        ...
 }

Definition at line 108 of file HTTP.cpp.

References _hhandle::AdditionalHeader, _hhandle::conexion, _hhandle::Cookie, _hhandle::DownloadBwLimit, _hhandle::LastAuthenticationString, _hhandle::LastRequestedUri, _hhandle::lpProxyPassword, _hhandle::lpProxyUserName, _hhandle::NeedSSL, _hhandle::port, _hhandle::ProxyHost, _hhandle::ProxyPort, _hhandle::target, _hhandle::targetDNS, _hhandle::ThreadID, _hhandle::UserAgent, and _hhandle::version.

PHTTP_DATA RemoveHeader ( PHTTP_DATA  request,
char *  Header 
)

This function Searches a PHTTP_DATA structure for specific headers and if found , the header is removed.

Parameters:
request PHTTP_DATA pointer to the headers
Header Null Terminated pointer to the string that is going to be removed.

Definition at line 679 of file HTTP.cpp.

References _data::Header, _data::HeaderSize, and strnicmp.

PREQUEST SendHttpRequest ( HTTPHANDLE  HTTPHandle,
char *  VHost,
char *  HTTPMethod,
char *  url,
char *  Postdata,
char *  lpUsername,
char *  lpPassword,
int  AuthMethod 
)

This function is used by the user to send a request against a webserver.

Parameters:
HTTPHandle HANDLE that identifies the remote HTTP Host. This handle is returned by InitHTTPConnectionHandle()
VHost Alternate VHost for the http request. This value will be send in the "Host:" header instead of the ip address. This value can be NULL
HTTPMethod Pointer to the HTTP verb that will be send in the request. Examples "GET", "POST", "HEAD","OPTIONS",
url Pointer to the url. Example "/index.html"
Postdata Optional data to be send in the request. For example "login=user&pass=mypassword"
lpUsername Pointer to an optional username. This value is used if the remote host needs an username for authentication. (error 401)
lpPassword Pointer to an optional password. This value is used if the remote host needs password for authentication. (error 401)
AuthMethod This value specifies the authentication scheme. If the value is NO_AUTH (0) lpUsername and lpPassword are ignored.
Returns:
a Pointer to a _request struct is returned with information of the http response.
Note:
SendHttpRequest() is only able to handle NTLM and digest authentication when running under win32. This function returns NULL if the remote connection cant be stablished
#include "http.h"


int test(char *hostname, int port, int sslNeeded)
{
 struct _request *data,*newdata;
 HTTPHANDLE HTTPHandle=InitHTTPConnectionHandle(hostname,port,sslNeeded);
 if (!HTTPHandle)
 {
         printf("[-] InitHTTPConnectionHandle() Error. Unable to resolve %s\n",hostname);
         return(0);
 }

  data=SendHttpRequest(HTTPHandle,hostname,"GET","/admin/",NULL,NULL,NULL,NO_AUTH);
  if (!data)
  {
          printf("[-] SendHttpRequest() Error. Unable to connect to %s:%i\n",hostname,port);
          CloseHTTPConnectionHandle(HTTPHandle);
          return(0);
  }
  if (data->status==401)
  {
                newdata=SendHttpRequest(HTTPHandle,hostname,"GET","/admin/",NULL,"user","password",data->challenge);
                if (newdata)
                {
                        printf("[+] Status: %i\n",newdata->status);
                        for(int i=0;i<newdata->nheaders,i++)
                        {
                                printf("[+] Header(%i): %s\n",i,newdata->header[i]);

                        }
                        printf("[+] Data: %s\n",newdata->lpBuffer);
                        FreeRequest(newdata);
                }
  }
  CloseHTTPConnectionHandle(HTTPHandle);
  FreeRequest(data);
  return(1);
}


void main(int argc, char *argv[])
{

        InitHTTPApi();
        test("www.tarasco.org",80,0);
        CloseHTTPApi();
}

Definition at line 812 of file HTTP.cpp.

References _hhandle::AdditionalHeader, AddLine(), Base64Encode(), BASIC_AUTH, BuildAuthRequest(), buildAuthResponse(), _request::challenge, _hhandle::Cookie, CreateDigestAuth(), _data::Data, _data::DataSize, DIGEST_AUTH, DispatchHTTPRequest(), dumpAuthChallenge(), FreeRequest(), from64tobits(), GetHeaderValue(), _data::Header, InitHTTPData(), _hhandle::LastAuthenticationString, _hhandle::LastRequestedUri, MAX_POST_LENGHT, _hhandle::NeedSSL, NEGOTIATE_AUTH, NTLM_AUTH, ParseReturnedBuffer(), _hhandle::port, _hhandle::ProxyHost, _request::response, SendHttpRequest(), SmbLength, snprintf, _request::status, _hhandle::targetDNS, to64frombits(), _request::url, UserAgent, and _hhandle::UserAgent.

Referenced by SendHttpRequest().

Here is the call graph for this function:

PREQUEST SendRawHttpRequest ( HTTPHANDLE  HTTPHandle,
char *  headers,
char *  postdata 
)

This function is used by the user to send an special crafted HTTP Request against a webserver.

Parameters:
HTTPHandle HANDLE that identifies the remote HTTP Host. This handle is returned by InitHTTPConnectionHandle()
headers pointer to a null terminated string that contains the headers sent to the HTTP Server. This string must end with "\r\n\r\n" to avoid HTTP errors.
postdata pointer to an optional string containing additional data (like POST data)
Returns:
a Pointer to a _request struct is returned with information of the http response.
Note:
This function returns NULL if the remote connection cant be stablished
/*

Definition at line 734 of file HTTP.cpp.

int SetHTTPAPIConfig ( int  opt,
char *  parameter 
)

This function is used to set global configuration options for each connection.

/param opt This value indicates the kind of data that is going to be modified. Valid options are OPT_HTTP_PROXY_HOST, OPT_HTTP_PROXY_PORT, OPT_HTTP_PROXY_USER,OPT_HTTP_PROXY_PASS, OPT_HTTP_PROXY_HEADER, OPT_HTTP_COOKIE, OPT_HTTP_USERAGENT, OPT_HTTP_PROXY_PROTOCOL /parameter Pointer to the option data.

Definition at line 74 of file HTTP.cpp.

References SetHTTPConfig().

Here is the call graph for this function:

int SetHTTPConfig ( HTTPHANDLE  HTTPHandle,
int  opt,
char *  parameter 
)

This function Allows users to change some HTTP request parameters.

Parameters:
HTTPHandle pointer to a handle returned by a previous call to InitHTTPConnectionHandle()
opt this value indicates the kind of data that is going to be modified. Valid options are OPT_HTTP_PROXY_HOST, OPT_HTTP_PROXY_PORT, OPT_HTTP_PROXY_USER,OPT_HTTP_PROXY_PASS, OPT_HTTP_PROXY_HEADER, OPT_HTTP_COOKIE, OPT_HTTP_USERAGENT, OPT_HTTP_PROXY_PROTOCOL
parameter pointer to the header that will be included in the http request.
Returns:
This function returns 1 if operation succed, otherwhise -1 is returned.
Note:
if parameter is NULL or an empty string, the stored data is erased for that option.
 HTTPHANDLE connection = InitHTTPConnectionHandle("mail.google.com",443,1);
 if (connection)
 {
        SetHTTPConfig(connection,OPT_HTTP_USERAGENT,"FHScan Core API client");
        PREQUEST DATA = SendHTTPRequest(connection,"GET","/index.html",NULL,NULL,NO_AUTH);
        if (DATA) {
                printf("Returned Headers: %i bytes\n %s\n",DATA->response->HeaderSize,DATA->response->Header);
                printf("Returned Data: %i bytes\n %s\n",DATA->response->DataSize,DATA->response->Data);

                FreeRequest(DATA);
        }
        SetHTTPConfig(connection,OPT_HTTP_USERAGENT,NULL);
        //...
 }

Definition at line 229 of file HTTP.cpp.

References _hhandle::AdditionalHeader, _hhandle::conexion, _hhandle::Cookie, _hhandle::DownloadBwLimit, _hhandle::lpProxyPassword, _hhandle::lpProxyUserName, _hhandle::NeedSSL, OPT_HTTP_COOKIE, OPT_HTTP_HEADER, OPT_HTTP_MAXSPEED_DOWNLOAD, OPT_HTTP_PROTOCOL, OPT_HTTP_PROXY_HOST, OPT_HTTP_PROXY_PASS, OPT_HTTP_PROXY_PORT, OPT_HTTP_PROXY_USER, OPT_HTTP_USERAGENT, _hhandle::ProxyHost, _hhandle::ProxyPort, strnicmp, _hhandle::target, _hhandle::targetDNS, _hhandle::UserAgent, and _hhandle::version.

Referenced by SetHTTPAPIConfig().


Generated on Sun Jan 18 00:32:04 2009 for Fast HTTP Vulnerability Scanner by  doxygen 1.5.4