Class: Rex::Post::Meterpreter::Extensions::Lanattacks::Lanattacks

Inherits:
Rex::Post::Meterpreter::Extension show all
Defined in:
lib/rex/post/meterpreter/extensions/lanattacks/lanattacks.rb

Overview

This meterpreter extension can currently run DHCP and TFTP servers

Instance Attribute Summary

Attributes inherited from Rex::Post::Meterpreter::Extension

#name

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Lanattacks

Returns a new instance of Lanattacks.



19
20
21
22
23
24
25
26
27
# File 'lib/rex/post/meterpreter/extensions/lanattacks/lanattacks.rb', line 19

def initialize(client)
	super(client, 'lanattacks')

	client.register_extension_aliases(
		[{
				'name' => 'lanattacks',
				'ext'  => self
		 },])
end

Instance Method Details

#add_tftp_file(filename, data) ⇒ Object



85
86
87
88
89
90
91
# File 'lib/rex/post/meterpreter/extensions/lanattacks/lanattacks.rb', line 85

def add_tftp_file(filename, data)
	request = Packet.create_request('lanattacks_add_tftp_file')
	request.add_tlv(TLV_TYPE_LANATTACKS_OPTION_NAME, filename)
	request.add_tlv(TLV_TYPE_LANATTACKS_RAW, data, false, true) #compress it
	client.send_request(request)
	true
end

#dhcp_logObject



61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/rex/post/meterpreter/extensions/lanattacks/lanattacks.rb', line 61

def dhcp_log
	response = client.send_request(Packet.create_request('lanattacks_dhcp_log'))
	entries = []
	if( response.result == 0 )
		log = response.get_tlv_value( TLV_TYPE_LANATTACKS_RAW )
		while log.length > 0
			mac = log.slice!(0..5)
			ip = log.slice!(0..3)
			entries << [ mac, ip ]
		end
	end
	entries
end

#load_dhcp_options(datastore) ⇒ Object



47
48
49
50
51
52
53
54
# File 'lib/rex/post/meterpreter/extensions/lanattacks/lanattacks.rb', line 47

def load_dhcp_options(datastore)
	datastore.each do |name, value|
		if Regexp.new('DHCPIPSTART|DHCPIPEND|NETMASK|ROUTER|DNSSERVER|BROADCAST|'+
				'SERVEONCE|PXE|HOSTNAME|HOSTSTART|FILENAME|PXECONF|SRVHOST') =~ name
			set_dhcp_option(name,value)
		end
	end
end

#reset_dhcpObject



34
35
36
37
# File 'lib/rex/post/meterpreter/extensions/lanattacks/lanattacks.rb', line 34

def reset_dhcp
	client.send_request(Packet.create_request('lanattacks_reset_dhcp'))
	true
end

#reset_tftpObject



80
81
82
83
# File 'lib/rex/post/meterpreter/extensions/lanattacks/lanattacks.rb', line 80

def reset_tftp
	client.send_request(Packet.create_request('lanattacks_reset_tftp'))
	true
end

#set_dhcp_option(name, value) ⇒ Object



39
40
41
42
43
44
45
# File 'lib/rex/post/meterpreter/extensions/lanattacks/lanattacks.rb', line 39

def set_dhcp_option(name, value)
	request = Packet.create_request('lanattacks_set_dhcp_option')
	request.add_tlv(TLV_TYPE_LANATTACKS_OPTION_NAME, name)
	request.add_tlv(TLV_TYPE_LANATTACKS_OPTION, value)
	client.send_request(request)
	true
end

#start_dhcpObject



29
30
31
32
# File 'lib/rex/post/meterpreter/extensions/lanattacks/lanattacks.rb', line 29

def start_dhcp
	client.send_request(Packet.create_request('lanattacks_start_dhcp'))
	true
end

#start_tftpObject



75
76
77
78
# File 'lib/rex/post/meterpreter/extensions/lanattacks/lanattacks.rb', line 75

def start_tftp
	client.send_request(Packet.create_request('lanattacks_start_tftp'))
	true
end

#stop_dhcpObject



56
57
58
59
# File 'lib/rex/post/meterpreter/extensions/lanattacks/lanattacks.rb', line 56

def stop_dhcp
	client.send_request(Packet.create_request('lanattacks_stop_dhcp'))
	true
end

#stop_tftpObject



93
94
95
96
# File 'lib/rex/post/meterpreter/extensions/lanattacks/lanattacks.rb', line 93

def stop_tftp
	client.send_request(Packet.create_request('lanattacks_stop_tftp'))
	true
end