Edit on GitHub

#  Available Hooks

The following list all available event hooks.

The full Python documentation is available here

events

 1from pyscalpel import Request, Response, Flow, MatchEvent
 2
 3
 4def match(flow: Flow, events: MatchEvent) -> bool:
 5    """- Determine whether an event should be handled by a hook.
 6
 7    - Args:
 8        - flow ([Flow](../pdoc/python3-10/pyscalpel.html#Flow)): The event context (contains request and optional response).
 9        - events ([MatchEvent](../pdoc/python3-10/pyscalpel.html#MatchEvent)): The hook type (request, response, req_edit_in, ...).
10
11    - Returns:
12        - bool: True if the event must be handled. Otherwise, False.
13    """
14
15
16def request(req: Request) -> Request | None:
17    """- Intercept and rewrite a request.
18
19    - Args:
20        - req ([Request](../pdoc/python3-10/pyscalpel.html#Request)): The intercepted request
21
22    - Returns:
23        - [Request](../pdoc/python3-10/pyscalpel.html#Request) or None: The modified request. Otherwise, None to ignore the request.
24    """
25
26
27def response(res: Response) -> Response | None:
28    """- Intercept and rewrite a response.
29
30    - Args:
31        - res ([Response](../pdoc/python3-10/pyscalpel.html#Response)): The intercepted response.
32
33    - Returns:
34        - [Response](../pdoc/python3-10/pyscalpel.html#Response) or None: The modified response. Otherwise, None to ignore the response.
35    """
36
37
38def req_edit_in(req: Request) -> bytes | None:
39    """- Create or update a request editor's content from a request.
40       - May be used to decode a request to plaintext.
41
42    - Args:
43        - req ([Request](../pdoc/python3-10/pyscalpel.html#Request)): The HTTP request.
44
45    - Returns:
46        - bytes or None: The editor's contents.
47    """
48
49
50def req_edit_out(req: Request, modified_content: bytes) -> Request | None:
51    """- Update a request from an editor's modified content.
52       - May be used to encode a request from plaintext (modified_content).
53
54    - Args:
55        - req ([Request](../pdoc/python3-10/pyscalpel.html#Request)): The original request.
56        - modified_content (bytes): The editor's content.
57
58    - Returns:
59        - [Request](../pdoc/python3-10/pyscalpel.html#Request) or None: The new request.
60    """
61
62
63def res_edit_in(res: Response) -> bytes | None:
64    """- Create or update a response editor's content from a response.
65       - May be used to decode a response to plaintext.
66
67    - Args:
68        - res ([Response](../pdoc/python3-10/pyscalpel.html#Response)): The HTTP response.
69
70    - Returns:
71        - bytes or None: The editor contents.
72    """
73
74
75def res_edit_out(res: Response, modified_content: bytes) -> Response | None:
76    """- Update a response from an editor's modified content.
77       - May be used to encode a response from plaintext (modified_content).
78
79    - Args:
80        - res ([Response](../pdoc/python3-10/pyscalpel.html#Response)): The original response.
81        - modified_content (bytes): The editor's content.
82
83    - Returns:
84        - [Response](../pdoc/python3-10/pyscalpel.html#Response) or None: The new response.
85    """
def match( flow: pyscalpel.http.flow.Flow, events: Literal['request', 'response', 'req_edit_in', 'req_edit_out', 'res_edit_in', 'res_edit_out']) -> bool:
 5def match(flow: Flow, events: MatchEvent) -> bool:
 6    """- Determine whether an event should be handled by a hook.
 7
 8    - Args:
 9        - flow ([Flow](../pdoc/python3-10/pyscalpel.html#Flow)): The event context (contains request and optional response).
10        - events ([MatchEvent](../pdoc/python3-10/pyscalpel.html#MatchEvent)): The hook type (request, response, req_edit_in, ...).
11
12    - Returns:
13        - bool: True if the event must be handled. Otherwise, False.
14    """
  • Determine whether an event should be handled by a hook.

  • Args:

    • flow (Flow): The event context (contains request and optional response).
    • events (MatchEvent): The hook type (request, response, req_edit_in, ...).
  • Returns:

    • bool: True if the event must be handled. Otherwise, False.
