Skip to content

Commit 5b5ee50

Browse files
committed
chg: [cryptocurrency] add ripple address subtype + correlation
1 parent 6f964d7 commit 5b5ee50

File tree

3 files changed

+29
-4
lines changed

3 files changed

+29
-4
lines changed

bin/lib/ail_core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def get_object_all_subtypes(obj_type): # TODO Dynamic subtype
7474
if obj_type == 'chat-thread':
7575
return r_object.smembers(f'all_chat-thread:subtypes')
7676
if obj_type == 'cryptocurrency':
77-
return ['bitcoin', 'bitcoin-cash', 'dash', 'ethereum', 'litecoin', 'monero', 'tron', 'zcash']
77+
return ['bitcoin', 'bitcoin-cash', 'dash', 'ethereum', 'litecoin', 'monero', 'ripple', 'tron', 'zcash']
7878
if obj_type == 'pgp':
7979
return ['key', 'mail', 'name']
8080
if obj_type == 'username':

bin/lib/objects/CryptoCurrencies.py

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
config_loader = None
2323

2424
digits58 = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'
25+
digits58_ripple = 'rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz'
2526
digits32 = 'qpzry9x8gf2tvdw0s3jn54khce6mua7l'
2627

2728

@@ -56,7 +57,6 @@ def decode_base58(bc, length):
5657
n = n * 58 + digits58.index(char)
5758
return n.to_bytes(length, 'big')
5859

59-
6060
# http://rosettacode.org/wiki/Bitcoin/address_validation#Python
6161
def check_base58_address(bc):
6262
try:
@@ -65,6 +65,19 @@ def check_base58_address(bc):
6565
except Exception:
6666
return False
6767

68+
def decode_base58_ripple(bc, length):
69+
n = 0
70+
for char in bc:
71+
n = n * 58 + digits58_ripple.index(char)
72+
return n.to_bytes(length, 'big')
73+
74+
def check_base58_ripple_address(bc):
75+
try:
76+
bcbytes = decode_base58_ripple(bc, 25)
77+
return bcbytes[-4:] == sha256(sha256(bcbytes[:-4]).digest()).digest()[:4]
78+
except Exception:
79+
return False
80+
6881

6982
class CryptoCurrency(AbstractSubtypeObject):
7083
"""
@@ -92,6 +105,8 @@ def is_valid_address(self):
92105
return check_base58_address(self.id)
93106
elif self.subtype == 'dash' or self.subtype == 'litecoin' or self.subtype == 'tron':
94107
return check_base58_address(self.id)
108+
elif self.subtype == 'ripple':
109+
return check_base58_ripple_address(self.id)
95110
else:
96111
return True
97112

@@ -110,6 +125,8 @@ def get_currency_symbol(self):
110125
return 'ZEC'
111126
elif self.subtype == 'dash':
112127
return 'DASH'
128+
elif self.subtype == 'ripple':
129+
return 'XRP'
113130
elif self.subtype == 'tron':
114131
return 'TRX'
115132
return None
@@ -197,7 +214,7 @@ def sanitize_id_to_search(self, subtypes, name_to_search):
197214

198215
def get_all_subtypes():
199216
# return ail_core.get_object_all_subtypes(self.type)
200-
return ['bitcoin', 'bitcoin-cash', 'dash', 'ethereum', 'litecoin', 'monero', 'tron', 'zcash']
217+
return ['bitcoin', 'bitcoin-cash', 'dash', 'ethereum', 'litecoin', 'monero', 'ripple', 'tron', 'zcash']
201218

202219

203220
# def build_crypto_regex(subtype, search_id):
@@ -229,6 +246,8 @@ def get_subtype_by_symbol(symbol):
229246
return 'zcash'
230247
elif symbol == 'DASH':
231248
return 'dash'
249+
elif symbol == 'XRP':
250+
return 'ripple'
232251
elif symbol == 'TRX':
233252
return 'tron'
234253
return None

bin/modules/Cryptocurrencies.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,13 @@
9797
'regex': r'\b(?<![+/=])T[0-9a-zA-Z]{33}(?![+/=])\b',
9898
'max_execution_time': default_max_execution_time,
9999
'tag': 'infoleak:automatic-detection="tron-address"',
100-
},
100+
},
101+
'ripple': {
102+
'name': 'ripple', # e.g.
103+
'regex': r'\b(?<![+/=])r[0-9a-zA-Z]{24,34}(?![+/=])\b',
104+
'max_execution_time': default_max_execution_time,
105+
'tag': 'infoleak:automatic-detection="ripple-address"',
106+
},
101107
}
102108
##################################
103109
##################################

0 commit comments

Comments
 (0)