online 7ˆl–Ðz¾” ŠeJeAà™¸ËêbÑ¿�þDó@Y¹Dã­ÆGŠñüÿ „_ÁÀ¿(@local stdnse = require "stdnse" local shortport = require "shortport" local tn3270 = require "tn3270" local brute = require "brute" local creds = require "creds" local unpwdb = require "unpwdb" local nmap = require "nmap" local string = require "string" local stringaux = require "stringaux" description = [[ TSO User ID enumerator for IBM mainframes (z/OS). The TSO logon panel tells you when a user ID is valid or invalid with the message: IKJ56420I Userid not authorized to use TSO. The TSO logon process can work in two ways: 1) You get prompted with IKJ56700A ENTER USERID - to which you reply with the user you want to use. If the user ID is valid it will give you a normal TSO logon screen. Otherwise it will give you the screen logon error above. 2) You're given the TSO logon panel and enter your user ID at the Userid ===> prompt. If you give it an invalid user ID you receive the error message above. This script relies on the NSE TN3270 library which emulates a TN3270 screen for NMAP. TSO user IDs have the following rules: - it cannot begin with a number - only contains alpha-numeric characters and @, #, $. - it cannot be longer than 7 chars ]] --- -- @args tso-enum.commands Commands in a semi-colon separated list needed -- to access TSO. Defaults to tso. -- -- @usage -- nmap --script=tso-enum -p 23 -- -- @usage -- nmap -sV -p 9923 10.32.70.10 --script tso-enum --script-args userdb=tso_users.txt,tso-enum.commands="logon applid(tso)" -- -- @output -- PORT STATE SERVICE VERSION -- 23/tcp open tn3270 IBM Telnet TN3270 -- | tso-enum: -- | TSO User ID: -- | TSO User:RAZOR - Valid User ID -- | TSO User:BLADE - Valid User ID -- | TSO User:PLAGUE - Valid User ID -- |_ Statistics: Performed 6 guesses in 3 seconds, average tps: 2 -- -- @changelog -- 2015-07-04 - v0.1 - created by Soldier of Fortran -- 2015-10-30 - v0.2 - streamlined the code, relying on brute and unpwdb and -- renamed to tso-enum. -- 2017-1-13 - v0.3 - Fixed 'data' bug and added options checking to speedup -- 2019-02-01 - v0.4 - Disabled TN3270 Enhanced support and fixed debug errors author = "Philip Young aka Soldier of Fortran" license = "Same as Nmap--See https://nmap.org/book/man-legal.html" categories = {"intrusive", "brute"} portrule = shortport.port_or_service({23,992,623}, {"tn3270"}) Driver = { new = function(self, host, port, options) local o = {} setmetatable(o, self) self.__index = self o.host = host o.port = port o.options = options o.tn3270 = tn3270.Telnet:new() o.tn3270:disable_tn3270e() return o end, connect = function( self ) local status, err = self.tn3270:initiate(self.host,self.port) self.tn3270:get_screen_debug(2) if not status then stdnse.debug("Could not initiate TN3270: %s", err ) return false end return true end, disconnect = function( self ) self.tn3270:send_pf(3) self.tn3270:disconnect() self.tn3270 = nil return true end, login = function (self, user, pass) -- pass is actually the user id we want to try local commands = self.options['key1'] local skip = self.options['skip'] stdnse.debug(2,"Getting to TSO") local run = stringaux.strsplit(";%s*", commands) for i = 1, #run do stdnse.debug(2,"Issuing Command (#%s of %s): %s", i, #run ,run[i]) if i == #run and run[i]:upper():find("LOGON APPLID") and skip then stdnse.verbose(2,"Trying User ID: %s", pass) self.tn3270:send_cursor(run[i] .. " DATA(" .. pass .. ")") elseif i == #run and skip then stdnse.verbose(2,"Trying User ID: %s", pass) self.tn3270:send_cursor(run[i] .. " " .. pass) else self.tn3270:send_cursor(run[i]) end self.tn3270:get_all_data() end if self.tn3270:find("%*%*%*") then self.tn3270:send_enter() self.tn3270:get_all_data()