Commit Graph

125 Commits

Author SHA1 Message Date
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
7bad11a4a7 Allow comments in exclude list
This change allows for comments in the exclude list using the `#` symbol. The `#` symbol on a line and everything after it is ignored when parsing the exclude list.
2025-03-26 18:17:31 -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
f6cd4c783e Change nav bar names and icons
This change renames `Web Feed` to `Threats` and `Honeypot Logs` to `Logs` in the navigation bar.

Apply visual tweaks to the nav bar.
2025-03-20 16:34:48 -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
f72cf4ddba Use centralized stylesheet
This change removes the CSS sections from HTML templates and switches to using a single stylesheet at /css/style.css.
2025-03-19 19:55:14 -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
764188cf2b Require private IP when accessing log data 2025-03-18 09:40:58 -07:00
Ryan Smith
00b747341b Display message when feed/logs are empty
Adjust the html templates for web feed and log viewers to check if there's any data to display. If no data, a message is shown informing the user that there's no data.
2025-03-18 07:36:01 -07:00
Ryan Smith
97cddb8cfe Ensure log files are read in a consistent order
Use a slice instead of a map to track unique paths to ensure log files are read in the correct order.
2025-03-18 07:26:27 -07:00
Ryan Smith
9384834da1 Remove click effect on logo in nav bar 2025-03-17 19:56:10 -07:00
Ryan Smith
0d09a59d3c Explicitly ignore errors from rand.Read
The error is ignored because rand.Read is guranteed to never return an error.
2025-03-17 14:55:06 -07:00
Ryan Smith
182262d474 Add ability to view honeypot logs from the threat feed server 2025-03-17 14:08:13 -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
857966808c Revise CSS styling for threat feed server 2025-03-14 10:42:17 -07:00
Ryan Smith
70e8180b2b Add custom 404 page 2025-03-09 12:35:10 -07:00
Ryan Smith
1bde74187f Add nav bar and visual tweaks to management pages
- Add a horizontal navigation bar to the top of all management pages.
- Tweaks to colors and styling of management pages.
- Rename the endpoint '/threatfeed' to '/webfeed'.
- Rename the file 'htmlfeed.html' to 'webfeed.html'.
2025-03-09 10:08:05 -07:00
Ryan Smith
96b5be5758 Minor visual and structural revisions
- Remove the `/feed` endpoint, as this is already handled by `/plain`.
- Rename `/html` endpoint to `/threatfeed`.
- Add a `/docs` endpoint for displaying information on accessing the threat feed.
- Make the Deceptifeed logo smaller on HTML pages.
- Revise the layout of the initial homepage. Endpoint docs are now moved and linked to /docs.
- Remove `/html` from the list of threat feed endpoints in the docs, as it doesn't belong here (there is a link to the html threat feed on the home page).
2025-03-07 13:34:41 -08: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
122e1ca83d Update rand.Read error handling
As of Go 1.24, rand.Read is guaranteed to never return an error. This change removes the error check and the associated fallback function when calling rand.Read.
2025-03-03 22:07:45 -08:00
Ryan Smith
99b9760830 Update threat feed server to receive full app config
This change updates the threat feed server so that the entire application config is passed in to the threat feed server. This allows the threat feed server to access its own configuration as well as the settings for each honeypot server and any other application-wide settings.
2024-12-30 10:39:01 -08:00
Ryan Smith
126577d842 Revise saveCSV routine
Refactor saveCSV to use a bufio.NewWriter and manually format CSV data rather than using the built-in CSV writer. This results in slightly better performance and memory usage when the threat feed is large (>500k entries).

Various miscellaneous changes:
- Rename `mutex` variable to `mu`.
- Lock the mutex in `loadCSV` because it accesses the iocData map.
2024-12-28 23:35:14 -08:00
Ryan Smith
6f4d1d9921 Revise error messages 2024-12-27 22:04:13 -08:00
Ryan Smith
849709ae01 Explicitly ignore errors from file.Close()
In logrotate.OpenFile(), explicitly ignore errors from file.Close().
2024-12-27 21:43:48 -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
646c09a4fa Add logrotate package to manage log file rotation
The logrotate package implements an io.WriteCloser with automatic file rotation. When the file size exceeds a specified limit, the file is renamed with a `.1` suffix. Subsequent rotations overwrite the file with the `.1` suffix, meaning only one backup is retained. This approach keeps the rotation simple.
2024-12-27 17:31:21 -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
1a631e7e14 Use quoted strings when printing certain fields
This change adjusts the SSH, TCP, and UDP honeypots to print quoted (escaped) strings to the terminal for certain log fields rather than raw strings. The adjusted fields are SSH username, SSH password, TCP responses, and UDP received data.
2024-12-26 11:29:06 -08:00
Ryan Smith
079becbd82 Update threat feed html templates
Changes to HTML feed template:
- Drop milliseconds from added and last seen dates.
- Make the logo a link to return to the threat feed homepage.
- Fix logo sizing on small screens.
- Reduce logo margins.

