How jofpin/trape works
Project type and purpose
• Trape is a monolithic, full-stack Python web application designed for real-time OSINT tracking and social-engineering attacks.
• It combines a CLI entry-point (trape.py) with an HTTP/WS server, a small “database” layer, a dynamic front-end, and integration with external services (ngrok, target-site cloning, REST APIs).
File structure
Top-level
– trape.py ← CLI entry-point, starts the server
– requirements.txt ← Python dependencies
– static/ ← CSS, JS, image assets that run in the browser
– templates/ ← HTML views (login, home, error)
– core/ ← Python modules that implement business logic
• db.py ← data-storage interface (in-memory or flat files)
• sockets.py ← WebSocket server for real-time events
• ngrok.py ← wrapper to manage public tunnels
• user*.py ← user/session modeling
• stats.py ← data-aggregation and reporting
• trape.py ← core HTTP server/router and request handlers
• utils.py ← shared helper functions
Key insights from README
• Real-time geolocation + path tracking (JS → WS → Python → JS)
• REST API injection for remote control & social engineering
• Public tunnel management via ngrok API
• Two distinct user-flows:
a) Operator’s panel (login → dashboard → live data)
b) Victim’s browser (cloned page with injected JS hooks)
Main components
A. Actors (external)
1. Operator (security researcher)
2. Victim (target’s browser)
B. Backend (Python, single process)
1. CLI/Launcher (trape.py, core/trape.py)
2. HTTP Server (Flask/Custom router in core/trape.py)
3. WebSocket Server (core/sockets.py)
4. Data Store (core/db.py + in-memory structures)
5. Modules: ngrok manager, stats engine, user/session manager
C. Frontend (served static assets)
1. HTML Templates (templates/*.html)
2. JavaScript bundles (static/js/*.js)
D. External Services
1. ngrok.com API (public tunnel)
2. Cloned target website (--url)
3. Optional REST endpoints (speech, remote JS via --injectcode)
Relationships and interactions
1. Operator CLI invokes trape.py → starts HTTP + WS server
2. Operator’s browser ↔ HTTP (login, dashboard, REST API calls)
3. Server ↔ Data Store (CRUD of session, stats, hook logs)
4. Victim’s browser ↔ HTTP (serves cloned page + injected JS)
5. Victim’s browser ↔ WebSocket (push events: geolocation, network info, keylogger data)
6. Server ↔ ngrok API (manage public forwarding)
7. Server → External cloned URL (if --url is used)
Architectural patterns & design principles
• Monolithic client-server with clear separation of concerns:
– HTTP routing vs. WS routing
– Business logic (core/) vs. presentation (templates/static/)
• Event-driven real-time updates via WebSockets
• Plugin-style modules for extensibility (ngrok, speech, injection)
• Minimal persistence layer for captured data
Relevant technologies & libraries
• Python 3 (core application)
• colorama (CLI coloring)
• urllib2 shim (core/dependence)
• WebSockets (real-time comms)
• HTML5 geolocation & Web Speech (client JS APIs)
• ngrok.com API (public tunnels)
• Vanilla JS/CSS for frontend