packetfu 1.1.4 → 1.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/packetfu/utils.rb +27 -3
- data/lib/packetfu/version.rb +1 -1
- data/packetfu.gemspec +1 -1
- metadata +1 -1
data/lib/packetfu/utils.rb
CHANGED
@@ -132,7 +132,7 @@ module PacketFu
|
|
132
132
|
# method that returns an array rather than just the first candidate.
|
133
133
|
end
|
134
134
|
|
135
|
-
# Handles ifconfig for various (okay,
|
135
|
+
# Handles ifconfig for various (okay, two) platforms.
|
136
136
|
# Will have Windows done shortly.
|
137
137
|
#
|
138
138
|
# Takes an argument (either string or symbol) of the interface to look up, and
|
@@ -182,8 +182,32 @@ module PacketFu
|
|
182
182
|
ret[:ip6_saddr] = $1
|
183
183
|
ret[:ip6_obj] = IPAddr.new($1)
|
184
184
|
end
|
185
|
-
end
|
186
|
-
|
185
|
+
end # linux
|
186
|
+
when /darwin/i
|
187
|
+
ifconfig_data = %x[ifconfig #{iface}]
|
188
|
+
if ifconfig_data =~ /#{iface}/i
|
189
|
+
ifconfig_data = ifconfig_data.split(/[\s]*\n[\s]*/)
|
190
|
+
else
|
191
|
+
raise ArgumentError, "Cannot ifconfig #{iface}"
|
192
|
+
end
|
193
|
+
real_iface = ifconfig_data.first
|
194
|
+
ret[:iface] = real_iface.split(':')[0]
|
195
|
+
ifconfig_data.each do |s|
|
196
|
+
case s
|
197
|
+
when /ether[\s]([0-9a-fA-F:]{17})/i
|
198
|
+
ret[:eth_saddr] = $1
|
199
|
+
ret[:eth_src] = EthHeader.mac2str(ret[:eth_saddr])
|
200
|
+
when /inet[\s]*([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)(.*Mask:([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+))?/i
|
201
|
+
ret[:ip_saddr] = $1
|
202
|
+
ret[:ip_src] = [IPAddr.new($1).to_i].pack("N")
|
203
|
+
ret[:ip4_obj] = IPAddr.new($1)
|
204
|
+
ret[:ip4_obj] = ret[:ip4_obj].mask($3) if $3
|
205
|
+
when /inet6[\s]*([0-9a-fA-F:\x2f]+)/
|
206
|
+
ret[:ip6_saddr] = $1
|
207
|
+
ret[:ip6_obj] = IPAddr.new($1)
|
208
|
+
end
|
209
|
+
end # darwin
|
210
|
+
end # RUBY_PLATFORM
|
187
211
|
ret
|
188
212
|
end
|
189
213
|
|
data/lib/packetfu/version.rb
CHANGED
data/packetfu.gemspec
CHANGED