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

Inherits:
Object
  • Object
show all
Includes:
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." ])

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, #initialize, #log_error, #msf_loaded?, set_hash

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

#cmd_help, #cmd_help_help, #cmd_help_tabs, #deprecated_cmd, #deprecated_commands, #deprecated_help, #help_to_s, #initialize, #print, #print_error, #print_good, #print_line, #print_status, #print_warning, #tab_complete_filenames, #update_prompt

Instance Method Details

#cmd_tftp_add_file(*args) ⇒ Object


137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
# File 'lib/rex/post/meterpreter/ui/console/command_dispatcher/lanattacks/tftp.rb', line 137

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


114
115
116
117
118
119
120
121
122
123
124
125
126
# File 'lib/rex/post/meterpreter/ui/console/command_dispatcher/lanattacks/tftp.rb', line 114

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


68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/rex/post/meterpreter/ui/console/command_dispatcher/lanattacks/tftp.rb', line 68

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


91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/rex/post/meterpreter/ui/console/command_dispatcher/lanattacks/tftp.rb', line 91

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.


23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/rex/post/meterpreter/ui/console/command_dispatcher/lanattacks/tftp.rb', line 23

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"    => [ "lanattacks_start_tftp" ],
    "tftp_stop"     => [ "lanattacks_stop_tftp" ],
    "tftp_reset"    => [ "lanattacks_reset_tftp" ],
    "tftp_add_file" => [ "lanattacks_add_tftp_file" ],
  }

  all.delete_if do |cmd, desc|
    del = false
    reqs[cmd].each do |req|
      next if client.commands.include? req
      del = true
      break
    end

    del
  end

  all
end

#nameObject

Name for this dispatcher.


55
56
57
# File 'lib/rex/post/meterpreter/ui/console/command_dispatcher/lanattacks/tftp.rb', line 55

def name
  "Lanattacks: TFTP"
end

131
132
133
134
135
# File 'lib/rex/post/meterpreter/ui/console/command_dispatcher/lanattacks/tftp.rb', line 131

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

108
109
110
111
112
# File 'lib/rex/post/meterpreter/ui/console/command_dispatcher/lanattacks/tftp.rb', line 108

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

62
63
64
65
66
# File 'lib/rex/post/meterpreter/ui/console/command_dispatcher/lanattacks/tftp.rb', line 62

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

85
86
87
88
89
# File 'lib/rex/post/meterpreter/ui/console/command_dispatcher/lanattacks/tftp.rb', line 85

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