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.

connect()

Create a socket and establish a connection to the host.

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:
shutdown_socket()

Shutdown the socket of an established connection.

validate()

Validate an HTTP response.

Return a list of Response instances.

Raises:
terminate()

Terminate an established connection to the socket.

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.

add(beam)

Add a beam to the cannon.

Arguments:
  • beam: A Beam instance.

The attributes host, port and timeout of a Beam will be overwritten by this class’s attributes if they haven’t been defined explicitly.

pewpew(settings=True)

Align the laz0r cannon and PEWPEWs each laz0r Beam towards the HTTP server.

Arguments:
  • settings: If set to True setting informations will be printed.

4.4. Exceptions

class pewpewlaz0rt4nk.BeamError

This exception is for uncategorised beam errors.

class pewpewlaz0rt4nk.BeamRequestError

This exception is for HTTP request related errors.

class pewpewlaz0rt4nk.BeamResponseError

This exception is for HTTP response related errors.