code
stringlengths
1
1.73M
language
stringclasses
1 value
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory require 'metasm/cpu/arm/opcodes' module Metasm class ARM def dbg_register_pc @dbg_register_pc ||= :pc end def dbg_register_flags @dbg...
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory require 'metasm/cpu/arm/opcodes' require 'metasm/decode' module Metasm class ARM # create the bin_mask for a given opcode def build_opcode_...
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory require 'metasm/cpu/arm/opcodes' require 'metasm/encode' module Metasm class ARM def encode_instr_op(program, instr, op) base = op.bin ...
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory require 'metasm/cpu/arm/main' module Metasm class ARM private # ARM MODE def addop(name, bin, *args) args << :cond if not args.delete...
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory require 'metasm/cpu/arm/opcodes' require 'metasm/parse' module Metasm class ARM def opcode_list_byname @opcode_list_byname ||= opcode_lis...
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory require 'metasm/main' module Metasm class ARM < CPU class Reg class << self attr_accessor :s_to_i, :i_to_s end @i_to_s = %w[r0 r1 ...
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory class Metasm::MIPS < Metasm::CPU end require 'metasm/main' require 'metasm/cpu/mips/parse' require 'metasm/cpu/mips/encode' require 'metasm/c...
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory class Metasm::ARM < Metasm::CPU end require 'metasm/main' require 'metasm/cpu/arm/parse' require 'metasm/cpu/arm/encode' require 'metasm/cpu/...
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory class Metasm::X86_64 < Metasm::Ia32 end require 'metasm/main' require 'metasm/cpu/x86_64/parse' require 'metasm/cpu/x86_64/encode' require 'm...
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2010 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory require 'metasm/cpu/python/opcodes' require 'metasm/decode' module Metasm class Python def build_bin_lookaside opcode_list.inject({}) { |l...
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2010 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory require 'metasm/cpu/python/main' module Metasm class Python CMP_OP = %w[< <= == != > >= in not_in is is_not exch] def addop(name, bin, *ar...
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2010 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory require 'metasm/main' module Metasm class Python < CPU def initialize(prog = nil) super() @program = prog @endianness = (prog.respond_...
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory require 'metasm/main' require 'metasm/cpu/bpf/decode' require 'metasm/cpu/bpf/render'
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory require 'metasm/main' require 'metasm/cpu/z80/decode' require 'metasm/cpu/z80/render'
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2010 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory require 'metasm/main' require 'metasm/cpu/arc/decode'
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2010 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory require 'metasm/main' require 'metasm/cpu/python/decode'
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory require 'metasm/main' require 'metasm/cpu/ppc/parse' require 'metasm/cpu/ppc/encode' require 'metasm/cpu/ppc/decode' require 'metasm/cpu/ppc/...
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory require 'metasm/cpu/cy16/opcodes' require 'metasm/render' module Metasm class CY16 class Reg include Renderable def render ; [self.clas...
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory require 'metasm/cpu/cy16/opcodes' require 'metasm/decode' module Metasm class CY16 def build_opcode_bin_mask(op) # bit = 0 if can be muta...
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory require 'metasm/cpu/cy16/main' module Metasm class CY16 def addop(name, bin, *args) o = Opcode.new name, bin args.each { |a| o.args ...
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory require 'metasm/main' module Metasm class CY16 < CPU class Reg class << self attr_accessor :s_to_i, :i_to_s end @i_to_s = (0..14)....
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory require 'metasm/cpu/z80/opcodes' require 'metasm/render' module Metasm class Z80 class Reg include Renderable def render ; [self.class....
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory require 'metasm/cpu/z80/opcodes' require 'metasm/decode' module Metasm class Z80 def build_opcode_bin_mask(op) # bit = 0 if can be mutate...
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory require 'metasm/cpu/z80/main' module Metasm class Z80 def addop(name, bin, *args) o = Opcode.new name, bin args.each { |a| o.args <<...
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory require 'metasm/main' module Metasm class Z80 < CPU class Reg class << self attr_accessor :s_to_i, :i_to_s end @i_to_s = { 8 => { ...
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory require 'metasm/cpu/pic16c/opcodes' require 'metasm/decode' module Metasm class Pic16c def build_opcode_bin_mask(op) # bit = 0 if can be ...
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory require 'metasm/cpu/pic16c/main' module Metasm class Pic16c def addop(name, bin, *l) o = Opcode.new name, bin l.each { |ll| if @prop...
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory require 'metasm/main' module Metasm class Pic16c < CPU def initialize(endianness = :big) super() @endianness = endianness init end e...
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2010 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory require 'metasm/cpu/arc/opcodes' require 'metasm/decode' module Metasm class ARC def major_opcode(val, sz = 16) return val >> (sz == 16 ? ...
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2010 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory require 'metasm/cpu/arc/main' module Metasm class ARC def addop32(name, bin, *args) addop(:ac32, name, bin, *args) end def addop16(name...
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2010 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory require 'metasm/main' module Metasm class ARC < CPU def initialize(e = :little) super() @endianness = e @size = 32 end class Reg ...
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory require 'metasm/cpu/ppc/main' module Metasm class PowerPC # temporarily setup dasm.address_binding so that backtracking # stack-related of...
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory require 'metasm/cpu/ppc/opcodes' require 'metasm/decode' module Metasm class PowerPC def build_opcode_bin_mask(op) # bit = 0 if can be mu...
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory require 'metasm/cpu/ppc/opcodes' require 'metasm/encode' module Metasm class PowerPC private def encode_instr_op(exe, instr, op) base = ...
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory require 'metasm/cpu/ppc/main' module Metasm class PowerPC def addop(name, bin, *argprops) o = Opcode.new name, bin argprops.each { |a|...
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory require 'metasm/cpu/ppc/opcodes' require 'metasm/parse' module Metasm class PowerPC # TODO def parse_arg_valid?(op, sym, arg) case sym ...
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory require 'metasm/main' require 'metasm/render' module Metasm class PowerPC < CPU class Reg include Renderable class << self attr_acce...
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory require 'metasm/cpu/ia32/main' module Metasm class Ia32 # temporarily setup dasm.address_binding so that backtracking # stack-related offs...
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory require 'metasm/cpu/ia32/parse' require 'metasm/compile_c' module Metasm class Ia32 class CCompiler < C::Compiler # holds compiler state in...
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory require 'metasm/cpu/ia32/opcodes' require 'metasm/render' # XXX move context in another file ? module Metasm class Ia32 class Argument in...
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory require 'metasm/cpu/ia32/opcodes' module Metasm class Ia32 def dbg_register_pc @dbg_register_pc ||= :eip end def dbg_register_sp @dbg...
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory require 'metasm/cpu/ia32/opcodes' require 'metasm/decode' module Metasm class Ia32 class ModRM def self.decode(edata, byte, endianness, a...
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory require 'metasm/cpu/ia32/opcodes' require 'metasm/encode' module Metasm class Ia32 class InvalidModRM < Exception ; end class ModRM # re...
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory require 'metasm/cpu/ia32/main' module Metasm class Ia32 def init_cpu_constants @opcode_list ||= [] @fields_mask.update :w => 1, :s => 1...
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory require 'metasm/cpu/ia32/opcodes' require 'metasm/cpu/ia32/encode' require 'metasm/parse' module Metasm class Ia32 class ModRM # may return...
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory require 'metasm/main' module Metasm # The ia32 aka x86 CPU # currently limited to 16 and 32bit modes class Ia32 < CPU # some ruby magic t...
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory # fix autorequire warning class Metasm::Ia32 < Metasm::CPU end require 'metasm/main' require 'metasm/cpu/ia32/parse' require 'metasm/cpu/ia32...
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory require 'metasm/main' require 'metasm/cpu/sh4/decode'
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory require 'metasm/cpu/dalvik/opcodes' require 'metasm/decode' module Metasm class Dalvik def build_bin_lookaside end def decode_findopcode(...
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory # the Dalvik binary format, aka android java backend bytecode # this file was generated using the android source tree, as reference, # specifi...
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory require 'metasm/main' module Metasm class Dalvik < CPU class Reg attr_accessor :i def initialize(i) @i = i end def symbolic ...
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory require 'metasm/cpu/bpf/opcodes' require 'metasm/render' module Metasm class BPF class Reg include Renderable def render ; [@v.to_s] en...
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory require 'metasm/cpu/bpf/opcodes' require 'metasm/decode' module Metasm class BPF def build_bin_lookaside opcode_list.inject({}) { |h, op|...
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory require 'metasm/cpu/bpf/main' module Metasm class BPF def addop(name, bin, *args) o = Opcode.new name, bin args.each { |a| o.args <<...
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory require 'metasm/main' module Metasm class BPF < CPU class Reg attr_accessor :v def initialize(v) @v = v end def symbolic(orig=n...
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory require 'metasm/main' require 'metasm/decode' require 'metasm/parse_c' module Metasm class C::Variable; attr_accessor :stackoff; end class C...
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory require 'metasm/main' require 'metasm/parse_c' module Metasm module C class Parser def precompile @toplevel.precompile(Compiler.new(se...
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory require 'metasm/main' module Metasm # a Renderable element has a method #render that returns an array of [String or Renderable] module Rend...
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory # this file compliments disassemble.rb, adding misc user-friendly methods module Metasm class InstructionBlock # adds an address to the from...
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory module Metasm # this class implements a high-level debugging API (abstract superclass) class Debugger class Breakpoint attr_accessor :addre...
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory require 'metasm/main' require 'metasm/render' module Metasm # symbolic pointer dereference # API similar to Expression class Indirection < ...
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory require 'metasm/exe_format/main' module Metasm class ELF < ExeFormat MAGIC = "\x7fELF" # 0x7f454c46 CLASS = { 0 => 'NONE', 1 => '32', 2 =>...
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory require 'metasm/exe_format/main' require 'metasm/encode' require 'metasm/decode' module Metasm class JavaClass < ExeFormat MAGIC = "\xCA\xF...
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory require 'metasm/decode' require 'metasm/exe_format/elf' unless defined? Metasm::ELF module Metasm class ELF class Header # hook the decod...
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory require 'metasm/exe_format/main' require 'metasm/encode' require 'metasm/decode' begin require 'zlib' rescue LoadError end module Metasm cla...
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory require 'metasm/exe_format/main' require 'metasm/encode' require 'metasm/decode' module Metasm # BFLT is the binary flat format used by the u...
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory require 'metasm/exe_format/main' require 'metasm/encode' require 'metasm/decode' module Metasm class MZ < ExeFormat MAGIC = 'MZ' # 0x4d5a ...
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory require 'metasm/encode' require 'metasm/exe_format/elf' unless defined? Metasm::ELF module Metasm class ELF class Header def set_default_...
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory require 'metasm/exe_format/main' require 'metasm/encode' require 'metasm/decode' module Metasm # GameBoy ROM file format class GameBoyRom <...
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory require 'metasm/exe_format/main' module Metasm # the COFF object file format # mostly used on windows (PE/COFF) class COFF < ExeFormat CHAR...
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory require 'metasm/encode' require 'metasm/exe_format/coff' unless defined? Metasm::COFF module Metasm class COFF class OptionalHeader # enc...
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory require 'metasm/decode' require 'metasm/exe_format/coff' unless defined? Metasm::COFF module Metasm class COFF class OptionalHeader decod...
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory require 'metasm/exe_format/main' module Metasm # special class that decodes a PE, ELF, MachO or UnivBinary file from its signature # XXX Univ...
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory require 'metasm/exe_format/main' require 'metasm/exe_format/mz' require 'metasm/exe_format/coff' module Metasm class PE < COFF MAGIC = "PE\...
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory require 'metasm/exe_format/main' require 'metasm/encode' require 'metasm/decode' module Metasm class AOut < ExeFormat MAGIC = { 0407 => 'OMA...
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory require 'metasm/exe_format/main' require 'metasm/encode' require 'metasm/decode' module Metasm class XCoff < ExeFormat FLAGS = { 1 => 'RELFL...
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory require 'metasm/exe_format/main' require 'metasm/encode' require 'metasm/decode' module Metasm # Python preparsed module (.pyc) class PYC <...
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory require 'metasm/exe_format/main' require 'metasm/encode' require 'metasm/decode' module Metasm class Dol < ExeFormat attr_accessor :header, ...
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory require 'metasm/exe_format/main' require 'metasm/encode' require 'metasm/decode' module Metasm # Android Dalvik executable file format (sim...
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory require 'metasm/exe_format/main' require 'metasm/encode' require 'metasm/decode' module Metasm # Nintendo DS executable file format class N...
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory require 'metasm/exe_format/main' module Metasm # Similar to Shellcode, with distinct sections per memory permission (R / RW / RX) # encoding...
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory require 'metasm/exe_format/main' require 'metasm/encode' require 'metasm/decode' module Metasm class MachO < ExeFormat MAGIC = "\xfe\xed\xf...
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory require 'metasm/main' require 'metasm/parse' require 'metasm/encode' require 'metasm/decode' require 'metasm/exe_format/serialstruct' require...
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory module Metasm # a class representing a simple structure serialized in a binary class SerialStruct # hash shared by all classes # key = class...
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory require 'metasm/exe_format/main' module Metasm # a shellcode is a simple sequence of instructions class Shellcode < ExeFormat # the array o...
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory require 'metasm/exe_format/main' require 'metasm/encode' require 'metasm/decode' begin require 'zlib' rescue LoadError end # generic ZIP fil...
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory require 'metasm/decode' module Metasm # holds information for decoded instructions: the original opcode, a pointer to the InstructionBlock,...
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory require 'metasm/os/main' require 'metasm/debug' require 'socket' module Metasm # lowlevel interface to the gdbserver protocol class GdbClien...
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory require 'metasm/os/main' require 'metasm/debug' require 'metasm/dynldr' module Metasm class WinAPI < DynLdr def self.api_not_found(lib, func...
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory require 'metasm/os/main' require 'metasm/debug' module Metasm class PTrace attr_accessor :buf, :pid def self.open(target) ptrace = new(...
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory require 'metasm/main' module Metasm # this module regroups OS-related functions # (eg. find_process, inject_shellcode) # a 'class' just to be...
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory module Metasm class WindowsExports # exported symbol name => exporting library name for common libraries # used by PE#autoimports EXPORT =...
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory module Metasm class GNUExports # exported symbol name => exporting library name for common libraries # used by ELF#automagic_symbols EXPOR...
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory # This sample creates the dynldr.so ruby shared object that allows interaction with # native libraries # x86 only for now module Metasm class...
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory require 'metasm/gui/dasm_hex' require 'metasm/gui/dasm_listing' require 'metasm/gui/dasm_opcodes' require 'metasm/gui/dasm_coverage' require ...
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory module Metasm module Gui class CdecompListingWidget < DrawableWidget attr_accessor :dasm, :curaddr, :tabwidth def initialize_widget(dasm, p...
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory module Metasm module Gui class AsmOpcodeWidget < DrawableWidget attr_accessor :dasm # nr of raw data bytes to display next to decoded instru...
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory module Metasm module Gui class Graph # one box, has a text, an id, and a list of other boxes to/from class Box attr_accessor :id, :x, :y, ...
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory require 'metasm/gui/dasm_graph' module Metasm module Gui class FuncGraphViewWidget < GraphViewWidget # :full / :from / :to / :both # :from ...
Ruby
# This file is part of Metasm, the Ruby assembly manipulation suite # Copyright (C) 2006-2009 Yoann GUILLOT # # Licence is LGPL, see LICENCE in the top-level directory require 'metasm/gui/dasm_main' module Metasm module Gui # TODO invalidate dbg.disassembler on selfmodifying code class DbgWidget < Container...
Ruby