Skip to content

About

Java Spring Boot service for concurrent HTTP HEAD brute-force enumeration of predictable image URLs with HikariCP, MySQL, Spring Data JPA, and REST APIs.

Topics

Resources

Stars

2 stars

Watchers

1 watching

Forks

Repository files navigation

Brute Force Attack — Concurrent Image URL Enumerator

License: MIT Java Spring Boot Gradle MySQL

A lightweight Java Spring Boot application for scheduled, multi-threaded HTTP HEAD brute-force enumeration of predictable date-indexed image URLs (YYYY/MM/DD/IMG_XXXX.jpg), persisting discovered image records in MySQL via Spring Data JPA and HikariCP, and serving paginated results and health metrics over REST APIs.

Note: The original legacy version (Java 8, Spring Boot 2.1.9, Gradle 5.6.2) is archived under release v0.1.0-legacy.

Disclaimer: This project is provided strictly for educational and security-research purposes (such as demonstrating the risks of sequential, predictable asset URLs). Only probe hosts you own or have explicit authorization to test.

Key Features

  • Scheduled Brute-Force URL Enumeration: Uses Spring @Scheduled (ProcessImagesSchedule) to generate candidate date-based image paths (YYYY/MM/DD/IMG_0001 through IMG_9999) for configured HostInfo targets on an hourly cycle with an overlap guard.
  • High-Concurrency HTTP HEAD Probing: Dispatches lightweight HTTP HEAD requests (XUtils.isOk) across a configurable ThreadPoolTaskExecutor (50 core threads, up to 150 max threads) to detect existing assets returning HTTP 200.
  • Database Deduplication & Persistence: Checks candidate composite keys (domain, file_name) against MySQL via ImageRepo.findAllById before probing, and stores valid records (domain, file_name, thumbnail, file_url, created_at) using Spring Data JPA and Hibernate.
  • HikariCP Connection Pooling: Configures HikariDataSource (DbConfig / DataSourceUtils) with prepared-statement caching, connection leak detection, and tunable pool sizes.
  • REST API & Health Check: Exposes paginated image listings (GET /api/v1/images) sorted by createdAt descending, plus a GET /healthcheck endpoint that validates MySQL connectivity (SELECT 1) and reports JVM heap memory usage.

Tech Stack

  • Language: Java 17
  • Framework: Spring Boot 3.4.13 (Web, Data JPA, Scheduling, DevTools)
  • Database & Pool: MySQL (com.mysql:mysql-connector-j), Hibernate JPA (Jakarta Persistence), HikariCP (hsqldb on runtime classpath)
  • Utilities: Apache Commons Lang3 3.20.0, Apache Commons Text 1.15.0, Apache Commons IO 2.22.0
  • Build & Test: Gradle 8.11.1 (with Gradle Wrapper), JUnit 5

Project Structure

brute-force-attack/
├── build.gradle
├── gradle.properties
├── settings.gradle
├── gradlew / gradlew.bat
└── src/
    ├── main/
    │   ├── java/com/kuku/bruteforceattack/
    │   │   ├── Application.java                          # Spring Boot entry point (@EnableScheduling)
    │   │   ├── common/domain/PageInfo.java               # Pagination helper and page-range calculator
    │   │   ├── components/
    │   │   │   ├── host/domain/HostInfo.java             # Target host domain and base URL model
    │   │   │   └── images/
    │   │   │       ├── api/Get.java                      # GET /api/v1/images REST controller
    │   │   │       ├── domain/Image.java                 # JPA entity & composite key (domain, file_name)
    │   │   │       └── domain/ImageRepo.java             # Spring Data JPA repository & specifications
    │   │   ├── infra/
    │   │   │   ├── api/HealthCheck.java                  # GET /healthcheck (SQL + JVM heap metrics)
    │   │   │   └── config/
    │   │   │       ├── job/ProcessImagesSchedule.java    # Scheduled URL enumeration job
    │   │   │       ├── mysql/DbConfig.java               # HikariCP DataSource & JdbcTemplate beans
    │   │   │       ├── mysql/JpaConfig.java              # Hibernate EntityManagerFactory & TxManager
    │   │   │       └── thread/ThreadConfig.java          # Async ThreadPoolTaskExecutor & TaskScheduler
    │   │   └── utils/
    │   │       ├── DataSourceUtils.java                  # HikariConfig factory with MySQL statement cache
    │   │       └── XUtils.java                           # HTTP HEAD status-code probing utilities
    │   └── resources/
    │       ├── application.properties
    │       └── application.yml                           # Server port (1900), JDBC, JPA, logging config
    └── test/
        └── java/com/kuku/bruteforceattack/
            └── BruteForceAttackApplicationTests.java     # Spring Boot context load test

API Endpoints

Method Endpoint Description Query Parameters
GET /api/v1/images Returns paginated discovered Image records ordered by createdAt descending. page (default 1), size (default 10, valid range 1–199), q (optional)
GET /healthcheck Runs SELECT 1 against MySQL and returns JVM heap memory statistics (in MB). None

Prerequisites

  • JDK 17 (configured via Gradle Java Toolchain)
  • MySQL server (accessible at the host/database configured in application.yml)

Getting Started

  1. Clone the repository

    git clone https://github.com/sinhsac/brute-force-attack.git
    cd brute-force-attack
  2. Prepare the MySQL database

    Create the target database and the images table matching the Image JPA entity:

    CREATE TABLE IF NOT EXISTS images (
      domain     VARCHAR(255) NOT NULL,
      file_name  VARCHAR(255) NOT NULL,
      thumbnail  VARCHAR(512),
      file_url   VARCHAR(512),
      created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
      PRIMARY KEY (domain, file_name)
    );
  3. Configure application settings

    Update src/main/resources/application.yml (or supply Spring Boot command-line/environment overrides) with your MySQL connection details and pool settings:

    server:
      port: 1900
    
    jdbc:
      dbhost: localhost:3306
      dbname: your_database
      username: your_username
      password: your_password
      poolSize:
        normal: 500
        bulk: 1
  4. Run the application

    ./gradlew bootRun

    On Windows:

    gradlew.bat bootRun

    Once started on port 1900, verify the service:

    curl http://localhost:1900/healthcheck
    curl "http://localhost:1900/api/v1/images?page=1&size=10"
  5. Build and run tests

    ./gradlew build
    ./gradlew test

License

This project is licensed under the MIT License — see the LICENSE file for details.

About

Java Spring Boot service for concurrent HTTP HEAD brute-force enumeration of predictable image URLs with HikariCP, MySQL, Spring Data JPA, and REST APIs.

Topics

Resources

Stars

2 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages