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.
- Scheduled Brute-Force URL Enumeration: Uses Spring
@Scheduled(ProcessImagesSchedule) to generate candidate date-based image paths (YYYY/MM/DD/IMG_0001throughIMG_9999) for configuredHostInfotargets on an hourly cycle with an overlap guard. - High-Concurrency HTTP
HEADProbing: Dispatches lightweight HTTPHEADrequests (XUtils.isOk) across a configurableThreadPoolTaskExecutor(50core threads, up to150max threads) to detect existing assets returning HTTP200. - Database Deduplication & Persistence: Checks candidate composite keys (
domain,file_name) against MySQL viaImageRepo.findAllByIdbefore 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 bycreatedAtdescending, plus aGET /healthcheckendpoint that validates MySQL connectivity (SELECT 1) and reports JVM heap memory usage.
- 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 (hsqldbon runtime classpath) - Utilities: Apache Commons Lang3
3.20.0, Apache Commons Text1.15.0, Apache Commons IO2.22.0 - Build & Test: Gradle
8.11.1(with Gradle Wrapper), JUnit 5
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
| 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 |
- JDK 17 (configured via Gradle Java Toolchain)
- MySQL server (accessible at the host/database configured in
application.yml)
-
Clone the repository
git clone https://github.com/sinhsac/brute-force-attack.git cd brute-force-attack -
Prepare the MySQL database
Create the target database and the
imagestable matching theImageJPA 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) );
-
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
-
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" -
Build and run tests
./gradlew build ./gradlew test
This project is licensed under the MIT License — see the LICENSE file for details.