Created
March 24, 2020 23:30
-
-
Save ezr/0f8bf75a821b408d9c505f44f09563fa to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
from glob import glob | |
import os | |
session_files = glob(os.environ["HOME"] + "/.putty/sessions/*") | |
out_file = open("putty-sessions.reg", "w") | |
header = '''Windows Registry Editor Version 5.00 | |
[HKEY_CURRENT_USER\Software\SimonTatham\PuTTY\Sessions] | |
''' | |
out_file.write(header) | |
for fpath in session_files: | |
f = open(fpath, "r") | |
lines = f.readlines() | |
fname = fpath.split('/')[-1] | |
out_file.write("\n[HKEY_CURRENT_USER\Software\SimonTatham\PuTTY\Sessions\%s]\n" % fname) | |
for line in lines: | |
data = line.split("=") | |
key = data[0] | |
val = data[1].strip() | |
out_file.write("\"%s\"=" % key) | |
try: | |
int(val) | |
out_file.write("dword:%s\n" % val.zfill(8)) | |
except: | |
out_file.write("\"%s\"\n" % val) | |
f.close() | |
out_file.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is a python script that you can run on a linux system whose putty sessions are saved under ~/.putty/sessions/. The purpose is to migrate the info into a .reg file which can be imported on windows.
Very lightly tested. USE AT YOUR OWN RISK. If anyone attempts to use this then make sure to back up the registry keys on windows before making any changes.