load_custom_payloads_from_file
Load custom SQL injection payloads from a file to use in scanning. Specify the injection type, database type, and cache name for later reuse.
Instructions
Load custom SQL injection payloads from a file.
Args: file_path: Absolute path to the payload file (one payload per line) injection_type: Injection type for loaded payloads database_type: Database type for loaded payloads name: Name to cache the payloads under for later use
Returns: Information about loaded payloads
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| file_path | Yes | ||
| injection_type | No | error_based | |
| database_type | No | generic | |
| name | No | custom |
Implementation Reference
- src/sqli_mcp/server.py:400-443 (handler)The handler function for the 'load_custom_payloads_from_file' MCP tool. Decorated with @mcp.tool(), it loads custom SQL injection payloads from a file by delegating to 'load_custom_payloads' helper, caches them, and returns success/error info.
@mcp.tool() def load_custom_payloads_from_file( file_path: str, injection_type: str = "error_based", database_type: str = "generic", name: str = "custom" ) -> dict: """ Load custom SQL injection payloads from a file. Args: file_path: Absolute path to the payload file (one payload per line) injection_type: Injection type for loaded payloads database_type: Database type for loaded payloads name: Name to cache the payloads under for later use Returns: Information about loaded payloads """ try: payloads = load_custom_payloads( file_path, InjectionType(injection_type), DatabaseType(database_type) ) custom_payloads_cache[name] = payloads return { "success": True, "name": name, "count": len(payloads), "preview": [p.value for p in payloads[:5]], "message": f"Loaded {len(payloads)} custom payloads from {file_path}" } except FileNotFoundError: return { "success": False, "error": f"File not found: {file_path}" } except Exception as e: return { "success": False, "error": str(e) } - src/sqli_mcp/server.py:401-406 (schema)The function signature defines the input schema for the tool: file_path (str), injection_type (str, default 'error_based'), database_type (str, default 'generic'), and name (str, default 'custom'). The return type is dict.
def load_custom_payloads_from_file( file_path: str, injection_type: str = "error_based", database_type: str = "generic", name: str = "custom" ) -> dict: - src/sqli_mcp/server.py:400-400 (registration)The tool is registered using the @mcp.tool() decorator on the function, which registers it with the FastMCP server instance.
@mcp.tool() - The 'load_custom_payloads' helper function reads payloads from a file (one per line, skipping comments) and returns a list of Payload objects. This is the core logic called by the tool handler.
def load_custom_payloads( file_path: str, injection_type: InjectionType = InjectionType.ERROR_BASED, database_type: DatabaseType = DatabaseType.GENERIC ) -> list[Payload]: """ Load custom payloads from a file (one payload per line). Args: file_path: Path to the file containing payloads injection_type: Default injection type for loaded payloads database_type: Default database type for loaded payloads Returns: List of Payload objects """ path = Path(file_path) if not path.exists(): raise FileNotFoundError(f"Payload file not found: {file_path}") payloads = [] with open(path, "r", encoding="utf-8") as f: for line_num, line in enumerate(f, 1): line = line.strip() if line and not line.startswith("#"): # Skip empty lines and comments payloads.append(Payload( value=line, injection_type=injection_type, database_type=database_type, description=f"Custom payload from {path.name}:{line_num}" )) return payloads