Rimossi rol
This commit is contained in:
parent
167230d18d
commit
71266d07c0
@ -47,11 +47,6 @@ class InvalidValue(AssemblerException):
|
|||||||
def __init__(self, instruction):
|
def __init__(self, instruction):
|
||||||
super().__init__("Invalid value while assembling: {}".format(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:
|
class VMAssembler:
|
||||||
|
|
||||||
def __init__(self, key):
|
def __init__(self, key):
|
||||||
@ -182,17 +177,17 @@ class VMAssembler:
|
|||||||
def encrypt_ops(self, key):
|
def encrypt_ops(self, key):
|
||||||
key_ba = bytearray(key, 'utf-8')
|
key_ba = bytearray(key, 'utf-8')
|
||||||
olds = copy.deepcopy(ops)
|
olds = copy.deepcopy(ops)
|
||||||
|
|
||||||
# RC4 KSA! :-P
|
# RC4 KSA! :-P
|
||||||
arr = [i for i in range(256)]
|
arr = [i for i in range(256)]
|
||||||
j = 0
|
j = 0
|
||||||
for i in range(len(arr)):
|
for i in range(len(arr)):
|
||||||
j = (j + arr[i] + key_ba[i % len(key)]) % len(arr)
|
j = (j + arr[i] + key_ba[i % len(key)]) % len(arr)
|
||||||
arr[i], arr[j] = arr[j], arr[i]
|
arr[i], arr[j] = arr[j], arr[i]
|
||||||
|
|
||||||
for i, o in enumerate(ops):
|
for i, o in enumerate(ops):
|
||||||
o.set_value(arr[i])
|
o.set_value(arr[i])
|
||||||
|
|
||||||
for o, n in zip(olds, ops):
|
for o, n in zip(olds, ops):
|
||||||
print("{} : {}->{}".format(o.name, hex(o.value), hex(n.value)))
|
print("{} : {}->{}".format(o.name, hex(o.value), hex(n.value)))
|
||||||
|
|
||||||
|
@ -4,11 +4,6 @@
|
|||||||
#include "vmas.h"
|
#include "vmas.h"
|
||||||
#include <string.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) {
|
void VM::encryptOpcodes(uint8_t *key) {
|
||||||
uint8_t arr[256];
|
uint8_t arr[256];
|
||||||
uint32_t i, j, tmp, keysize;
|
uint32_t i, j, tmp, keysize;
|
||||||
|
Loading…
Reference in New Issue
Block a user