Wire Shodan watcher to trigger container‑level persona swaps#53
Open
Divyateja2709 wants to merge 72 commits intoOWASP:masterfrom
Open
Wire Shodan watcher to trigger container‑level persona swaps#53Divyateja2709 wants to merge 72 commits intoOWASP:masterfrom
Divyateja2709 wants to merge 72 commits intoOWASP:masterfrom
Conversation
Added optional CRS update logic and improved logging for background processes.
Added initial README.md for CRS Auto Update script with planned features and assumptions.
Removed comment about Sidekick code generation.
Added logging and process management for Apache and Filebeat.
Updated the script to enforce SHA256 checksum format and added timeout options for curl and wget commands.
Updated filebeat configuration path to absolute path.
Updated Dockerfile to include TARGETARCH argument and modified file paths.
Added headers to prevent HTTP_PROXY leakage and set authentication headers.
Add a test script to verify the existence of bundled CRS paths and includes in the Docker container.
This script tests the successful update of the CRS within a Docker container, ensuring that the configuration remains valid and usable after the update.
Refactor test script for CRS update to use unique identifiers and validate fixture installation.
This script tests the behavior of the CRS update when the updater is disabled, ensuring that the status reflects 'skipped' and that the bundled CRS files remain intact.
Add a test script to verify fallback behavior during CRS update download failure.
This script tests the fallback behavior of the CRS updater when the SHA256 checksum does not match the expected value. It verifies that the bundled CRS remains unchanged and that the correct status is recorded.
This script tests the behavior of the CRS update process when a lock is held by another instance. It verifies that the update is skipped and the bundled CRS remains intact.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hi @adrianwinckles,
Following PR9 (which introduced separate WordPress and Drupal persona containers behind the ModSecurity WAF), this PR connects the personas to the external stimulus you described — the Shodan API — and removes the old in‑container persona swapping.
What this PR adds
shodan_watcher.py (new):
Periodically discovers the container’s public IP (via ipify) and queries the Shodan API for that IP.
Looks for honeypot‑style tags and keywords in the Shodan response.
When the honeypot appears fingerprinted, rotates through the configured personas (generic → wordpress → drupal → …) and calls swap_persona.sh to perform a real Docker container swap.
Logs its actions so behaviour is visible via docker logs.
What this PR changes
modsec_entry.sh:
Removes the previous in‑container persona loading logic (copying persona HTML and ModSecurity config into the Apache document root).
Keeps the CRS auto‑update and process supervision (Apache, log preprocessor, Filebeat) behaviour.
Starts shodan_watcher.py in the background when SHODAN_API_KEY is set, and shuts it down cleanly when the container stops.
Dockerfile:
Adds environment defaults for SHODAN_API_KEY and SHODAN_POLL_INTERVAL.
Copies shodan_watcher.py into /app and the scripts/ directory into /app/scripts/, and ensures swap_persona.sh is executable so the watcher can trigger container swaps.
sample-env:
Documents SHODAN_API_KEY and SHODAN_POLL_INTERVAL so Shodan integration can be enabled via environment variables without changing the image.
What stays unchanged
scripts/swap_persona.sh from PR9 still handles stopping all persona containers and starting the selected one.
All persona implementations (generic, wordpress, drupal) and CRS/ModSecurity rules remain untouched.
With PR9 (persona containers) and this PR10 (Shodan‑driven swapping), the honeypot now has a chameleon variant that changes its visible application persona by swapping Docker containers when Shodan reveals it as a honeypot, as described in the project idea.