How 0x727/chkapi_0x727 works
Project Type and Purpose
• ChkApi is a Python-based CLI tool for automated API security scanning.
• It orchestrates a pipeline of plugins to extract URLs, discover API endpoints, run fuzzing and parameterized requests, apply bypass techniques, and aggregate results into text or Excel outputs.
File Structure Analysis
• Top-level:
• ChkApi.py – the CLI entry point and orchestration engine.
• build.sh – environment setup (chromedriver install).
• requirements.txt – Python dependencies.
• plugins/ – plugin modules plus rule config files.
• plugins/ directory: each .py implements one stage (URL extraction, JS/static URL find, API path finding, request runners, parameter extractors, result disposal, Excel export) plus two YAML rule sets.
Architectural Patterns
• Plugin Pipeline Pattern: ChkApi.py dynamically loads and invokes plugins in a fixed sequence.
• Layered Approach:
• Input Layer (CLI args)
• Orchestration Layer (ChkApi.py)
• Plugin Processing Layer (plugins/*.py)
• Persistence Layer (text/Excel outputs)
• Core design emphasizes extensibility: new plugins or rules can be added under plugins/.
Main Components and Interactions
a. CLI Interface (ChKApi.py)
• Parses arguments, kicks off scan.
• Loads rule configs (rule.yaml, sensitive_data_rule.yaml).
• Dynamically discovers and orders plugins.
b. Web Driver Module (plugins/webdriverFind.py)
• Uses Selenium/chromedriver to load target URL.
• Extracts automatic JS and static assets.
c. URL & JS Processor (plugins/jsAndStaticUrlFind.py)
• Fetches pages/JS files over HTTP.
• Normalizes and deduplicates URLs.
d. API Discovery
• Regex-based path finder (plugins/apiPathFind.py).
• Swagger parser (nodeCommon.py + rule.yaml).
• Fuzz tester (plugins/apiUrlReqNoParameter.py + apiUrlReqWithParameter.py).
e. Parameter Extraction (plugins/getParameter.py)
• Inspects blank-request results to infer parameters.
f. Dynamic Testing
• Requests with extracted parameters in GET, POST form-data, POST JSON.
• Bypass techniques module (plugins/disposeResults.py).
g. Result Aggregation & Export
• Sensitive data filter via sensitive_data_rule.yaml.
• Save to Excel (plugins/saveToExcel.py) and text files.
h. External Services & Dependencies
• Selenium/chromedriver
• Internet access to target site(s)
• Python libraries (requests, openpyxl, PyYAML, etc.)
[User/CLI] → [ChkApi Orchestrator] → [Plugin Pipeline] → [Data Store/Outputs]
1. webdriverFind → 2. jsAndStaticUrlFind → 3. apiPathFind & Swagger Parser → 4. apiUrlReqNoParameter & apiUrlReqWithParameter → 5. getParameter → 6. apiUrlReqWithParameter (param-driven) → 7. disposeResults (Bypass) → 8. saveToExcel
• Blue rectangles: core components (CLI, orchestrator)
• Green rectangles: plugins
• Gray clouds: external dependencies (chromedriver, target website)
• Enclose rule files (rule.yaml, sensitive_data_rule.yaml) as config artifacts feeding into discovery and filtering plugins.