Class: Rex::Post::Meterpreter::Ui::Console::CommandDispatcher::Lanattacks::Tftp

Inherits:
Object
  • Object
show all
Includes:
Extensions::Lanattacks, Rex::Post::Meterpreter::Ui::Console::CommandDispatcher
Defined in:
lib/rex/post/meterpreter/ui/console/command_dispatcher/lanattacks/tftp.rb

Overview

The TFTP portion of the lanattacks extension.

Constant Summary collapse

Klass =
Console::CommandDispatcher::Lanattacks::Tftp
@@tftp_start_opts =
Rex::Parser::Arguments.new(
"-h" => [ false, "Help banner." ])
@@tftp_stop_opts =
Rex::Parser::Arguments.new(
"-h" => [ false, "Help banner." ])
@@tftp_reset_opts =
Rex::Parser::Arguments.new(
"-h" => [ false, "Help banner." ])
@@tftp_add_file_opts =
Rex::Parser::Arguments.new(
"-h" => [ false, "Help banner." ])

Constants included from Extensions::Lanattacks

Extensions::Lanattacks::COMMAND_ID_LANATTACKS_ADD_TFTP_FILE, Extensions::Lanattacks::COMMAND_ID_LANATTACKS_DHCP_LOG, Extensions::Lanattacks::COMMAND_ID_LANATTACKS_RESET_DHCP, Extensions::Lanattacks::COMMAND_ID_LANATTACKS_RESET_TFTP, Extensions::Lanattacks::COMMAND_ID_LANATTACKS_SET_DHCP_OPTION, Extensions::Lanattacks::COMMAND_ID_LANATTACKS_START_DHCP, Extensions::Lanattacks::COMMAND_ID_LANATTACKS_START_TFTP, Extensions::Lanattacks::COMMAND_ID_LANATTACKS_STOP_DHCP, Extensions::Lanattacks::COMMAND_ID_LANATTACKS_STOP_TFTP, Extensions::Lanattacks::EXTENSION_ID_LANATTACKS, Extensions::Lanattacks::TLV_TYPE_LANATTACKS_OPTION, Extensions::Lanattacks::TLV_TYPE_LANATTACKS_OPTION_NAME, Extensions::Lanattacks::TLV_TYPE_LANATTACKS_RAW, Extensions::Lanattacks::TLV_TYPE_LANATTACKS_UINT

Instance Attribute Summary

Attributes included from Ui::Text::DispatcherShell::CommandDispatcher

#shell, #tab_complete_items

Instance Method Summary collapse

Methods included from Rex::Post::Meterpreter::Ui::Console::CommandDispatcher

check_hash, #client, #docs_dir, #filter_commands, #initialize, #log_error, #msf_loaded?, set_hash, #unknown_command

Methods included from Ui::Text::DispatcherShell::CommandDispatcher

#cmd_help, #cmd_help_help, #cmd_help_tabs, #deprecated_cmd, #deprecated_commands, #deprecated_help, #docs_dir, #help_to_s, included, #initialize, #print, #print_error, #print_good, #print_line, #print_status, #print_warning, #tab_complete_directory, #tab_complete_filenames, #tab_complete_generic, #tab_complete_source_address, #unknown_command, #update_prompt

Instance Method Details

#cmd_tftp_add_file(*args) ⇒ Object



126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
# File 'lib/rex/post/meterpreter/ui/console/command_dispatcher/lanattacks/tftp.rb', line 126

def cmd_tftp_add_file(*args)
  @@tftp_add_file_opts.parse(args) { |opt, idx, val|
    case opt
    when '-h'
      print_tftp_add_file_usage
      return true
    end
  }

  name = args.shift

  print_status( "Adding file #{name} ..." )
  client.lanattacks.tftp.add_file(name, ::File.read(name))
  print_good( "File added." )
end

#cmd_tftp_reset(*args) ⇒ Object



