python3-10.pyscalpel.edit
Scalpel allows choosing between normal and binary editors,
to do so, the user can apply the editor
decorator to the req_edit_in
/ res_edit_int
hook:
1""" 2 Scalpel allows choosing between normal and binary editors, 3 to do so, the user can apply the `editor` decorator to the `req_edit_in` / `res_edit_int` hook: 4""" 5from typing import Callable, Literal, get_args 6 7EditorMode = Literal["raw", "hex", "octal", "binary", "decimal"] 8EDITOR_MODES: set[EditorMode] = set(get_args(EditorMode)) 9 10 11def editor(mode: EditorMode): 12 """Decorator to specify the editor type for a given hook 13 14 This can be applied to a req_edit_in / res_edit_in hook declaration to specify the editor that should be displayed in Burp 15 16 Example: 17 ```py 18 @editor("hex") 19 def req_edit_in(req: Request) -> bytes | None: 20 return bytes(req) 21 ``` 22 This displays the request in an hex editor. 23 24 Currently, the only modes supported are `"raw"`, `"hex"`, `"octal"`, `"binary"` and `"decimal"`. 25 26 27 Args: 28 mode (EDITOR_MODE): The editor mode (raw, hex,...) 29 """ 30 31 if mode not in EDITOR_MODES: 32 raise ValueError(f"Argument must be one of {EDITOR_MODES}") 33 34 def decorator(hook: Callable): 35 hook.__annotations__["scalpel_editor_mode"] = mode 36 return hook 37 38 return decorator
EditorMode =
typing.Literal['raw', 'hex', 'octal', 'binary', 'decimal']
EDITOR_MODES: set[typing.Literal['raw', 'hex', 'octal', 'binary', 'decimal']] =
{'raw', 'binary', 'octal', 'hex', 'decimal'}
def
editor(mode: Literal['raw', 'hex', 'octal', 'binary', 'decimal']):
12def editor(mode: EditorMode): 13 """Decorator to specify the editor type for a given hook 14 15 This can be applied to a req_edit_in / res_edit_in hook declaration to specify the editor that should be displayed in Burp 16 17 Example: 18 ```py 19 @editor("hex") 20 def req_edit_in(req: Request) -> bytes | None: 21 return bytes(req) 22 ``` 23 This displays the request in an hex editor. 24 25 Currently, the only modes supported are `"raw"`, `"hex"`, `"octal"`, `"binary"` and `"decimal"`. 26 27 28 Args: 29 mode (EDITOR_MODE): The editor mode (raw, hex,...) 30 """ 31 32 if mode not in EDITOR_MODES: 33 raise ValueError(f"Argument must be one of {EDITOR_MODES}") 34 35 def decorator(hook: Callable): 36 hook.__annotations__["scalpel_editor_mode"] = mode 37 return hook 38 39 return decorator
Decorator to specify the editor type for a given hook
This can be applied to a req_edit_in / res_edit_in hook declaration to specify the editor that should be displayed in Burp
Example:
@editor("hex")
def req_edit_in(req: Request) -> bytes | None:
return bytes(req)
This displays the request in an hex editor.
Currently, the only modes supported are "raw"
, "hex"
, "octal"
, "binary"
and "decimal"
.
Args: mode (EDITOR_MODE): The editor mode (raw, hex,...)