Library proxy
Functions for proxy testing.
Author:
| Joao Correa <joao@livewire.com.br> |
Copyright© Same as Nmap--See http://nmap.org/book/man-legal.html
Source: http://nmap.org/svn/nselib/proxy.lua
Functions
| connectProxy (host, port, proxyType, hostname) |
Creates a socket, performs proxy handshake if necessary and returns it |
| hex_resolve (hostname) |
Function that resolves IP address for hostname and returns it as hex values |
| redirectCheck (resp1, resp2) |
Checks if two different responses are equal, if true, the proxy server might be redirecting the requests to a default page |
| return_args () |
Checks if any parameter was used in old or new syntax and return the parameters |
| socksHandshake (socket, version, hostname) |
Performs a socks handshake on a socket and returns it |
| test_connect (host, port, proxyType, hostname) |
Builds the CONNECT request and calls test |
| test_get (host, port, proxyType, test_url, hostname, pattern) |
Builds the GET request and calls test |
| test_head (host, port, proxyType, test_url, hostname, pattern) |
Builds the HEAD request and calls test |
Functions
- connectProxy (host, port, proxyType, hostname)
-
Creates a socket, performs proxy handshake if necessary and returns it
Parameters
- host: The host table
- port: The port table
- proxyType: A string with the proxy type. Might be "http","socks4" or "socks5"
- hostname: The proxy destination hostname
Return value:
socket A socket with the handshake already done - hex_resolve (hostname)
-
Function that resolves IP address for hostname and returns it as hex values
Parameters
- hostname: Hostname to resolve
Return value:
Ip address of hostname in hex - redirectCheck (resp1, resp2)
-
Checks if two different responses are equal, if true, the proxy server might be redirecting the requests to a default page
Functions slipts body from head before comparing, to avoid session variables, cookies...
Parameters
- resp1: A string with the response for the first request
- resp2: A string with the response for the second request
Return value:
bool true if both responses are equal, otherwise false - return_args ()
-
Checks if any parameter was used in old or new syntax and return the parameters
Return values:
- url the proxy.url parameter
- pattern the proxy.pattern parameter
- socksHandshake (socket, version, hostname)
-
Performs a socks handshake on a socket and returns it
Parameters
- socket: The socket where the handshake will be performed
- version: The socks version (might be 4 or 5)
- hostname: The proxy destination hostname
Return value:
socket A socket with the handshake already done - test_connect (host, port, proxyType, hostname)
-
Builds the CONNECT request and calls test
Parameters
- host: The host table
- port: The port table
- proxyType: The proxy type to be tested, might be 'socks4', 'socks5' or 'http'
- hostname: The hostname of the server to send the request
Return value:
the result of the function test (status and the request result) - test_get (host, port, proxyType, test_url, hostname, pattern)
-
Builds the GET request and calls test
Parameters
- host: The host table
- port: The port table
- proxyType: The proxy type to be tested, might be 'socks4', 'socks5' or 'http'
- test_url: The url to send the request
- hostname: The hostname of the server to send the request
- pattern: The pattern to check for valid result
Return value:
the result of the function test (status and the request result) - test_head (host, port, proxyType, test_url, hostname, pattern)
-
Builds the HEAD request and calls test
Parameters
- host: The host table
- port: The port table
- proxyType: The proxy type to be tested, might be 'socks4', 'socks5' or 'http'
- test_url: The url te send the request
- hostname: The hostname of the server to send the request
- pattern: The pattern to check for valid result
Return value:
the result of the function test (status and the request result)


