|
78 | 78 |
|
79 | 79 | """ |
80 | 80 | import re |
| 81 | +import base64 |
81 | 82 | from typing import Optional, Dict, Tuple, Any |
82 | 83 |
|
83 | 84 | import intelmq.lib.harmonization as harmonization |
@@ -204,6 +205,18 @@ def convert_date_utc(value: str) -> Optional[str]: |
204 | 205 | return harmonization.DateTime.sanitize(value + '+00:00') |
205 | 206 |
|
206 | 207 |
|
| 208 | +_base64_alphabet = set('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=') |
| 209 | + |
| 210 | + |
| 211 | +def maybe_base64(value: Optional[str]) -> Optional[str]: |
| 212 | + if not value: |
| 213 | + return None |
| 214 | + elif set(value).issubset(_base64_alphabet): |
| 215 | + return value |
| 216 | + |
| 217 | + return base64.b64encode(value.encode()).decode() |
| 218 | + |
| 219 | + |
207 | 220 | # https://www.shadowserver.org/wiki/pmwiki.php/Services/Open-DB2 |
208 | 221 | open_db2_discovery_service = { |
209 | 222 | 'required_fields': [ |
@@ -2813,6 +2826,71 @@ def scan_exchange_identifier(field): |
2813 | 2826 | } |
2814 | 2827 | } |
2815 | 2828 |
|
| 2829 | +# https://www.shadowserver.org/what-we-do/network-reporting/honeypot-http-scanner-events/ |
| 2830 | +honeypot_http_scan = { |
| 2831 | + 'required_fields': [ |
| 2832 | + ('time.source', 'timestamp', add_UTC_to_timestamp), |
| 2833 | + ('source.ip', 'src_ip', validate_ip), |
| 2834 | + ('source.port', 'src_port'), |
| 2835 | + ], |
| 2836 | + 'optional_fields': [ |
| 2837 | + ('source.asn', 'src_asn', invalidate_zero), |
| 2838 | + ('source.geolocation.cc', 'src_geo'), |
| 2839 | + ('source.geolocation.region', 'src_region'), |
| 2840 | + ('source.geolocation.city', 'src_city'), |
| 2841 | + ('source.reverse_dns', 'src_hostname'), |
| 2842 | + ('extra.source.naics', 'src_naics', invalidate_zero), |
| 2843 | + ('extra.source.sector', 'src_sector', validate_to_none), |
| 2844 | + ('extra.', 'device_vendor', validate_to_none), |
| 2845 | + ('extra.', 'device_type', validate_to_none), |
| 2846 | + ('extra.', 'device_model', validate_to_none), |
| 2847 | + ('destination.ip', 'dst_ip', validate_ip), |
| 2848 | + ('destination.port', 'dst_port'), |
| 2849 | + ('destination.asn', 'dst_asn', invalidate_zero), |
| 2850 | + ('destination.geolocation.cc', 'dst_geo'), |
| 2851 | + ('destination.geolocation.region', 'dst_region'), |
| 2852 | + ('destination.geolocation.city', 'dst_city'), |
| 2853 | + ('destination.reverse_dns', 'dst_hostname'), |
| 2854 | + ('extra.destination.naics', 'dst_naics', invalidate_zero), |
| 2855 | + ('extra.destination.sector', 'dst_sector', invalidate_zero), |
| 2856 | + ('extra.', 'public_source', validate_to_none), |
| 2857 | + ('malware.name', 'infection'), |
| 2858 | + ('extra.', 'family', validate_to_none), |
| 2859 | + ('extra.', 'tag', validate_to_none), |
| 2860 | + ('extra.', 'application', validate_to_none), |
| 2861 | + ('extra.', 'version', validate_to_none), |
| 2862 | + ('extra.', 'event_id', validate_to_none), |
| 2863 | + ('extra.', 'pattern', validate_to_none), |
| 2864 | + ('destination.url', 'http_url', convert_http_host_and_url, True), |
| 2865 | + ('user_agent', 'http_agent', validate_to_none), |
| 2866 | + ('extra.method', 'http_request_method', validate_to_none), |
| 2867 | + ('extra.', 'url_scheme', validate_to_none), |
| 2868 | + ('extra.', 'session_tags', validate_to_none), |
| 2869 | + ('extra.', 'vulnerability_enum', validate_to_none), |
| 2870 | + ('extra.', 'vulnerability_id', validate_to_none), |
| 2871 | + ('extra.', 'vulnerability_class', validate_to_none), |
| 2872 | + ('extra.', 'vulnerability_score', validate_to_none), |
| 2873 | + ('extra.', 'vulnerability_severity', validate_to_none), |
| 2874 | + ('extra.', 'vulnerability_version', validate_to_none), |
| 2875 | + ('extra.', 'threat_framework', validate_to_none), |
| 2876 | + ('extra.', 'threat_tactic_id', validate_to_none), |
| 2877 | + ('extra.', 'threat_technique_id', validate_to_none), |
| 2878 | + ('extra.', 'target_vendor', validate_to_none), |
| 2879 | + ('extra.', 'target_product', validate_to_none), |
| 2880 | + ('extra.', 'target_class', validate_to_none), |
| 2881 | + ('extra.', 'file_md5', validate_to_none), |
| 2882 | + ('extra.', 'file_sha256', validate_to_none), |
| 2883 | + ('extra.', 'request_raw', maybe_base64), |
| 2884 | + ('extra.', 'body_raw', maybe_base64), |
| 2885 | + ], |
| 2886 | + 'constant_fields': { |
| 2887 | + 'classification.identifier': 'honeypot-http-scan', |
| 2888 | + 'classification.taxonomy': 'other', |
| 2889 | + 'classification.type': 'other', |
| 2890 | + 'protocol.application': 'http', |
| 2891 | + } |
| 2892 | +} |
| 2893 | + |
2816 | 2894 | mapping = ( |
2817 | 2895 | # feed name, file name, function |
2818 | 2896 | ('Accessible-ADB', 'scan_adb', accessible_adb), |
@@ -2845,6 +2923,7 @@ def scan_exchange_identifier(field): |
2845 | 2923 | ('Honeypot-Amplification-DDoS-Events', 'event4_honeypot_ddos_amp', honeypot_ddos_amp), |
2846 | 2924 | ('Honeypot-Brute-Force-Events', 'event4_honeypot_brute_force', honeypot_brute_force), |
2847 | 2925 | ('Honeypot-Darknet', 'event4_honeypot_darknet', event4_honeypot_darknet), |
| 2926 | + ('Honeypot-HTTP-Scan', 'event4_honeypot_http_scan', honeypot_http_scan), |
2848 | 2927 | ('ICS-Scanners', 'hp_ics_scan', ics_scanners), |
2849 | 2928 | ('IPv6-Sinkhole-HTTP-Drone', 'sinkhole6_http', ipv6_sinkhole_http_drone), # legacy (replaced by event46_sinkhole_http) |
2850 | 2929 | ('IP-Spoofer-Events', 'event4_ip_spoofer', event4_ip_spoofer), |
|
0 commit comments