Skip to content

Instantly share code, notes, and snippets.

@terenty-rezman
Last active July 23, 2020 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save terenty-rezman/48f0ef8b435ae98b6092a479e65b5cee to your computer and use it in GitHub Desktop.
Save terenty-rezman/48f0ef8b435ae98b6092a479e65b5cee to your computer and use it in GitHub Desktop.
EVE-NG mobaXterm wrapper Windows
python "C:\Program Files\EVE-NG\mobaxterm_wrapper.py" %1
import sys
import subprocess
import re
arg_str = sys.argv[1]
# parse protocol, host, port from arg line
protocol_re = r'^\w+(?=:)'
host_re = r'(?<=:\/\/)[^:]+(?=:)'
port_re = r'(?<=:)[\d|.]+'
protocol_match = re.search(protocol_re, arg_str)
host_match = re.search(host_re, arg_str)
port_match = re.search(port_re, arg_str)
protocol = protocol_match.group()
host = host_match.group()
port = port_match.group()
# mobaxterm run example:
# $ MobaXterm.exe -newtab "telnet 192.168.231.110 32771"
moba_command = f'{protocol} {host} {port}'
# launch mobaxterm with corret args from where it's installed
subprocess.Popen(["E:/games/Mobatek/MobaXterm/MobaXterm.exe", "-newtab", moba_command])
@terenty-rezman
Copy link
Author

You need python3 installed on your system obviously,
And you need to somehow point your Windows to use your mobaxterm_wrapper.bat whenever it tries telnet://192.168.231.110:32771 protocol for example.
In my case I installed PuTTY first and then overridden the following key in regedit
Computer\HKEY_CLASSES_ROOT\Putty.telnet\shell\open\command to point to my mobaxterm_wrapper.bat instead of pytty.exe.
A bit ugly though, but works perfectly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment