Commit Graph

43 Commits

Author SHA1 Message Date
Ryan Smith
8ebec3a8c4 feat: add TLS support to threat feed server
This change adds optional support for running the threat feed server over HTTPS. This is controlled via the configuration file. Depending on the confgiuration, the threat feed may operate over either HTTP or HTTPS, but not both.

The following configuration options are added to the threat feed (the `<threatFeed>` section in the conffguration file):
- `<enableTLS>` - If `true`, the threat feed uses TLS. If `false` or if this is missing, use HTTP.
- `<certPath>` - Path to TLS cert in PEM format.
- `<keyPath>` - Path to private key in PEM format.

Default configuration files are updated to include the new settings. The TLS feature is off by default. Existing user configuration files only need to be updated if this feature is needed. Otherwise, existing configuration files start the threat feed using HTTP as before.

When the threat feed server starts in TLS mode, it automatically generates a self-signed cert if the cert and key files aen't found.
2025-04-16 08:33:36 -07:00
Ryan Smith
d3f7cb4e86 Add logmonitor to configuration 2025-03-31 08:59:49 -07:00
Ryan Smith
4fd048c287 Remove feature for custom threat file
This change removes the `CustomThreatsPath` setting from the threat feed configuration. The default configuration files are updated with this setting removed.
2025-03-26 18:23:37 -07:00
Ryan Smith
920759db70 Explicitly disable threat feed for UDP honeypots
This change explicitly disables the threat feed for UDP honeypots in the configuration. The UDP honeypot server does not implement the threat feed.
2025-03-24 11:17:05 -07:00
Ryan Smith
7dc7b1ee83 Add setting and getting version information
- Add `Version` string var to config package for storing version information.
- Update Makefile to set the `Version` variable at build time using the latest Git tag.
- Add `-version` flag to main package to print version information and exit.
- Remove setting the GO111MODULE environment variable from Makefile when building. It's not needed.
2025-03-22 08:56:10 -07:00
Ryan Smith
4cf8d15402 Add FilePath field to Config struct
The FilePath field stores the absolute path to the running configuration file and is set while the configuration file is initially loading.
2025-03-20 09:44:40 -07:00
Ryan Smith
60ab753c42 Remove threat score feature, replace with observation count
This change removes the 'threat score' feature which allowed users to configure each honeypot server with a variable 'score' when updating the threat feed.

It is replaced with a fixed observation count that is incremented by 1 for each honeypot interaction.

The field `threat_score` has been replaced with `observations` in all API call parameters and threat feed data.

The `threat_score` field in the CSV file has been renamed to `observations`. Existing threat feed CSV files will be automatically updated on the next threat feed save.
2025-03-20 09:20:15 -07:00
Ryan Smith
b23e9b4a9e Remove minimum threat score feature and settings 2025-03-19 20:50:21 -07:00
Ryan Smith
d50bce3fbf Explicitly set default SSH banner
This change explicitly sets the default SSH banner in the running configuration when the application starts.

If starting without a configuration file, the global default banner is always used.

If starting with a configuration file, the global default banner is used when no banner is specified.
2025-03-19 19:36:59 -07:00
Ryan Smith
bc7fcef4b5 Refactor log path initialization
Previously:
When no log path was specified for a server, it would fall back to the global/default log path during logger initialization. However, the `LogPath` field didn't update and would not reflect the actual path used by the logger.

Now:
Log path determination is handled while the configuration is loading. If a server falls back to the default log path, the `LogPath` field is updated to reflect the actual path used by the logger.
2025-03-17 13:25:09 -07:00
Ryan Smith
3e72919170 Use slog.DiscardHandler when logging is disabled
This change switches to using slog.DiscardHandler, added to Go 1.24, when logging is disabled.
2025-03-03 22:26:41 -08:00
Ryan Smith
6f4d1d9921 Revise error messages 2024-12-27 22:04:13 -08:00
Ryan Smith
ae596b82e8 Automatically rotate honeypot logs
This change configures the honeypot loggers to use the internal `logrotate` package. This enables automatic log file rotation. The maximum log size is set to 50 MB.
2024-12-27 21:06:59 -08:00
Ryan Smith
0269fe34d2 Ensure only 1 file handle/logger is created per log file
This change adjusts logger initialization to ensure only 1 file handle and 1 logger is created per unique log path.

