Commit Graph

154 Commits

Author SHA1 Message Date
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
c96313242a Update dependencies 2025-03-03 21:59:24 -08:00
Ryan Smith
bfc121ce06 Increment minimum Go version to v1.24 2025-03-03 21:49:30 -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
ef2bc057f4 Update dependencies 2024-12-27 21:17:36 -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
c120b2633f Update README.md 2024-12-09 17:20:17 -08:00
Ryan Smith
3d727ff0cf Change references from /feed to /plain v0.18.0 2024-12-05 22:12:02 -08:00
Ryan Smith
183e078671 Add tzdata package step to Dockerfile
This change adjusts the Dockerfile to add the `tzdata` package to the Alpine Linux image. This allows users to set a timezone through the `TZ` environment variable when running Deceptifeed as a Docker container.
2024-12-05 18:01:08 -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
d728a9a500 Update dependencies 2024-12-05 16:30:21 -08:00
Ryan Smith
1b76ac5251 Add default configuration file for Docker usage 2024-12-05 15:45:35 -08:00
Ryan Smith
e3261088f4 Update README.md 2024-12-05 14:44:20 -08:00
Ryan Smith
ae670554e8 Add threat feed web screenshot 2024-12-05 14:40:28 -08:00
Ryan Smith
060027d2ee Update README.md 2024-12-05 13:52:55 -08:00
Ryan Smith
e269e8289e Update README.md 2024-12-04 17:27:20 -08:00
Ryan Smith
1bfcd140e7 Merge branch 'main' of https://github.com/r-smith/deceptifeed 2024-12-04 17:26:45 -08:00
Ryan Smith
e3a4a1ade6 Update .SVG diagrams 2024-12-04 17:26:39 -08:00
Ryan Smith
3af87f4a1d Update README.md 2024-12-04 17:19:55 -08:00
Ryan Smith
f90ff62af2 Update README.md 2024-12-04 17:18:21 -08:00
Ryan Smith
9c19418d1f Revise diagrams 2024-12-04 17:06:22 -08:00
Ryan Smith
bd7212fa92 Revise diagrams 2024-11-28 20:37:19 -08:00
Ryan Smith
9b6524be40 Add diagrams 2024-11-27 14:06:29 -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
0c46913497 Add Dockerfile 2024-11-25 13:04:06 -08:00
Ryan Smith
865d06dd21 Update default config
This change updates the default configuration file by removing most comments. Configuration options will be documented separately.

The regex patterns in the default ruleset for HTTP honeypots is simplified.
2024-11-25 13:03:49 -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
94bf060035 Set default config file to 'config.xml' if found
If the `-config` flag is not provided, the app will automatically use "config.xml" from the current directory, if it exists.
2024-11-22 12:21:09 -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
Ryan Smith
716988a546 Adjust feed output
- Change the date/time format to include fractional seconds when saving the threat feed to CSV. This ensures saved threat feed timestamps match that of the in-memory threat feed.

- Change STIX indicator name field from `ip : honeypot interaction` to `Honeypot interaction: ip`.
2024-11-18 12:58:33 -08:00