chg: [cryptocurrency] add ripple address subtype + correlation
Some checks failed
CI / ail_test (3.10) (push) Has been cancelled
CI / ail_test (3.7) (push) Has been cancelled
CI / ail_test (3.8) (push) Has been cancelled
CI / ail_test (3.9) (push) Has been cancelled

This commit is contained in:
terrtia 2024-12-11 14:51:44 +01:00
parent 6f964d7f8b
commit 5b5ee502d0
No known key found for this signature in database
GPG key ID: 1E1B1F50D84613D0
3 changed files with 29 additions and 4 deletions

View file

@ -74,7 +74,7 @@ def get_object_all_subtypes(obj_type): # TODO Dynamic subtype
if obj_type == 'chat-thread':
return r_object.smembers(f'all_chat-thread:subtypes')
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':
return ['key', 'mail', 'name']
if obj_type == 'username':

View file

@ -22,6 +22,7 @@ baseurl = config_loader.get_config_str("Notifications", "ail_domain")
config_loader = None
digits58 = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'
digits58_ripple = 'rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz'
digits32 = 'qpzry9x8gf2tvdw0s3jn54khce6mua7l'
@ -56,7 +57,6 @@ def decode_base58(bc, length):
n = n * 58 + digits58.index(char)
return n.to_bytes(length, 'big')
# http://rosettacode.org/wiki/Bitcoin/address_validation#Python
def check_base58_address(bc):
try:
@ -65,6 +65,19 @@ def check_base58_address(bc):
except Exception:
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):
"""
@ -92,6 +105,8 @@ class CryptoCurrency(AbstractSubtypeObject):
return check_base58_address(self.id)
elif self.subtype == 'dash' or self.subtype == 'litecoin' or self.subtype == 'tron':
return check_base58_address(self.id)
elif self.subtype == 'ripple':
return check_base58_ripple_address(self.id)
else:
return True
@ -110,6 +125,8 @@ class CryptoCurrency(AbstractSubtypeObject):
return 'ZEC'
elif self.subtype == 'dash':
return 'DASH'
elif self.subtype == 'ripple':
return 'XRP'
elif self.subtype == 'tron':
return 'TRX'
return None
@ -197,7 +214,7 @@ class CryptoCurrencies(AbstractSubtypeObjects):
def get_all_subtypes():
# 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):
@ -229,6 +246,8 @@ def get_subtype_by_symbol(symbol):
return 'zcash'
elif symbol == 'DASH':
return 'dash'
elif symbol == 'XRP':
return 'ripple'
elif symbol == 'TRX':
return 'tron'
return None

View file

@ -98,6 +98,12 @@ CURRENCIES = {
'max_execution_time': default_max_execution_time,
'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"',
},
}
##################################
##################################