Each honeypot server may have its own log path specified, which may be unique or may be shared with other honeypot servers.

Previously, each honeypot server would open a separate file handle and logger, even if the file was already opened by another server.
2024-12-27 09:01:02 -08:00
Ryan Smith
563c76696b Change default SSH banner to appear as OpenSSH 9.6
This change adjusts the default SSH server version string to `SSH-2.0-OpenSSH_9.6`. This makes SSH honeypots appear as OpenSSH 9.6.

The change is applied both to default configuration files and as an application default when no configuration is provided.
2024-12-27 08:48:43 -08:00
Ryan Smith
16f7b6a86d Rename XML element isPrivateIncluded to includePrivateIPs 2024-11-25 12:57:40 -08:00
Ryan Smith
0f1af8704d Change default listen ports
- Change the SSH honeypot server default port from 2022 to 2222
- Change the threat feed server default port from 8081 to 9000
2024-11-17 13:46:31 -08:00
Ryan Smith
dead75f037 Add custom error page option for HTTP honeypots
- Added a new `<errorPagePath>` configuration option. This lets you specify a custom error page for HTTP and HTTPS honeypot servers. Only a single static HTML file may be specified.
- Renamed `<htmlPath>` to `<homePagePath>` in the configuration.
- Changed the default threat expiry hours from 168 (one week) to 336 (two weeks).
- Changed minimum threat score from `1` to `0` for honeypot servers.
2024-11-14 16:54:54 -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
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
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
6485bbf3ff Change expiryHours from uint to int 2024-11-01 11:32:55 -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
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
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
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
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
d17f6fffaa Rename the project to Deceptifeed 2024-10-21 17:18:09 -07:00
Ryan Smith
8b6021faf4 Change threat feed default to include private IPs
When starting without a configuration file, the threat feed now enables the option to include private IPs by default.
2024-10-21 09:53:20 -07:00
Ryan Smith
8b2cfeb8d5 Make minor adjustment to for/range loop 2024-10-20 22:25:27 -07:00
Ryan Smith
57954f8c81 Add option to control sending to threat feed
This change adds a new XML element, sendToThreatFeed, to the configuration for servers to control whether interactions with the server should update the threat feed.
2024-10-20 21:09:58 -07:00
Ryan Smith
f332508dab Add option to disable logging per server
This change adds a new XML element, logEnabled, to <server> sections to control whether logging is enabled.
2024-10-20 21:02:04 -07:00
Ryan Smith
34ef291f08 Add ability to supply exclude list for filtering the threat feed
This change adds a new option in the threat feed configuration for specifying a file path for an exclude list. If this path is provided, IPs in the file will be excluded from the threat feed.
2024-10-20 13:50:15 -07:00
Ryan Smith
152fb2c8e2 Rename CustomThreatFile to CustomThreatsPath for consistency 2024-10-20 13:42:43 -07:00
Ryan Smith
ebe3b217bc Don't create logger if server isn't enabled 2024-10-19 22:57:38 -07:00
Ryan Smith
b08431ecf0 Enable individual logging for each honeypot server
This change moves the slog.Logger from the Config struct to the Server struct, allowing each honeypot server to have its own logger. Each server can now specify a custom log file path, defaulting to the main log path in the Config if none is provided.
2024-10-19 22:08:48 -07:00
Ryan Smith
2b5349aacf Rename XML logPath element to defaultLogPath
This change modifies the XML schema for the configuration file. The top-level `logPath` element is renamed to `defaultLogPath`. This adjustment prepares for a future change to allow each server to specify its own log path.
2024-10-19 19:32:01 -07:00
Ryan Smith
54c46b9584 Add ability to supply custom threat file
This change adds a new threat feed configuration option `customThreatFile`. The option allows you to specify a text file containing additional content for the threat feed. The contents of the custom threat file are appended to the output of the threat feed. This could be IP addresses or any other type of text.
2024-10-19 17:49:39 -07:00
Ryan Smith
c7bb4b7b28 first commit 2024-10-16 11:48:13 -07:00