Skip to main content

Firegex client

Project description

Firegex Python Library and CLI

This is the Python library for Firegex. It is used to get additional features of Firegex and use the feature of the command fgex.

Installation

pip install -U firegex

fgex is an alias of firegex. You can use fgex instead of firegex.

Command line usage:

➤ fgex nfproxy -h

 Usage: fgex nfproxy [OPTIONS] FILTER_FILE ADDRESS PORT

 Run an nfproxy simulation

╭─ Arguments ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ *    filter_file      TEXT     The path to the filter file [default: None] [required]                                                               │
│ *    address          TEXT     The address of the target to proxy [default: None] [required]                                                        │
│ *    port             INTEGER  The port of the target to proxy [default: None] [required]                                                           │
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
╭─ Options ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ --proto                 [tcp|http]  The protocol to proxy [default: tcp]                                                                            │
│ --from-address          TEXT        The address of the local server [default: None]                                                                 │
│ --from-port             INTEGER     The port of the local server [default: 7474]                                                                    │
│                 -6                  Use IPv6 for the connection                                                                                     │
│ --help          -h                  Show this message and exit.                                                                                     │
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯

Library usage:

NfProxy decorator

from firegex.nfproxy import pyfilter

This decorator is used to create a filter for the nfproxy. Example:

@pyfilter
def my_filter(raw_packet: RawPacket): #Logging filter
    print(raw_packet.data)

Data handlers

RawPacket

from firegex.nfproxy import RawPacket

This handler will be called every time arrives a packet from the network. It will receive a RawPacket object with the following properties:

  • is_input: bool - It's true if the packet is an input packet, false if it's an output packet
  • is_ipv6: bool - It's true if the packet is an ipv6 packet, false if it's an ipv4 packet
  • is_tcp: bool - It's true if the packet is a tcp packet, false if it's an udp packet
  • data: bytes - The data of the packet assembled and sorted from TCP
  • l4_size: int - The size of the layer 4 data
  • raw_packet_header_len: int - The size of the original packet header
  • l4_data: bytes - The layer 4 payload of the packet
  • raw_packet: bytes - The raw packet with IP and TCP headers

TCPInputStream

Alias: TCPClientStream

from firegex.nfproxy import TCPInputStream

This handler will be called every time a TCP stream is assembled in input. It will receive a TCPInputStream object with the following properties:

  • data: bytes - The data of the packets assembled and sorted from TCP
  • is_ipv6: bool - It's true if the packet is an ipv6 packet, false if it's an ipv4 packet
  • total_stream_size: int - The size of the stream

TCPOutputStream

Alias: TCPServerStream

from firegex.nfproxy import TCPOutputStream

This handler will be called every time a TCP stream is assembled in output. It will receive a TCPOutputStream object with the following properties:

  • data: bytes - The data of the packets assembled and sorted from TCP
  • is_ipv6: bool - It's true if the packet is an ipv6 packet, false if it's an ipv4 packet
  • total_stream_size: int - The size of the stream

HttpRequest

from firegex.nfproxy import HttpRequest

This handler will be called twice: one for the request headers and one for the request body. It will receive a HttpRequest object with the following properties:

  • method: bytes - The method of the request
  • url: str - The url of the request
  • headers: dict - The headers of the request
  • user_agent: str - The user agent of the request
  • content_encoding: str - The content encoding of the request
  • body: bytes - The body of the request
  • headers_complete: bool - It's true if the headers are complete
  • message_complete: bool - It's true if the message is complete
  • http_version: str - The http version of the request
  • keep_alive: bool - It's true if the request should keep alive
  • should_upgrade: bool - It's true if the request should upgrade
  • content_length: int - The content length of the request
  • get_header(header: str, default=None): str - Get a header from the request without caring about the case
  • total_size: int - The total size of the stream
  • stream: bytes - The stream of the request

HttpRequestHeader

from firegex.nfproxy import HttpRequestHeader

This handler will be called only when the request headers are complete. It will receive a HttpRequestHeader object with the same properties as HttpRequest.

HttpFullRequest

from firegex.nfproxy import HttpFullRequest

This handler will be called only when the request is complete. It will receive a HttpFullRequest object with the same properties as HttpRequest.

HttpResponse

from firegex.nfproxy import HttpResponse

This handler will be called twice: one for the response headers and one for the response body. It will receive a HttpResponse object with the following properties:

  • status_code: int - The status code of the response
  • url: str - The url of the response
  • headers: dict - The headers of the response
  • user_agent: str - The user agent of the response
  • content_encoding: str - The content encoding of the response
  • body: bytes - The body of the response
  • headers_complete: bool - It's true if the headers are complete
  • message_complete: bool - It's true if the message is complete
  • http_version: str - The http version of the response
  • keep_alive: bool - It's true if the response should keep alive
  • should_upgrade: bool - It's true if the response should upgrade
  • content_length: int - The content length of the response
  • get_header(header: str, default=None): str - Get a header from the response without caring about the case
  • total_size: int - The total size of the stream
  • stream: bytes - The stream of the response

HttpResponseHeader

from firegex.nfproxy import HttpResponseHeader

This handler will be called only when the response headers are complete. It will receive a HttpResponseHeader object with the same properties as HttpResponse.

HttpFullResponse

from firegex.nfproxy import HttpFullResponse

This handler will be called only when the response is complete. It will receive a HttpFullResponse object with the same properties as HttpResponse.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

firegex-3.4.5.tar.gz (18.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

firegex-3.4.5-py3-none-any.whl (20.3 kB view details)

Uploaded Python 3

File details

Details for the file firegex-3.4.5.tar.gz.

File metadata

  • Download URL: firegex-3.4.5.tar.gz
  • Upload date:
  • Size: 18.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.23

File hashes

Hashes for firegex-3.4.5.tar.gz
Algorithm Hash digest
SHA256 2d9c6012dc729a1c639c2cbc574d7cad9857e5ab8753ce739051bd516f4df9c2
MD5 d0bb2a6494dc89e0739b1e81f047fa67
BLAKE2b-256 02cb3c99c1a4baad6bcf0b8a6d78d8f0c2b4c7981afddc89846ed5c7afbca686

See more details on using hashes here.

File details

Details for the file firegex-3.4.5-py3-none-any.whl.

File metadata

  • Download URL: firegex-3.4.5-py3-none-any.whl
  • Upload date:
  • Size: 20.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.23

File hashes

Hashes for firegex-3.4.5-py3-none-any.whl
Algorithm Hash digest
SHA256 91e1f4286b5fd7ac68551244d1816348fcf0660eaa3ffe80dacd24e9f873165e
MD5 a7a15b01fbb566dfa89a7a7ad503f2c1
BLAKE2b-256 2f9ba882707801d49b058e513d5cd93b8f45361a3a81627fa8ce15ba72987a26

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page