# vaginessa/qrljacking architecture

> Architecture diagram of the GitHub repository vaginessa/qrljacking, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-06-05). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/vaginessa/qrljacking
- Repository: https://github.com/vaginessa/qrljacking

## Overview

##### Project Type and Purpose
- This repository is an open-source security tool and exploitation framework (QRLJacking Framework) with example phishing templates.
- Its purpose is to demonstrate and automate the QRLJacking attack vector: hijacking “Login with QR code” sessions by proxying, cloning, and serving attacker-controlled QR codes.

##### File-Structure Analysis
- Top-level components:
- QrlJacking-Framework/ – Python-based core framework (QRLJacker.py, Data/Custom.ini, requirements.txt).
- Templates-Examples/ – Example modules and phishing page templates (All-in-one module, WhatsApp Web, etc.).
- Standalone demo files (WhatsAppQRJackingModule.js, phishing.html, qrHandler.php) for quick manual use.
- The framework follows a plug-in pattern: modules in Templates-Examples or custom JS files injected via Greasemonkey.
- Deployment artifacts: qrHandler.php (converts base64 strings to tmp.jpg), storeQR.php (example of QR persistence).

##### Key Insights from README
- Two logical sides:
a) Server Side – hosts phishing page, serves cloned QR images.
b) Client Side – injects code into target site to hijack the QR payload in real time.
- Supports manual (Greasemonkey) and automated (QRLJacker.py) modes.
- Examples focus on WhatsApp Web, but any QR-login service is vulnerable.

##### Components
A. Attacker Infrastructure
1. QRLJacking Framework (Python)
- QRLJacker.py: WebSocket/HTTP proxy trapping QR data.
- Data/Custom.ini: Configuration (target URL, ports).
- requirements.txt: Dependencies (e.g., flask, socketIO).
2. Phishing Server (PHP)
- qrHandler.php: Converts incoming base64 → tmp.jpg.
- phishing.html/storeQR.php: Phishing page serving tmp.jpg and capturing session.
3. Greasemonkey Module (JS)
- WhatsAppQRJackingModule.js (or other modules): Injects into victim’s browser to intercept the QR from the legitimate site.

B. Victim Environment
- Victim’s Browser on web.whatsapp.com (or other target service).
- Scans attacker-controlled QR on phishing page.

C. Target Service
- Legitimate WebSocket endpoint on web.whatsapp.com delivering QR challenge.

##### Relationships and Data Flow
1. Framework proxy opens a WebSocket to the real target service and injects into it, capturing the live QR base64.
2. QRLJacker.py pushes the base64 to the phishing server’s qrHandler.php via HTTP POST.
3. qrHandler.php writes tmp.jpg to the phishing root.
4. Victim accesses phishing.html which poll-loads tmp.jpg.
5. Victim scans QR; whose session cookie is bound to the attacker’s proxied WebSocket.
6. Attacker’s QRLJacker.py now controls the session and can issue API calls or extract cookies.

- Real Target → Framework Proxy (WebSocket)
- Framework → qrHandler.php (HTTP POST)
- Phishing Page → tmp.jpg (HTTP GET polling)
- Victim Mobile App → Legitimate Service (QR scan)
- Legitimate Service → Framework Proxy (authenticated session flow)

