Class: Msf::Sessions::MainframeShell

Inherits:
CommandShell show all
Includes:
Msf::Session::Basic, Msf::Session::Provider::SingleCommandShell
Defined in:
lib/msf/base/sessions/mainframe_shell.rb

Overview

This class provides basic interaction with a Unix Systems Service command shell on a mainframe (IBM System Z) running Z/OS This session is initialized with a stream that will be used as the pipe for reading and writing the command shell.

Date:    Oct 8, 2015
Author:  Bigendian Smalls

Instance Attribute Summary collapse

Attributes included from Msf::Session::Interactive

#rstream

Attributes included from Rex::Ui::Interactive

#completed, #interacting, #next_session, #on_command_proc, #on_print_proc, #orig_suspend, #orig_usr1

Attributes included from Rex::Ui::Subscriber::Input

#user_input

Attributes included from Rex::Ui::Subscriber::Output

#user_output

Attributes included from Msf::Session

#alive, #db_record, #exploit, #exploit_datastore, #exploit_task, #exploit_uuid, #framework, #info, #machine_id, #payload_uuid, #routes, #sid, #sname, #target_host, #target_port, #username, #uuid, #via, #workspace

Attributes included from Framework::Offspring

#framework

Attributes inherited from CommandShell

#arch, #max_threads, #platform

Instance Method Summary collapse

Methods included from Msf::Session::Provider::SingleCommandShell

#set_shell_token_index, #shell_close, #shell_command_token, #shell_command_token_unix, #shell_command_token_win32, #shell_init, #shell_read_until_token

Methods included from Msf::Session::Basic

#_interact, #type

Methods included from Msf::Session::Interactive

#_interact, #_interact_complete, #_interrupt, #_suspend, #_usr1, #cleanup, #interactive?, #kill, #run_cmd, #tunnel_local, #tunnel_peer, #user_want_abort?

Methods included from Rex::Ui::Interactive

#_interact, #_interact_complete, #_interrupt, #_local_fd, #_remote_fd, #_stream_read_local_write_remote, #_stream_read_remote_write_local, #_suspend, #detach, #handle_suspend, #handle_usr1, #interact, #interact_stream, #prompt, #prompt_yesno, #restore_suspend, #restore_usr1

Methods included from Rex::Ui::Subscriber

#copy_ui, #init_ui, #reset_ui

Methods included from Rex::Ui::Subscriber::Input

#gets

Methods included from Rex::Ui::Subscriber::Output

#flush, #print, #print_blank_line, #print_error, #print_good, #print_line, #print_status, #print_warning

Methods included from Msf::Session

#alive?, #cleanup, #dead?, #inspect, #interactive?, #kill, #log_file_name, #log_source, #name, #name=, #register?, #session_host, #session_host=, #session_port, #session_port=, #session_type, #set_from_exploit, #set_via, #tunnel_local, #tunnel_peer, #tunnel_to_s, #type, type, #via_exploit, #via_payload

Methods inherited from CommandShell

#_interact, #_interact_stream, #binary_exists, #cleanup, #cmd_background, #cmd_background_help, #cmd_download, #cmd_download_help, #cmd_help, #cmd_help_help, #cmd_irb, #cmd_irb_help, #cmd_pry, #cmd_pry_help, #cmd_resource, #cmd_resource_help, #cmd_sessions, #cmd_sessions_help, #cmd_shell, #cmd_shell_help, #cmd_source, #cmd_source_help, #cmd_upload, #cmd_upload_help, #commands, #docs_dir, #file_exists, #process_autoruns, #repr, #run_builtin_cmd, #run_single, #shell_close, #shell_command, #shell_init, #type, type

Methods included from Rex::Ui::Text::Resource

#load_resource

Methods included from Msf::Session::Scriptable

#execute_script, included, #legacy_script_to_post_module

Constructor Details

#initialize(*args) ⇒ MainframeShell

initialize as mf shell session


34
35
36
37
38
39
# File 'lib/msf/base/sessions/mainframe_shell.rb', line 34

def initialize(*args)
  self.platform = 'mainframe'
  self.arch = ARCH_ZARCH
  self.translate_1047 = true
  super
end

Instance Attribute Details

#translate_1047Object

Returns the value of attribute translate_1047


95
96
97
# File 'lib/msf/base/sessions/mainframe_shell.rb', line 95

def translate_1047
  @translate_1047
end

Instance Method Details

#descObject

Returns the session description.


45
46
47
# File 'lib/msf/base/sessions/mainframe_shell.rb', line 45

def desc
  "Mainframe shell"
end

#execute_file(full_path, args) ⇒ Object

Raises:

  • (NotImplementedError)

81
82
83
84
# File 'lib/msf/base/sessions/mainframe_shell.rb', line 81

def execute_file(full_path, args)
  #mfimpl
  raise NotImplementedError
end

#shell_read(length = -1,, timeout = 1) ⇒ Object

override shell_read to include decode of cp1047


53
54
55
56
57
58
59
60
61
62
# File 'lib/msf/base/sessions/mainframe_shell.rb', line 53

def shell_read(length=-1, timeout=1)
  begin
    rv = Rex::Text.from_ibm1047(rstream.get_once(length, timeout))
    framework.events.on_session_output(self, rv) if rv
    return rv
  rescue ::Rex::SocketError, ::EOFError, ::IOError, ::Errno::EPIPE => e
    shell_close
    raise e
  end
end

#shell_write(buf) ⇒ Object

override shell_write to include encode of cp1047


68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/msf/base/sessions/mainframe_shell.rb', line 68

def shell_write(buf)
  #mfimpl
  return unless buf

  begin
    framework.events.on_session_command(self, buf.strip)
    rstream.write(Rex::Text.to_ibm1047(buf))
  rescue ::Rex::SocketError, ::EOFError, ::IOError, ::Errno::EPIPE => e
    shell_close
    raise e
  end
end