Rimossi rol
This commit is contained in:
parent
167230d18d
commit
71266d07c0
@ -47,11 +47,6 @@ class InvalidValue(AssemblerException):
|
||||
def __init__(self, instruction):
|
||||
super().__init__("Invalid value while assembling: {}".format(instruction))
|
||||
|
||||
rol = lambda val, r_bits, max_bits: \
|
||||
(val << r_bits % max_bits) & (2**max_bits - 1) | \
|
||||
((val & (2**max_bits - 1)) >> (max_bits - (r_bits % max_bits)))
|
||||
|
||||
|
||||
class VMAssembler:
|
||||
|
||||
def __init__(self, key):
|
||||
@ -182,17 +177,17 @@ class VMAssembler:
|
||||
def encrypt_ops(self, key):
|
||||
key_ba = bytearray(key, 'utf-8')
|
||||
olds = copy.deepcopy(ops)
|
||||
|
||||
|
||||
# RC4 KSA! :-P
|
||||
arr = [i for i in range(256)]
|
||||
j = 0
|
||||
for i in range(len(arr)):
|
||||
j = (j + arr[i] + key_ba[i % len(key)]) % len(arr)
|
||||
arr[i], arr[j] = arr[j], arr[i]
|
||||
|
||||
|
||||
for i, o in enumerate(ops):
|
||||
o.set_value(arr[i])
|
||||
|
||||
|
||||
for o, n in zip(olds, ops):
|
||||
print("{} : {}->{}".format(o.name, hex(o.value), hex(n.value)))
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user