Changes to home page template:
- Update /stix API endpoint documentation to change references from /stix/indicators and /stix/observables to just /stix.
- Update TAXII documentation to include the new sightings collection.
- Update TAXII documentation with shortened collection names.
- Set `break-word` wrapping on code snippets to fix rendering on small screens.
- Collapse API endpoint table on small screens.
- Fix logo sizing on small screens.
- Reduce logo margins.
2024-12-26 10:27:46 -08:00
Ryan Smith
b47d5278f4 Consilidate STIX endpoints to /stix
This change removes the /stix/indicators and /stix/observables endpoints and replaces them with a single /stix endpoint. The /stix endpoint returns the threat feed as STIX indicators.
2024-12-26 10:16:04 -08:00
Ryan Smith
505e1fa2e0 Add sightings TAXII collection
- Add `sightings` TAXII collection to represent IP addresses observed interacting with Deceptifeed as STIX sightings
- Rename collection aliases `deceptifeed-indicators` and `deceptifeed-observables` to `indicators` and `observables`.
- Add `convertToSightings` method for converting the threat feed to STIX sightings.
- Set a confidence score of 100 to STIX indicators.
- Rename label `honeypot` to `honeypot-interaction` on STIX indicators.
2024-12-26 10:05:55 -08:00
Ryan Smith
45bb7e48b9 Define a maximum threat score of 999,999,999
This change sets a maximum threat score of 999,999,999. Previously, the maximum threat score was the max signed int value (9,223,372,036,854,775,807 on 64-bit systems).
2024-12-26 09:42:54 -08:00
Ryan Smith
73e2dd1c4b Add Sighting STIX Relationship Object
This change adds a `Sighting` struct to the stix package for representing a `Sighting` STIX Relationship Object (SRO).
2024-12-26 08:49:17 -08:00
Ryan Smith
1df1a045d0 Fix: Don't log "User-Agent" in headers key
This commit ensures the `User-Agent` value is removed from the HTTP request headers when logging the request. `User-Agent` is logged in the `event_details` array, so it should not duplicate the value in the `headers` array when logging. This commit fixes the issue introduced in commit 12ada38faa which normalised header names to lowercase.
2024-12-19 16:34:57 -08:00
Ryan Smith
41eab266fa Fix missing end tag in /html template 2024-12-17 10:36:56 -08:00
Ryan Smith
c35c8ebda9 Revise HTML styles 2024-12-17 10:20:26 -08:00
Ryan Smith
3d727ff0cf Change references from /feed to /plain 2024-12-05 22:12:02 -08:00
Ryan Smith
f5561776a7 Add error check in handleHome
This change adds a missing error check to the template .Execute call in `handleHome`.
2024-12-05 16:48:00 -08:00
Ryan Smith
f6a4f1ff5f Add default landing page and revise routes
This change adds a default landing page that is served when accessing the threat feed root URL. The landing page provides information about accessing the threat feed.

Move the template from handleHTML to the templates directory and embed using embed.FS.

Several changes to HTTP routes:
- Delete `/csv/ips` route and handler.
- Delete `/json/ips` route and handler.
- Rename `/stix2` route to `/stix/indicators`.
- Rename `/stix2/ips` route to `/stix/observables`.
- Change default route `/` to return 404 Not Found.
- Move plain text feed to `/feed` and `/plain` routes.
2024-11-26 08:59:29 -08:00
Ryan Smith
16f7b6a86d Rename XML element isPrivateIncluded to includePrivateIPs 2024-11-25 12:57:40 -08:00
Ryan Smith
19b61b90e7 Set default sort method for html route 2024-11-25 12:56:35 -08:00
Ryan Smith
c952356879 Add support for serving the threat feed as a web page
- Add new route `/html` and associated handler for serving the threat feed as a web page for viewing in a browser.
- Revise sorting methods to apply a secondary sort by IP adddress when the values for the requested sort method are equal.
2024-11-21 17:48:55 -08:00
Ryan Smith
0db1b81617 Refactor threat feed data structure
- Add a `feedEntry` struct to represent threat feed data as it is being served to clients. The threat feed is now served as a slice of feedEntries. Previously, the threat feed was built using a slice of net.IPs. The new struct avoids additional map lookups when formatting the feed and faster sorting operations.
- Rename `IoC` struct to `IOC` and make fields non-exportable.
- Revise HTTP handlers to format/encode the feed results using the new structs.
2024-11-21 14:17:57 -08:00
Ryan Smith
0421fd66ba Add sort direction option
- Add `sortDirection` type to represent sort directions.
- Add sortDirection argument to applySort function.
- Add `direction` HTTP query parameter for setting the sort direction option.
2024-11-21 08:38:17 -08:00
Ryan Smith
64cd270d9b Add sort and filter query parameters to all endpoints
- Add `sort` query parameter to sort the threat feed by IP (default), last seen date, added date, or by threat score.
- Add `last_seen_hours` query parameter to have the threat feed only return IPs that have been seen within the specified number of hours.

Examples:

`http://127.0.0.1:9000/json?sort=added`

`http://127.0.0.1:9000/?sort=ip&last_seen_hours=24`
2024-11-20 13:12:19 -08:00
Ryan Smith
b7ed763661 Refactor feed operations
- Add parseParams function to parse HTTP query parameters.
- Switch from functional options to an options struct for prepareFeed.
- Define a `feed` type for []net.IP.
- Add `applySort` method for sorting the feed.
- Change `convertToObservables` and `convertToIndicators` from functions to methods.
- Optimize exclude list processing.
  - parseExcludeList now determines and tracks whether each entry is a single IP or a CIDR block and now returns both a map of single IPs and a slice of CIDR blocks.
  - prepareFeed now calls parseExcludeList prior to iterating over iocData.
  - Delete the filterIPs function. All filtering logic is applied while iterating over iocData rather than afterwards.
2024-11-20 08:31:20 -08:00