229 Commits

Author SHA1 Message Date
Ryan Smith
df83ee2c87 Refactor http handler
This change moves the code for preparing the threat feed IP list into a separate function.
2024-11-11 22:08:12 -08:00
Ryan Smith
8820970e33 Optimize filterIPs function
Parse CIDRs once before iterating over `ipList`. This improves performance by avoiding redundant parsing.

Modify `ipList` in place.
2024-11-11 21:38:14 -08:00
Ryan Smith
090868a5dd Allow loopback address access to threat feed
This change allows access to the threat feed locally using a loopback address (http://127.0.0.1:8081)
2024-11-08 13:55:43 -08:00
Ryan Smith
e2b3dc51c5 Switch long arguments to short for better compatibility
Changed all commands that use long arguments to short arguments in the installation script and Makefile. This improves compatibility, as short arguments are more universally supported.
2024-11-08 13:32:13 -08:00
Ryan Smith
744717886b Backup original binary when upgrading 2024-11-08 13:26:08 -08:00
Ryan Smith
927903e47a Rename request_headers log field to headers 2024-11-08 10:10:50 -08:00
Ryan Smith
a8ee70ae3e Upgrade modules 2024-11-08 09:53:58 -08:00
Ryan Smith
c12f0d7746 Revise casing to match new log format
Header names are now logged in all lowercase. The HTTP honeypot log sample now reflects that.
2024-11-08 09:35:18 -08:00
Ryan Smith
c920d9a4a8 Change custom headers element to <headers>
This change modifies the configuration for HTTP honeypot servers. Previously, custom headers were defined using the `<banner>` element, which was shared with SSH and TCP honeypot servers. Now there is a dedicated `<headers>` element allowing any number of `<header>` elements to be defined for custom HTTP response headers.

Before (old configuration):
```xml
<server type="http">
  <banner>Server: Microsoft-IIS/8.5, X-Powered-By: ASP.NET</banner>
</server>
```

After (new configuration):
```xml
<server type="http">
  <headers>
    <header>Server: Microsoft-IIS/8.5</header>
    <header>X-Powered-By: ASP.NET</header>
  </headers>
</server>
```
2024-11-08 09:26:12 -08:00
Ryan Smith
6b2088b5bf Change XML structure for <prompt> elements
This change revises the configuration for custom prompts in the TCP honeypot server. Previously, `<prompt>` elements were defined directly within the `<server>` element. In the new configuration, a `<prompts>` element is used to enclose any number of `<prompt>` elements.

Before (old configuration):
```xml
<server type="tcp">
  <prompt>Username:</prompt>
  <prompt>Password:</prompt>
</server>
```

After (new configuration):
```xml
<server type="tcp">
  <prompts>
    <prompt>Username:</prompt>
    <prompt>Password:</prompt>
  </prompts>
</server>
```
2024-11-08 08:37:34 -08:00
Ryan Smith
fc43f99af7 Force HTTP response header casing to WWW-Authenticate
This change forces the `WWW-Authenticate` casing for the default HTTP response header on the HTTP/HTTPS honeypot servers. Previously, Go automatically converted it to `Www-Authenticate`. This update matches the casing used by most other web servers. The change is intended to reduce the risk of fingerprinting the honeypot server by making it behave more like a typical web server.
2024-11-07 17:13:22 -08:00
Ryan Smith
7cd36a5018 Change HTTP honeypot to return empty body by default
This changes modifies the HTTP/HTTPS honeypot servers to return an empty response body by default. While status codes remain intact, the body content is now empty. This change is intended to minimize the risk of fingerprinting the honeypot server.
2024-11-07 17:06:50 -08:00
Ryan Smith
12ada38faa Change http header name logging to lowercase
This change converts HTTP header names to lower case when writing to JSON logs. This ensures consistent casing across all log fields.
2024-11-07 16:17:10 -08:00
Ryan Smith
a99f03768b Adjust ASCII logo colors to match SVG logo 2024-11-07 15:34:00 -08:00
Ryan Smith
70db9094cd Add ability to specify header to use for source IP
This change adds a new `<sourceIpHeader>` element to the HTTP/HTTPS honeypot server configuration. It allows you to specify an HTTP header to use as the source IP address when updating the threat feed.

You would set this option if the HTTP honeypot server is behind a proxy server. Typically a proxy would set an HTTP header, such as `X-Forwarded-For`, that records the source IP of the originating client.

Example configuration:
```xml
<sourceIpHeader>X-Forwarded-For</sourceIpHeader>
```
2024-11-05 17:07:48 -08:00
Ryan Smith
cfc9650085 Add negate attribute to regex rules
This change introduces a `negate` attribute to `<include>` and `<exclude>` rules in the configuration. When `negate` is set to `true`, the rule applies when the regex pattern does not match.

For example, the following _include_ rule matches when the HTTP request does not equal "GET", "HEAD", or "OPTIONS":

```xml
<include target="method" negate="true">(?i)^(GET|HEAD|OPTIONS)$</include>
```
2024-11-05 16:06:27 -08:00
Ryan Smith
2274ebbc29 Rename match to include
This change renames the `<match>` XML element in the configuration to `<include>`.
2024-11-05 15:58:51 -08:00
Ryan Smith
50dfbe2d6b Add project logo 2024-11-04 16:40:17 -08:00
Ryan Smith
57dc10edb0 Add logos 2024-11-04 16:16:40 -08:00
Ryan Smith
c84a1e60a5 Remove source port from logging
This change removes the logging of source ports for connecting clients in the honeypot servers. The source port does not provide value for this type of honeypot and only clutters the logs.
2024-11-02 09:41:15 -07:00
Ryan Smith
324dd67ff0 Add deadline and delay to SSH honeypot
This change adds a 30-second deadline to SSH connections. Client connections are forced closed after the deadline.

Additionally, a 2-second delay is added prior to rejecting authentication requests. This mimics the `pam_faildelay` PAM module found on modern Linux systems.
2024-11-02 09:22:50 -07:00
Ryan Smith
368914b566 Add public key callback
This change adds a public key authentication callback function to the SSH honeypot server. All requests are rejected, and currently, no data is logged.
2024-11-02 08:31:38 -07:00
Ryan Smith
496b211243 Remove unnecessary channel handling
This change removes unnecessary channel handling code from the SSH honeypot server. Since authentication requests are always rejected, `ssh.NewServerConn` will consistently return an error, making the channel handling redundant.
2024-11-02 08:04:40 -07:00
Ryan Smith
aa61a99c8a Add ability to define rules for when a request updates the threat feed
This change adds Rule and Rules structs for HTTP honeypot configurations. The rules are regex patterns that define when an HTTP request should trigger an update the threat feed.

The Rule struct allows you specify a target that defines which part of the HTTP request should match your pattern.

Example configuration:
```
<server type="http">
  <rules>
    <match target="path">\.php$</match>
  </rules>
</server>
```

This example triggers an update to the threat feed only if the HTTP request path ends with `.php`. Any other request will not trigger an update.
2024-11-01 20:39:14 -07:00
Ryan Smith
59414fd00e Rename srv variables to cfg 2024-11-01 11:38:42 -07:00
Ryan Smith
6485bbf3ff Change expiryHours from uint to int 2024-11-01 11:32:55 -07:00
Ryan Smith
d230c6721d Fix expiry logic when serving the threat feed
Previously, setting `expiryHours` to `0` did not prevent IP addresses from expiring in the threat feed. This has been corrected. Now, when `expiryHours` is set to `0`, IP addresses never expire from the threat feed.
2024-11-01 11:31:46 -07:00
Ryan Smith
9e3e3303f5 Add explicit discard for non-essential errors
This change adds explicit discard statments on function calls that return errors when the error is irrelevant.
2024-11-01 10:58:25 -07:00
Ryan Smith
16971d7c0d Add timeouts to http servers 2024-11-01 10:31:30 -07:00
Ryan Smith
855d913ade Revise readme 2024-10-30 13:31:28 -07:00
Ryan Smith
0bf7cbf694 Add auto-confirmation option for upgrades and uninstalls
* Add `-y` and `--yes` command-line arguments to the installation script. Setting this argument sets the `auto_confirm_prompts` variable to `true`. When a confirmation is needed, the variable is checked to determine whether to show a prompt or to auto-confirm.

* Add `print_usage` function to print basic help and usage information. It is shown if an unsupported argument is supplied (including `-h` and --`help`).
2024-10-30 13:26:37 -07:00
Ryan Smith
cbb18f4189 Add vhs tape file used to generate install.gif 2024-10-30 10:31:10 -07:00
Ryan Smith
5a1095b7e8 Reduce padding for install.gif 2024-10-30 10:30:23 -07:00
Ryan Smith
a2c97a5900 Create README.md 2024-10-29 09:32:59 -07:00
Ryan Smith
6bf0ba6331 Add install.gif 2024-10-29 09:19:35 -07:00
Ryan Smith
2ba09f7b06 Change 'answers' references to 'responses' v0.9.0 2024-10-28 11:49:49 -07:00
Ryan Smith
0e09a25258 Add threatScore settings to default config 2024-10-27 21:02:06 -07:00
Ryan Smith
bbe06edf18 Add minimum threat score to threat feed
This commit introduces a MinimumThreatScore setting to the threat feed server. This setting allows users to filter IP addresses based on their threat score. Only IP addresses that meet or exceed the specified threshold are included in the threat feed.
2024-10-27 20:58:31 -07:00
Ryan Smith
e8fc641778 Rename confidence level to threat score 2024-10-27 20:51:08 -07:00
Ryan Smith
f5fa1ef842 Set confidence defaults when no config provided
This change sets the default confidence level to 1 for all honeypot servers when no configuration file is provided.
2024-10-27 20:35:56 -07:00
Ryan Smith
222f85ba22 Add confidence level to honeypots and threat feed
This change introduces a ConfidenceLevel configuration setting for honeypot servers and the IoC struct in the threat feed database. Each IP in the database now maintains a confidence level. Whenever a honeypot calls UpdateIoC, the confidence level of the IP is incremented by the configued amount for the honeypot.
2024-10-27 08:41:06 -07:00
Ryan Smith
45e13ff90d Switch database updates to delayed writes
This commit improves performance for handling large threat feeds by adjusting the timing of CSV file saves. Previously, any changes to the IoC map triggered an immediate write to disk. Now, the IoC map is saved in a separate goroutine using a timer that triggers every 10 seconds.
2024-10-26 20:50:52 -07:00
Ryan Smith
9167188216 Change the default log path 2024-10-26 20:19:37 -07:00
Ryan Smith
6274c93d2a Change threat feed database to CSV
This commit changes the threat feed database format from JSON to CSV for improved efficiency when saving updates.
2024-10-26 20:19:07 -07:00
Ryan Smith
dc217cecd8 Remove data added field from IoC database 2024-10-26 19:16:38 -07:00
Ryan Smith
d276da92a1 Change threat feed access to private IPs only
This change adds an HTTP middleware to the threat feed server, restricting access to private IP addresses. This enforces a secure default, as the threat feed is not intended for public sharing. A separate HTTP proxy server can be used to implement public sharing.
2024-10-25 14:46:53 -07:00
Ryan Smith
d6433aa9ff Apply restrictive permissions when saving keys
This change sets the Unix file permissions to `0600` for generated private keys saved to disk, ensuring that ownly the owner can access the keys. While private keys for the honeypot servers are mostly insignificant, this change aligns with typical private key permissions.
2024-10-25 09:42:49 -07:00
Ryan Smith
4f9ee7e231 Add custom error logger to discard https errors
This change adds a custom logger to the HTTPS honeypot to discard error output. Without it, TLS handshake errors would generate unwanted error messages from the application. Since this is a honeypot server, we have no interest in seeing those types of errors.
2024-10-24 17:53:54 -07:00
Ryan Smith
6535b5ca68 Revise installation script 2024-10-24 10:53:53 -07:00
Ryan Smith
fe8947bd54 Change default permissions to 755/644
This commit changes to default permissions on created files and directories from 775/664 to 755/644.
2024-10-23 10:10:52 -07:00