MeanDiff icon indicating copy to clipboard operation
MeanDiff copied to clipboard

Example code for testing ARM lifting

Open ebtaleb opened this issue 6 years ago • 1 comments

Hi,

I would like to test ARM lifting for BAP and pyVEX, but I am puzzled by the CLI interface. How does one go about generating instructions to test and to feed to the lifters? The usage part in the README is still to be done.

Could you please provide a minimum working example for testing instructions other than x86/x64?

Thank you.

ebtaleb avatar Nov 19 '18 14:11 ebtaleb

Hi, thank you for your interest in MeanDiff.

Adding architectures without modifying current MeanDiff code is not supported yet, so if you want to test BAP and pyVEX for ARM, you need to fix MeanDiff.

  1. StreamGen Modification You should modify StreamGen module, because current module only generates x86 or x64 instructions. Functions need to be fixed are, blackListGen, whiteListGen, and allGen. Former one is generating instructions based on black list, and the latter is based on white list. You can generate ARM instructions on your own systematic way, or just random instruction generation. You might need a module to check generated instructions are valid or not. Very simple (and dumb) implementation of blackListGen will look like:
let blackListGen arch path =
  let target = readLinesToList path
  match arch with
  | X86 ->
      // existing code
      ...
  | X64 ->
      // existing code
      ...
  | ARM -> // to support ARM, you need to add another type for indicating ARM in CmdOpt.fs
      [ "00000000" ] // this only generates an instruction, "andeq r0, r0, r0"
  1. Lifter Modification Another modules you need to fix are MeanDiff-LifterPyVEX and MeanDiff-LifterBAP written in Python, and OCaml, respectively. You'll only need a small modification like giving an address of image base, or something else.

Please let me know if you have any further questions.

Thank you.

soomin-kim avatar Nov 20 '18 07:11 soomin-kim