LogHunter is a modular Bash security log analyzer for Linux servers. It parses Apache, Nginx, SSH, auth, secure, journal, and compressed log sources; detects suspicious web activity and brute-force login behavior; and exports terminal, JSON, CSV, and standalone HTML reports.
LogHunter is a defensive log-analysis tool. Analyze only logs and systems you are authorized to access.
- Apache and Nginx access-log statistics: source IPs, methods, URLs, status codes, user agents, referrers, transfer size, and hourly activity.
- SSH/auth analysis: failed logins, accepted logins, invalid users, targeted usernames, root attempts, and source-IP summaries.
- Rule-driven web detection for sensitive files, SQL injection, XSS, command injection, suspicious user agents, and unusual methods.
- Brute-force detection for repeated failures from one IP and username-spraying behavior.
- Optional GeoIP context with local/private IP protection and cache support.
- Large-file friendly line-by-line processing with
--head,--tail, and--max-lines. - Real-time monitoring with
tail -F. - Safe exports using
jqfor JSON plus CSV and escaped standalone HTML.
cd LogHunter
bash loghunter.sh --file examples/auth.log --type ssh --brute-force
bash loghunter.sh --file examples/apache_access.log --type apache --export-html apache-report.htmlLogHunter runs directly from the project folder:
git clone https://github.com/your-name/LogHunter.git
cd LogHunter
chmod +x loghunter.sh install.sh tests/*.sh
./loghunter.sh --helpOptional system install:
sudo ./install.sh /usr/local/bin/loghunterRequired: bash, awk, sed, grep, sort, uniq, date, jq.
Optional: gzip, journalctl, geoiplookup, mmdblookup, curl, column, tput.
Install examples:
# Debian / Ubuntu
sudo apt update && sudo apt install bash gawk sed grep coreutils jq gzip curl geoip-bin
# Fedora
sudo dnf install bash gawk sed grep coreutils jq gzip curl GeoIP
# Arch Linux
sudo pacman -S bash gawk sed grep coreutils jq gzip curl geoip
# Alpine Linux
sudo apk add bash gawk sed grep coreutils jq gzip curl
# macOS
brew install bash gawk jq grep gnu-sed coreutils./loghunter.sh --file /var/log/auth.log
./loghunter.sh --file /var/log/nginx/access.log --type nginx
./loghunter.sh --directory /var/log/nginx/
./loghunter.sh --journal ssh
./loghunter.sh --file access.log --geoip
./loghunter.sh --file auth.log --brute-force --threshold 10 --window 300
./loghunter.sh --file access.log --export-json report.json --export-csv report.csv --export-html report.html
./loghunter.sh --file /var/log/auth.log --watchRun ./loghunter.sh --help for the full option reference. Common controls include --file, --directory, --type, --journal, --since, --until, --ip, --username, --top, --geoip, --brute-force, --threshold, --window, --watch, --export-json, --export-csv, --export-html, --head, --tail, --max-lines, --quiet, --verbose, and --no-color.
Defaults live in config/loghunter.conf. Command-line flags override matching configuration values.
Important settings include:
BRUTE_FORCE_THRESHOLDBRUTE_FORCE_WINDOWUSERNAME_SPRAY_THRESHOLDWEB_REQUEST_RATE_THRESHOLDENABLE_GEOIPGEOIP_DATABASECACHE_DIRECTORYREPORT_DIRECTORYMAX_LINE_LENGTH
Rules live under rules/ and can be edited without changing the main script:
sensitive_paths.txtsql_injection_patterns.txtxss_patterns.txtcommand_injection_patterns.txtsuspicious_user_agents.txtignored_ips.txt
Empty lines and # comments are ignored. Sensitive paths use conservative case-insensitive substring matching; injection and user-agent rules use extended regular expressions.
Use --geoip to enrich unique public IP addresses. LogHunter avoids external lookups for loopback, private, link-local, and reserved local ranges. It prefers local tools such as geoiplookup and falls back to curl only for public IPs.
GeoIP data is context only. LogHunter does not classify an address as malicious because of its country.
- JSON: structured analyzer, analysis, summary, top lists, hourly stats, and alerts.
- CSV: source IP, username, status, and alert summaries.
- HTML: standalone dark report with summary cards, severity badges, top tables, and printable styling.
bash tests/test_apache_parser.sh
bash tests/test_nginx_parser.sh
bash tests/test_ssh_parser.sh
bash tests/test_brute_force.shLogHunter/
loghunter.sh
config/
lib/
rules/
tests/
examples/
install.sh
LICENSE
README.md
Log content is untrusted input. LogHunter avoids eval, avoids dynamically constructed shell commands, validates readable input files, bounds maximum line length, escapes CSV/HTML output, and builds JSON through jq. Keep rule files and configuration under trusted ownership on production servers.