Changeset 5565
- Timestamp:
- 07/22/08 14:03:59 (1 month ago)
- Files:
-
- framework3/trunk/lib/rex/socket.rb (modified) (1 diff)
- framework3/trunk/lib/rex/socket/comm/local.rb (modified) (3 diffs)
- framework3/trunk/lib/rex/socket/ip.rb (added)
- framework3/trunk/lib/rex/socket/parameters.rb (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
framework3/trunk/lib/rex/socket.rb
r5561 r5565 67 67 end 68 68 69 # 70 # Create a IP socket using the supplied parameter hash. 71 # 72 def self.create_ip(opts = {}) 73 return create_param(Rex::Socket::Parameters.from_hash(opts.merge('Proto' => 'ip'))) 74 end 75 69 76 ## 70 77 # framework3/trunk/lib/rex/socket/comm/local.rb
r5546 r5565 5 5 require 'rex/socket/ssl_tcp_server' 6 6 require 'rex/socket/udp' 7 require 'rex/socket/ip' 7 8 require 'timeout' 8 9 … … 26 27 when 'udp' 27 28 return create_by_type(param, ::Socket::SOCK_DGRAM, ::Socket::IPPROTO_UDP) 29 when 'ip' 30 return create_ip(param) 28 31 else 29 32 raise Rex::UnsupportedProtocol.new(param.proto), caller … … 31 34 end 32 35 36 37 # 38 # Creates a raw IP socket using the supplied Parameter instance. 39 # Special-cased because of how different it is from UDP/TCP 40 # 41 def self.create_ip(param) 42 sock = ::Socket.open(::Socket::PF_INET, ::Socket::SOCK_RAW, ::Socket::IPPROTO_RAW) 43 unless sock.getsockopt(::Socket::SOL_IP, ::Socket::IP_HDRINCL) 44 sock.setsockopt(::Socket::SOL_IP, ::Socket::IP_HDRINCL, true) 45 end 46 47 return sock if (param.bare?) 48 49 sock.extend(::Rex::Socket::Ip) 50 sock.initsock(param) 51 52 sock 53 end 54 55 33 56 # 34 57 # Creates a socket using the supplied Parameter instance. framework3/trunk/lib/rex/socket/parameters.rb
r5113 r5565 193 193 194 194 # 195 # Returns true if the protocol for the parameters is IP. 196 # 197 def ip? 198 return (proto == 'ip') 199 end 200 201 # 195 202 # Returns true if the socket is a bare socket that does not inherit from 196 203 # any extended Rex classes.
