Skip to content

Commit daf2acc

Browse files
committed
Initial work to support Mettle exetensions (and a sniffer).
See MS-2775.
1 parent 95b6cda commit daf2acc

File tree

3 files changed

+35
-9
lines changed

3 files changed

+35
-9
lines changed

lib/msf/base/sessions/meterpreter.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,7 @@ def binary_suffix
646646
when 'windows'
647647
"#{self.arch}.dll"
648648
when 'linux' , 'aix' , 'hpux' , 'irix' , 'unix'
649-
'lso'
649+
'bin'
650650
when 'android', 'java'
651651
'jar'
652652
when 'php'

lib/rex/post/meterpreter/extensions/sniffer/sniffer.rb

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,13 @@ def interfaces()
3939
response.each(TLV_TYPE_SNIFFER_INTERFACES) { |p|
4040
vals = p.tlvs.map{|x| x.value }
4141
iface = { }
42-
ikeys = %W{idx name description type mtu wireless usable dhcp}
42+
if vals.length == 8
43+
# Windows
44+
ikeys = %W{idx name description type mtu wireless usable dhcp}
45+
else
46+
# Mettle
47+
ikeys = %W{idx name description usable}
48+
end
4349
ikeys.each_index { |i| iface[ikeys[i]] = vals[i] }
4450
ifaces << iface
4551
}

lib/rex/post/meterpreter/ui/console/command_dispatcher/sniffer.rb

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,26 @@ def initialize(shell)
2828
# List of supported commands.
2929
#
3030
def commands
31+
#all = {
3132
{
3233
"sniffer_interfaces" => "Enumerate all sniffable network interfaces",
3334
"sniffer_start" => "Start packet capture on a specific interface",
3435
"sniffer_stop" => "Stop packet capture on a specific interface",
3536
"sniffer_stats" => "View statistics of an active capture",
3637
"sniffer_dump" => "Retrieve captured packet data to PCAP file",
37-
"sniffer_release" => "Free captured packets on a specific interface instead of downloading them",
38+
"sniffer_release" => "Free captured packets on a specific interface instead of downloading them"
3839
}
40+
41+
#reqs = {
42+
# "sniffer_interfaces" => ['sniffer_interfaces'],
43+
# "sniffer_start" => ['sniffer_capture_start'],
44+
# "sniffer_stop" => ['sniffer_capture_stop'],
45+
# "sniffer_stats" => ['sniffer_capture_stats'],
46+
# "sniffer_dump" => ['sniffer_capture_dump'],
47+
# "sniffer_release" => ['sniffer_capture_release']
48+
#}
49+
50+
#filter_commands(all, reqs)
3951
end
4052

4153

@@ -46,10 +58,18 @@ def cmd_sniffer_interfaces(*args)
4658
print_line()
4759

4860
ifaces.each do |i|
49-
print_line(sprintf("%d - '%s' ( type:%d mtu:%d usable:%s dhcp:%s wifi:%s )",
50-
i['idx'], i['description'],
51-
i['type'], i['mtu'], i['usable'], i['dhcp'], i['wireless'])
52-
)
61+
if i.length == 8
62+
# Windows
63+
print_line(sprintf("%d - '%s' ( type:%d mtu:%d usable:%s dhcp:%s wifi:%s )",
64+
i['idx'], i['description'],
65+
i['type'], i['mtu'], i['usable'], i['dhcp'], i['wireless'])
66+
)
67+
else
68+
# Mettle
69+
print_line(sprintf("%d - '%s' ( usable:%s )",
70+
i['idx'], i['description'], i['usable'])
71+
)
72+
end
5373
end
5474

5575
print_line()
@@ -167,10 +187,10 @@ def cmd_sniffer_dump(*args)
167187
# TODO: reorder packets based on the ID (only an issue if the buffer wraps)
168188
while(true)
169189
buf = od.read(20)
170-
break if not buf
190+
break unless buf
171191

172192
idh,idl,thi,tlo,len = buf.unpack('N5')
173-
break if not len
193+
break unless len
174194
if(len > 10000)
175195
print_error("Corrupted packet data (length:#{len})")
176196
break

0 commit comments

Comments
 (0)