2009-03-29 07:30:54 +00:00
|
|
|
#!/usr/bin/env ruby
|
|
|
|
# This file is part of Metasm, the Ruby assembly manipulation suite
|
2010-09-09 18:19:35 +00:00
|
|
|
# Copyright (C) 2006-2009 Yoann GUILLOT
|
2009-03-29 07:30:54 +00:00
|
|
|
#
|
|
|
|
# Licence is LGPL, see LICENCE in the top-level directory
|
|
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
# quick demonstration that the disassembler's backtracker works
|
|
|
|
#
|
|
|
|
|
2010-09-09 18:19:35 +00:00
|
|
|
require 'metasm'
|
|
|
|
Metasm.require 'samples/metasm-shell'
|
2009-03-29 07:30:54 +00:00
|
|
|
|
|
|
|
puts <<EOS.encode.decode
|
|
|
|
.base_addr 0
|
|
|
|
|
|
|
|
; compute jump target
|
|
|
|
mov ebx, 0x12345678
|
|
|
|
mov eax, ((toto + 12) ^ 0x12345678)
|
|
|
|
xor eax, ebx
|
|
|
|
sub eax, 12
|
|
|
|
|
|
|
|
; jump
|
|
|
|
call eax
|
|
|
|
|
|
|
|
; trap
|
|
|
|
add eax, 42
|
|
|
|
; die, you vile reverser !
|
|
|
|
db 0e9h
|
|
|
|
|
|
|
|
; real target
|
|
|
|
toto:
|
|
|
|
mov eax, 28h
|
|
|
|
pop ebx
|
|
|
|
ret
|
|
|
|
|
|
|
|
EOS
|