Key Features
- Persistent Sessions: Variables and imports persist across executions
- Multiple Sessions: Run concurrent Python sessions
- IPython Magic: Full support for magic commands (%pip, %time, %%writefile, etc.)
- Proxy Integration: All proxy functions pre-imported in every session
- Security Focus: Ideal for exploit development and pentesting workflows
Common Use Cases
- Security script development and testing (payload generation, exploit scripts)
- Data analysis of security logs, network traffic, or vulnerability scans
- Cryptographic operations and security tool automation
- Interactive penetration testing workflows and proof-of-concept development
- Processing security data formats (JSON, XML, CSV from security tools)
- HTTP proxy interaction for web security testing (all proxy functions are pre-imported)
Parameters
The Python action to perform:
new_session: Create a new Python interpreter session (MUST be first action)execute: Execute Python code in the specified sessionclose: Close the specified session instancelist_sessions: List all active Python sessions
Required for
new_session (as initial code) and execute actions. The Python code to execute.Maximum execution time in seconds for code execution. Applies to both
new_session and execute actions.Unique identifier for the Python session. If not provided, uses the default session ID.
Response
The ID of the session that was operated on
Captured standard output from code execution
Any error message if execution failed
String representation of the last expression result
Time taken to execute the code in seconds
Status message about the action performed
Examples
Basic Session Management
IPython Magic Commands
HTTP Proxy Integration
Long-Running Security Scans
Multiple Sessions
Pre-Imported Proxy Functions
All proxy action functions are automatically imported into every Python session:list_requests()- List and filter captured HTTP requestsview_request()- View request/response detailssend_request()- Send new HTTP request through proxyrepeat_request()- Repeat and modify existing requestsscope_rules()- Manage proxy scope patternslist_sitemap()- View discovered endpointsview_sitemap_entry()- Get sitemap entry details
Important Notes
Persistence: Session instances remain active and maintain their state (variables, imports, function definitions) until explicitly closed with the ‘close’ action.
Code Execution
- Both expressions and statements are supported
- Expressions automatically return their result
- Print statements and stdout are captured
- Variables persist between executions in the same session
- Imports and function definitions persist in the session
Session Management
- Session interaction MUST begin with
new_sessionaction - Only one action can be performed per call
- Each session has its own isolated namespace
- Variables in one session don’t affect others
- Python sessions can operate concurrently with other tools
IPython Features
- Line magics:
%pip,%time,%whos,%pwd, etc. - Cell magics:
%%writefile,%%timeit,%%bash, etc. - Shell commands:
!ls,!cat file.txt, etc. - All standard IPython functionality is available