def request( req: pyscalpel.http.request.Request) -> pyscalpel.http.request.Request | None:
17def request(req: Request) -> Request | None:
18    """- Intercept and rewrite a request.
19
20    - Args:
21        - req ([Request](../pdoc/python3-10/pyscalpel.html#Request)): The intercepted request
22
23    - Returns:
24        - [Request](../pdoc/python3-10/pyscalpel.html#Request) or None: The modified request. Otherwise, None to ignore the request.
25    """
  • Intercept and rewrite a request.

  • Args:

    • req (Request): The intercepted request
  • Returns:

    • Request or None: The modified request. Otherwise, None to ignore the request.
def response( res: pyscalpel.http.response.Response) -> pyscalpel.http.response.Response | None:
28def response(res: Response) -> Response | None:
29    """- Intercept and rewrite a response.
30
31    - Args:
32        - res ([Response](../pdoc/python3-10/pyscalpel.html#Response)): The intercepted response.
33
34    - Returns:
35        - [Response](../pdoc/python3-10/pyscalpel.html#Response) or None: The modified response. Otherwise, None to ignore the response.
36    """
  • Intercept and rewrite a response.

  • Args:

    • res (Response): The intercepted response.
  • Returns:

    • Response or None: The modified response. Otherwise, None to ignore the response.
def req_edit_in(req: pyscalpel.http.request.Request) -> bytes | None:
39def req_edit_in(req: Request) -> bytes | None:
40    """- Create or update a request editor's content from a request.
41       - May be used to decode a request to plaintext.
42
43    - Args:
44        - req ([Request](../pdoc/python3-10/pyscalpel.html#Request)): The HTTP request.
45
46    - Returns:
47        - bytes or None: The editor's contents.
48    """
  • Create or update a request editor's content from a request.

    • May be used to decode a request to plaintext.
  • Args:

  • Returns:

    • bytes or None: The editor's contents.
def req_edit_out( req: pyscalpel.http.request.Request, modified_content: bytes) -> pyscalpel.http.request.Request | None:
51def req_edit_out(req: Request, modified_content: bytes) -> Request | None:
52    """- Update a request from an editor's modified content.
53       - May be used to encode a request from plaintext (modified_content).
54
55    - Args:
56        - req ([Request](../pdoc/python3-10/pyscalpel.html#Request)): The original request.
57        - modified_content (bytes): The editor's content.
58
59    - Returns:
60        - [Request](../pdoc/python3-10/pyscalpel.html#Request) or None: The new request.
61    """
  • Update a request from an editor's modified content.

    • May be used to encode a request from plaintext (modified_content).
  • Args:

    • req (Request): The original request.
    • modified_content (bytes): The editor's content.
  • Returns:

    • Request or None: The new request.
def res_edit_in(res: pyscalpel.http.response.Response) -> bytes | None:
64def res_edit_in(res: Response) -> bytes | None:
65    """- Create or update a response editor's content from a response.
66       - May be used to decode a response to plaintext.
67
68    - Args:
69        - res ([Response](../pdoc/python3-10/pyscalpel.html#Response)): The HTTP response.
70
71    - Returns:
72        - bytes or None: The editor contents.
73    """
  • Create or update a response editor's content from a response.

    • May be used to decode a response to plaintext.
  • Args:

  • Returns:

    • bytes or None: The editor contents.
def res_edit_out( res: pyscalpel.http.response.Response, modified_content: bytes) -> pyscalpel.http.response.Response | None:
76def res_edit_out(res: Response, modified_content: bytes) -> Response | None:
77    """- Update a response from an editor's modified content.
78       - May be used to encode a response from plaintext (modified_content).
79
80    - Args:
81        - res ([Response](../pdoc/python3-10/pyscalpel.html#Response)): The original response.
82        - modified_content (bytes): The editor's content.
83
84    - Returns:
85        - [Response](../pdoc/python3-10/pyscalpel.html#Response) or None: The new response.
86    """
  • Update a response from an editor's modified content.

    • May be used to encode a response from plaintext (modified_content).
  • Args:

    • res (Response): The original response.
    • modified_content (bytes): The editor's content.
  • Returns:

#  ⚠️ Good to know

#  Further reading

Check out the Custom Burp Editors section.