Module: Ragweed::Blocks
Constant Summary
Constants included from Rasm
Rasm::Addl, Rasm::Eax, Rasm::Ebp, Rasm::Ebx, Rasm::Ecx, Rasm::Edi, Rasm::Edx, Rasm::Esi, Rasm::Esp, Rasm::LIBPATH, Rasm::PATH, Rasm::Subl, Rasm::VERSION
Class Method Summary collapse
Instance Method Summary collapse
Methods included from Rasm
eax, ebp, ebx, ecx, edi, edx, esi, esp, libpath, method_missing, path, require_all_libs_relative_to, require_utils, version
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Ragweed::Rasm
Class Method Details
.remote_trampoline(argc, opts = {}) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/ragweed/blocks.rb', line 10 def remote_trampoline(argc, opts={}) i = Ragweed::Rasm::Subprogram.new # drop directly to debugger i << Int(3) if opts[:debug] # psuedo-frame-pointer i.<< Push(esi) i.<< Mov(esi, esp) # get the thread arg i.<< Add(esi, 8) # load it i.<< Mov(esi, [esi]) i.<< Push(ebx) i.<< Mov(ebx, [esi]) i.<< Push(ecx) # harvest arguments out of the argument buffer (0...argc).each do |n| i.<< Mov(ecx, [esi+(4+(n*4))]) i.<< Push(ecx) end i.<< Call(ebx) # stuff return value after args i.<< Mov([esi + (4+(argc*4))], eax) # epilogue i.<< Pop(ecx) i.<< Pop(ebx) i.<< Pop(esi) i.<< Ret() # i think this is an artifact of my IRB, TODO clean up end |
Instance Method Details
#event_pair_stub(opts = {}) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
# File 'lib/ragweed/blocks.rb', line 48 def event_pair_stub(opts={}) i = Ragweed::Rasm::Subprogram.new i << Int(3) if opts[:debug] i.<< Push(ebp) i.<< Mov(ebp, esp) i.<< Sub(esp, 12) i.<< Push(esi) i.<< Mov(esi, [ebp+8]) i.<< Push(eax) i.<< Push(ebx) i.<< Push(edx) # OpenProcess i.<< Mov(ebx, [esi]) # function ptr i.<< Mov(eax, [esi+24]) i.<< Push(eax) i.<< Xor(eax, eax) i.<< Push(eax) i.<< Or(eax, 0x1F0FFF) i.<< Push(eax) i.<< Call(ebx) i.<< Mov([ebp-4], eax) # DuplicateHandle i.<< Mov(ebx, [esi+4]) # function ptr (1..2).each do |which| i.<< Push(2) # flags i.<< Push(0) # dunno i.<< Push(0) # dunno i.<< Mov(edx, ebp) # my LEA encoding is broken i.<< Sub(edx, 8+(4*(which-1))) i.<< Lea(eax, [edx]) i.<< Push(eax) # handle out-arg i.<< Xor(eax, eax) i.<< Not(eax) i.<< Push(eax) # target process i.<< Mov(ecx, esi) i.<< Add(ecx, (20 + (4 * which))) i.<< Push([ecx]) i.<< Push([ebp-4]) # target process handle i.<< Call(ebx) end # ResetHandle i.<< Mov(ebx, [esi+8]) # function ptr (0..1).each do |which| i.<< Push([ebp-(8+(4*which))]) i.<< Call(ebx) end # SignalHandle i.<< Mov(ebx, [esi+12]) # function ptr i.<< Push([ebp-8]) i.<< Call(ebx) # WaitForSingleObject i.<< Mov(ebx, [esi+16]) i.<< Xor(eax, eax) i.<< Not(eax) i.<< Push(eax) i.<< Push([ebp-12]) i.<< Call(ebx) # All done! i.<< Pop(edx) i.<< Pop(ebx) i.<< Pop(eax) i.<< Pop(ecx) i.<< Pop(esi) i.<< Add(esp, 12) i.<< Pop(ebp) i.<< Ret() end |