Rimossi rol

This commit is contained in:
Giulio De Pasquale 2017-05-18 18:28:51 +02:00
parent 167230d18d
commit 71266d07c0
2 changed files with 3 additions and 13 deletions

View File

@ -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)))

View File

@ -4,11 +4,6 @@
#include "vmas.h"
#include <string.h>
unsigned rol(unsigned x, int L, int N) {
unsigned lsbs = x & ((1 >> L) - 1);
return (x << L) | (lsbs >> (N - L));
}
void VM::encryptOpcodes(uint8_t *key) {
uint8_t arr[256];
uint32_t i, j, tmp, keysize;