23
23
inquestlabs [options] yara hexcase <instring>
24
24
inquestlabs [options] yara uint <instring> [--offset=<offset>] [--hex]
25
25
inquestlabs [options] yara widere <regex> [(--big-endian|--little-endian)]
26
+ inquestlabs [options] yara cidr <ipv4>
26
27
inquestlabs [options] lookup ip <ioc>
27
28
inquestlabs [options] lookup domain <ioc>
28
29
inquestlabs [options] report <ioc>
83
84
84
85
# extract version from installed package metadata
85
86
__application_name__ = "inquestlabs"
86
- __version__ = "1.2.3 "
87
+ __version__ = "1.2.4 "
87
88
# __version__ = version(__application_name__)
88
89
__full_version__ = f"{ __application_name__ } { __version__ } "
89
90
@@ -144,7 +145,7 @@ def __init__ (self, api_key=None, config=None, proxies=None, base_url=None, retr
144
145
self .api_key = api_key
145
146
self .base_url = base_url
146
147
self .config_file = config
147
- self .retries = retries
148
+ self .retries = retries
148
149
self .proxies = proxies
149
150
self .verify_ssl = verify_ssl
150
151
self .verbosity = verbose
@@ -214,7 +215,7 @@ def __init__ (self, api_key=None, config=None, proxies=None, base_url=None, retr
214
215
self .__VERBOSE ("api_key_source=%s" % self .api_key_source , INFO )
215
216
216
217
####################################################################################################################
217
- def API (self , api , data = None , path = None , method = "GET" , raw = False ):
218
+ def API (self , api , data = None , path = None , method = "GET" , raw = False , params = None ):
218
219
"""
219
220
Internal API wrapper.
220
221
@@ -228,6 +229,8 @@ def API (self, api, data=None, path=None, method="GET", raw=False):
228
229
:param method: API method, one of "GET" or "POST".
229
230
:type raw: bool
230
231
:param raw: Default behavior is to expect JSON encoded content, raise this flag to expect raw data.
232
+ :type method: str
233
+ :param method: Set a parameter for the request.
231
234
232
235
:rtype: dict | str
233
236
:return: Response dictionary or string if 'raw' flag is raised.
@@ -258,6 +261,7 @@ def API (self, api, data=None, path=None, method="GET", raw=False):
258
261
"headers" : headers ,
259
262
"proxies" : self .proxies ,
260
263
"verify" : self .verify_ssl ,
264
+ "params" : params
261
265
}
262
266
263
267
# make attempts to dance with the API endpoint, use a jittered exponential back-off delay.
@@ -1243,6 +1247,23 @@ def yara_uint (self, magic, offset=0, is_hex=False):
1243
1247
1244
1248
return self .API ("/yara/trigger" , dict (trigger = magic , offset = offset , is_hex = is_hex ))
1245
1249
1250
+ ####################################################################################################################
1251
+ def cidr_to_regex (self , data ):
1252
+ """
1253
+ Produce a regular expression from a IPv4 CIDR notation in a form suitable for usage as a YARA string.
1254
+
1255
+ :type regex: str
1256
+ :param regex: Regular expression to convert.
1257
+
1258
+ :rtype: str
1259
+ :return: Regex string suitable for YARA.
1260
+ """
1261
+
1262
+ # dance with the API and return results.
1263
+ return self .API ("/yara/cidr2regex" , params = {
1264
+ "cidr" : data
1265
+ })
1266
+
1246
1267
########################################################################################################################
1247
1268
########################################################################################################################
1248
1269
########################################################################################################################
@@ -1414,6 +1435,10 @@ def main ():
1414
1435
elif args ['widere' ]:
1415
1436
print (labs .yara_widere (args ['<regex>' ], endian ))
1416
1437
1438
+ # inquestlabs [options] yara cidr <ipv4>
1439
+ elif args ['cidr' ]:
1440
+ print (labs .cidr_to_regex (args ['<ipv4>' ]))
1441
+
1417
1442
# huh?
1418
1443
else :
1419
1444
raise inquestlabs_exception ("yara argument parsing fail." )
0 commit comments