Module: Ronin::Payloads::Mixins::Network
- Included in:
- Shellcode::BindShellPayload, Shellcode::ReverseShellPayload
- Defined in:
- lib/ronin/payloads/mixins/network.rb
Overview
Base class for all reverse shell shellcode payloads.
Instance Method Summary collapse
-
#pack_ipv4(ip, negate: false) ⇒ String
Packs the IPv4 address in network byte-order.
-
#pack_ipv6(ip, negate: false) ⇒ String
Packs the IPv6 address in network byte-order.
-
#pack_port(port, negate: false) ⇒ String
Packs the port number in network byte-order.
Instance Method Details
#pack_ipv4(ip, negate: false) ⇒ String
Packs the IPv4 address in network byte-order.
48 49 50 51 52 53 54 55 56 57 |
# File 'lib/ronin/payloads/mixins/network.rb', line 48 def pack_ipv4(ip, negate: false) ipaddr = IPAddr.new(ip) unless ipaddr.ipv4? raise(ArgumentError,"IP must be an IPv4 address: #{ip.inspect}") end ipaddr = ~ipaddr if negate ipaddr.hton end |
#pack_ipv6(ip, negate: false) ⇒ String
Packs the IPv6 address in network byte-order.
71 72 73 74 75 76 77 78 79 80 |
# File 'lib/ronin/payloads/mixins/network.rb', line 71 def pack_ipv6(ip, negate: false) ipaddr = IPAddr.new(ip) unless ipaddr.ipv6? raise(ArgumentError,"IP must be an IPv6 address: #{ip.inspect}") end ipaddr = ~ipaddr if negate ipaddr.hton end |
#pack_port(port, negate: false) ⇒ String
Packs the port number in network byte-order.
94 95 96 97 |
# File 'lib/ronin/payloads/mixins/network.rb', line 94 def pack_port(port, negate: false) port = ~port if negate [port].pack('n') end |