proxy NSE Library — Nmap Scripting Engine documentation (original) (raw)
Functions for proxy testing.
Author:
Copyright © Same as Nmap--See https://nmap.org/book/man-legal.html
Source: https://svn.nmap.org/nmap/nselib/proxy.lua
Script Arguments
proxy.url
Url that will be requested to the proxy
proxy.pattern
Pattern that will be searched inside the request results
Functions
connectProxy (host, port, proxyType, hostname)
Creates a socket, performs proxy handshake if necessary and returns it
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 values:
- status True if handshake succeeded, false otherwise
- socket A socket with the handshake already done, or an error if
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 splits 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 values:
- status True if handshake succeeded, false otherwise
- socket A socket with the handshake already done, or an error if status is false
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)