def insert_random_bytes(bytecode, amount=1): len_instr = len(bytecode) for _ in range(amount): index = Rnd.uni_integer(0, len_instr - 1) bytecode = bytecode[:index] + Rnd.byte_sequence( 1) + bytecode[index + 1:] return bytecode
import random import evmdasm import evmcodegen from evmcodegen.codegen import Rnd from .code import _RndCodeBase from .address import RndAddress, RndDestAddress, RndAddressType from .base import WeightedRandomizer VALUEMAP = { evmdasm.argtypes.Address: lambda: RndDestAddress().as_bytes(), evmdasm.argtypes.Word: lambda: Rnd.byte_sequence(32), evmdasm.argtypes.Timestamp: lambda: Rnd.byte_sequence(4), evmdasm.argtypes.Data: lambda: Rnd.byte_sequence(Rnd.uni_integer(0, Rnd.opcode())), evmdasm.argtypes.CallValue: lambda: Rnd.uni_integer(0, 1024), evmdasm.argtypes.Gas: lambda: Rnd.uni_integer(0, 1024), evmdasm.argtypes.Length: lambda: Rnd.small_memory_length_1024(), evmdasm.argtypes.MemOffset: lambda: Rnd.small_memory_length_1024(), evmdasm.argtypes.Index256: lambda: Rnd.uni_integer(1, 256), evmdasm.argtypes.Index64: lambda: Rnd.uni_integer(1, 64), evmdasm.argtypes.Index32: lambda: Rnd.length_32(),