diff --git a/scripts/breakout-to-secureCRT-session/Capture.PNG b/scripts/breakout-to-secureCRT-session/Capture.PNG new file mode 100644 index 0000000..b64e987 Binary files /dev/null and b/scripts/breakout-to-secureCRT-session/Capture.PNG differ diff --git a/scripts/breakout-to-secureCRT-session/__init__.py b/scripts/breakout-to-secureCRT-session/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/scripts/breakout-to-secureCRT-session/cmlApiCalls.py b/scripts/breakout-to-secureCRT-session/cmlApiCalls.py new file mode 100644 index 0000000..b0f8137 --- /dev/null +++ b/scripts/breakout-to-secureCRT-session/cmlApiCalls.py @@ -0,0 +1,37 @@ +import requests +import json +requests.packages.urllib3.disable_warnings() + + +class CML: + + def auth(server, username, password): + headers = { + "accept": "application/json", + "Content-Type": "application/json" + } + + data = {"username":username,"password":password} + a = '{"username":' + b = f'"{username}","password":"{password}' + c = '"}' + data = a+b+c + response = requests.post(f"https://{server}/api/v0/authenticate", headers=headers, data=data, verify=False) + + access_token = "Bearer " + json.loads(response.text) + return(access_token) + + def getNodesByID(auth, server, lab, node_id): + headers = { + 'accept': 'application/json', + 'Authorization': auth, + } + + response = requests.get(f'https://{server}/api/v0/labs/{lab}/nodes/{node_id}?simplified=true', headers=headers, verify=False) + + node = json.loads(response.text) + + if response.status_code == 200: + return(node) + else: + return("end of list") \ No newline at end of file diff --git a/scripts/breakout-to-secureCRT-session/config.ini b/scripts/breakout-to-secureCRT-session/config.ini new file mode 100644 index 0000000..588f600 --- /dev/null +++ b/scripts/breakout-to-secureCRT-session/config.ini @@ -0,0 +1,257 @@ +S:"Username"= +S:"Monitor Password V2"= +S:"Login Script V3"= +S:"Local Shell Command Pre-connect V2"=02:69ed0d0044bfb68ab8e3b851eeb862e99806502e56eb5d9295733b1fbe04e6937b1b8a323bc69b26daabb84c658b4b38 +S:"Monitor Username"= +B:"Normal Font v2"=00000060 + f1 ff ff ff 00 00 00 00 00 00 00 00 00 00 00 00 90 01 00 00 00 00 00 01 00 00 00 01 4c 00 75 00 + 63 00 69 00 64 00 61 00 20 00 43 00 6f 00 6e 00 73 00 6f 00 6c 00 65 00 00 00 00 00 00 00 00 00 + 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 75 00 00 00 +B:"Narrow Font v2"=00000060 + f3 ff ff ff 00 00 00 00 00 00 00 00 00 00 00 00 90 01 00 00 00 00 00 01 00 00 00 01 4c 00 75 00 + 63 00 69 00 64 00 61 00 20 00 43 00 6f 00 6e 00 73 00 6f 00 6c 00 65 00 00 00 00 00 00 00 00 00 + 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 61 00 00 00 +S:"PGP Upload Command V2"= +D:"Use Narrow Font"=00000000 +S:"SCP Shell Password V2"= +S:"PGP Download Command V2"= +D:"Use Login Script"=00000000 +D:"Send Initial Carriage Return"=00000001 +D:"Cols"=0000005a +D:"Foreground"=00000000 +S:"Keyword Set"= +D:"AlwaysOnTop"=00000000 +S:"Display Tab String"= +S:"Color Scheme"=Monochrome +D:"Blinking Cursor"=00000001 +D:"ANSI Color"=00000000 +S:"Answerback"= +D:"Cursor Color"=00000000 +D:"File System Case"=00000000 +B:"ANSI Color RGB"=00000040 + 00 00 00 00 a0 00 00 00 00 a0 00 00 a0 a0 00 00 00 00 a0 00 a0 00 a0 00 00 a0 a0 00 c0 c0 c0 00 + 80 80 80 00 ff 00 00 00 00 ff 00 00 ff ff 00 00 00 00 ff 00 ff 00 ff 00 00 ff ff 00 ff ff ff 00 +D:"Rows"=0000002c +D:"Idle NO-OP Check"=00000000 +D:"CUA Copy Paste"=00000000 +D:"Audio Bell"=00000001 +D:"Background"=00ffffff +D:"Auto Reconnect"=00000002 +D:"Hard Reset on ESC c"=00000000 +D:"Bold"=00000000 +D:"Buffer Pass Through Printing"=00000000 +D:"Character Send Delay"=00000000 +D:"Clear On Disconnect"=00000000 +D:"Color Scheme Overrides Ansi Color"=00000000 +D:"Enable Alternate Screen Switching"=00000001 +D:"Close On Disconnect"=00000000 +D:"Copy to clipboard as RTF and plain text"=00000000 +D:"Copy Translates ANSI Line Drawing Characters"=00000000 +D:"Cursor Key Mode"=00000000 +D:"Cursor Style"=00000000 +D:"Dumb Terminal Ignores CRLF"=00000000 +S:"Custom Log Message Connect"= +S:"Emulation"=VT100 +S:"Custom Log Message Disconnect"= +S:"Custom Log Message Each Line"= +D:"Printer Stop Bits"=00000000 +S:"Default Download Directory V2"= +D:"Y Position"=00000008 +S:"Default SCS"=B +D:"Disable Directory Tree Detection"=00000002 +D:"Disable MLSX"=00000000 +D:"Log Mode"=00000000 +D:"Disable Pass Through Printing"=00000000 +S:"Hostname"=127.0.0.1 +D:"Server Requires Bare CR"=00000000 +D:"Disable Resize"=00000002 +D:"Enable 80-132 Column Switching"=00000001 +D:"Disable ZModem"=00000000 +D:"Enable Cursor Key Mode Switching"=00000001 +D:"Display Tab"=00000000 +S:"Download Directory V2"=C:\Users\Administrator\Downloads +D:"Highlight Reverse Video"=00000001 +S:"Firewall Name"=None +D:"Show Chat Window"=00000002 +S:"Printer Name"= +D:"Eject Page Interval"=00000000 +D:"Enable Line Wrap Mode Switching"=00000001 +D:"Emacs Mode"=00000000 +D:"Emacs Mode 8 Bit"=00000000 +D:"Enable Keypad Mode Switching"=00000001 +D:"Enable NAWS"=00000001 +D:"Idle Check"=00000000 +D:"Horizontal Scrollbar"=00000002 +D:"Use Multiple SFTP Channels"=00000000 +D:"Enable NTLM Authentication"=00000001 +D:"Use Global ANSI Colors"=00000001 +S:"Output Transformer Name"=Default +S:"File Creation Mask"= +D:"Monitor Allow Remote Input"=00000000 +D:"Filenames Always Use UTF8"=00000000 +D:"Force 1024 for ZModem"=00000000 +D:"Force Black On White"=00000000 +D:"SecureFX Trace Level"=00000001 +D:"Force Char Mode"=00000000 +D:"Paper Size"=00000001 +D:"Generate Unique Log File Name When File In Use"=00000001 +D:"Highlight Color"=00000000 +D:"Is Full Screen"=00000000 +D:"Highlight Bold"=00000000 +D:"Idle NO-OP Timeout"=0000003c +S:"Idle String"= +S:"Ident String"= +D:"Idle Timeout"=0000012c +D:"Ignore Shift Out Sequence"=00000000 +D:"Ignore Window Title Change Requests"=00000000 +S:"Initial Local Directory V2"= +D:"Use Cursor Color"=00000000 +D:"Is Session"=00000001 +D:"Jump Scroll"=00000001 +D:"Keyboard Char Send Delay"=00000000 +D:"Preserve Timestamp"=00000001 +S:"Upload Directory V2"=C:\Users\Administrator +B:"Page Margins"=00000020 + 00 00 00 00 00 00 e0 3f 00 00 00 00 00 00 e0 3f 00 00 00 00 00 00 e0 3f 00 00 00 00 00 00 e0 3f +S:"Keymap Filename V2"= +S:"Keymap Name"=Default +D:"Keypad Mode"=00000000 +S:"Last Directory"= +D:"Y Position Relative Top"=00000000 +D:"Line Send Delay"=00000005 +D:"Line Wrap"=00000001 +D:"Local Echo"=00000000 +S:"Log Filename V2"= +D:"Log Multiple Sessions"=00000000 +D:"Log Only Custom"=00000000 +D:"Log Prompt"=00000000 +D:"Map Backspace"=00000000 +D:"Map Delete"=00000000 +D:"Max Transfer Buffers"=00000004 +D:"ZModem Uses 32 Bit CRC"=00000000 +D:"Minimize Drawing While Jump Scrolling"=00000000 +D:"Paper Source"=00000007 +S:"Monitor Listen Address"=0.0.0.0:22 +D:"New Log File At Midnight"=00000000 +D:"Newline Mode"=00000000 +S:"ZModem Receive Command"=rz\r +D:"Operating System"=00000000 +D:"SecureFX Use Control Address For Data Connections"=00000001 +D:"Printer XON Flow"=00000000 +D:"Page Orientation"=00000001 +D:"Port"=REPLACE +D:"Wait For Prompt Timeout"=00000000 +D:"Position Cursor on Left Click"=00000000 +D:"Preserve Alt-Gr"=00000000 +D:"Printer Baud Rate"=00009600 +D:"Log Screen"=00000000 +D:"Printer CTS Flow"=00000000 +D:"Printer Data Bits"=00000008 +S:"User Button Bar Name"=Default +D:"Printer DSR Flow"=00000000 +D:"Printer DTR Flow Control"=00000001 +S:"Wait For Prompt Text"= +B:"Printer Font v2"=00000060 + f3 ff ff ff 00 00 00 00 00 00 00 00 00 00 00 00 90 01 00 00 00 00 00 00 03 02 01 31 43 00 6f 00 + 75 00 72 00 69 00 65 00 72 00 20 00 4e 00 65 00 77 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 + 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 64 00 00 00 +S:"Printer Name Of Pipe"= +D:"Resize Mode"=00000000 +D:"Printer Parity"=00000000 +S:"Printer Port"= +D:"Printer RTS Flow Control"=00000001 +S:"Protocol Name"=Telnet +D:"Raw Log"=00000000 +S:"Remote ExplorerFrame State"=1,-1,-1 +S:"Remote ListView State"=1,1,1,0,0 +D:"Shift Forces Local Mouse Operations"=00000001 +B:"RemoteFrame Window Placement"=0000002c + 2c 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 fc ff ff ff fc ff ff ff 00 00 00 00 + 00 00 00 00 00 00 00 00 00 00 00 00 +D:"Printer Color"=00000001 +D:"Verify Retrieve File Status"=00000002 +D:"Resolve Symbolic Links"=00000002 +D:"Send Scroll Wheel Events To Remote"=00000000 +D:"Restart Data Size"=00000000 +S:"Restart Datafile Path"= +D:"SCO Line Wrap"=00000000 +S:"Script Arguments"= +S:"Script Filename V2"= +D:"Scroll To Bottom On Keypress"=00000001 +D:"Scroll To Bottom On Output"=00000001 +D:"Scroll To Clear"=00000001 +D:"Enable Xterm-256color"=00000000 +D:"Scrollback"=00002710 +S:"SecureFX Remote Tab State"=1,-1,-1 +D:"Send SGA"=00000001 +D:"Send SGA All"=00000000 +D:"Send Zmodem Init When Upload Starts"=00000000 +D:"SGR Zero Resets ANSI Color"=00000001 +D:"Show Wyse Label Line"=00000000 +D:"SSH2 Common Config Version"=00000006 +D:"Start Log Upon Connect"=00000000 +D:"Start Tftp Server"=00000000 +D:"Strip 8th Bit"=00000000 +D:"Suppress Stat On CWD"=00000000 +D:"Sync View Cols"=00000001 +D:"Sync View Rows"=00000001 +D:"Telnet Disable SSL Certificate Verification"=00000000 +S:"Terminal Type"= +S:"Time Zone"= +S:"Title Bar"= +D:"Trace Level"=00000000 +S:"Transfer Protocol Name"=None +D:"Translate Incoming CR To CRLF"=00000000 +D:"Use Alternate Keyboard"=00000000 +D:"Use Answerback"=00000000 +D:"Use Global Print Settings"=00000001 +D:"Use PGP For All Transfers"=00000000 +D:"Use Position"=00000000 +D:"Use Printer Port"=00000000 +D:"ZModem Encodes DEL"=00000001 +D:"Use Raw Mode"=00000000 +D:"Use Script File"=00000000 +D:"Use Symbolic Names For Non-Printable Characters"=00000000 +D:"Use Terminal Type"=00000000 +D:"Use Title Bar"=00000000 +D:"Use Unicode Line Drawing"=00000001 +D:"Use Word Delimiter Chars"=00000000 +D:"User Button Bar"=00000002 +S:"User Font Map V2"= +S:"User Line Drawing Map V2"= +D:"Disable STAT For SFTP Directory Validation"=00000000 +D:"Vertical Scrollbar"=00000002 +D:"Visual Bell"=00000000 +D:"Wait For Prompt"=00000000 +D:"WaitForStrings Ignores Color"=00000000 +D:"Will LFLOW"=00000001 +B:"Window Placement"=0000002c + 2c 00 00 00 00 00 00 00 01 00 00 00 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff 21 03 00 00 + 06 00 00 00 78 07 00 00 ff 03 00 00 +S:"Word Delimiter Chars"= +D:"X Position"=00000008 +D:"X Position Relative Left"=00000000 +D:"XModem Send Packet Size"=00000000 +D:"ZModem Force All Caps Filenames to Lower Case on Upload"=00000001 +D:"Printer Duplex"=00000001 +D:"Enable Xterm-Truecolor"=00000000 +D:"Ignore 80-132 Column Switching When Maximized or Full Screen"=00000000 +D:"Alternate Screen Output Added To Scrollback"=00000000 +D:"Allow OSC 52 Escape Sequence"=00000000 +D:"Enable TN3270 Base Colors"=00000000 +D:"Raw EOL Mode"=00000000 +D:"Printer Quality"=fffffffd +D:"Printer Media Type"=00000001 +D:"Use A Separate Transport For Every Connection"=00000000 +D:"Use STAT For SFTP Directory Validation"=00000000 +D:"SecureFX Trace Level V2"=00000002 +D:"Basepoint Trace Level"=00000001 +D:"Disable Remote File System Watches"=00000000 +D:"AWS Allow Pseudo Directories"=00000001 +Z:"SecureFX Bookmarks"=00000000 +Z:"Description"=00000000 +Z:"Keymap v3"=00000000 +Z:"SCP Shell Prompts"=00000001 + "? ",0,"\n" +Z:"SecureFX Post Login User Commands"=00000000 +Z:"Keymap v5"=00000000 diff --git a/scripts/breakout-to-secureCRT-session/main.py b/scripts/breakout-to-secureCRT-session/main.py new file mode 100644 index 0000000..7910c44 --- /dev/null +++ b/scripts/breakout-to-secureCRT-session/main.py @@ -0,0 +1,62 @@ +import requests +import json +import os +requests.packages.urllib3.disable_warnings() +from cmlApiCalls import CML as cml + +#edit the following variables +server = "cml.server.com" +username = "admin" +password = "CMLpassword123" +lab = "53b3fe" + + +user = os.getlogin() +auth = cml.auth(server, username, password) + +N = True +n_id = 0 +port = 9000 +try: + os.mkdir(rf"C:/Users/{user}/AppData/Roaming/VanDyke/Config/Sessions/CML-{lab}") +except: + print("directory already exists... continue...") + + +while N: + node_id = f"n{n_id}" + response = cml.getNodesByID(auth, server, lab, node_id) + + if response == "end of list": + #exit if end of list + N = False + + elif response.get("node_definition") == "external_connector": + # dont count external_connector as usable + n_id = n_id + 1 + + else: + # get label + node_label = response.get("label") + + # turn port number into hex + # strip "0x2233" and make it only 4 charators + hexport = hex(port).split('x')[-1] + + with open("config.ini", "r") as config: + temp = config.read() + temp = temp.replace("REPLACE", "0000" + hexport) + location = rf"C:/Users/{user}/AppData/Roaming/VanDyke/Config/Sessions/CML-{lab}/{port}-{node_label}.ini" + with open( location, "w") as config2write: + config2write.write(temp) + + if response.get("node_definition") == "wan_emulator": + # add by 1 if wan_emulator + port = port + 1 + else: + port = port + 2 + n_id = n_id + 1 + + + + diff --git a/scripts/breakout-to-secureCRT-session/readme.md b/scripts/breakout-to-secureCRT-session/readme.md new file mode 100644 index 0000000..62ec45b --- /dev/null +++ b/scripts/breakout-to-secureCRT-session/readme.md @@ -0,0 +1,28 @@ +# CML-Breakout-SecureCRT-Session +performs API calls to CML and populates a secure-crt sessions for you to use with the breakout tool + +Assumptions: +- secure-crt session database is in the default location. +- using windows OS +- "populate all nodes" must be turned on in the breakout configuration. +- This creates sessions using ipv4 loopback. +- the device name in the database is the label in CML, not the CLI hostname. + +Tested on: +- CML: 2.2.2+build52 +- breakout-windows-x86_amd64.exe 0.2.1-build-v2.2.2-52 +- secureCRT 9.0.2 + +Variables to edit: +on main.py edit server, username, password, and lab number. + +This python app will create a new folder and all the telnet sessions for the lab. +Port numbers are listed in front of the devices name so you can quickly bounce it off the breakout tool if something doesnt seem right... + +![alt text](https://github.com/M35a2/CML-Breakout-SecureCRT-Session/blob/main/Capture.PNG?raw=true) + +easist way to update a lab after adding/deleting devices is to just delete the lab folder in secureCRT, rerun the script, and restart secureCRT + +Known issues: +only tested on wan emulators, routers, switches... +i haven't tested on anything that requires VNC or breakout might handle differently than adding by two port numbers. \ No newline at end of file