32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
# File 'lib/bettercap/monkey/packetfu/utils.rb', line 32
def self.ifconfig(iface='eth0')
ret = {}
iface = iface.to_s.scan(/[0-9A-Za-z]/).join
BetterCap::Logger.debug "ifconfig #{iface}"
if BetterCap::Shell.available?('ifconfig')
BetterCap::Logger.debug "Using ifconfig"
data = BetterCap::Shell.ifconfig(iface)
if data =~ /#{iface}/i
data = data.split(/[\s]*\n[\s]*/)
else
raise ArgumentError, "Cannot ifconfig #{iface}"
end
case RUBY_PLATFORM
when /linux/i
ret = linux_ifconfig iface, data
when /darwin/i
ret = darwin_ifconfig iface, data
when /openbsd/i
ret = openbsd_ifconfig iface, data
end
elsif BetterCap::Shell.available?('ip')
BetterCap::Logger.debug "Using iproute2"
data = BetterCap::Shell.ip(iface)
ret = linux_ip iface, data
else
raise BetterCap::Error, 'Unsupported operating system'
end
ret
end
|