4. API Reference¶
This module provides an HTTP server testing facility.
You really want to pwn someone’s server, right? Go ahead, extend the
Beam
or do something even more sinister.
4.1. Response¶
-
class
pewpewlaz0rt4nk.
Response
(pass_, expected, received)¶ Container to store a validated HTTP response line.
- Arguments:
- pass_: Represents a valid or invalid response line.
- expected: The expected response string.
- received: The actual response string.
4.2. Beam¶
-
class
pewpewlaz0rt4nk.
Beam
(request, response, description=None, host=None, port=None, timeout=None, buffer_=4096, shutdown=False)¶ A beam to be shot by the
Laz0rCannon
(e.g. an HTTP test case).- Arguments:
- request: The request string that will be sent.
- response: An iterable of strings containing the expected response.
- description: The description of the test case.
- host: The hostname of the HTTP server.
- port: The port number where the HTTP server is reachable.
- timeout: The amount of seconds until a timeout occurs while
- reading from/writing to the socket.
- buffer_: The amount of bytes that will be sent at once. See this section.
- shutdown: False or one of the constants of module
socket
. See this section.
-
reset
()¶ Reset attributes needed to reuse this beam.
-
send
()¶ Send the HTTP request via an established connection.
Return the amount of calls to
send()
.Raises a
BeamRequestError
if the request has already been sent.
-
receive
()¶ Receive the HTTP response via an established connection.
Return the amount of calls to
recv()
.- Raises:
BeamRequestError
: The HTTP request has not been sent, yet.BeamResponseError
: The HTTP response has already been received.
-
validate
()¶ Validate an HTTP response.
Return a list of
Response
instances.- Raises:
BeamRequestError
: The HTTP request has not been sent, yet.BeamResponseError
: The HTTP response not been received, yet.
4.3. Laz0rCannon¶
-
class
pewpewlaz0rt4nk.
Laz0rCannon
(host=None, port=None, timeout=3, use_colors=True)¶ A laz0r cannon that shoots laz0r beams at HTTP servers.
- Arguments:
- host: The hostname of the HTTP server.
- port: The port number where the HTTP server is reachable.
- timeout: The amount of seconds until a timeout occurs while reading from/writing to the socket.
- use_colors: Turn colored output on the console on or off.
-
reset
()¶ Reset statistics of passed and failed HTTP responses.