#!/usr/bin/env python ## -*- coding: utf-8 -*- ## ## This program is under the terms of the BSD License. ## Jonathan Salwan - 2020-03-18 ## ## Generate oracles table for obfuscated expressions synthesis ## import sys import operator from ctypes import c_uint64 from random import randrange HOW_BIG_IS_THE_TABLE = 1000 def gen_op(op, sign): print(' {') print(' \'oracles\' : [') for i in range(HOW_BIG_IS_THE_TABLE): s1 = randrange(0, 0x100) s2 = randrange(0, 0x100) r1 = c_uint64(op(s1, s2)).value s3 = randrange(0x100, 0x10000) s4 = randrange(0x100, 0x10000) r2 = c_uint64(op(s3, s4)).value s5 = randrange(0x10000, 0x100000000) s6 = randrange(0x10000, 0x100000000) r3 = c_uint64(op(s5, s6)).value s7 = randrange(0x100000000, 0x10000000000000000) s8 = randrange(0x100000000, 0x10000000000000000) r4 = c_uint64(op(s7, s8)).value print(' (%d, %d, %d), (%d, %d, %d), (%d, %d, %d), (%d, %d, %d),' % (s1, s2, r1, s3, s4, r2, s5, s6, r3, s7, s8, r4) ) print(' ],') print(' \'synthesis\' : \'x %s y\'' %(sign)) print(' },') return def main(): print('oracles_table = [') gen_op(operator.__add__, '+') gen_op(operator.__sub__, '-') gen_op(operator.__xor__, '^') gen_op(operator.__or__, '|') gen_op(operator.__and__, '&') gen_op(operator.__mul__, '*') print(']') return 0 if __name__ == '__main__': sys.exit(main())