##### Architectural Patterns and Principles
- **Proxy Pattern**: QRLJacker acts as middleware between victim and real service.
- **Plugin/Module Architecture**: Templates-Examples folder demonstrates how new modules (JS files + HTML/PHP) can be dropped in.
- **Separation of Concerns**:
- Python side handles communication and WebSocket hijacking.
- PHP side handles presentation and image conversion.
- JS side handles in-browser injection.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Attacker Infrastructure
    subgraph "Attacker Infrastructure"
        direction TB
        subgraph "QRLJacking Framework (Python Core)" 
            direction TB
            QRLJ["QRLJacker.py"]:::attackerComp
            Config["Custom.ini"]:::attackerComp
            Req["requirements.txt"]:::attackerComp
            ReadmeCore["Readme.md"]:::attackerComp
        end
        QRH["qrHandler.php"]:::attackerComp
        PHISH_ROOT["phishing.html"]:::attackerComp
        GM["WhatsAppQRJackingModule.js"]:::attackerComp
        subgraph "Templates-Examples"
            direction TB
            subgraph "All-in-one Module"
                direction TB
                AIO_JS["QRLJackingAll.js"]:::attackerComp
                AIO_PH["phishing.html"]:::attackerComp
                AIO_STORE["storeQR.php"]:::attackerComp
            end
            subgraph "WhatsApp Web Module"
                direction TB
                WA_JS["WhatsAppQRJackingModule.js"]:::attackerComp
                WA_PH["phishing.html"]:::attackerComp
                WA_STORE["storeQR.php"]:::attackerComp
            end
        end
    end

    %% Victim Environment
    subgraph "Victim Environment"
        direction TB
        VictimBrowser["Victim Browser"]:::victimComp
        VictimMobile["Victim Mobile App"]:::victimComp
    end

    %% Target Service
    subgraph "Legitimate Service (Target Service)"
        direction TB
        TargetService["WebSocket Endpoint"]:::targetComp
    end

    %% Data Flows
    TargetService -->|"WebSocket QR stream"| QRLJ
    QRLJ -->|"POST base64"| QRH
    QRH -->|"writes tmp.jpg"| PHISH_ROOT
    VictimBrowser -->|"GET tmp.jpg poll"| PHISH_ROOT
    VictimMobile -->|"scans QR"| TargetService
    TargetService -->|"authenticated session"| QRLJ
    GM -->|"inject JS"| VictimBrowser
    AIO_JS -->|"extension point"| QRLJ
    WA_JS -->|"extension point"| QRLJ

    %% Click Events
    click QRLJ "https://github.com/vaginessa/qrljacking/blob/master/QrlJacking-Framework/QRLJacker.py"
    click Config "https://github.com/vaginessa/qrljacking/blob/master/QrlJacking-Framework/Data/Custom.ini"
    click Req "https://github.com/vaginessa/qrljacking/blob/master/QrlJacking-Framework/requirements.txt"
    click ReadmeCore "https://github.com/vaginessa/qrljacking/blob/master/QrlJacking-Framework/Readme.md"
    click PHISH_ROOT "https://github.com/vaginessa/qrljacking/blob/master/phishing.html"
    click QRH "https://github.com/vaginessa/qrljacking/blob/master/qrHandler.php"
    click GM "https://github.com/vaginessa/qrljacking/blob/master/WhatsAppQRJackingModule.js"
    click AIO_JS "https://github.com/vaginessa/qrljacking/blob/master/Templates-Examples/All-in-one module/QRLJackingAll.js"
    click AIO_PH "https://github.com/vaginessa/qrljacking/blob/master/Templates-Examples/All-in-one module/phishing.html"
    click AIO_STORE "https://github.com/vaginessa/qrljacking/blob/master/Templates-Examples/All-in-one module/storeQR.php"
    click WA_JS "https://github.com/vaginessa/qrljacking/blob/master/Templates-Examples/WhatsApp Web/WhatsAppQRJackingModule.js"
    click WA_PH "https://github.com/vaginessa/qrljacking/blob/master/Templates-Examples/WhatsApp Web/phishing.html"
    click WA_STORE "https://github.com/vaginessa/qrljacking/blob/master/Templates-Examples/WhatsApp Web/storeQR.php"
    click ReadmeRoot "https://github.com/vaginessa/qrljacking/blob/master/README.md"

    %% Styles
    classDef attackerComp fill:#f8d7da,stroke:#721c24;
    classDef victimComp fill:#d1ecf1,stroke:#0c5460;
    classDef targetComp fill:#d4edda,stroke:#155724;
```
