Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Path: blob/master/lib/msf/base/sessions/mainframe_shell.rb
Views: 11784
# -*- coding: binary -*-123module Msf::Sessions45###6#7# This class provides basic interaction with a Unix Systems Service8# command shell on a mainframe (IBM System Z) running Z/OS9# This session is initialized with a stream that will be used10# as the pipe for reading and writing the command shell.11#12# Date: Oct 8, 201513# Author: Bigendian Smalls14#15###16class MainframeShell < Msf::Sessions::CommandShell1718#19# This interface supports basic interaction.20#21include Msf::Session::Basic2223#24# This interface supports interacting with a single command shell.25#26include Msf::Session::Provider::SingleCommandShell2728##29#30# initialize as mf shell session31#32def initialize(*args)33self.platform = 'mainframe'34self.arch = ARCH_ZARCH35self.translate_1047 = true36super37end3839##40#41# Returns the session description.42#43def desc44"Mainframe shell"45end4647##48#49# override shell_read to include decode of cp104750#51def shell_read(length=-1, timeout=1)52begin53rv = Rex::Text.from_ibm1047(rstream.get_once(length, timeout))54framework.events.on_session_output(self, rv) if rv55return rv56rescue ::Rex::SocketError, ::EOFError, ::IOError, ::Errno::EPIPE => e57shell_close58raise e59end60end6162##63#64# override shell_write to include encode of cp104765#66def shell_write(buf)67#mfimpl68return unless buf6970begin71framework.events.on_session_command(self, buf.strip)72rstream.write(Rex::Text.to_ibm1047(buf))73rescue ::Rex::SocketError, ::EOFError, ::IOError, ::Errno::EPIPE => e74shell_close75raise e76end77end7879def execute_file(full_path, args)80#mfimpl81raise NotImplementedError82end8384def self.can_cleanup_files85false86end8788# need to do more testing on this before we either use the default in command_shell89# or write a new one. For now we just make it unavailble. This prevents a hang on90# initial session creation. See PR#606791undef_method :process_autoruns9293def desc94"Mainframe USS session"95end9697attr_accessor :translate_1047 # tells the session whether or not to translate98# ebcdic (cp1047) <-> ASCII for certain mainframe payloads99# this will be used in post modules to be able to switch on/off the100# translation on file transfers, for instance101102protected103104end105end106107108