From 774325b02660f2826c05a038378bef70eb3282c1 Mon Sep 17 00:00:00 2001 From: Usama015 Date: Mon, 19 Jun 2023 12:52:11 +0500 Subject: [PATCH 01/23] added new Module of IPGeolocation.io --- README.md | 5 +- documentation/README.md | 21 ++++ documentation/logos/ipgeolocation.png | Bin 0 -> 15988 bytes documentation/mkdocs/expansion.md | 21 ++++ .../website/expansion/ipgeolocation.json | 13 +++ misp_modules/modules/expansion/__init__.py | 2 +- .../modules/expansion/ipgeolocation.py | 106 ++++++++++++++++++ 7 files changed, 165 insertions(+), 3 deletions(-) create mode 100644 documentation/logos/ipgeolocation.png create mode 100644 documentation/website/expansion/ipgeolocation.json create mode 100644 misp_modules/modules/expansion/ipgeolocation.py diff --git a/README.md b/README.md index d589bc2..b1aaca0 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,7 @@ For more information: [Extending MISP with Python modules](https://www.misp-proj * [Cytomic Orion](misp_modules/modules/expansion/cytomic_orion.py) - An expansion module to enrich attributes in MISP and share indicators of compromise with Cytomic Orion. * [DBL Spamhaus](misp_modules/modules/expansion/dbl_spamhaus.py) - a hover module to check Spamhaus DBL for a domain name. * [DNS](misp_modules/modules/expansion/dns.py) - a simple module to resolve MISP attributes like hostname and domain to expand IP addresses attributes. +* [DNS WhoisFreaks](https://whoisfreaks.com/products/dns-records-api.html) - a simple Whoisfreaks Module that is useful for DNS Information. Our DNS checker API is a great way to gain a more in-depth understanding of an organization's online presence. * [docx-enrich](misp_modules/modules/expansion/docx_enrich.py) - an enrichment module to get text out of Word document into MISP (using free-text parser). * [DomainTools](misp_modules/modules/expansion/domaintools.py) - a hover and expansion module to get information from [DomainTools](http://www.domaintools.com/) whois. * [EQL](misp_modules/modules/expansion/eql.py) - an expansion module to generate event query language (EQL) from an attribute. [Event Query Language](https://eql.readthedocs.io/en/latest/) @@ -50,6 +51,7 @@ For more information: [Extending MISP with Python modules](https://www.misp-proj * [html_to_markdown](misp_modules/modules/expansion/html_to_markdown.py) - Simple HTML to markdown converter * [HYAS Insight](misp_modules/modules/expansion/hyasinsight.py) - a hover and expansion module to get information from [HYAS Insight](https://www.hyas.com/hyas-insight). * [intel471](misp_modules/modules/expansion/intel471.py) - an expansion module to get info from [Intel471](https://intel471.com). +* [Ipgeolocation](https://ipgeolocation.io/) - an expansion and hover module for IP Intelligence Stack with [IP to Geolocation](https://ipgeolocation.io/ip-location-api.html), [Timezone](https://ipgeolocation.io/astronomy-api.html) and [Astronomy API](https://ipgeolocation.io/timezone-api.html). * [IPASN](misp_modules/modules/expansion/ipasn.py) - a hover and expansion to get the BGP ASN of an IP address. * [ipinfo.io](misp_modules/modules/expansion/ipinfo.py) - an expansion module to get additional information on an IP address using the ipinfo.io API * [iprep](misp_modules/modules/expansion/iprep.py) - an expansion module to get IP reputation from packetmail.net. @@ -96,8 +98,7 @@ For more information: [Extending MISP with Python modules](https://www.misp-proj * [VulnDB](misp_modules/modules/expansion/vulndb.py) - a module to query [VulnDB](https://www.riskbasedsecurity.com/). * [Vulners](misp_modules/modules/expansion/vulners.py) - an expansion module to expand information about CVEs using Vulners API. * [whois](misp_modules/modules/expansion/whois.py) - a module to query a local instance of [uwhois](https://github.com/rafiot/uwhoisd). -* [whoisfreaks](misp_modules/modules/expansion/whoisfreaks.py) - An expansion module for [whoisfreaks](https://whoisfreaks.com/) that will provide an enriched analysis of the provided domain, including WHOIS and DNS information. -Our [Whois service](https://whoisfreaks.com/products/whois-api.html), [DNS Lookup API](https://whoisfreaks.com/products/dns-records-api.html), and [SSL analysis](https://whoisfreaks.com/products/ssl-certificate-api.html), equips organizations with comprehensive threat intelligence and attack surface analysis capabilities for enhanced security. Explore our website's product section at https://whoisfreaks.com/ for a wide range of additional services catering to threat intelligence and attack surface analysis needs. +* [whoisfreaks](misp_modules/modules/expansion/whoisfreaks.py) - An expansion module for [whoisfreaks](https://whoisfreaks.com/) that will provide an enriched analysis of the provided domain, including WHOIS and DNS information. Our [Whois service](https://whoisfreaks.com/products/whois-api.html), [DNS Lookup API](https://whoisfreaks.com/products/dns-records-api.html), and [SSL analysis](https://whoisfreaks.com/products/ssl-certificate-api.html), equips organizations with comprehensive threat intelligence and attack surface analysis capabilities for enhanced security. Explore our website's product section at https://whoisfreaks.com/ for a wide range of additional services catering to threat intelligence and attack surface analysis needs. * [wikidata](misp_modules/modules/expansion/wiki.py) - a [wikidata](https://www.wikidata.org) expansion module. * [xforce](misp_modules/modules/expansion/xforceexchange.py) - an IBM X-Force Exchange expansion module. * [xlsx-enrich](misp_modules/modules/expansion/xlsx_enrich.py) - an enrichment module to get text out of an Excel document into MISP (using free-text parser). diff --git a/documentation/README.md b/documentation/README.md index ec9366f..c056ccd 100644 --- a/documentation/README.md +++ b/documentation/README.md @@ -796,6 +796,27 @@ Module to query an IP ASN history service (https://github.com/D4-project/IPASN-H ----- +#### [ipgeolocation](https://github.com/MISP/misp-modules/tree/main/misp_modules/modules/expansion/ipgeolocation.py) + + + +An expansion module to query IpGeolocation.io to gather more information on a given IP address. We provide data such as country name, country code, city, state, local currency, time zone, ISP, ASN, Company Details, device data from User Agent String, VPN, Proxy, Tor and threat intelligence data served globally with latency based routing. +- **features**: +>The module takes an IP address attribute as input and queries the IpGeolocation API. +>The geolocation information on the IP address is always returned. +> +>Depending on the subscription plan, the API returns different pieces of information for details check our [page](https://ipgeolocation.io/ip-location-api.html). +- **input**: +>IP address +- **output**: +>Additional information on the IP address, like its geolocation, the autonomous system it is included in. +- **references**: +>https://ipgeolocation.io/ +- **requirements**: +>An apiKey of ipGeolocation + +----- + #### [ipinfo](https://github.com/MISP/misp-modules/tree/main/misp_modules/modules/expansion/ipinfo.py) diff --git a/documentation/logos/ipgeolocation.png b/documentation/logos/ipgeolocation.png new file mode 100644 index 0000000000000000000000000000000000000000..6c078d4126dad89c921ebb350ce909c3eee8cd1d GIT binary patch literal 15988 zcmbVzWmuHmyYGO6(ntvm;iw?p-QC?FATe}zhe${xDUEap(%s!5-Q6KAeV+0Czk8n# z``XvJ4qs-TXV$vc-RoYzd+|k4UI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Egj*Zn@m+{Z=~dOF6g>0M;~ zeV)$nG37gVeA00(=e#N4Q@CeMM@rotpqb3N1$4q0^;*WOEb9ZYD z>eA+Wj$UVhu5tczv;4SuC>wPD{PE_eYTOq7S)6}%Nt~okMekxUOc;RC>1}BHhK*)*v z#`00G>49B)DDQ2Y&%Q?83QVRh93bedaRz7g3s`p10Xy08#1ukSQ8m?CFTslTN1UiAEd(JDI*~pTi7=x^K>?k53i_{&>FdQ)5$9g=I>- zNUqNJ#9|&oKkIS1G5BdGrD%(4TAEhq9Qx|f8psVpFH?c&XhsMFH@YUO-u*&bE6ROfozo4lFb>lyLl?L`U;qj>F0;_qbYN_-K6C$o%FGkkaXXcqc+YH zuXCKfR(`BJ%o@9_&PYxTmork@K^%`4S{qA^#k4h-Z@r}J>2C+G&)#+gk6fKjTYqV6 zsw&rRi?=56AXzZ9pF1r|u!!ofVNX~%4#Rt$=&x^5?v?%CcBsoX#^vo<^4Wao zNUu|uHgc71@_mYajpvow?~$38h3iKNKgI`jW*^Mvd3%?lm6upOW}?16LG3qJ5Rp?6 zdBm!09TCQ{_Ln2b9R>>dzbm|0+V*JvSp8O01AVzVh3{!5oggMwMSrtrSYZVulfuD$Jt>v)I55CpJ!_{#Y?wiYm{#Q*J01&s8oRIMf>WMQnPA; z6+_~WshNilrIpq8T@q6k!0yRDfP2X`x1fu$t}@`xa2H$6PN@sBrbS%fJayUp%sgU_ z7`)eQ-s1o|=G=S#!taX3&M+! + +An expansion module to query IpGeolocation.io to gather more information on a given IP address. We provide data such as country name, country code, city, state, local currency, time zone, ISP, ASN, Company Details, device data from User Agent String, VPN, Proxy, Tor and threat intelligence data served globally with latency based routing. +- **features**: +>The module takes an IP address attribute as input and queries the IpGeolocation API. +>The geolocation information on the IP address is always returned. +> +>Depending on the subscription plan, the API returns different pieces of information for details check our [page](https://ipgeolocation.io/ip-location-api.html). +- **input**: +>IP address +- **output**: +>Additional information on the IP address, like its geolocation, the autonomous system it is included in. +- **references**: +>https://ipgeolocation.io/ +- **requirements**: +>An apiKey of ipGeolocation + +----- + #### [ipinfo](https://github.com/MISP/misp-modules/tree/main/misp_modules/modules/expansion/ipinfo.py) diff --git a/documentation/website/expansion/ipgeolocation.json b/documentation/website/expansion/ipgeolocation.json new file mode 100644 index 0000000..8c2c418 --- /dev/null +++ b/documentation/website/expansion/ipgeolocation.json @@ -0,0 +1,13 @@ +{ + "description": "An expansion module to query IpGeolocation.io to gather more information on a given IP address. We provide data such as country name, country code, city, state, local currency, time zone, ISP, ASN, Company Details, device data from User Agent String, VPN, Proxy, Tor and threat intelligence data served globally with latency based routing.", + "logo": "ipgeolocation.png", + "requirements": [ + "An apiKey of ipGeolocation" + ], + "input": "IP address", + "output": "Additional information on the IP address, like its geolocation, the autonomous system it is included in.", + "references": [ + "https://ipgeolocation.io/" + ], + "features": "The module takes an IP address attribute as input and queries the IpGeolocation API. \nThe geolocation information on the IP address is always returned.\n\nDepending on the subscription plan, the API returns different pieces of information for details check our [page](https://ipgeolocation.io/ip-location-api.html)." +} diff --git a/misp_modules/modules/expansion/__init__.py b/misp_modules/modules/expansion/__init__.py index bf6c6db..d801834 100644 --- a/misp_modules/modules/expansion/__init__.py +++ b/misp_modules/modules/expansion/__init__.py @@ -20,7 +20,7 @@ __all__ = ['cuckoo_submit', 'vmray_submit', 'bgpranking', 'circl_passivedns', 'c 'trustar_enrich', 'recordedfuture', 'html_to_markdown', 'socialscan', 'passive-ssh', 'qintel_qsentry', 'mwdb', 'hashlookup', 'mmdb_lookup', 'ipqs_fraud_and_risk_scoring', 'clamav', 'jinja_template_rendering','hyasinsight', 'variotdbs', 'crowdsec', - 'extract_url_components', 'ipinfo', 'whoisfreaks'] + 'extract_url_components', 'ipinfo', 'whoisfreaks', 'ipgeolocation'] minimum_required_fields = ('type', 'uuid', 'value') diff --git a/misp_modules/modules/expansion/ipgeolocation.py b/misp_modules/modules/expansion/ipgeolocation.py new file mode 100644 index 0000000..946ccb2 --- /dev/null +++ b/misp_modules/modules/expansion/ipgeolocation.py @@ -0,0 +1,106 @@ +import json + +import requests +from pymisp import MISPAttribute, MISPEvent, MISPObject + +mispattributes = { + 'input': ['ip-dst'], + 'format': 'misp_standard' +} +moduleinfo = { + 'version': '1', 'author': 'IpGeolocation', + 'description': 'Querry Using IpGeolocation.io', + 'module-type': ['expansion', 'hover'] +} +moduleconfig = ['apiKey'] +misperrors = {'error': 'Error'} + + +def handler(q=False): + # Input checks + if q is False: + return False + request = json.loads(q) + if not request.get('config'): + misperrors['error'] = 'IpGeolocation Configuration is missing' + return misperrors + if not request['config'].get('apiKey'): + misperrors['error'] = 'IpGeolocation apiKey is missing' + return misperrors + + if request.get('ip-src'): + ip = request['ip-dst'] + apiKey = request['config']['apiKey'] + return handle_ip(apiKey, ip, misperrors) + else: + misperrors['error'] = "Unsupported attributes types" + return misperrors + +def handle_ip(apiKey, ip, misperrors): + + try: + results = query_ipgeolocation(apiKey, ip) + except Exception: + misperrors['error'] = "Error while processing IP Data" + return [], False + + + # Check if the IP address is not reserved for special use + if results.get('message'): + if 'bogon' in results['message']: + return {'error': 'The IP address(bogon IP) is reserved for special use'} + else: + return {'error': 'Error Occurred during IP data Extraction'} + + # Initiate the MISP data structures + misp_event = MISPEvent() + input_attribute = MISPAttribute() + misp_event.add_attribute(**input_attribute) + + # Parse the geolocation information related to the IP address + ipObject = MISPObject('ip-api-address') + mapping = get_mapping() + for field, relation in mapping.items(): + ipObject.add_attribute(relation, results[field]) + + misp_event.add_object(ipObject) + + # Return the results in MISP format + event = json.loads(misp_event.to_json()) + return { + 'results': {key: event[key] for key in ('Attribute', 'Object')} + } + + +def query_ipgeolocation(apiKey, ip): + query = requests.get( + f"https://api.ipgeolocation.io/ipgeo?apiKey={apiKey}&ip={ip}" + ) + if query.status_code != 200: + return {'error': f'Error while querying ipGeolocation.io - {query.status_code}: {query.reason}'} + return query.json() + +def get_mapping(): + return { + 'isp':'ISP', + 'asn':'asn', + 'city':'city', + 'country_name':'country', + 'country_code2':'country-code', + 'latitude':'latitude', + 'longitude':'longitude', + 'organization':'organization', + 'continent_name':'region', + 'continent_code':'region-code', + 'state_prov':'state', + 'zipcode':'zipcode', + 'ip':'ip-src' + } + +def introspection(): + return mispattributes + + +def version(): + moduleinfo['config'] = moduleconfig + return moduleinfo From 78a60d8e96edabacfbcd6baeb447134ed32f59a5 Mon Sep 17 00:00:00 2001 From: Usama015 Date: Mon, 19 Jun 2023 13:52:55 +0500 Subject: [PATCH 02/23] updated IPGeolocation Module --- misp_modules/modules/expansion/ipgeolocation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/misp_modules/modules/expansion/ipgeolocation.py b/misp_modules/modules/expansion/ipgeolocation.py index 946ccb2..bfa1e4c 100644 --- a/misp_modules/modules/expansion/ipgeolocation.py +++ b/misp_modules/modules/expansion/ipgeolocation.py @@ -28,7 +28,7 @@ def handler(q=False): misperrors['error'] = 'IpGeolocation apiKey is missing' return misperrors - if request.get('ip-src'): + if request.get('ip-dst'): ip = request['ip-dst'] apiKey = request['config']['apiKey'] return handle_ip(apiKey, ip, misperrors) From 0d40d067ae00b7ac8dbdc72cb5a8b5089fd26453 Mon Sep 17 00:00:00 2001 From: Usama015 Date: Mon, 19 Jun 2023 15:11:41 +0500 Subject: [PATCH 03/23] added multiple Attributes --- .../modules/expansion/ipgeolocation.py | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/misp_modules/modules/expansion/ipgeolocation.py b/misp_modules/modules/expansion/ipgeolocation.py index bfa1e4c..107adce 100644 --- a/misp_modules/modules/expansion/ipgeolocation.py +++ b/misp_modules/modules/expansion/ipgeolocation.py @@ -4,7 +4,7 @@ import requests from pymisp import MISPAttribute, MISPEvent, MISPObject mispattributes = { - 'input': ['ip-dst'], + 'input': ['ip-dst', 'ip-src'], 'format': 'misp_standard' } moduleinfo = { @@ -28,20 +28,19 @@ def handler(q=False): misperrors['error'] = 'IpGeolocation apiKey is missing' return misperrors - if request.get('ip-dst'): - ip = request['ip-dst'] - apiKey = request['config']['apiKey'] - return handle_ip(apiKey, ip, misperrors) - else: - misperrors['error'] = "Unsupported attributes types" - return misperrors + if request['attribute']['type'] not in mispattributes['input']: + return {'error': 'Unsupported attribute type.'} + + ip = request['attribute']['value'] + apiKey = request['config']['apiKey'] + return handle_ip(apiKey, ip, misperrors) def handle_ip(apiKey, ip, misperrors): try: results = query_ipgeolocation(apiKey, ip) except Exception: - misperrors['error'] = "Error while processing IP Data" + misperrors['error'] = "Error while Querying IP Address" return [], False @@ -50,7 +49,7 @@ def handle_ip(apiKey, ip, misperrors): if 'bogon' in results['message']: return {'error': 'The IP address(bogon IP) is reserved for special use'} else: - return {'error': 'Error Occurred during IP data Extraction'} + return {'error': 'Error Occurred during IP data Extraction from Message'} # Initiate the MISP data structures misp_event = MISPEvent() From a15d06e94fa4dcb7287ee5d17516a901f27b84d4 Mon Sep 17 00:00:00 2001 From: Usama015 Date: Mon, 19 Jun 2023 16:04:13 +0500 Subject: [PATCH 04/23] updated --- misp_modules/modules/expansion/ipgeolocation.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/misp_modules/modules/expansion/ipgeolocation.py b/misp_modules/modules/expansion/ipgeolocation.py index 107adce..131f7d4 100644 --- a/misp_modules/modules/expansion/ipgeolocation.py +++ b/misp_modules/modules/expansion/ipgeolocation.py @@ -31,8 +31,14 @@ def handler(q=False): if request['attribute']['type'] not in mispattributes['input']: return {'error': 'Unsupported attribute type.'} - ip = request['attribute']['value'] - apiKey = request['config']['apiKey'] + try: + ip = request['attribute']['value'] + except Exception: + return {'error': 'Error Getting IP' + request} + try: + apiKey = request['config']['apiKey'] + except Exception: + return {'error': 'Error Getting apiKey' + request} return handle_ip(apiKey, ip, misperrors) def handle_ip(apiKey, ip, misperrors): From 7c42950e9b45015803201bad88cb66be4b311858 Mon Sep 17 00:00:00 2001 From: Usama015 Date: Mon, 19 Jun 2023 16:11:58 +0500 Subject: [PATCH 05/23] updated --- misp_modules/modules/expansion/ipgeolocation.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/misp_modules/modules/expansion/ipgeolocation.py b/misp_modules/modules/expansion/ipgeolocation.py index 131f7d4..ed5aabc 100644 --- a/misp_modules/modules/expansion/ipgeolocation.py +++ b/misp_modules/modules/expansion/ipgeolocation.py @@ -47,7 +47,7 @@ def handle_ip(apiKey, ip, misperrors): results = query_ipgeolocation(apiKey, ip) except Exception: misperrors['error'] = "Error while Querying IP Address" - return [], False + return [] # Check if the IP address is not reserved for special use @@ -65,9 +65,11 @@ def handle_ip(apiKey, ip, misperrors): # Parse the geolocation information related to the IP address ipObject = MISPObject('ip-api-address') mapping = get_mapping() - for field, relation in mapping.items(): - ipObject.add_attribute(relation, results[field]) - + try: + for field, relation in mapping.items(): + ipObject.add_attribute(relation, results[field]) + except Exception: + return {'error': 'Error while Adding attributes'} misp_event.add_object(ipObject) # Return the results in MISP format From 6ac1ea946ed020c57a757513c84f027b905e9143 Mon Sep 17 00:00:00 2001 From: Usama015 Date: Mon, 19 Jun 2023 17:26:19 +0500 Subject: [PATCH 06/23] updated --- .../modules/expansion/ipgeolocation.py | 26 +++++++------------ 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/misp_modules/modules/expansion/ipgeolocation.py b/misp_modules/modules/expansion/ipgeolocation.py index ed5aabc..db507bd 100644 --- a/misp_modules/modules/expansion/ipgeolocation.py +++ b/misp_modules/modules/expansion/ipgeolocation.py @@ -13,7 +13,6 @@ moduleinfo = { 'module-type': ['expansion', 'hover'] } moduleconfig = ['apiKey'] -misperrors = {'error': 'Error'} def handler(q=False): @@ -22,32 +21,25 @@ def handler(q=False): return False request = json.loads(q) if not request.get('config'): - misperrors['error'] = 'IpGeolocation Configuration is missing' - return misperrors + return {'error' : 'IpGeolocation Configuration is missing'} if not request['config'].get('apiKey'): - misperrors['error'] = 'IpGeolocation apiKey is missing' - return misperrors + return {'error' : 'IpGeolocation apiKey is missing'} if request['attribute']['type'] not in mispattributes['input']: return {'error': 'Unsupported attribute type.'} - try: - ip = request['attribute']['value'] - except Exception: - return {'error': 'Error Getting IP' + request} - try: - apiKey = request['config']['apiKey'] - except Exception: - return {'error': 'Error Getting apiKey' + request} - return handle_ip(apiKey, ip, misperrors) + ip = request['attribute']['value'] + apiKey = request['config']['apiKey'] + response = handle_ip(apiKey, ip) + return {'error': 'Going to the handleIP method' + response} -def handle_ip(apiKey, ip, misperrors): + +def handle_ip(apiKey, ip): try: results = query_ipgeolocation(apiKey, ip) except Exception: - misperrors['error'] = "Error while Querying IP Address" - return [] + return {'error' : 'Error during querying IPGeolocation API.'} # Check if the IP address is not reserved for special use From 2c2628114ea62c4ce41085438cb46eaa81d463c0 Mon Sep 17 00:00:00 2001 From: Usama015 Date: Mon, 19 Jun 2023 18:29:59 +0500 Subject: [PATCH 07/23] updated --- misp_modules/modules/expansion/ipgeolocation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/misp_modules/modules/expansion/ipgeolocation.py b/misp_modules/modules/expansion/ipgeolocation.py index db507bd..8672c5a 100644 --- a/misp_modules/modules/expansion/ipgeolocation.py +++ b/misp_modules/modules/expansion/ipgeolocation.py @@ -31,7 +31,7 @@ def handler(q=False): ip = request['attribute']['value'] apiKey = request['config']['apiKey'] response = handle_ip(apiKey, ip) - return {'error': 'Going to the handleIP method' + response} + return {'error': 'Going to the handleIP method'} def handle_ip(apiKey, ip): From 44fa20d6439f77f1bef8c58edf68f0bdd473a837 Mon Sep 17 00:00:00 2001 From: Usama015 Date: Mon, 19 Jun 2023 20:59:22 +0500 Subject: [PATCH 08/23] updated readme for Index Page --- README.md | 2 +- documentation/mkdocs/index.md | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index b1aaca0..2475329 100644 --- a/README.md +++ b/README.md @@ -98,7 +98,7 @@ For more information: [Extending MISP with Python modules](https://www.misp-proj * [VulnDB](misp_modules/modules/expansion/vulndb.py) - a module to query [VulnDB](https://www.riskbasedsecurity.com/). * [Vulners](misp_modules/modules/expansion/vulners.py) - an expansion module to expand information about CVEs using Vulners API. * [whois](misp_modules/modules/expansion/whois.py) - a module to query a local instance of [uwhois](https://github.com/rafiot/uwhoisd). -* [whoisfreaks](misp_modules/modules/expansion/whoisfreaks.py) - An expansion module for [whoisfreaks](https://whoisfreaks.com/) that will provide an enriched analysis of the provided domain, including WHOIS and DNS information. Our [Whois service](https://whoisfreaks.com/products/whois-api.html), [DNS Lookup API](https://whoisfreaks.com/products/dns-records-api.html), and [SSL analysis](https://whoisfreaks.com/products/ssl-certificate-api.html), equips organizations with comprehensive threat intelligence and attack surface analysis capabilities for enhanced security. Explore our website's product section at https://whoisfreaks.com/ for a wide range of additional services catering to threat intelligence and attack surface analysis needs. +* [whoisfreaks](misp_modules/modules/expansion/whoisfreaks.py) - an expansion module for [whoisfreaks](https://whoisfreaks.com/) that will provide an enriched analysis of the provided domain, including WHOIS and DNS information. Our [Whois service](https://whoisfreaks.com/products/whois-api.html), [DNS Lookup API](https://whoisfreaks.com/products/dns-records-api.html), and [SSL analysis](https://whoisfreaks.com/products/ssl-certificate-api.html), equips organizations with comprehensive threat intelligence and attack surface analysis capabilities for enhanced security. Explore our website's product section at https://whoisfreaks.com/ for a wide range of additional services catering to threat intelligence and attack surface analysis needs. * [wikidata](misp_modules/modules/expansion/wiki.py) - a [wikidata](https://www.wikidata.org) expansion module. * [xforce](misp_modules/modules/expansion/xforceexchange.py) - an IBM X-Force Exchange expansion module. * [xlsx-enrich](misp_modules/modules/expansion/xlsx_enrich.py) - an enrichment module to get text out of an Excel document into MISP (using free-text parser). diff --git a/documentation/mkdocs/index.md b/documentation/mkdocs/index.md index e2c5a13..72e520c 100644 --- a/documentation/mkdocs/index.md +++ b/documentation/mkdocs/index.md @@ -42,6 +42,7 @@ For more information: [Extending MISP with Python modules](https://www.circl.lu/ * [hashdd](https://github.com/MISP/misp-modules/tree/main/misp_modules/modules/expansion/hashdd.py) - a hover module to check file hashes against [hashdd.com](http://www.hashdd.com) including NSLR dataset. * [hibp](https://github.com/MISP/misp-modules/tree/main/misp_modules/modules/expansion/hibp.py) - a hover module to lookup against Have I Been Pwned? * [intel471](https://github.com/MISP/misp-modules/tree/main/misp_modules/modules/expansion/intel471.py) - an expansion module to get info from [Intel471](https://intel471.com). +* [Ipgeolocation](https://ipgeolocation.io/) - an expansion and hover module for IP Intelligence Stack with [IP to Geolocation](https://ipgeolocation.io/ip-location-api.html), [Timezone](https://ipgeolocation.io/astronomy-api.html) and [Astronomy API](https://ipgeolocation.io/timezone-api.html). * [IPASN](https://github.com/MISP/misp-modules/tree/main/misp_modules/modules/expansion/ipasn.py) - a hover and expansion to get the BGP ASN of an IP address. * [iprep](https://github.com/MISP/misp-modules/tree/main/misp_modules/modules/expansion/iprep.py) - an expansion module to get IP reputation from packetmail.net. * [Joe Sandbox submit](https://github.com/MISP/misp-modules/tree/main/misp_modules/modules/expansion/joesandbox_submit.py) - Submit files and URLs to Joe Sandbox. @@ -76,6 +77,7 @@ For more information: [Extending MISP with Python modules](https://www.circl.lu/ * [VulnDB](https://github.com/MISP/misp-modules/tree/main/misp_modules/modules/expansion/vulndb.py) - a module to query [VulnDB](https://www.riskbasedsecurity.com/). * [Vulners](https://github.com/MISP/misp-modules/tree/main/misp_modules/modules/expansion/vulners.py) - an expansion module to expand information about CVEs using Vulners API. * [whois](https://github.com/MISP/misp-modules/tree/main/misp_modules/modules/expansion/whois.py) - a module to query a local instance of [uwhois](https://github.com/rafiot/uwhoisd). +* [whoisfreaks](misp_modules/modules/expansion/whoisfreaks.py) - an expansion module for [whoisfreaks](https://whoisfreaks.com/) that will provide an enriched analysis of the provided domain, including WHOIS and DNS information. Our [Whois service](https://whoisfreaks.com/products/whois-api.html), [DNS Lookup API](https://whoisfreaks.com/products/dns-records-api.html), and [SSL analysis](https://whoisfreaks.com/products/ssl-certificate-api.html), equips organizations with comprehensive threat intelligence and attack surface analysis capabilities for enhanced security. Explore our website's product section at https://whoisfreaks.com/ for a wide range of additional services catering to threat intelligence and attack surface analysis needs. * [wikidata](https://github.com/MISP/misp-modules/tree/main/misp_modules/modules/expansion/wiki.py) - a [wikidata](https://www.wikidata.org) expansion module. * [xforce](https://github.com/MISP/misp-modules/tree/main/misp_modules/modules/expansion/xforceexchange.py) - an IBM X-Force Exchange expansion module. * [xlsx-enrich](https://github.com/MISP/misp-modules/tree/main/misp_modules/modules/expansion/xlsx-enrich.py) - an enrichment module to get text out of an Excel document into MISP (using free-text parser). From fd929c592c9165c168141338bd92df87b9124717 Mon Sep 17 00:00:00 2001 From: Usama015 Date: Mon, 19 Jun 2023 21:00:11 +0500 Subject: [PATCH 09/23] updated --- misp_modules/modules/expansion/ipgeolocation.py | 1 + 1 file changed, 1 insertion(+) diff --git a/misp_modules/modules/expansion/ipgeolocation.py b/misp_modules/modules/expansion/ipgeolocation.py index 8672c5a..3c0522e 100644 --- a/misp_modules/modules/expansion/ipgeolocation.py +++ b/misp_modules/modules/expansion/ipgeolocation.py @@ -30,6 +30,7 @@ def handler(q=False): ip = request['attribute']['value'] apiKey = request['config']['apiKey'] + return {'error': 'Going to the handleIP method'} response = handle_ip(apiKey, ip) return {'error': 'Going to the handleIP method'} From b28d1871f7df9c7393aaa4e66a5f61ee8b63acea Mon Sep 17 00:00:00 2001 From: Usama015 Date: Mon, 19 Jun 2023 21:00:52 +0500 Subject: [PATCH 10/23] updated --- misp_modules/modules/expansion/ipgeolocation.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/misp_modules/modules/expansion/ipgeolocation.py b/misp_modules/modules/expansion/ipgeolocation.py index 3c0522e..5d3a1c4 100644 --- a/misp_modules/modules/expansion/ipgeolocation.py +++ b/misp_modules/modules/expansion/ipgeolocation.py @@ -31,8 +31,8 @@ def handler(q=False): ip = request['attribute']['value'] apiKey = request['config']['apiKey'] return {'error': 'Going to the handleIP method'} - response = handle_ip(apiKey, ip) - return {'error': 'Going to the handleIP method'} + # response = handle_ip(apiKey, ip) + # return {'error': 'Going to the handleIP method'} def handle_ip(apiKey, ip): From fe047eafc717a0099dc96a9cbf4dcc709dd4dc08 Mon Sep 17 00:00:00 2001 From: Usama015 Date: Mon, 19 Jun 2023 21:47:24 +0500 Subject: [PATCH 11/23] testing --- .../modules/expansion/ipgeolocation.py | 53 ++++++++++--------- 1 file changed, 29 insertions(+), 24 deletions(-) diff --git a/misp_modules/modules/expansion/ipgeolocation.py b/misp_modules/modules/expansion/ipgeolocation.py index 5d3a1c4..5556620 100644 --- a/misp_modules/modules/expansion/ipgeolocation.py +++ b/misp_modules/modules/expansion/ipgeolocation.py @@ -30,9 +30,9 @@ def handler(q=False): ip = request['attribute']['value'] apiKey = request['config']['apiKey'] + # Correct + response = handle_ip(apiKey, ip) return {'error': 'Going to the handleIP method'} - # response = handle_ip(apiKey, ip) - # return {'error': 'Going to the handleIP method'} def handle_ip(apiKey, ip): @@ -44,32 +44,37 @@ def handle_ip(apiKey, ip): # Check if the IP address is not reserved for special use - if results.get('message'): - if 'bogon' in results['message']: - return {'error': 'The IP address(bogon IP) is reserved for special use'} - else: - return {'error': 'Error Occurred during IP data Extraction from Message'} - - # Initiate the MISP data structures - misp_event = MISPEvent() - input_attribute = MISPAttribute() - misp_event.add_attribute(**input_attribute) - - # Parse the geolocation information related to the IP address - ipObject = MISPObject('ip-api-address') - mapping = get_mapping() try: - for field, relation in mapping.items(): - ipObject.add_attribute(relation, results[field]) + if results.get('message'): + if 'bogon' in results['message']: + return {'error': 'The IP address(bogon IP) is reserved for special use'} + else: + return {'error': 'Error Occurred during IP data Extraction from Message'} except Exception: - return {'error': 'Error while Adding attributes'} - misp_event.add_object(ipObject) + return {'error': 'line 54'} + try: + misp_event = MISPEvent() + except Exception: + return {'error': 'line 58'} + # input_attribute = MISPAttribute() + # misp_event.add_attribute(**input_attribute) + + ipObject = MISPObject('ip-api-address') + return {'error': 'line 64'} + # mapping = get_mapping().json() + # try: + # for field, relation in mapping.items(): + # ipObject.add_attribute(relation, results[field]) + # except Exception: + # return {'error': 'Error while Adding attributes'} + # misp_event.add_object(ipObject) +# # Return the results in MISP format - event = json.loads(misp_event.to_json()) - return { - 'results': {key: event[key] for key in ('Attribute', 'Object')} - } + # event = json.loads(misp_event.to_json()) + # return { + # 'results': {key: event[key] for key in ('Attribute', 'Object')} + # } def query_ipgeolocation(apiKey, ip): From 84ecb424d14a7916f0ff773b544e0800725564df Mon Sep 17 00:00:00 2001 From: Usama015 Date: Mon, 19 Jun 2023 22:21:35 +0500 Subject: [PATCH 12/23] updated --- .../modules/expansion/ipgeolocation.py | 53 ++++++++----------- 1 file changed, 22 insertions(+), 31 deletions(-) diff --git a/misp_modules/modules/expansion/ipgeolocation.py b/misp_modules/modules/expansion/ipgeolocation.py index 5556620..a18cc9d 100644 --- a/misp_modules/modules/expansion/ipgeolocation.py +++ b/misp_modules/modules/expansion/ipgeolocation.py @@ -28,14 +28,14 @@ def handler(q=False): if request['attribute']['type'] not in mispattributes['input']: return {'error': 'Unsupported attribute type.'} + attribute = request['attribute'] ip = request['attribute']['value'] apiKey = request['config']['apiKey'] # Correct - response = handle_ip(apiKey, ip) - return {'error': 'Going to the handleIP method'} + return handle_ip(apiKey, ip, attribute) -def handle_ip(apiKey, ip): +def handle_ip(apiKey, ip, attribute): try: results = query_ipgeolocation(apiKey, ip) @@ -44,37 +44,28 @@ def handle_ip(apiKey, ip): # Check if the IP address is not reserved for special use - try: - if results.get('message'): - if 'bogon' in results['message']: - return {'error': 'The IP address(bogon IP) is reserved for special use'} - else: - return {'error': 'Error Occurred during IP data Extraction from Message'} - except Exception: - return {'error': 'line 54'} - try: - misp_event = MISPEvent() - except Exception: - return {'error': 'line 58'} - # input_attribute = MISPAttribute() - # misp_event.add_attribute(**input_attribute) - + if results.get('message'): + if 'bogon' in results['message']: + return {'error': 'The IP address(bogon IP) is reserved for special use'} + else: + return {'error': 'Error Occurred during IP data Extraction from Message'} + misp_event = MISPEvent() + input_attribute = MISPAttribute() + input_attribute.from_dict(**attribute) + misp_event.add_attribute(**input_attribute) ipObject = MISPObject('ip-api-address') - return {'error': 'line 64'} - # mapping = get_mapping().json() - # try: - # for field, relation in mapping.items(): - # ipObject.add_attribute(relation, results[field]) - # except Exception: - # return {'error': 'Error while Adding attributes'} - # misp_event.add_object(ipObject) -# + # Correct + mapping = get_mapping().json() + for field, relation in mapping.items(): + ipObject.add_attribute(relation, results[field]) + misp_event.add_object(ipObject) + # Return the results in MISP format - # event = json.loads(misp_event.to_json()) - # return { - # 'results': {key: event[key] for key in ('Attribute', 'Object')} - # } + event = json.loads(misp_event.to_json()) + return { + 'results': {key: event[key] for key in ('Attribute', 'Object')} + } def query_ipgeolocation(apiKey, ip): From 00f1af5c5935fdd406d3109d896a9ae083b09265 Mon Sep 17 00:00:00 2001 From: Usama015 Date: Tue, 20 Jun 2023 11:32:10 +0500 Subject: [PATCH 13/23] removed the bug --- misp_modules/modules/expansion/ipgeolocation.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/misp_modules/modules/expansion/ipgeolocation.py b/misp_modules/modules/expansion/ipgeolocation.py index a18cc9d..34cf045 100644 --- a/misp_modules/modules/expansion/ipgeolocation.py +++ b/misp_modules/modules/expansion/ipgeolocation.py @@ -56,7 +56,7 @@ def handle_ip(apiKey, ip, attribute): ipObject = MISPObject('ip-api-address') # Correct - mapping = get_mapping().json() + mapping = get_mapping() for field, relation in mapping.items(): ipObject.add_attribute(relation, results[field]) misp_event.add_object(ipObject) @@ -100,3 +100,14 @@ def introspection(): def version(): moduleinfo['config'] = moduleconfig return moduleinfo + +# def main(): +# attribute = { +# 'type' : 'ip-src', +# 'value' : '20.20.12.154' +# } +# handle_ip('efe037a76a17432fad2dbdca8299d559','21.02.15.123', attribute) + +# if __name__ == '__main__': +# main() + From 36fb91882ab8863e1949b445e49bf940db8ad728 Mon Sep 17 00:00:00 2001 From: Usama015 Date: Tue, 20 Jun 2023 12:49:05 +0500 Subject: [PATCH 14/23] updated --- .../modules/expansion/ipgeolocation.py | 62 ++++++++++++------- 1 file changed, 39 insertions(+), 23 deletions(-) diff --git a/misp_modules/modules/expansion/ipgeolocation.py b/misp_modules/modules/expansion/ipgeolocation.py index 34cf045..509bfb9 100644 --- a/misp_modules/modules/expansion/ipgeolocation.py +++ b/misp_modules/modules/expansion/ipgeolocation.py @@ -1,4 +1,5 @@ import json +import traceback import requests from pymisp import MISPAttribute, MISPEvent, MISPObject @@ -32,8 +33,8 @@ def handler(q=False): ip = request['attribute']['value'] apiKey = request['config']['apiKey'] # Correct - return handle_ip(apiKey, ip, attribute) - + response = handle_ip(apiKey, ip, attribute) + return {'error' : f'Completed Response - {response}'} def handle_ip(apiKey, ip, attribute): @@ -49,23 +50,37 @@ def handle_ip(apiKey, ip, attribute): return {'error': 'The IP address(bogon IP) is reserved for special use'} else: return {'error': 'Error Occurred during IP data Extraction from Message'} - misp_event = MISPEvent() - input_attribute = MISPAttribute() - input_attribute.from_dict(**attribute) - misp_event.add_attribute(**input_attribute) + try: + misp_event = MISPEvent() + input_attribute = MISPAttribute() + # input_attribute.from_dict(**attribute) + misp_event.add_attribute(**input_attribute) + except Exception: + return {'error': f'Error on line 58 - {traceback.print_exc()}'} ipObject = MISPObject('ip-api-address') # Correct - mapping = get_mapping() - for field, relation in mapping.items(): - ipObject.add_attribute(relation, results[field]) - misp_event.add_object(ipObject) - + try: + mapping = get_mapping() + except Exception: + return {'error': f'Error on line 66 - {traceback.print_exc()}'} + try: + for field, relation in mapping.items(): + ipObject.add_attribute(relation, results[field]) + except Exception: + return {'error': f'Error on line 71 - {traceback.print_exc()}'} + try: + misp_event.add_object(ipObject) + except Exception: + return {'error': f'Error on line 75 - {traceback.print_exc()}'} # Return the results in MISP format - event = json.loads(misp_event.to_json()) - return { - 'results': {key: event[key] for key in ('Attribute', 'Object')} - } + try: + event = json.loads(misp_event.to_json()) + return { + 'results': {key: event[key] for key in ('Attribute', 'Object')} + } + except Exception: + return {'error': f'Error on line 83 - {traceback.print_exc()}'} def query_ipgeolocation(apiKey, ip): @@ -101,13 +116,14 @@ def version(): moduleinfo['config'] = moduleconfig return moduleinfo -# def main(): -# attribute = { -# 'type' : 'ip-src', -# 'value' : '20.20.12.154' -# } -# handle_ip('efe037a76a17432fad2dbdca8299d559','21.02.15.123', attribute) +def main(): + attribute = { + 'type' : 'ip-src', + 'value' : '20.20.12.154' + } + handle_ip('efe037a76a17432fad2dbdca8299d559','21.02.15.123', attribute) -# if __name__ == '__main__': -# main() +if __name__ == '__main__': + main() + From 2a1b8102ab967cb05f6fd7b80a763125c66f99ac Mon Sep 17 00:00:00 2001 From: Usama015 Date: Tue, 20 Jun 2023 12:52:24 +0500 Subject: [PATCH 15/23] updated --- misp_modules/modules/expansion/ipgeolocation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/misp_modules/modules/expansion/ipgeolocation.py b/misp_modules/modules/expansion/ipgeolocation.py index 509bfb9..f127d97 100644 --- a/misp_modules/modules/expansion/ipgeolocation.py +++ b/misp_modules/modules/expansion/ipgeolocation.py @@ -53,7 +53,7 @@ def handle_ip(apiKey, ip, attribute): try: misp_event = MISPEvent() input_attribute = MISPAttribute() - # input_attribute.from_dict(**attribute) + input_attribute.from_dict(**attribute) misp_event.add_attribute(**input_attribute) except Exception: return {'error': f'Error on line 58 - {traceback.print_exc()}'} From aeb65b1328b55c4d18c43f3189c4193501cdc610 Mon Sep 17 00:00:00 2001 From: Usama015 Date: Tue, 20 Jun 2023 13:07:42 +0500 Subject: [PATCH 16/23] updated --- misp_modules/modules/expansion/ipgeolocation.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/misp_modules/modules/expansion/ipgeolocation.py b/misp_modules/modules/expansion/ipgeolocation.py index f127d97..94ad6a5 100644 --- a/misp_modules/modules/expansion/ipgeolocation.py +++ b/misp_modules/modules/expansion/ipgeolocation.py @@ -116,14 +116,14 @@ def version(): moduleinfo['config'] = moduleconfig return moduleinfo -def main(): - attribute = { - 'type' : 'ip-src', - 'value' : '20.20.12.154' - } - handle_ip('efe037a76a17432fad2dbdca8299d559','21.02.15.123', attribute) +# def main(): +# attribute = { +# 'type' : 'ip-src', +# 'value' : '20.20.12.154' +# } +# handle_ip('efe037a76a17432fad2dbdca8299d559','21.02.15.123', attribute) -if __name__ == '__main__': - main() +# if __name__ == '__main__': +# main() From 4021b97254a088724a7d55e2adf2fdcfbc22b165 Mon Sep 17 00:00:00 2001 From: Usama015 Date: Tue, 20 Jun 2023 13:50:31 +0500 Subject: [PATCH 17/23] updated --- .../modules/expansion/ipgeolocation.py | 65 ++++++------------- 1 file changed, 19 insertions(+), 46 deletions(-) diff --git a/misp_modules/modules/expansion/ipgeolocation.py b/misp_modules/modules/expansion/ipgeolocation.py index 94ad6a5..783f53f 100644 --- a/misp_modules/modules/expansion/ipgeolocation.py +++ b/misp_modules/modules/expansion/ipgeolocation.py @@ -32,64 +32,37 @@ def handler(q=False): attribute = request['attribute'] ip = request['attribute']['value'] apiKey = request['config']['apiKey'] - # Correct - response = handle_ip(apiKey, ip, attribute) - return {'error' : f'Completed Response - {response}'} - -def handle_ip(apiKey, ip, attribute): - - try: - results = query_ipgeolocation(apiKey, ip) - except Exception: - return {'error' : 'Error during querying IPGeolocation API.'} + query = requests.get(f"https://api.ipgeolocation.io/ipgeo?apiKey={apiKey}&ip={ip}") + if query.status_code != 200: + return {'error': f'Error while querying ipGeolocation.io - {query.status_code}: {query.reason}'} # Check if the IP address is not reserved for special use - if results.get('message'): - if 'bogon' in results['message']: + if query.get('message'): + if 'bogon' in query['message']: return {'error': 'The IP address(bogon IP) is reserved for special use'} else: return {'error': 'Error Occurred during IP data Extraction from Message'} - try: - misp_event = MISPEvent() - input_attribute = MISPAttribute() - input_attribute.from_dict(**attribute) - misp_event.add_attribute(**input_attribute) - except Exception: - return {'error': f'Error on line 58 - {traceback.print_exc()}'} + misp_event = MISPEvent() + input_attribute = MISPAttribute() + input_attribute.from_dict(**attribute) + misp_event.add_attribute(**input_attribute) ipObject = MISPObject('ip-api-address') # Correct - try: - mapping = get_mapping() - except Exception: - return {'error': f'Error on line 66 - {traceback.print_exc()}'} - try: - for field, relation in mapping.items(): - ipObject.add_attribute(relation, results[field]) - except Exception: - return {'error': f'Error on line 71 - {traceback.print_exc()}'} - try: - misp_event.add_object(ipObject) - except Exception: - return {'error': f'Error on line 75 - {traceback.print_exc()}'} + mapping = get_mapping() + for field, relation in mapping.items(): + ipObject.add_attribute(relation, query[field]) + misp_event.add_object(ipObject) # Return the results in MISP format - try: - event = json.loads(misp_event.to_json()) - return { - 'results': {key: event[key] for key in ('Attribute', 'Object')} - } - except Exception: - return {'error': f'Error on line 83 - {traceback.print_exc()}'} + event = json.loads(misp_event.to_json()) + return { + 'results': {key: event[key] for key in ('Attribute', 'Object')} + } + # return {'error' : 'Completed Response'} + -def query_ipgeolocation(apiKey, ip): - query = requests.get( - f"https://api.ipgeolocation.io/ipgeo?apiKey={apiKey}&ip={ip}" - ) - if query.status_code != 200: - return {'error': f'Error while querying ipGeolocation.io - {query.status_code}: {query.reason}'} - return query.json() def get_mapping(): return { From 15a6adce869818e97b094934c9f975739d389b2d Mon Sep 17 00:00:00 2001 From: Usama015 Date: Tue, 20 Jun 2023 14:02:49 +0500 Subject: [PATCH 18/23] updated --- misp_modules/modules/expansion/ipgeolocation.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/misp_modules/modules/expansion/ipgeolocation.py b/misp_modules/modules/expansion/ipgeolocation.py index 783f53f..45719bb 100644 --- a/misp_modules/modules/expansion/ipgeolocation.py +++ b/misp_modules/modules/expansion/ipgeolocation.py @@ -53,6 +53,7 @@ def handler(q=False): mapping = get_mapping() for field, relation in mapping.items(): ipObject.add_attribute(relation, query[field]) + ipObject.add_reference(input_attribute.uuid, 'locates') misp_event.add_object(ipObject) # Return the results in MISP format event = json.loads(misp_event.to_json()) @@ -61,9 +62,6 @@ def handler(q=False): } # return {'error' : 'Completed Response'} - - - def get_mapping(): return { 'isp':'ISP', From c32d7722757beb5fc44fe32da1fd32553a55f29f Mon Sep 17 00:00:00 2001 From: Usama015 Date: Tue, 20 Jun 2023 14:26:53 +0500 Subject: [PATCH 19/23] updated --- .../modules/expansion/ipgeolocation.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/misp_modules/modules/expansion/ipgeolocation.py b/misp_modules/modules/expansion/ipgeolocation.py index 45719bb..0451eb3 100644 --- a/misp_modules/modules/expansion/ipgeolocation.py +++ b/misp_modules/modules/expansion/ipgeolocation.py @@ -15,6 +15,22 @@ moduleinfo = { } moduleconfig = ['apiKey'] +_IPGEO_MAPPING ={ + 'isp':'ISP', + 'asn':'asn', + 'city':'city', + 'country_name':'country', + 'country_code2':'country-code', + 'latitude':'latitude', + 'longitude':'longitude', + 'organization':'organization', + 'continent_name':'region', + 'continent_code':'region-code', + 'state_prov':'state', + 'zipcode':'zipcode', + 'ip':'ip-src' + } + def handler(q=False): # Input checks @@ -50,8 +66,7 @@ def handler(q=False): ipObject = MISPObject('ip-api-address') # Correct - mapping = get_mapping() - for field, relation in mapping.items(): + for field, relation in _IPGEO_MAPPING.items(): ipObject.add_attribute(relation, query[field]) ipObject.add_reference(input_attribute.uuid, 'locates') misp_event.add_object(ipObject) From d3d772a2251c19cb59d86572829c52b8977f1d75 Mon Sep 17 00:00:00 2001 From: Usama015 Date: Tue, 20 Jun 2023 14:31:10 +0500 Subject: [PATCH 20/23] updated --- .../modules/expansion/ipgeolocation.py | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/misp_modules/modules/expansion/ipgeolocation.py b/misp_modules/modules/expansion/ipgeolocation.py index 0451eb3..e3c615c 100644 --- a/misp_modules/modules/expansion/ipgeolocation.py +++ b/misp_modules/modules/expansion/ipgeolocation.py @@ -16,20 +16,20 @@ moduleinfo = { moduleconfig = ['apiKey'] _IPGEO_MAPPING ={ - 'isp':'ISP', - 'asn':'asn', - 'city':'city', - 'country_name':'country', - 'country_code2':'country-code', - 'latitude':'latitude', - 'longitude':'longitude', - 'organization':'organization', - 'continent_name':'region', - 'continent_code':'region-code', - 'state_prov':'state', - 'zipcode':'zipcode', - 'ip':'ip-src' - } + 'isp':'ISP', + 'asn':'asn', + 'city':'city', + 'country_name':'country', + 'country_code2':'country-code', + 'latitude':'latitude', + 'longitude':'longitude', + 'organization':'organization', + 'continent_name':'region', + 'continent_code':'region-code', + 'state_prov':'state', + 'zipcode':'zipcode', + 'ip':'ip-src' +} def handler(q=False): @@ -37,7 +37,7 @@ def handler(q=False): if q is False: return False request = json.loads(q) - if not request.get('config'): + if request.get('config'): return {'error' : 'IpGeolocation Configuration is missing'} if not request['config'].get('apiKey'): return {'error' : 'IpGeolocation apiKey is missing'} From 0c9550fae5494dd25d58bc2ed80bcc8b997cc21d Mon Sep 17 00:00:00 2001 From: Usama015 Date: Tue, 20 Jun 2023 14:42:35 +0500 Subject: [PATCH 21/23] updated --- misp_modules/modules/expansion/ipgeolocation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/misp_modules/modules/expansion/ipgeolocation.py b/misp_modules/modules/expansion/ipgeolocation.py index e3c615c..22adeb3 100644 --- a/misp_modules/modules/expansion/ipgeolocation.py +++ b/misp_modules/modules/expansion/ipgeolocation.py @@ -37,7 +37,7 @@ def handler(q=False): if q is False: return False request = json.loads(q) - if request.get('config'): + if not request.get('config'): return {'error' : 'IpGeolocation Configuration is missing'} if not request['config'].get('apiKey'): return {'error' : 'IpGeolocation apiKey is missing'} From fe1dc07de81b56c08278b9a3fb2df39b9d2404cf Mon Sep 17 00:00:00 2001 From: Usama015 Date: Tue, 20 Jun 2023 14:45:51 +0500 Subject: [PATCH 22/23] updated --- misp_modules/modules/expansion/ipgeolocation.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/misp_modules/modules/expansion/ipgeolocation.py b/misp_modules/modules/expansion/ipgeolocation.py index 22adeb3..a2244ae 100644 --- a/misp_modules/modules/expansion/ipgeolocation.py +++ b/misp_modules/modules/expansion/ipgeolocation.py @@ -51,8 +51,7 @@ def handler(q=False): query = requests.get(f"https://api.ipgeolocation.io/ipgeo?apiKey={apiKey}&ip={ip}") if query.status_code != 200: return {'error': f'Error while querying ipGeolocation.io - {query.status_code}: {query.reason}'} - - + query = query.json() # Check if the IP address is not reserved for special use if query.get('message'): if 'bogon' in query['message']: From 98cb43668d119f7c75fc758fa6561a9b749561b0 Mon Sep 17 00:00:00 2001 From: Usama015 Date: Tue, 20 Jun 2023 15:43:09 +0500 Subject: [PATCH 23/23] Completed Testing --- docs/index.md | 2 ++ .../modules/expansion/ipgeolocation.py | 27 ------------------- 2 files changed, 2 insertions(+), 27 deletions(-) diff --git a/docs/index.md b/docs/index.md index e2c5a13..5bb9272 100644 --- a/docs/index.md +++ b/docs/index.md @@ -41,6 +41,7 @@ For more information: [Extending MISP with Python modules](https://www.circl.lu/ * [Greynoise](https://github.com/MISP/misp-modules/tree/main/misp_modules/modules/expansion/greynoise.py) - a hover to get information from greynoise. * [hashdd](https://github.com/MISP/misp-modules/tree/main/misp_modules/modules/expansion/hashdd.py) - a hover module to check file hashes against [hashdd.com](http://www.hashdd.com) including NSLR dataset. * [hibp](https://github.com/MISP/misp-modules/tree/main/misp_modules/modules/expansion/hibp.py) - a hover module to lookup against Have I Been Pwned? +* [Ipgeolocation](https://ipgeolocation.io/) - an expansion and hover module for IP Intelligence Stack with [IP to Geolocation](https://ipgeolocation.io/ip-location-api.html), [Timezone](https://ipgeolocation.io/astronomy-api.html) and [Astronomy API](https://ipgeolocation.io/timezone-api.html). * [intel471](https://github.com/MISP/misp-modules/tree/main/misp_modules/modules/expansion/intel471.py) - an expansion module to get info from [Intel471](https://intel471.com). * [IPASN](https://github.com/MISP/misp-modules/tree/main/misp_modules/modules/expansion/ipasn.py) - a hover and expansion to get the BGP ASN of an IP address. * [iprep](https://github.com/MISP/misp-modules/tree/main/misp_modules/modules/expansion/iprep.py) - an expansion module to get IP reputation from packetmail.net. @@ -75,6 +76,7 @@ For more information: [Extending MISP with Python modules](https://www.circl.lu/ * [VMray](https://github.com/MISP/misp-modules/tree/main/misp_modules/modules/expansion/vmray_submit.py) - a module to submit a sample to VMray. * [VulnDB](https://github.com/MISP/misp-modules/tree/main/misp_modules/modules/expansion/vulndb.py) - a module to query [VulnDB](https://www.riskbasedsecurity.com/). * [Vulners](https://github.com/MISP/misp-modules/tree/main/misp_modules/modules/expansion/vulners.py) - an expansion module to expand information about CVEs using Vulners API. +* [whoisfreaks](misp_modules/modules/expansion/whoisfreaks.py) - an expansion module for [whoisfreaks](https://whoisfreaks.com/) that will provide an enriched analysis of the provided domain, including WHOIS and DNS information. Our [Whois service](https://whoisfreaks.com/products/whois-api.html), [DNS Lookup API](https://whoisfreaks.com/products/dns-records-api.html), and [SSL analysis](https://whoisfreaks.com/products/ssl-certificate-api.html), equips organizations with comprehensive threat intelligence and attack surface analysis capabilities for enhanced security. Explore our website's product section at https://whoisfreaks.com/ for a wide range of additional services catering to threat intelligence and attack surface analysis needs. * [whois](https://github.com/MISP/misp-modules/tree/main/misp_modules/modules/expansion/whois.py) - a module to query a local instance of [uwhois](https://github.com/rafiot/uwhoisd). * [wikidata](https://github.com/MISP/misp-modules/tree/main/misp_modules/modules/expansion/wiki.py) - a [wikidata](https://www.wikidata.org) expansion module. * [xforce](https://github.com/MISP/misp-modules/tree/main/misp_modules/modules/expansion/xforceexchange.py) - an IBM X-Force Exchange expansion module. diff --git a/misp_modules/modules/expansion/ipgeolocation.py b/misp_modules/modules/expansion/ipgeolocation.py index a2244ae..c4030ec 100644 --- a/misp_modules/modules/expansion/ipgeolocation.py +++ b/misp_modules/modules/expansion/ipgeolocation.py @@ -74,24 +74,6 @@ def handler(q=False): return { 'results': {key: event[key] for key in ('Attribute', 'Object')} } - # return {'error' : 'Completed Response'} - -def get_mapping(): - return { - 'isp':'ISP', - 'asn':'asn', - 'city':'city', - 'country_name':'country', - 'country_code2':'country-code', - 'latitude':'latitude', - 'longitude':'longitude', - 'organization':'organization', - 'continent_name':'region', - 'continent_code':'region-code', - 'state_prov':'state', - 'zipcode':'zipcode', - 'ip':'ip-src' - } def introspection(): return mispattributes @@ -101,14 +83,5 @@ def version(): moduleinfo['config'] = moduleconfig return moduleinfo -# def main(): -# attribute = { -# 'type' : 'ip-src', -# 'value' : '20.20.12.154' -# } -# handle_ip('efe037a76a17432fad2dbdca8299d559','21.02.15.123', attribute) - -# if __name__ == '__main__': -# main()