103
104
105
106
107
108
109
110
111
112
113
114
115
# File 'lib/rex/post/meterpreter/ui/console/command_dispatcher/lanattacks/tftp.rb', line 103

def cmd_tftp_reset(*args)
  @@tftp_reset_opts.parse(args) { |opt, idx, val|
    case opt
    when '-h'
      print_tftp_reset_usage
      return true
    end
  }

  print_status( "Resetting TFTP server ..." )
  client.lanattacks.tftp.reset
  print_good( "TFTP server reset." )
end

#cmd_tftp_start(*args) ⇒ Object



57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/rex/post/meterpreter/ui/console/command_dispatcher/lanattacks/tftp.rb', line 57

def cmd_tftp_start(*args)
  @@tftp_start_opts.parse(args) { |opt, idx, val|
    case opt
    when '-h'
      print_tftp_start_usage
      return true
    end
  }

  print_status( "Starting TFTP server ..." )
  client.lanattacks.tftp.start
  print_good( "TFTP server startd." )
end

#cmd_tftp_stop(*args) ⇒ Object



80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/rex/post/meterpreter/ui/console/command_dispatcher/lanattacks/tftp.rb', line 80

def cmd_tftp_stop(*args)
  @@tftp_stop_opts.parse(args) { |opt, idx, val|
    case opt
    when '-h'
      print_tftp_stop_usage
      return true
    end
  }

  print_status( "Stopping TFTP server ..." )
  client.lanattacks.tftp.stop
  print_good( "TFTP server stopped." )
end

#commandsObject

List of supported commands.



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/rex/post/meterpreter/ui/console/command_dispatcher/lanattacks/tftp.rb', line 25

def commands
  all = {
    'tftp_start'    => 'Start the TFTP server',
    'tftp_stop'     => 'Stop the TFTP server',
    'tftp_reset'    => 'Reset the TFTP server',
    'tftp_add_file' => 'Add a file to the TFTP server'
  }
  reqs = {
    'tftp_start'    => [COMMAND_ID_LANATTACKS_START_TFTP],
    'tftp_stop'     => [COMMAND_ID_LANATTACKS_STOP_TFTP],
    'tftp_reset'    => [COMMAND_ID_LANATTACKS_RESET_TFTP],
    'tftp_add_file' => [COMMAND_ID_LANATTACKS_ADD_TFTP_FILE],
  }
  filter_commands(all, reqs)
end

#nameObject

Name for this dispatcher.



44
45
46
# File 'lib/rex/post/meterpreter/ui/console/command_dispatcher/lanattacks/tftp.rb', line 44

def name
  'Lanattacks: TFTP'
end


120
121
122
123
124
# File 'lib/rex/post/meterpreter/ui/console/command_dispatcher/lanattacks/tftp.rb', line 120

def print_tftp_add_file_usage
  print("tftp_add_file <file> [-h]\n\n" +
        "Add a file to the currently running TFTP server.\n" +
        @@tftp_add_file_opts.usage + "\n")
end


97
98
99
100
101
# File 'lib/rex/post/meterpreter/ui/console/command_dispatcher/lanattacks/tftp.rb', line 97

def print_tftp_reset_usage
  print("tftp_reset [-h]\n\n" +
        "Resets the currently running TFTP server.\n" +
        @@tftp_reset_opts.usage + "\n")
end


51
52
53
54
55
# File 'lib/rex/post/meterpreter/ui/console/command_dispatcher/lanattacks/tftp.rb', line 51

def print_tftp_start_usage
  print("tftp_start [-h]\n\n" +
        "Starts a TFTP server in the current Meterpreter session.\n" +
        @@tftp_start_opts.usage + "\n")
end


74
75
76
77
78
# File 'lib/rex/post/meterpreter/ui/console/command_dispatcher/lanattacks/tftp.rb', line 74

def print_tftp_stop_usage
  print("tftp_stop [-h]\n\n" +
        "Stops the currently running TFTP server.\n" +
        @@tftp_stop_opts.usage + "\n")
end