
एक बार जब छोटे scripts बनने लगें, तो अगला कदम है उन्हें एक framework में जोड़ना — जहाँ हर काम का अलग module हो, एक command से चले और output एक जगह सेव हो। यही तरीका बड़े pentest में समय बचाता है।
Framework का ढाँचा
recon/
__init__.py
dns.py
ports.py
report.py
main.py
config.json
हर module का एक ही काम हो — dns.py सिर्फ़ DNS, ports.py सिर्फ़ ports। इससे code पढ़ना, test करना और बदलना आसान रहता है।
Main script
import argparse
from recon import dns, ports
parser = argparse.ArgumentParser()
parser.add_argument("module", choices=["dns", "ports"])
parser.add_argument("target")
args = parser.parse_args()
if args.module == "dns":
result = dns.run(args.target)
else:
result = ports.run(args.target)
print(result)
यही pattern बढ़ाकर आगे और modules जोड़े जा सकते हैं — headers, subdomain, report।
Config और logging
- config.json: timeout, threads, output folder — code में hardcode न करें।
- logging: हर module अपना log लिखे, समय के साथ।
- JSON output: हर module एक ही structure में result दे, ताकि report बने।
- Error handling: एक module fail हो तो बाकी न रुकें।
Safe defaults
Framework का default धीमा और सुरक्षित रखें — कम threads, लंबा timeout और rate limit। तेज़ scanning का option explicit हो, ताकि गलती से production पर भार न पड़े। साथ में हर run से पहले scope की जाँच करने वाला step रखें।
Version control
Git से हर बदलाव track करें। Framework बढ़ने पर पुराना काम करने वाला version वापस पाना आसान होता है। README में हर module का उदाहरण लिखें — छह महीने बाद आप खुद भूल जाएँगे।
- एक module, एक काम
- Config, logging और JSON output पहले से तय
- Default settings धीमे और सुरक्षित
- Scope check हर run में
दो modules वाला छोटा framework बनाएँ — एक DNS lookup, एक port check। दोनों का result एक ही JSON में जोड़ें।