0

I am doing work on the feature extraction of malware .I want to translate the assembly instructions, by discarding the operands and encoding each operator with a unique number (say instruction ID).

I want output like this: Instruction sequence: MOV→CALL→ SUB→MOV IDS of Instruction: 240→33→386→240

Hamad
  • 1
  • 1

1 Answers1

0

Something like:

public static Map<Integer, String> LOOK_UP = new HashMap<>();
static {
    LOOK_UP.put(240, "MOV");
    ...
}

public static String InstructionToString(Integer i) {
    if(LOOK_UP.contains(i)) {
        return LOOK_UP.get(i);
    } else {
        //return error of some kinde
    }
}

public static List<String> InstructionsToString(Integer[] arrayOfInst) {
    List<String> ret = new LinkedList<>();
    for(int i : arrayOfInst) {
        ret.add(InstructionToString(i));
    }
    return ret;
}

(I've not check the syntax of the code)

TungstenX
  • 830
  • 3
  • 19
  • 40