Module: Msf::Exploit::Remote::Ip
- Defined in:
- lib/msf/core/exploit/remote/ip.rb
Overview
This module provides methods for communicating with a host over raw IP
Instance Attribute Summary collapse
-
#ip_sock ⇒ Object
protected
Returns the value of attribute ip_sock.
Instance Method Summary collapse
-
#cleanup ⇒ Object
Performs cleanup, closes the socket if necessary.
-
#connect_ip(global = true, opts = {}) ⇒ Object
Creates an IP socket for communicating with a remote host.
-
#disconnect_ip(nsock = self.ip_sock) ⇒ Object
Closes the IP socket.
-
#handler(nsock = self.ip_sock) ⇒ Object
Claims the IP socket if the payload so desires.
-
#initialize(info = {}) ⇒ Object
Initializes an instance of an exploit module that sends raw IP datagrams.
-
#ip_write(dgram) ⇒ Object
Sends a datagram to the host specified in RHOST.
-
#rhost ⇒ Object
Returns the target host.
Instance Attribute Details
#ip_sock ⇒ Object (protected)
Returns the value of attribute ip_sock.
115 116 117 |
# File 'lib/msf/core/exploit/remote/ip.rb', line 115 def ip_sock @ip_sock end |
Instance Method Details
#cleanup ⇒ Object
Performs cleanup, closes the socket if necessary
86 87 88 89 |
# File 'lib/msf/core/exploit/remote/ip.rb', line 86 def cleanup super disconnect_ip end |
#connect_ip(global = true, opts = {}) ⇒ Object
Creates an IP socket for communicating with a remote host
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/msf/core/exploit/remote/ip.rb', line 27 def connect_ip(global = true, opts={}) begin nsock = Rex::Socket::Ip.create( 'Context' => { 'Msf' => framework, 'MsfExploit' => self, }) # Set this socket to the global socket as necessary self.ip_sock = nsock if (global) # Add this socket to the list of sockets created by this exploit add_socket(nsock) return nsock rescue ::Exception => e print_line(" ") print_error( "This module is configured to use a raw IP socket. " + "On Unix systems, only the root user is allowed to create raw sockets. " + "Please run the framework as root to use this module." ) print_line(" ") nil end end |
#disconnect_ip(nsock = self.ip_sock) ⇒ Object
Closes the IP socket
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/msf/core/exploit/remote/ip.rb', line 59 def disconnect_ip(nsock = self.ip_sock) begin if (nsock) nsock.close end rescue IOError end if (nsock == ip_sock) self.ip_sock = nil end # Remove this socket from the list of sockets created by this exploit remove_socket(nsock) end |
#handler(nsock = self.ip_sock) ⇒ Object
Claims the IP socket if the payload so desires. No exploits use raw socket payloads yet…
79 80 81 |
# File 'lib/msf/core/exploit/remote/ip.rb', line 79 def handler(nsock = self.ip_sock) true end |
#initialize(info = {}) ⇒ Object
Initializes an instance of an exploit module that sends raw IP datagrams.
15 16 17 18 19 20 21 22 |
# File 'lib/msf/core/exploit/remote/ip.rb', line 15 def initialize(info = {}) super ( [ Opt::RHOST, ], Msf::Exploit::Remote::Ip) end |
#ip_write(dgram) ⇒ Object
Sends a datagram to the host specified in RHOST
94 95 96 97 |
# File 'lib/msf/core/exploit/remote/ip.rb', line 94 def ip_write(dgram) return nil if not ip_sock ip_sock.sendto(dgram, rhost) end |
#rhost ⇒ Object
Returns the target host
108 109 110 |
# File 'lib/msf/core/exploit/remote/ip.rb', line 108 def rhost datastore['RHOST'] end |