Over the years, we’ve helped countless organizations recover from compromises. Surprisingly, many breaches
are discovered by chance rather than deliberate detection. A common scenario involves finding anomalies during
routine investigations, leading to the discovery of hidden threats.
Take this classic example: “While looking for A, I stumbled upon B, which shouldn’t be there, and uncovered C,
revealing we’ve been hacked.”
In some cases, breaches aren’t even discovered internally. External parties, such as law enforcement or attackers
themselves (e.g., during ransom demands), often alert organizations to their vulnerabilities. This occurs even in
companies with robust cybersecurity budgets and cutting-edge tools.
To stay ahead of such scenarios, organizations must adopt exploratory or unstructured threat hunting. This involves
dedicating time to actively search for anomalies, suspicious activities, or indicators of compromise. While traditional
threat hunting can start with alerts from tools like IDS/IPS or WAF, this guide emphasizes exploratory hunts, where you start
from scratch to uncover hidden threats.
Before diving into threat hunting, you must establish a strong foundation. Without proper groundwork, your efforts may lack
critical data. Here’s what you need to prepare:
These are some of the items you need to have before you start your threat hunting:
Effective threat hunting begins with knowing what to look for and where to find it. By examining patterns and behaviors in your logs, you can uncover hidden threats that automated tools might miss. This section focuses on practical techniques to identify anomalies, unauthorized access, and other suspicious activities. Whether it’s tracking unusual system user logins or detecting failed logins followed by success, these strategies will help you proactively protect your organization from cyber threats.
System users (e.g., daemon, bin, sys, nobody) should never log in. Investigate any instances where they do. Use tools like grep to identify anomalies in authentication logs:
zcat /var/log/central.auth.log*.gz | grep -E "Accepted [a-z]+ for (daemon|bin|sys|www-data|nobody|...)"
Review successful logins to systems where users have no business need. For example:
cat all-logs* | grep -E "Accepted (password|publickey) for" | cut -d ":" -f 3- | cut -d " " -f 2,7 | sort | uniq -c
These logs reveal user-to-server relationships, helping you identify unauthorized access attempts.
For local organizations, track logins outside standard business hours (e.g., 10 PM to 5 AM). This can uncover malicious activity with minimal false positives. Use SIEM tools or custom scripts to create time-based alerts.
Encourage SSH logins via keys and flag password-based logins as potential violations of security policy:
grep "Accepted password for" /var/log/auth.log
Attackers often mask their IP addresses using proxies or Tor. Leverage reputation databases (e.g., NOC Reputation API) to flag suspicious IPs:
for ip in $(cat list-of-ips); do curl -s "https://reputation.noc.org/api/?ip=$ip" | grep true; done
Use GeoIP data to flag logins from unexpected countries or impossible locations (e.g., logins from the US and Europe within hours). Anomalies in IP ranges can also reveal unauthorized activity.
Track repeated failed login attempts followed by a successful login. This could indicate brute-force attacks:
grep "Failed password for" /var/log/auth.log | cut -d " " -f 1-2 | uniq -c
Threat hunting is proactive, enabling organizations to uncover hidden threats before they escalate into breaches. Unlike reactive measures, which rely on alerts triggered after malicious activity, threat hunting actively seeks anomalies in patterns, behaviors, and network logs. This approach uncovers:
Threat hunting is not a one-time task—it’s an ongoing process that evolves as your organization’s infrastructure and threat landscape
change. By analyzing logs creatively and methodically, you can stay ahead of attackers and strengthen your security posture.
If you’re looking for a reliable centralized logging solution, check out Trunc to streamline your log collection and analysis. Have your
own threat-hunting tips? Share them with us!
Stay vigilant and happy hunting!