mirror of
https://github.com/ail-project/ail-framework.git
synced 2025-01-18 16:36:13 +00:00
chg: [cryptocurrency] add ripple address subtype + correlation
This commit is contained in:
parent
6f964d7f8b
commit
5b5ee502d0
3 changed files with 29 additions and 4 deletions
|
@ -74,7 +74,7 @@ def get_object_all_subtypes(obj_type): # TODO Dynamic subtype
|
||||||
if obj_type == 'chat-thread':
|
if obj_type == 'chat-thread':
|
||||||
return r_object.smembers(f'all_chat-thread:subtypes')
|
return r_object.smembers(f'all_chat-thread:subtypes')
|
||||||
if obj_type == 'cryptocurrency':
|
if obj_type == 'cryptocurrency':
|
||||||
return ['bitcoin', 'bitcoin-cash', 'dash', 'ethereum', 'litecoin', 'monero', 'tron', 'zcash']
|
return ['bitcoin', 'bitcoin-cash', 'dash', 'ethereum', 'litecoin', 'monero', 'ripple', 'tron', 'zcash']
|
||||||
if obj_type == 'pgp':
|
if obj_type == 'pgp':
|
||||||
return ['key', 'mail', 'name']
|
return ['key', 'mail', 'name']
|
||||||
if obj_type == 'username':
|
if obj_type == 'username':
|
||||||
|
|
|
@ -22,6 +22,7 @@ baseurl = config_loader.get_config_str("Notifications", "ail_domain")
|
||||||
config_loader = None
|
config_loader = None
|
||||||
|
|
||||||
digits58 = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'
|
digits58 = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'
|
||||||
|
digits58_ripple = 'rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz'
|
||||||
digits32 = 'qpzry9x8gf2tvdw0s3jn54khce6mua7l'
|
digits32 = 'qpzry9x8gf2tvdw0s3jn54khce6mua7l'
|
||||||
|
|
||||||
|
|
||||||
|
@ -56,7 +57,6 @@ def decode_base58(bc, length):
|
||||||
n = n * 58 + digits58.index(char)
|
n = n * 58 + digits58.index(char)
|
||||||
return n.to_bytes(length, 'big')
|
return n.to_bytes(length, 'big')
|
||||||
|
|
||||||
|
|
||||||
# http://rosettacode.org/wiki/Bitcoin/address_validation#Python
|
# http://rosettacode.org/wiki/Bitcoin/address_validation#Python
|
||||||
def check_base58_address(bc):
|
def check_base58_address(bc):
|
||||||
try:
|
try:
|
||||||
|
@ -65,6 +65,19 @@ def check_base58_address(bc):
|
||||||
except Exception:
|
except Exception:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def decode_base58_ripple(bc, length):
|
||||||
|
n = 0
|
||||||
|
for char in bc:
|
||||||
|
n = n * 58 + digits58_ripple.index(char)
|
||||||
|
return n.to_bytes(length, 'big')
|
||||||
|
|
||||||
|
def check_base58_ripple_address(bc):
|
||||||
|
try:
|
||||||
|
bcbytes = decode_base58_ripple(bc, 25)
|
||||||
|
return bcbytes[-4:] == sha256(sha256(bcbytes[:-4]).digest()).digest()[:4]
|
||||||
|
except Exception:
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
class CryptoCurrency(AbstractSubtypeObject):
|
class CryptoCurrency(AbstractSubtypeObject):
|
||||||
"""
|
"""
|
||||||
|
@ -92,6 +105,8 @@ class CryptoCurrency(AbstractSubtypeObject):
|
||||||
return check_base58_address(self.id)
|
return check_base58_address(self.id)
|
||||||
elif self.subtype == 'dash' or self.subtype == 'litecoin' or self.subtype == 'tron':
|
elif self.subtype == 'dash' or self.subtype == 'litecoin' or self.subtype == 'tron':
|
||||||
return check_base58_address(self.id)
|
return check_base58_address(self.id)
|
||||||
|
elif self.subtype == 'ripple':
|
||||||
|
return check_base58_ripple_address(self.id)
|
||||||
else:
|
else:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@ -110,6 +125,8 @@ class CryptoCurrency(AbstractSubtypeObject):
|
||||||
return 'ZEC'
|
return 'ZEC'
|
||||||
elif self.subtype == 'dash':
|
elif self.subtype == 'dash':
|
||||||
return 'DASH'
|
return 'DASH'
|
||||||
|
elif self.subtype == 'ripple':
|
||||||
|
return 'XRP'
|
||||||
elif self.subtype == 'tron':
|
elif self.subtype == 'tron':
|
||||||
return 'TRX'
|
return 'TRX'
|
||||||
return None
|
return None
|
||||||
|
@ -197,7 +214,7 @@ class CryptoCurrencies(AbstractSubtypeObjects):
|
||||||
|
|
||||||
def get_all_subtypes():
|
def get_all_subtypes():
|
||||||
# return ail_core.get_object_all_subtypes(self.type)
|
# return ail_core.get_object_all_subtypes(self.type)
|
||||||
return ['bitcoin', 'bitcoin-cash', 'dash', 'ethereum', 'litecoin', 'monero', 'tron', 'zcash']
|
return ['bitcoin', 'bitcoin-cash', 'dash', 'ethereum', 'litecoin', 'monero', 'ripple', 'tron', 'zcash']
|
||||||
|
|
||||||
|
|
||||||
# def build_crypto_regex(subtype, search_id):
|
# def build_crypto_regex(subtype, search_id):
|
||||||
|
@ -229,6 +246,8 @@ def get_subtype_by_symbol(symbol):
|
||||||
return 'zcash'
|
return 'zcash'
|
||||||
elif symbol == 'DASH':
|
elif symbol == 'DASH':
|
||||||
return 'dash'
|
return 'dash'
|
||||||
|
elif symbol == 'XRP':
|
||||||
|
return 'ripple'
|
||||||
elif symbol == 'TRX':
|
elif symbol == 'TRX':
|
||||||
return 'tron'
|
return 'tron'
|
||||||
return None
|
return None
|
||||||
|
|
|
@ -97,7 +97,13 @@ CURRENCIES = {
|
||||||
'regex': r'\b(?<![+/=])T[0-9a-zA-Z]{33}(?![+/=])\b',
|
'regex': r'\b(?<![+/=])T[0-9a-zA-Z]{33}(?![+/=])\b',
|
||||||
'max_execution_time': default_max_execution_time,
|
'max_execution_time': default_max_execution_time,
|
||||||
'tag': 'infoleak:automatic-detection="tron-address"',
|
'tag': 'infoleak:automatic-detection="tron-address"',
|
||||||
},
|
},
|
||||||
|
'ripple': {
|
||||||
|
'name': 'ripple', # e.g.
|
||||||
|
'regex': r'\b(?<![+/=])r[0-9a-zA-Z]{24,34}(?![+/=])\b',
|
||||||
|
'max_execution_time': default_max_execution_time,
|
||||||
|
'tag': 'infoleak:automatic-detection="ripple-address"',
|
||||||
|
},
|
||||||
}
|
}
|
||||||
##################################
|
##################################
|
||||||
##################################
|
##################################
|
||||||
|
|
Loading…
Add table
Reference in a new issue