Skip to content

Instantly share code, notes, and snippets.

@StefanIGit
Created October 2, 2018 09:26
Show Gist options
  • Save StefanIGit/8828cf31da9f43c4c7aa5d97ea64ec39 to your computer and use it in GitHub Desktop.
Save StefanIGit/8828cf31da9f43c4c7aa5d97ea64ec39 to your computer and use it in GitHub Desktop.
Quick and dirty import of putty / kitty sessions into RDP-Manager 4.9.72 x64
'''
Quick and dirty import of putty / kitty sessions into RDP-Manager 4.9.72 x64
MAKE a BACKUP before you they this!!!111!1 you have been warned :D
StefaniGit@knallakoff.de 2018-10-02
!!Read the comments, there are some preconditiones, manual tasks, things you have to change in the script.
'''
import uuid
import sqlite3
import itertools
import _winreg
from _winreg import CloseKey
import traceback
# have a look at the connection table to get the UUIDs
# I guess they are unique so get yours and update the 'data' dictionary
# Especially there is the UUID of the SSH folder I manually created in RDP-Manager
# you have to the replace %USERNAME% with your username I guess
dbfile = r'C:\Users\%USERNAME%\AppData\Roaming\Cinspiration\RDP-Manager\C__Program Files_Cinspiration_RDP-Manager\SqLiteDatabase.db3'
db = sqlite3.connect(dbfile)
cursor = db.cursor()
# columnnames got it with SQLiteStudio
keys = ['Id',
'Name',
'Target',
'Sorting',
'Icon',
'Color',
'Parent',
'Setting',
'Credential',
'Type',
'LastConnection',
'LastConTime',
'ConTime',
'Additional',
'LastUser',
'Description',
'DefaultAdditional',
'Deleted',
'JumpList']
cursor.execute('SELECT %s FROM connections' %(', '.join(keys)))
#not sure but it wrks for me ;)
user1 = cursor.fetchone() #retrieve the first row
print(user1[0]) #Print the first column retrieved(user's name)
all_rows = cursor.fetchall()
for row in all_rows:
# print some nice dictionarys
print dict(zip(keys, row))
db.close()
if False:
# Path in regisrty to Kitty Sessions
# like HKEY_CURRENT_USER\...
# you have to look up the putty path
path = 'Software\\9bis.com\\Kitty\\Sessions'
try:
sessionName = _winreg.OpenKey(_winreg.HKEY_CURRENT_USER, path)
except WindowsError:
raise EnvironmentError
for i in itertools.count():
try:
val = _winreg.EnumKey(sessionName, i)
# blanks are %20 sessionnames
print str(val).replace('%20', ' ')
for b in itertools.count():
try:
newKey = _winreg.OpenKey(_winreg.HKEY_CURRENT_USER, path + '\\' + val)
values = _winreg.EnumValue(newKey, b)
# only care for hostname...
if 'HostName' in values:
print str(values[1])
data = {'ConTime': '28',
'Credential': '3338AF54-19FB-4875-B752-8B6F035764D6',
'Sorting': '0',
'Additional': '',
'Target': str(values[1]),
# this is the UUID of the SSH folder I created in RDP-Manager manually
'Parent': 'DD1CB055-F02A-4F2E-82A2-72C1883248A1',
'Color': '-16777216',
'LastConTime': '28',
'DefaultAdditional': '',
'Description': '',
'Deleted': '0',
'Setting': 'E338AF54-19FB-4875-B752-8B6F035764D6',
'JumpList': '0',
'LastConnection': '2018-10-02 09:24:19.30129',
'LastUser': '',
'Name': str(val.replace('%20', ' ')),
'Type': '4CB65FA2-506E-4E3F-93E5-AB7A16F79397',
'Id': str(uuid.uuid4()),
'Icon': 'a4a11c6e-1027-4b63-8f77-2428f161c957'}
# writ the stuff in the the DM
cursor.execute('''INSERT INTO connections({})
VALUES({})'''.format(', '.join(data.keys()),
"'"+"', '".join(data.values())+"'"
)
)
except EnvironmentError:
break
except EnvironmentError:
break
CloseKey(sessionName)
db.commit()
db.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment