Beispiel #1
0
  @Override
  public void init() throws Exception {
    random = new Random(5 + index);

    long rpl = random.nextInt(4);

    String instruction;
    while (true) {
      layers.clear();

      LinkedList<Pair<Long, Long>> prohibited_list = new LinkedList<>();

      InstructionLayer instr = new InstructionLayer(random, prohibited_list);
      layers.add(instr);
      layers.add(new StackLayer(random, prohibited_list));
      layers.add(new OtherLayer(OtherLayer.Type.RANDOM, random));
      layers.add(new FlagsLayer(FlagsLayer.Type.RANDOM, random));
      layers.add(new GeneralRegisterLayer(random));
      layers.add(new SegmentLayer(random));
      layers.add(new MemoryLayer(random));
      layers.add(new IOLayer(random));
      layers.addFirst(
          new HandleModeChangeLayer(
              getInput("cr0_pe"),
              getInput("vmflag"),
              rpl, // getInput("cs_rpl"),
              getInput("cs_p"),
              getInput("cs_s"),
              getInput("cs_type")));

      // instruction size
      boolean cs_d_b = getInput("cs_d_b") == 1;

      boolean a32 = random.nextBoolean();
      boolean o32 = random.nextBoolean();

      // instruction
      instruction = prepare_instr(cs_d_b, a32, o32, null);

      instruction += instruction;
      instruction += "0F0F";

      // add instruction
      instr.add_instruction(instruction);

      // end condition
      break;
    }

    System.out.println("Instruction: [" + instruction + "]");
  }
Beispiel #2
0
  @Override
  public void init() throws Exception {

    random = new Random(1 + index);

    String instruction;
    while (true) {
      layers.clear();

      LinkedList<Pair<Long, Long>> prohibited_list = new LinkedList<>();

      // if false: v8086 mode
      boolean is_real = random.nextBoolean();

      InstructionLayer instr = new InstructionLayer(random, prohibited_list);
      layers.add(instr);
      StackLayer stack = new StackLayer(random, prohibited_list);
      layers.add(stack);
      layers.add(
          new OtherLayer(
              is_real ? OtherLayer.Type.REAL : OtherLayer.Type.PROTECTED_OR_V8086, random));
      layers.add(new FlagsLayer(is_real ? FlagsLayer.Type.RANDOM : FlagsLayer.Type.V8086, random));
      layers.add(new GeneralRegisterLayer(random));
      layers.add(new SegmentLayer(random));
      layers.add(new MemoryLayer(random));
      layers.add(new IOLayer(random));
      layers.addFirst(
          new HandleModeChangeLayer(
              getInput("cr0_pe"),
              getInput("vmflag"),
              getInput("cs_rpl"),
              getInput("cs_p"),
              getInput("cs_s"),
              getInput("cs_type")));

      // instruction size
      boolean cs_d_b = getInput("cs_d_b") == 1;

      boolean a32 = random.nextBoolean();
      boolean o32 = random.nextBoolean();

      final Random final_random = random;
      Layer eax_layer =
          new Layer() {
            long eax() {
              return final_random.nextBoolean()
                  ? 0
                  : final_random.nextBoolean() ? 1 : final_random.nextInt();
            }
          };
      layers.addFirst(eax_layer);

      // instruction
      instruction = prepare_instr(cs_d_b, a32, o32);

      instruction += instruction;
      instruction += "0F0F";

      // add instruction
      instr.add_instruction(instruction);

      // end condition
      break;
    }

    System.out.println("Instruction: [" + instruction + "]");
  }