Class: Ownlan::Attack::Base
- Inherits:
-
Object
- Object
- Ownlan::Attack::Base
- Defined in:
- lib/ownlan/attack/base.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#crafted_packet ⇒ Object
readonly
Returns the value of attribute crafted_packet.
Instance Method Summary collapse
-
#initialize(config) ⇒ Base
constructor
A new instance of Base.
- #ip_to_mac(ip = nil) ⇒ Object
Constructor Details
#initialize(config) ⇒ Base
Returns a new instance of Base.
7 8 9 |
# File 'lib/ownlan/attack/base.rb', line 7 def initialize(config) @config = config end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
5 6 7 |
# File 'lib/ownlan/attack/base.rb', line 5 def config @config end |
#crafted_packet ⇒ Object (readonly)
Returns the value of attribute crafted_packet.
5 6 7 |
# File 'lib/ownlan/attack/base.rb', line 5 def crafted_packet @crafted_packet end |
Instance Method Details
#ip_to_mac(ip = nil) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/ownlan/attack/base.rb', line 12 def ip_to_mac(ip = nil) if ip == ServiceObjects::NetworkInformation.self_ip(config.interface) mac = ServiceObjects::NetworkInformation.self_mac(config.interface) else mac = ::PacketFu::Utils::arp(ip, iface: config.interface) mac ||= raise ::Ownlan::VictimNotReachable, "#{ip}'s mac address cannot be guessed." end rescue RuntimeError raise ::Ownlan::NotRoot, "Please rerun this tool with root privileges." rescue ArgumentError raise ::Ownlan::WrongVictimIpFormat, "#{ip} is not a valid ip format." rescue StandardError raise ::Ownlan::WrongInterace, "#{config.interface} is not ready? Retry again" end |