Commit 35d1570e by Csók Tamás

client: pythonw.exe instead of python.exe

parent 2f746a10
# Backport of OrderedDict() class that runs on Python 2.4, 2.5, 2.6, 2.7 and pypy. # Backport of OrderedDict() class that runs on Python 2.4, 2.5, 2.6, 2.7 and pypy.
# Passes Python2.7's test suite and incorporates all the latest updates. # Passes Python2.7's test suite and incorporates all the latest updates.
# flake8: noqa
try: try:
from thread import get_ident as _get_ident from thread import get_ident as _get_ident
......
...@@ -8,8 +8,6 @@ The Client job is to help the ease of use of the cloud system. ...@@ -8,8 +8,6 @@ The Client job is to help the ease of use of the cloud system.
import platform import platform
import argparse import argparse
import sys
import time
try: try:
from selenium import webdriver from selenium import webdriver
from selenium.webdriver.common.by import By from selenium.webdriver.common.by import By
...@@ -49,19 +47,20 @@ def parse_arguments(): ...@@ -49,19 +47,20 @@ def parse_arguments():
parser.add_argument("-p", "--password", type=str) parser.add_argument("-p", "--password", type=str)
parser.add_argument( parser.add_argument(
"-d", "--driver", "-d", "--driver",
help="Select webdriver. Aside from Firefox, you have to install "+ help = "Select webdriver. Aside from Firefox, you have to install "+
"first the proper driver.", type=str, "first the proper driver.", type=str,
choices=['firefox', 'chrome', 'ie', 'opera'], choices = ['firefox', 'chrome', 'ie', 'opera'],
default="firefox") default = "firefox")
args = parser.parse_args() args = parser.parse_args()
return args return args
class Browser: class Browser:
""" """
Browser initialisation Browser initialisation
Keyword arguments: Keyword arguments:
@param args -- args.driver tells us which installed browser @param args -- args.driver tells us which installed browser
we want to use with selenium. we want to use with selenium.
""" """
def __init__(self, args): def __init__(self, args):
...@@ -92,11 +91,10 @@ class Browser: ...@@ -92,11 +91,10 @@ class Browser:
driver.find_element_by_css_selector( driver.find_element_by_css_selector(
"input[type='submit']").click() "input[type='submit']").click()
def main(self): def main(self):
""" """
Use of the https://cloud.bme.hu/ Use of the https://cloud.bme.hu/
Keyword arguments: Keyword arguments:
@return vm -- Necessarily parameters to connect @return vm -- Necessarily parameters to connect
to the Virtual Machine to the Virtual Machine
...@@ -142,7 +140,7 @@ def main(): ...@@ -142,7 +140,7 @@ def main():
args = parse_arguments() args = parse_arguments()
if args.uri is not None: if args.uri is not None:
vm = Struct() vm = Struct()
vm.protocol,vm.user,vm.password,vm.host,vm.port = \ vm.protocol, vm.user, vm.password, vm.host, vm.port = \
args.uri.split(':',4) args.uri.split(':',4)
vm.protocol = vm.protocol.upper() vm.protocol = vm.protocol.upper()
vm.state = "RUN" vm.state = "RUN"
...@@ -158,7 +156,7 @@ def main(): ...@@ -158,7 +156,7 @@ def main():
connect(vm) connect(vm)
except: except:
print "Unknown error occurred! Please contact the developers!" print "Unknown error occurred! Please contact the developers!"
if __name__ == "__main__": if __name__ == "__main__":
main() main()
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
""" """
Configuration of the Windows specific tools to enhance the ease of use Configuration of the Windows specific tools to enhance the ease of use
of the CIRCLE cloud. Handles the auto launch and auto configuration of the CIRCLE cloud. Handles the auto launch and auto configuration
of these specific connectivity programs. of these specific connectivity programs.
""" """
...@@ -29,8 +29,9 @@ def connect(vm): ...@@ -29,8 +29,9 @@ def connect(vm):
vm.password -- Password used for the connection vm.password -- Password used for the connection
""" """
if vm.protocol == "SSH": if vm.protocol == "SSH":
arguments = "-ssh -P %s -pw %s %s@%s" % (vm.port, vm.password, vm.user, vm.host) arguments = ("-ssh -P %s -pw %s" % (vm.port, vm.password)
subprocess.Popen("putty.exe "+arguments, shell = True) + "%s@%s" % (vm.user, vm.host))
subprocess.Popen("putty.exe "+arguments, shell=True)
elif vm.protocol == "NX": elif vm.protocol == "NX":
listdir = os.path.expanduser("~\\.nx\\config\\*.nxs") listdir = os.path.expanduser("~\\.nx\\config\\*.nxs")
found = False found = False
...@@ -43,18 +44,20 @@ def connect(vm): ...@@ -43,18 +44,20 @@ def connect(vm):
found = True found = True
break break
if not found: if not found:
config_file = "%s%s%s" % (os.path.expanduser("~\\.nx\\config\\"), str(int(time.time()*1000)), ".nxs") config_file = "%s%s%s" % (os.path.expanduser("~\\.nx\\config\\"),
str(int(time.time()*1000)), ".nxs")
password = nxkey.NXKeyGen(vm.password).getEncrypted() password = nxkey.NXKeyGen(vm.password).getEncrypted()
config = NX_template % {'USERNAME' : vm.user, 'PASSWORD' : password, 'HOST' : vm.host, 'PORT' : vm.port} config = NX_template % {'USERNAME': vm.user, 'PASSWORD': password,
'HOST': vm.host, 'PORT': vm.port}
f = open(config_file, 'w') f = open(config_file, 'w')
f.write(config) f.write(config)
f.close() f.close()
subprocess.Popen(config_file, shell = True) subprocess.Popen(config_file, shell=True)
elif vm.protocol == "RDP": elif vm.protocol == "RDP":
listdir = os.path.dirname(os.path.realpath(__file__))+"\\.rdp\\*.rdp" listdir = os.path.dirname(os.path.realpath(__file__))+"\\.rdp\\*.rdp"
found = False found = False
full_address = "full address:s:%s:%s" % (vm.host, vm.port) full_address = "full address:s:%s:%s" % (vm.host, vm.port)
user = "username:s:%s" % vm.user user = "username:s:%s" % vm.user
for config_file in glob.glob(listdir): for config_file in glob.glob(listdir):
with open(config_file) as f: with open(config_file) as f:
file = f.read() file = f.read()
...@@ -62,13 +65,17 @@ def connect(vm): ...@@ -62,13 +65,17 @@ def connect(vm):
found = True found = True
break break
if not found: if not found:
config_file = "%s%s%s" % (os.path.dirname(os.path.realpath(__file__))+"\\.rdp\\", str(int(time.time()*1000)), ".rdp") config_file = "%s%s%s" % ((os.path.dirname(
password = binascii.hexlify(win32crypt.CryptProtectData(u"%s" % vm.password,u'psw',None,None,None,0)) os.path.realpath(__file__))+"\\.rdp\\"),
config = RPD_template % {'USERNAME' : vm.user, 'PASSWORD' : password, 'HOST' : vm.host, 'PORT' : vm.port} str(int(time.time()*1000)), ".rdp")
password = binascii.hexlify(win32crypt.CryptProtectData(
u"%s" % vm.password, u'psw', None, None, None, 0))
config = RPD_template % {'USERNAME': vm.user, 'PASSWORD': password,
'HOST': vm.host, 'PORT': vm.port}
f = open(config_file, 'w') f = open(config_file, 'w')
f.write(config) f.write(config)
f.close() f.close()
subprocess.Popen(config_file, shell = True) subprocess.Popen(config_file, shell=True)
NX_template = """<!DOCTYPE NXClientSettings> NX_template = """<!DOCTYPE NXClientSettings>
...@@ -90,4 +97,4 @@ NX_template = """<!DOCTYPE NXClientSettings> ...@@ -90,4 +97,4 @@ NX_template = """<!DOCTYPE NXClientSettings>
RPD_template = """username:s:%(USERNAME)s RPD_template = """username:s:%(USERNAME)s
full address:s:%(HOST)s:%(PORT)s full address:s:%(HOST)s:%(PORT)s
password 51:b:%(PASSWORD)s""" password 51:b:%(PASSWORD)s"""
\ No newline at end of file
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
# #
# If you're wondering how this is created, the secret is # If you're wondering how this is created, the secret is
# "contrib/build-installer" from the pip repository. # "contrib/build-installer" from the pip repository.
# flake8: noqa
ZIPFILE = b""" ZIPFILE = b"""
UEsDBBQAAAAIAHeDxEQMVWtseQwAAOokAAAPAAAAcGlwL19faW5pdF9fLnB5pRprb+M28rt/BTdp UEsDBBQAAAAIAHeDxEQMVWtseQwAAOokAAAPAAAAcGlwL19faW5pdF9fLnB5pRprb+M28rt/BTdp
...@@ -24,11 +24,11 @@ def parse_arguments(): ...@@ -24,11 +24,11 @@ def parse_arguments():
parser = argparse.ArgumentParser() parser = argparse.ArgumentParser()
if windowsclasses.DecideArchitecture.Is64Windows(): if windowsclasses.DecideArchitecture.Is64Windows():
local_default = (windowsclasses.DecideArchitecture.GetProgramFiles64() local_default = (windowsclasses.DecideArchitecture.GetProgramFiles64()
+"\\CIRCLE\\") + "\\CIRCLE\\")
else: else:
local_default = (windowsclasses.DecideArchitecture.GetProgramFiles32() local_default = (windowsclasses.DecideArchitecture.GetProgramFiles32()
+"\\CIRCLE\\") + "\\CIRCLE\\")
if (not os.path.exists(local_default[:-1]) if (not os.path.exists(local_default[:-1])
and os.path.exists(os.environ['APPDATA']+"\\CIRCLE")): and os.path.exists(os.environ['APPDATA']+"\\CIRCLE")):
local_default = os.environ['APPDATA']+"\\CIRCLE\\" local_default = os.environ['APPDATA']+"\\CIRCLE\\"
parser.add_argument( parser.add_argument(
...@@ -38,20 +38,20 @@ def parse_arguments(): ...@@ -38,20 +38,20 @@ def parse_arguments():
args = parser.parse_args() args = parser.parse_args()
return args return args
def main(): def main():
try: try:
args = parse_arguments()
nx_install_location = None nx_install_location = None
while nx_install_location is None: while nx_install_location is None:
print "Checking whether NX Client for Windows is installed" print "Checking whether NX Client for Windows is installed"
handler = windowsclasses.RegistryHandler() handler = windowsclasses.RegistryHandler()
try: try:
nx_install_location = handler.get_key_value( nx_install_location = handler.get_key_value(
"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"+ "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
"Uninstall\\nxclient_is1", + "Uninstall\\nxclient_is1",
"InstallLocation", "key") "InstallLocation", "key")
print ("NX Client for Windows is found at " print ("NX Client for Windows is found at "
"'%s'" % nx_install_location) "'%s'" % nx_install_location)
process = subprocess.Popen( process = subprocess.Popen(
"%s\\nxclient.exe" % nx_install_location) "%s\\nxclient.exe" % nx_install_location)
time.sleep(2) time.sleep(2)
...@@ -60,10 +60,10 @@ def main(): ...@@ -60,10 +60,10 @@ def main():
print "NX Client for Windows isn't installed on the system." print "NX Client for Windows isn't installed on the system."
print "\tCommencing the install" print "\tCommencing the install"
subprocess.Popen(os.path.dirname( subprocess.Popen(os.path.dirname(
os.path.realpath(__file__))+ os.path.realpath(__file__))
"\\nxclient-3.5.0-9.exe").wait() + "\\nxclient-3.5.0-9.exe").wait()
except: except:
pass pass
if __name__ == "__main__": if __name__ == "__main__":
main() main()
\ No newline at end of file
...@@ -8,9 +8,9 @@ https://www.nomachine.com/AR01C00125 ...@@ -8,9 +8,9 @@ https://www.nomachine.com/AR01C00125
import sys import sys
import random import random
import re
from xml.sax.saxutils import escape from xml.sax.saxutils import escape
class NXKeyGen: class NXKeyGen:
""" """
NXKeyGen class NXKeyGen class
...@@ -18,6 +18,7 @@ class NXKeyGen: ...@@ -18,6 +18,7 @@ class NXKeyGen:
""" """
numValidCharList = 85 numValidCharList = 85
dummyString = "{{{{" dummyString = "{{{{"
def __init__(self, password): def __init__(self, password):
""" """
Initialize the class Initialize the class
...@@ -26,7 +27,7 @@ class NXKeyGen: ...@@ -26,7 +27,7 @@ class NXKeyGen:
@param password -- Password that will be scrambled @param password -- Password that will be scrambled
""" """
self.password = password self.password = password
def getEncrypted(self): def getEncrypted(self):
""" """
Encrypt (scramble) the given password Encrypt (scramble) the given password
...@@ -36,7 +37,7 @@ class NXKeyGen: ...@@ -36,7 +37,7 @@ class NXKeyGen:
password password
""" """
return self.scrambleString(self.password) return self.scrambleString(self.password)
def getvalidCharList(self, pos): def getvalidCharList(self, pos):
""" """
Valid character list Valid character list
...@@ -45,16 +46,15 @@ class NXKeyGen: ...@@ -45,16 +46,15 @@ class NXKeyGen:
@return validcharlist -- List of the valid characters @return validcharlist -- List of the valid characters
""" """
validcharlist = [ validcharlist = [
"!", "#", "$", "%", "&", "(", ")", "*", "+", "-", "!", "#", "$", "%", "&", "(", ")", "*", "+", "-",
".", "0", "1", "2", "3", "4", "5", "6", "7", "8", ".", "0", "1", "2", "3", "4", "5", "6", "7", "8",
"9", ":", ";", "<", ">", "?", "@", "A", "B", "C", "9", ":", ";", "<", ">", "?", "@", "A", "B", "C",
"D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M",
"N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W",
"X", "Y", "Z", "[", "]", "_", "a", "b", "c", "d", "X", "Y", "Z", "[", "]", "_", "a", "b", "c", "d",
"e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n",
"o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x",
"y", "z", "{", "|", "}" "y", "z", "{", "|", "}"]
]
return validcharlist[pos] return validcharlist[pos]
def encodePassword(self, p): def encodePassword(self, p):
...@@ -71,7 +71,7 @@ class NXKeyGen: ...@@ -71,7 +71,7 @@ class NXKeyGen:
for i in range(len(p)): for i in range(len(p)):
c = p[i:i+1] c = p[i:i+1]
a = ord(c) a = ord(c)
sTmp = str( a + i + 1) + ":" sTmp = str(a + i + 1) + ":"
sPass += sTmp sPass += sTmp
sTmp = "" sTmp = ""
return sPass return sPass
...@@ -86,7 +86,7 @@ class NXKeyGen: ...@@ -86,7 +86,7 @@ class NXKeyGen:
""" """
i = -1 i = -1
for j in range(self.numValidCharList): for j in range(self.numValidCharList):
randchar = self.getvalidCharList(j); randchar = self.getvalidCharList(j)
if randchar == c: if randchar == c:
i = j i = j
return i return i
...@@ -99,7 +99,7 @@ class NXKeyGen: ...@@ -99,7 +99,7 @@ class NXKeyGen:
Keyword arguments: Keyword arguments:
@return char -- Valid character placed 0-60 in the valid list @return char -- Valid character placed 0-60 in the valid list
""" """
return self.getvalidCharList(random.randint(0,60)) return self.getvalidCharList(random.randint(0, 60))
def scrambleString(self, s): def scrambleString(self, s):
""" """
...@@ -124,25 +124,25 @@ class NXKeyGen: ...@@ -124,25 +124,25 @@ class NXKeyGen:
l = k + len(sRet) - 2 l = k + len(sRet) - 2
sRet = app + sRet sRet = app + sRet
for i1 in range(1, len(sRet)): for i1 in range(1, len(sRet)):
app2 = sRet[i1 : i1 + 1] app2 = sRet[i1: i1 + 1]
j = self.findCharInList(app2) j = self.findCharInList(app2)
if j == -1: if j == -1:
return sRet return sRet
i = (j + l * (i1 + 1)) % self.numValidCharList i = (j + l * (i1 + 1)) % self.numValidCharList
car = self.getvalidCharList(i) car = self.getvalidCharList(i)
sRet = self.substr_replace(sRet,car,i1,1) sRet = self.substr_replace(sRet, car, i1, 1)
c = (ord(self.getRandomValidCharFromList())) + 2 c = (ord(self.getRandomValidCharFromList())) + 2
c2 = chr(c) c2 = chr(c)
sRet = sRet + c2 sRet = sRet + c2
return escape(sRet) return escape(sRet)
def substr_replace(self,in_str,ch,pos,qt): def substr_replace(self,in_str,ch,pos,qt):
""" """
Replace a character at a special position Replace a character at a special position
""" """
clist = list(in_str) clist = list(in_str)
count = 0; count = 0
tmp_str = ''; tmp_str = ''
for key in clist: for key in clist:
if count != pos: if count != pos:
tmp_str += key tmp_str += key
...@@ -156,4 +156,3 @@ if __name__ == "__main__": ...@@ -156,4 +156,3 @@ if __name__ == "__main__":
NXPass = NXKeyGen(sys.argv[1]) NXPass = NXKeyGen(sys.argv[1])
print NXPass.password print NXPass.password
print NXPass.getEncrypted() print NXPass.getEncrypted()
...@@ -16,13 +16,13 @@ def main(): ...@@ -16,13 +16,13 @@ def main():
Main program Main program
Job: Job:
Install Pywin32 to the computer Install Pywin32 to the computer
""" """
if sys.hexversion < 0x02060000: if sys.hexversion < 0x02060000:
print "Not a 2.6+ version Python is running, commencing update" print "Not a 2.6+ version Python is running, commencing update"
subprocess.Popen( subprocess.Popen(
"%s\\no_root_install.bat" % os.path.dirname( "%s\\no_root_install.bat" % os.path.dirname(
os.path.realpath(__file__))) os.path.realpath(__file__)))
sys.exit(1) sys.exit(1)
else: else:
pywin32_version = str(219) pywin32_version = str(219)
...@@ -50,7 +50,7 @@ def main(): ...@@ -50,7 +50,7 @@ def main():
pywin32_version)).wait() pywin32_version)).wait()
else: else:
print "Unsupported Python version is found!" print "Unsupported Python version is found!"
if __name__ == "__main__": if __name__ == "__main__":
main() main()
\ No newline at end of file
...@@ -13,11 +13,9 @@ import shutil ...@@ -13,11 +13,9 @@ import shutil
from win32com.shell import shell, shellcon from win32com.shell import shell, shellcon
import windowsclasses import windowsclasses
try: try:
from collections import * from collections import * # noqa
except ImportError: except ImportError:
from OrderedDict import * from OrderedDict import * # noqa
def parse_arguments(): def parse_arguments():
""" """
...@@ -35,13 +33,13 @@ def parse_arguments(): ...@@ -35,13 +33,13 @@ def parse_arguments():
'iexplore', 'opera']) 'iexplore', 'opera'])
if windowsclasses.DecideArchitecture.Is64Windows(): if windowsclasses.DecideArchitecture.Is64Windows():
local_default = (windowsclasses.DecideArchitecture.GetProgramFiles64() local_default = (windowsclasses.DecideArchitecture.GetProgramFiles64()
+"\\CIRCLE\\") + "\\CIRCLE\\")
else: else:
local_default = (windowsclasses.DecideArchitecture.GetProgramFiles32() local_default = (windowsclasses.DecideArchitecture.GetProgramFiles32()
+"\\CIRCLE\\") + "\\CIRCLE\\")
if (not os.path.exists(local_default[:-1]) if (not os.path.exists(local_default[:-1]) and
and os.path.exists(os.environ['APPDATA']+"\\CIRCLE")): os.path.exists(os.environ['APPDATA'] + "\\CIRCLE")):
local_default = os.environ['APPDATA']+"\\CIRCLE\\" local_default = os.environ['APPDATA'] + "\\CIRCLE\\"
parser.add_argument( parser.add_argument(
"-l", "--location", help="Location of the client files in the system", "-l", "--location", help="Location of the client files in the system",
default=local_default, required=False) default=local_default, required=False)
...@@ -59,7 +57,8 @@ def parse_arguments(): ...@@ -59,7 +57,8 @@ def parse_arguments():
default="https://cloud.bme.hu/", required=False) default="https://cloud.bme.hu/", required=False)
args = parser.parse_args() args = parser.parse_args()
return args return args
def custom_protocol_register(custom_protocol): def custom_protocol_register(custom_protocol):
""" """
Custom protocol register based on RegistryHandler module Custom protocol register based on RegistryHandler module
...@@ -79,7 +78,7 @@ def custom_protocol_register(custom_protocol): ...@@ -79,7 +78,7 @@ def custom_protocol_register(custom_protocol):
print "\t\tDone!" print "\t\tDone!"
except: except:
raise raise
def main(): def main():
""" """
...@@ -92,13 +91,13 @@ def main(): ...@@ -92,13 +91,13 @@ def main():
""" """
try: try:
args = parse_arguments() args = parse_arguments()
shortcut = pythoncom.CoCreateInstance ( shortcut = pythoncom.CoCreateInstance(
shell.CLSID_ShellLink, shell.CLSID_ShellLink,
None, None,
pythoncom.CLSCTX_INPROC_SERVER, pythoncom.CLSCTX_INPROC_SERVER,
shell.IID_IShellLink shell.IID_IShellLink
) )
desktop_path = shell.SHGetFolderPath ( desktop_path = shell.SHGetFolderPath(
0, shellcon.CSIDL_DESKTOP, 0, 0) 0, shellcon.CSIDL_DESKTOP, 0, 0)
if args.remove: if args.remove:
location = os.path.join(desktop_path, "Cloud GUI") location = os.path.join(desktop_path, "Cloud GUI")
...@@ -117,15 +116,15 @@ def main(): ...@@ -117,15 +116,15 @@ def main():
shortcut.write('URL='+args.target) shortcut.write('URL='+args.target)
shortcut.close() shortcut.close()
else: else:
shortcut.SetPath (args.location+"cloud.py") shortcut.SetPath(args.location+"cloud.py")
if args.driver == "chrome": if args.driver == "chrome":
shortcut.SetArguments("-d chrome") shortcut.SetArguments("-d chrome")
elif args.driver == "iexplore": elif args.driver == "iexplore":
shortcut.SetArguments("-d ie") shortcut.SetArguments("-d ie")
elif args.driver == "opera": elif args.driver == "opera":
shortcut.SetArguments("-d opera") shortcut.SetArguments("-d opera")
shortcut.SetDescription ("Tool to use CIRCLE Cloud") shortcut.SetDescription("Tool to use CIRCLE Cloud")
shortcut.SetIconLocation (args.location+"cloud.ico", 0) shortcut.SetIconLocation(args.location+"cloud.ico", 0)
desktop_path = shell.SHGetFolderPath( desktop_path = shell.SHGetFolderPath(
0, shellcon.CSIDL_DESKTOP, 0, 0) 0, shellcon.CSIDL_DESKTOP, 0, 0)
persist_file = shortcut.QueryInterface( persist_file = shortcut.QueryInterface(
...@@ -137,34 +136,43 @@ def main(): ...@@ -137,34 +136,43 @@ def main():
print "Creating custom URL protocol handlers" print "Creating custom URL protocol handlers"
try: try:
custom_ssh = OrderedDict( custom_ssh = OrderedDict(
[('ssh', ["default", "URL:ssh Protocol", "URL Protocol", ""]), [('ssh', ["default",
"URL:ssh Protocol",
"URL Protocol",
""]),
('ssh\\URL Protocol', ""), ('ssh\\URL Protocol', ""),
('ssh\\DefaultIcon', args.location+"cloud.ico"), ('ssh\\DefaultIcon', args.location+"cloud.ico"),
('ssh\\shell', {'open': { ('ssh\\shell', {'open': {
'command': "\"python.exe\" \"%s" % args.location+ 'command': "\"pythonw.exe\" \"%s" % args.location
"cloud.py\" \"%1\""}})]) + "cloud.py\" \"%1\""}})])
custom_protocol_register(custom_ssh) custom_protocol_register(custom_ssh)
custom_rdp = OrderedDict( custom_rdp = OrderedDict(
[('rdp', ["default", "URL:rdp Protocol", "URL Protocol", ""]), [('rdp', ["default",
"URL:rdp Protocol",
"URL Protocol",
""]),
('rdp\\URL Protocol', ""), ('rdp\\URL Protocol', ""),
('rdp\\DefaultIcon', args.location+"cloud.ico"), ('rdp\\DefaultIcon', args.location + "cloud.ico"),
('rdp\\shell', {'open': { ('rdp\\shell', {'open': {
'command': "\"python.exe\" \"%s" % args.location+ 'command': "\"pythonw.exe\" \"%s" % args.location
"cloud.py\" \"%1\""}})]) + "cloud.py\" \"%1\""}})])
custom_protocol_register(custom_rdp) custom_protocol_register(custom_rdp)
custom_nx = OrderedDict( custom_nx = OrderedDict(
[('nx', ["default", "URL:nx Protocol", "URL Protocol", ""]), [('nx', ["default",
"URL:nx Protocol",
"URL Protocol",
""]),
('nx\\URL Protocol', ""), ('nx\\URL Protocol', ""),
('nx\\DefaultIcon', args.location+"cloud.ico"), ('nx\\DefaultIcon', args.location + "cloud.ico"),
('nx\\shell', {'open': { ('nx\\shell', {'open': {
'command': "\"python.exe\" \"%s" % args.location+ 'command': "\"pythonw.exe\" \"%s" % args.location
"cloud.py\" \"%1\""}})]) + "cloud.py\" \"%1\""}})])
custom_protocol_register(custom_nx) custom_protocol_register(custom_nx)
except: except:
print "Error! URL Protocol handler installation aborted!" print "Error! URL Protocol handler installation aborted!"
except: except:
print "Unknown error occurred! Please contact the developers!" print "Unknown error occurred! Please contact the developers!"
if __name__ == "__main__": if __name__ == "__main__":
main() main()
\ No newline at end of file
...@@ -11,11 +11,12 @@ Currently here: ...@@ -11,11 +11,12 @@ Currently here:
import os import os
import argparse import argparse
import errno import errno
from _winreg import * from _winreg import * # noqa
try: try:
from collections import * from collections import * # noqa
except ImporError: except ImporError:
from OrderedDict import * from OrderedDict import * # noqa
def parse_arguments(): def parse_arguments():
""" """
...@@ -41,9 +42,11 @@ def parse_arguments(): ...@@ -41,9 +42,11 @@ def parse_arguments():
args = parser.parse_args() args = parser.parse_args()
return args return args
def main(): def main():
return RegistryHandler(parse_arguments()) return RegistryHandler(parse_arguments())
class Struct: class Struct:
""" """
Parameter bypassing struct Parameter bypassing struct
...@@ -53,13 +56,13 @@ class Struct: ...@@ -53,13 +56,13 @@ class Struct:
class RegistryHandler: class RegistryHandler:
""" """
Registry handling class, makes registry based queries and Registry handling class, makes registry based queries and
manipulations easier. manipulations easier.
This class can handle WOW64 based application differently and none This class can handle WOW64 based application differently and none
differently (default) differently (default)
""" """
def __init__(self, args = None): def __init__(self, args=None):
"""Initialise RegistryHandler """Initialise RegistryHandler
Keyword arguments: Keyword arguments:
...@@ -96,7 +99,7 @@ class RegistryHandler: ...@@ -96,7 +99,7 @@ class RegistryHandler:
elif self.args.registry == "HKCC": elif self.args.registry == "HKCC":
self.args.registry = HKEY_CURRENT_CONFIG self.args.registry = HKEY_CURRENT_CONFIG
else: else:
#print "Non supported registry type" # print "Non supported registry type"
raise AttributeError raise AttributeError
def connect_registry(self): def connect_registry(self):
...@@ -106,12 +109,12 @@ class RegistryHandler: ...@@ -106,12 +109,12 @@ class RegistryHandler:
Keyword arguments: Keyword arguments:
@return connected_registy -- Reference to the newly opened @return connected_registy -- Reference to the newly opened
registry registry
""" """
return ConnectRegistry(None,self.args.registry) return ConnectRegistry(None, self.args.registry)
def create_registry_from_dict_chain( def create_registry_from_dict_chain(
self, dict_chain, both = False, architect = KEY_WOW64_64KEY, self, dict_chain, both=False, architect=KEY_WOW64_64KEY,
needed_rights = KEY_ALL_ACCESS): needed_rights=KEY_ALL_ACCESS):
"""" """"
Create registry key and value multilevel tree by chained Create registry key and value multilevel tree by chained
dictionaries. dictionaries.
...@@ -183,9 +186,9 @@ class RegistryHandler: ...@@ -183,9 +186,9 @@ class RegistryHandler:
key -- Reference to the opened key -- Reference to the opened
key handler key handler
architect -- 0 for x86 architect -- 0 for x86
KEY_WOW64_32KEY or KEY_WOW64_32KEY or
KEY_WOW64_64KEY KEY_WOW64_64KEY
depending where we depending where we
found the key on x64 found the key on x64
""" """
connected_registy = self.connect_registry() connected_registy = self.connect_registry()
...@@ -208,14 +211,14 @@ class RegistryHandler: ...@@ -208,14 +211,14 @@ class RegistryHandler:
return [key, architect] return [key, architect]
def get_key_values( def get_key_values(
self, key_name, subkey_list, subroutine = False, self, key_name, subkey_list, subroutine=False,
depth = "subkeys"): depth="subkeys"):
""" """
Getting registry subkeys value by it's key's name and subkeys Getting registry subkeys value by it's key's name and subkeys
name name
Can raise LookupError exception if there are missing data Can raise LookupError exception if there are missing data
Can raise AttributeError exception if depth attribute is wrong Can raise AttributeError exception if depth attribute is wrong
Keyword arguments: Keyword arguments:
@param key_name -- The specific key name of which subkey's @param key_name -- The specific key name of which subkey's
we are interested in we are interested in
...@@ -224,7 +227,7 @@ class RegistryHandler: ...@@ -224,7 +227,7 @@ class RegistryHandler:
@param subroutine -- Whether suppress exception about not @param subroutine -- Whether suppress exception about not
having enough results or not having enough results or not
(default: False) (default: False)
@param depth -- How depth the search should go for @param depth -- How depth the search should go for
[options: key, subkeys, all] [options: key, subkeys, all]
(default: subkeys) (default: subkeys)
@return results{} -- Dictionary with the subkey_name - value @return results{} -- Dictionary with the subkey_name - value
...@@ -243,9 +246,9 @@ class RegistryHandler: ...@@ -243,9 +246,9 @@ class RegistryHandler:
key = key_and_architect[0] key = key_and_architect[0]
architect = key_and_architect[1] architect = key_and_architect[1]
except KeyError: except KeyError:
#print "%s doesn't exist in the registry" % key_name # print "%s doesn't exist in the registry" % key_name
raise LookupError raise LookupError
#print "%s found in the registry" % key_name # print "%s found in the registry" % key_name
results = {} results = {}
if int_depth >= 1: if int_depth >= 1:
for i in xrange(0, QueryInfoKey(key)[0]-1): for i in xrange(0, QueryInfoKey(key)[0]-1):
...@@ -261,24 +264,24 @@ class RegistryHandler: ...@@ -261,24 +264,24 @@ class RegistryHandler:
skey, subkey_name)[0] skey, subkey_name)[0]
except OSError as e: except OSError as e:
if e.errno == errno.ENOENT: if e.errno == errno.ENOENT:
#print ("%s doesn't exist in this" % subkey_name # print ("%s doesn't exist in this" % subkey_name
# " subkey") # " subkey")
pass pass
skey.Close() skey.Close()
if not results or len(results) != len(subkey_list): if not results or len(results) != len(subkey_list):
for subkey_name in subkey_list: for subkey_name in subkey_list:
try: try:
results[subkey_name] = QueryValueEx(key, subkey_name)[0] results[subkey_name] = QueryValueEx(key, subkey_name)[0]
except OSError as e: except OSError as e:
pass pass
key.Close() key.Close()
if len(results) != len(subkey_list): if len(results) != len(subkey_list):
#print "We are missing important variables" # print "We are missing important variables"
raise LookupError raise LookupError
return results return results
def get_key_value( def get_key_value(
self, key_name, subkey_name, subroutine = None, depth = None): self, key_name, subkey_name, subroutine=None, depth=None):
""" """
This is a wrapper for the get_key_values to be easier to use This is a wrapper for the get_key_values to be easier to use
for single subkeys. for single subkeys.
...@@ -296,14 +299,14 @@ class RegistryHandler: ...@@ -296,14 +299,14 @@ class RegistryHandler:
""" """
try: try:
if subroutine is None: if subroutine is None:
return self.get_key_values(key_name, return self.get_key_values(
[subkey_name])[subkey_name] key_name, [subkey_name])[subkey_name]
elif depth is None: elif depth is None:
return self.get_key_values(key_name, [subkey_name], return self.get_key_values(
subroutine)[subkey_name] key_name, [subkey_name], subroutine)[subkey_name]
else: else:
return self.get_key_values(key_name, [subkey_name], return self.get_key_values(
subroutine, depth)[subkey_name] key_name, [subkey_name], subroutine, depth)[subkey_name]
except: except:
raise raise
...@@ -313,18 +316,21 @@ class DecideArchitecture: ...@@ -313,18 +316,21 @@ class DecideArchitecture:
Helper class to get the true ProgramFiles directory. Helper class to get the true ProgramFiles directory.
This class doesn't depend on Phyton or Windows architecture. This class doesn't depend on Phyton or Windows architecture.
""" """
@staticmethod @staticmethod
def Is64Windows(): def Is64Windows():
return 'PROGRAMFILES(X86)' in os.environ return 'PROGRAMFILES(X86)' in os.environ
@staticmethod @staticmethod
def GetProgramFiles32(): def GetProgramFiles32():
if DecideArchitecture.Is64Windows(): if DecideArchitecture.Is64Windows():
return os.environ['PROGRAMFILES(X86)'] return os.environ['PROGRAMFILES(X86)']
else: else:
return os.environ['PROGRAMFILES'] return os.environ['PROGRAMFILES']
@staticmethod @staticmethod
def GetProgramFiles64(): def GetProgramFiles64():
if DecideArchitecture.Is64Windows(): if DecideArchitecture.Is64Windows():
return os.environ['PROGRAMW6432'] return os.environ['PROGRAMW6432']
else: else:
return None return None
\ No newline at end of file
# Backport of OrderedDict() class that runs on Python 2.4, 2.5, 2.6, 2.7 and pypy. # Backport of OrderedDict() class that runs on Python 2.4, 2.5, 2.6, 2.7 and pypy.
# Passes Python2.7's test suite and incorporates all the latest updates. # Passes Python2.7's test suite and incorporates all the latest updates.
# flake8: noqa
try: try:
from thread import get_ident as _get_ident from thread import get_ident as _get_ident
......
...@@ -8,8 +8,6 @@ The Client job is to help the ease of use of the cloud system. ...@@ -8,8 +8,6 @@ The Client job is to help the ease of use of the cloud system.
import platform import platform
import argparse import argparse
import sys
import time
try: try:
from selenium import webdriver from selenium import webdriver
from selenium.webdriver.common.by import By from selenium.webdriver.common.by import By
...@@ -49,19 +47,20 @@ def parse_arguments(): ...@@ -49,19 +47,20 @@ def parse_arguments():
parser.add_argument("-p", "--password", type=str) parser.add_argument("-p", "--password", type=str)
parser.add_argument( parser.add_argument(
"-d", "--driver", "-d", "--driver",
help="Select webdriver. Aside from Firefox, you have to install "+ help = "Select webdriver. Aside from Firefox, you have to install "+
"first the proper driver.", type=str, "first the proper driver.", type=str,
choices=['firefox', 'chrome', 'ie', 'opera'], choices = ['firefox', 'chrome', 'ie', 'opera'],
default="firefox") default = "firefox")
args = parser.parse_args() args = parser.parse_args()
return args return args
class Browser: class Browser:
""" """
Browser initialisation Browser initialisation
Keyword arguments: Keyword arguments:
@param args -- args.driver tells us which installed browser @param args -- args.driver tells us which installed browser
we want to use with selenium. we want to use with selenium.
""" """
def __init__(self, args): def __init__(self, args):
...@@ -92,11 +91,10 @@ class Browser: ...@@ -92,11 +91,10 @@ class Browser:
driver.find_element_by_css_selector( driver.find_element_by_css_selector(
"input[type='submit']").click() "input[type='submit']").click()
def main(self): def main(self):
""" """
Use of the https://cloud.bme.hu/ Use of the https://cloud.bme.hu/
Keyword arguments: Keyword arguments:
@return vm -- Necessarily parameters to connect @return vm -- Necessarily parameters to connect
to the Virtual Machine to the Virtual Machine
...@@ -142,7 +140,7 @@ def main(): ...@@ -142,7 +140,7 @@ def main():
args = parse_arguments() args = parse_arguments()
if args.uri is not None: if args.uri is not None:
vm = Struct() vm = Struct()
vm.protocol,vm.user,vm.password,vm.host,vm.port = \ vm.protocol, vm.user, vm.password, vm.host, vm.port = \
args.uri.split(':',4) args.uri.split(':',4)
vm.protocol = vm.protocol.upper() vm.protocol = vm.protocol.upper()
vm.state = "RUN" vm.state = "RUN"
...@@ -158,7 +156,7 @@ def main(): ...@@ -158,7 +156,7 @@ def main():
connect(vm) connect(vm)
except: except:
print "Unknown error occurred! Please contact the developers!" print "Unknown error occurred! Please contact the developers!"
if __name__ == "__main__": if __name__ == "__main__":
main() main()
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
""" """
Configuration of the Windows specific tools to enhance the ease of use Configuration of the Windows specific tools to enhance the ease of use
of the CIRCLE cloud. Handles the auto launch and auto configuration of the CIRCLE cloud. Handles the auto launch and auto configuration
of these specific connectivity programs. of these specific connectivity programs.
""" """
...@@ -29,8 +29,9 @@ def connect(vm): ...@@ -29,8 +29,9 @@ def connect(vm):
vm.password -- Password used for the connection vm.password -- Password used for the connection
""" """
if vm.protocol == "SSH": if vm.protocol == "SSH":
arguments = "-ssh -P %s -pw %s %s@%s" % (vm.port, vm.password, vm.user, vm.host) arguments = ("-ssh -P %s -pw %s" % (vm.port, vm.password)
subprocess.Popen("putty.exe "+arguments, shell = True) + "%s@%s" % (vm.user, vm.host))
subprocess.Popen("putty.exe "+arguments, shell=True)
elif vm.protocol == "NX": elif vm.protocol == "NX":
listdir = os.path.expanduser("~\\.nx\\config\\*.nxs") listdir = os.path.expanduser("~\\.nx\\config\\*.nxs")
found = False found = False
...@@ -43,18 +44,20 @@ def connect(vm): ...@@ -43,18 +44,20 @@ def connect(vm):
found = True found = True
break break
if not found: if not found:
config_file = "%s%s%s" % (os.path.expanduser("~\\.nx\\config\\"), str(int(time.time()*1000)), ".nxs") config_file = "%s%s%s" % (os.path.expanduser("~\\.nx\\config\\"),
str(int(time.time()*1000)), ".nxs")
password = nxkey.NXKeyGen(vm.password).getEncrypted() password = nxkey.NXKeyGen(vm.password).getEncrypted()
config = NX_template % {'USERNAME' : vm.user, 'PASSWORD' : password, 'HOST' : vm.host, 'PORT' : vm.port} config = NX_template % {'USERNAME': vm.user, 'PASSWORD': password,
'HOST': vm.host, 'PORT': vm.port}
f = open(config_file, 'w') f = open(config_file, 'w')
f.write(config) f.write(config)
f.close() f.close()
subprocess.Popen(config_file, shell = True) subprocess.Popen(config_file, shell=True)
elif vm.protocol == "RDP": elif vm.protocol == "RDP":
listdir = os.path.dirname(os.path.realpath(__file__))+"\\.rdp\\*.rdp" listdir = os.path.dirname(os.path.realpath(__file__))+"\\.rdp\\*.rdp"
found = False found = False
full_address = "full address:s:%s:%s" % (vm.host, vm.port) full_address = "full address:s:%s:%s" % (vm.host, vm.port)
user = "username:s:%s" % vm.user user = "username:s:%s" % vm.user
for config_file in glob.glob(listdir): for config_file in glob.glob(listdir):
with open(config_file) as f: with open(config_file) as f:
file = f.read() file = f.read()
...@@ -62,13 +65,17 @@ def connect(vm): ...@@ -62,13 +65,17 @@ def connect(vm):
found = True found = True
break break
if not found: if not found:
config_file = "%s%s%s" % (os.path.dirname(os.path.realpath(__file__))+"\\.rdp\\", str(int(time.time()*1000)), ".rdp") config_file = "%s%s%s" % ((os.path.dirname(
password = binascii.hexlify(win32crypt.CryptProtectData(u"%s" % vm.password,u'psw',None,None,None,0)) os.path.realpath(__file__))+"\\.rdp\\"),
config = RPD_template % {'USERNAME' : vm.user, 'PASSWORD' : password, 'HOST' : vm.host, 'PORT' : vm.port} str(int(time.time()*1000)), ".rdp")
password = binascii.hexlify(win32crypt.CryptProtectData(
u"%s" % vm.password, u'psw', None, None, None, 0))
config = RPD_template % {'USERNAME': vm.user, 'PASSWORD': password,
'HOST': vm.host, 'PORT': vm.port}
f = open(config_file, 'w') f = open(config_file, 'w')
f.write(config) f.write(config)
f.close() f.close()
subprocess.Popen(config_file, shell = True) subprocess.Popen(config_file, shell=True)
NX_template = """<!DOCTYPE NXClientSettings> NX_template = """<!DOCTYPE NXClientSettings>
...@@ -90,4 +97,4 @@ NX_template = """<!DOCTYPE NXClientSettings> ...@@ -90,4 +97,4 @@ NX_template = """<!DOCTYPE NXClientSettings>
RPD_template = """username:s:%(USERNAME)s RPD_template = """username:s:%(USERNAME)s
full address:s:%(HOST)s:%(PORT)s full address:s:%(HOST)s:%(PORT)s
password 51:b:%(PASSWORD)s""" password 51:b:%(PASSWORD)s"""
\ No newline at end of file
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
# #
# If you're wondering how this is created, the secret is # If you're wondering how this is created, the secret is
# "contrib/build-installer" from the pip repository. # "contrib/build-installer" from the pip repository.
# flake8: noqa
ZIPFILE = b""" ZIPFILE = b"""
UEsDBBQAAAAIAHeDxEQMVWtseQwAAOokAAAPAAAAcGlwL19faW5pdF9fLnB5pRprb+M28rt/BTdp UEsDBBQAAAAIAHeDxEQMVWtseQwAAOokAAAPAAAAcGlwL19faW5pdF9fLnB5pRprb+M28rt/BTdp
...@@ -24,11 +24,11 @@ def parse_arguments(): ...@@ -24,11 +24,11 @@ def parse_arguments():
parser = argparse.ArgumentParser() parser = argparse.ArgumentParser()
if windowsclasses.DecideArchitecture.Is64Windows(): if windowsclasses.DecideArchitecture.Is64Windows():
local_default = (windowsclasses.DecideArchitecture.GetProgramFiles64() local_default = (windowsclasses.DecideArchitecture.GetProgramFiles64()
+"\\CIRCLE\\") + "\\CIRCLE\\")
else: else:
local_default = (windowsclasses.DecideArchitecture.GetProgramFiles32() local_default = (windowsclasses.DecideArchitecture.GetProgramFiles32()
+"\\CIRCLE\\") + "\\CIRCLE\\")
if (not os.path.exists(local_default[:-1]) if (not os.path.exists(local_default[:-1])
and os.path.exists(os.environ['APPDATA']+"\\CIRCLE")): and os.path.exists(os.environ['APPDATA']+"\\CIRCLE")):
local_default = os.environ['APPDATA']+"\\CIRCLE\\" local_default = os.environ['APPDATA']+"\\CIRCLE\\"
parser.add_argument( parser.add_argument(
...@@ -38,20 +38,20 @@ def parse_arguments(): ...@@ -38,20 +38,20 @@ def parse_arguments():
args = parser.parse_args() args = parser.parse_args()
return args return args
def main(): def main():
try: try:
args = parse_arguments()
nx_install_location = None nx_install_location = None
while nx_install_location is None: while nx_install_location is None:
print "Checking whether NX Client for Windows is installed" print "Checking whether NX Client for Windows is installed"
handler = windowsclasses.RegistryHandler() handler = windowsclasses.RegistryHandler()
try: try:
nx_install_location = handler.get_key_value( nx_install_location = handler.get_key_value(
"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"+ "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
"Uninstall\\nxclient_is1", + "Uninstall\\nxclient_is1",
"InstallLocation", "key") "InstallLocation", "key")
print ("NX Client for Windows is found at " print ("NX Client for Windows is found at "
"'%s'" % nx_install_location) "'%s'" % nx_install_location)
process = subprocess.Popen( process = subprocess.Popen(
"%s\\nxclient.exe" % nx_install_location) "%s\\nxclient.exe" % nx_install_location)
time.sleep(2) time.sleep(2)
...@@ -60,10 +60,10 @@ def main(): ...@@ -60,10 +60,10 @@ def main():
print "NX Client for Windows isn't installed on the system." print "NX Client for Windows isn't installed on the system."
print "\tCommencing the install" print "\tCommencing the install"
subprocess.Popen(os.path.dirname( subprocess.Popen(os.path.dirname(
os.path.realpath(__file__))+ os.path.realpath(__file__))
"\\nxclient-3.5.0-9.exe").wait() + "\\nxclient-3.5.0-9.exe").wait()
except: except:
pass pass
if __name__ == "__main__": if __name__ == "__main__":
main() main()
\ No newline at end of file
...@@ -8,9 +8,9 @@ https://www.nomachine.com/AR01C00125 ...@@ -8,9 +8,9 @@ https://www.nomachine.com/AR01C00125
import sys import sys
import random import random
import re
from xml.sax.saxutils import escape from xml.sax.saxutils import escape
class NXKeyGen: class NXKeyGen:
""" """
NXKeyGen class NXKeyGen class
...@@ -18,6 +18,7 @@ class NXKeyGen: ...@@ -18,6 +18,7 @@ class NXKeyGen:
""" """
numValidCharList = 85 numValidCharList = 85
dummyString = "{{{{" dummyString = "{{{{"
def __init__(self, password): def __init__(self, password):
""" """
Initialize the class Initialize the class
...@@ -26,7 +27,7 @@ class NXKeyGen: ...@@ -26,7 +27,7 @@ class NXKeyGen:
@param password -- Password that will be scrambled @param password -- Password that will be scrambled
""" """
self.password = password self.password = password
def getEncrypted(self): def getEncrypted(self):
""" """
Encrypt (scramble) the given password Encrypt (scramble) the given password
...@@ -36,7 +37,7 @@ class NXKeyGen: ...@@ -36,7 +37,7 @@ class NXKeyGen:
password password
""" """
return self.scrambleString(self.password) return self.scrambleString(self.password)
def getvalidCharList(self, pos): def getvalidCharList(self, pos):
""" """
Valid character list Valid character list
...@@ -45,16 +46,15 @@ class NXKeyGen: ...@@ -45,16 +46,15 @@ class NXKeyGen:
@return validcharlist -- List of the valid characters @return validcharlist -- List of the valid characters
""" """
validcharlist = [ validcharlist = [
"!", "#", "$", "%", "&", "(", ")", "*", "+", "-", "!", "#", "$", "%", "&", "(", ")", "*", "+", "-",
".", "0", "1", "2", "3", "4", "5", "6", "7", "8", ".", "0", "1", "2", "3", "4", "5", "6", "7", "8",
"9", ":", ";", "<", ">", "?", "@", "A", "B", "C", "9", ":", ";", "<", ">", "?", "@", "A", "B", "C",
"D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M",
"N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W",
"X", "Y", "Z", "[", "]", "_", "a", "b", "c", "d", "X", "Y", "Z", "[", "]", "_", "a", "b", "c", "d",
"e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n",
"o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x",
"y", "z", "{", "|", "}" "y", "z", "{", "|", "}"]
]
return validcharlist[pos] return validcharlist[pos]
def encodePassword(self, p): def encodePassword(self, p):
...@@ -71,7 +71,7 @@ class NXKeyGen: ...@@ -71,7 +71,7 @@ class NXKeyGen:
for i in range(len(p)): for i in range(len(p)):
c = p[i:i+1] c = p[i:i+1]
a = ord(c) a = ord(c)
sTmp = str( a + i + 1) + ":" sTmp = str(a + i + 1) + ":"
sPass += sTmp sPass += sTmp
sTmp = "" sTmp = ""
return sPass return sPass
...@@ -86,7 +86,7 @@ class NXKeyGen: ...@@ -86,7 +86,7 @@ class NXKeyGen:
""" """
i = -1 i = -1
for j in range(self.numValidCharList): for j in range(self.numValidCharList):
randchar = self.getvalidCharList(j); randchar = self.getvalidCharList(j)
if randchar == c: if randchar == c:
i = j i = j
return i return i
...@@ -99,7 +99,7 @@ class NXKeyGen: ...@@ -99,7 +99,7 @@ class NXKeyGen:
Keyword arguments: Keyword arguments:
@return char -- Valid character placed 0-60 in the valid list @return char -- Valid character placed 0-60 in the valid list
""" """
return self.getvalidCharList(random.randint(0,60)) return self.getvalidCharList(random.randint(0, 60))
def scrambleString(self, s): def scrambleString(self, s):
""" """
...@@ -124,25 +124,25 @@ class NXKeyGen: ...@@ -124,25 +124,25 @@ class NXKeyGen:
l = k + len(sRet) - 2 l = k + len(sRet) - 2
sRet = app + sRet sRet = app + sRet
for i1 in range(1, len(sRet)): for i1 in range(1, len(sRet)):
app2 = sRet[i1 : i1 + 1] app2 = sRet[i1: i1 + 1]
j = self.findCharInList(app2) j = self.findCharInList(app2)
if j == -1: if j == -1:
return sRet return sRet
i = (j + l * (i1 + 1)) % self.numValidCharList i = (j + l * (i1 + 1)) % self.numValidCharList
car = self.getvalidCharList(i) car = self.getvalidCharList(i)
sRet = self.substr_replace(sRet,car,i1,1) sRet = self.substr_replace(sRet, car, i1, 1)
c = (ord(self.getRandomValidCharFromList())) + 2 c = (ord(self.getRandomValidCharFromList())) + 2
c2 = chr(c) c2 = chr(c)
sRet = sRet + c2 sRet = sRet + c2
return escape(sRet) return escape(sRet)
def substr_replace(self,in_str,ch,pos,qt): def substr_replace(self,in_str,ch,pos,qt):
""" """
Replace a character at a special position Replace a character at a special position
""" """
clist = list(in_str) clist = list(in_str)
count = 0; count = 0
tmp_str = ''; tmp_str = ''
for key in clist: for key in clist:
if count != pos: if count != pos:
tmp_str += key tmp_str += key
...@@ -156,4 +156,3 @@ if __name__ == "__main__": ...@@ -156,4 +156,3 @@ if __name__ == "__main__":
NXPass = NXKeyGen(sys.argv[1]) NXPass = NXKeyGen(sys.argv[1])
print NXPass.password print NXPass.password
print NXPass.getEncrypted() print NXPass.getEncrypted()
...@@ -16,13 +16,13 @@ def main(): ...@@ -16,13 +16,13 @@ def main():
Main program Main program
Job: Job:
Install Pywin32 to the computer Install Pywin32 to the computer
""" """
if sys.hexversion < 0x02060000: if sys.hexversion < 0x02060000:
print "Not a 2.6+ version Python is running, commencing update" print "Not a 2.6+ version Python is running, commencing update"
subprocess.Popen( subprocess.Popen(
"%s\\no_root_install.bat" % os.path.dirname( "%s\\no_root_install.bat" % os.path.dirname(
os.path.realpath(__file__))) os.path.realpath(__file__)))
sys.exit(1) sys.exit(1)
else: else:
pywin32_version = str(219) pywin32_version = str(219)
...@@ -50,7 +50,7 @@ def main(): ...@@ -50,7 +50,7 @@ def main():
pywin32_version)).wait() pywin32_version)).wait()
else: else:
print "Unsupported Python version is found!" print "Unsupported Python version is found!"
if __name__ == "__main__": if __name__ == "__main__":
main() main()
\ No newline at end of file
...@@ -13,11 +13,9 @@ import shutil ...@@ -13,11 +13,9 @@ import shutil
from win32com.shell import shell, shellcon from win32com.shell import shell, shellcon
import windowsclasses import windowsclasses
try: try:
from collections import * from collections import * # noqa
except ImportError: except ImportError:
from OrderedDict import * from OrderedDict import * # noqa
def parse_arguments(): def parse_arguments():
""" """
...@@ -35,13 +33,13 @@ def parse_arguments(): ...@@ -35,13 +33,13 @@ def parse_arguments():
'iexplore', 'opera']) 'iexplore', 'opera'])
if windowsclasses.DecideArchitecture.Is64Windows(): if windowsclasses.DecideArchitecture.Is64Windows():
local_default = (windowsclasses.DecideArchitecture.GetProgramFiles64() local_default = (windowsclasses.DecideArchitecture.GetProgramFiles64()
+"\\CIRCLE\\") + "\\CIRCLE\\")
else: else:
local_default = (windowsclasses.DecideArchitecture.GetProgramFiles32() local_default = (windowsclasses.DecideArchitecture.GetProgramFiles32()
+"\\CIRCLE\\") + "\\CIRCLE\\")
if (not os.path.exists(local_default[:-1]) if (not os.path.exists(local_default[:-1]) and
and os.path.exists(os.environ['APPDATA']+"\\CIRCLE")): os.path.exists(os.environ['APPDATA'] + "\\CIRCLE")):
local_default = os.environ['APPDATA']+"\\CIRCLE\\" local_default = os.environ['APPDATA'] + "\\CIRCLE\\"
parser.add_argument( parser.add_argument(
"-l", "--location", help="Location of the client files in the system", "-l", "--location", help="Location of the client files in the system",
default=local_default, required=False) default=local_default, required=False)
...@@ -59,7 +57,8 @@ def parse_arguments(): ...@@ -59,7 +57,8 @@ def parse_arguments():
default="https://cloud.bme.hu/", required=False) default="https://cloud.bme.hu/", required=False)
args = parser.parse_args() args = parser.parse_args()
return args return args
def custom_protocol_register(custom_protocol): def custom_protocol_register(custom_protocol):
""" """
Custom protocol register based on RegistryHandler module Custom protocol register based on RegistryHandler module
...@@ -79,7 +78,7 @@ def custom_protocol_register(custom_protocol): ...@@ -79,7 +78,7 @@ def custom_protocol_register(custom_protocol):
print "\t\tDone!" print "\t\tDone!"
except: except:
raise raise
def main(): def main():
""" """
...@@ -92,13 +91,13 @@ def main(): ...@@ -92,13 +91,13 @@ def main():
""" """
try: try:
args = parse_arguments() args = parse_arguments()
shortcut = pythoncom.CoCreateInstance ( shortcut = pythoncom.CoCreateInstance(
shell.CLSID_ShellLink, shell.CLSID_ShellLink,
None, None,
pythoncom.CLSCTX_INPROC_SERVER, pythoncom.CLSCTX_INPROC_SERVER,
shell.IID_IShellLink shell.IID_IShellLink
) )
desktop_path = shell.SHGetFolderPath ( desktop_path = shell.SHGetFolderPath(
0, shellcon.CSIDL_DESKTOP, 0, 0) 0, shellcon.CSIDL_DESKTOP, 0, 0)
if args.remove: if args.remove:
location = os.path.join(desktop_path, "Cloud GUI") location = os.path.join(desktop_path, "Cloud GUI")
...@@ -117,15 +116,15 @@ def main(): ...@@ -117,15 +116,15 @@ def main():
shortcut.write('URL='+args.target) shortcut.write('URL='+args.target)
shortcut.close() shortcut.close()
else: else:
shortcut.SetPath (args.location+"cloud.py") shortcut.SetPath(args.location+"cloud.py")
if args.driver == "chrome": if args.driver == "chrome":
shortcut.SetArguments("-d chrome") shortcut.SetArguments("-d chrome")
elif args.driver == "iexplore": elif args.driver == "iexplore":
shortcut.SetArguments("-d ie") shortcut.SetArguments("-d ie")
elif args.driver == "opera": elif args.driver == "opera":
shortcut.SetArguments("-d opera") shortcut.SetArguments("-d opera")
shortcut.SetDescription ("Tool to use CIRCLE Cloud") shortcut.SetDescription("Tool to use CIRCLE Cloud")
shortcut.SetIconLocation (args.location+"cloud.ico", 0) shortcut.SetIconLocation(args.location+"cloud.ico", 0)
desktop_path = shell.SHGetFolderPath( desktop_path = shell.SHGetFolderPath(
0, shellcon.CSIDL_DESKTOP, 0, 0) 0, shellcon.CSIDL_DESKTOP, 0, 0)
persist_file = shortcut.QueryInterface( persist_file = shortcut.QueryInterface(
...@@ -137,34 +136,43 @@ def main(): ...@@ -137,34 +136,43 @@ def main():
print "Creating custom URL protocol handlers" print "Creating custom URL protocol handlers"
try: try:
custom_ssh = OrderedDict( custom_ssh = OrderedDict(
[('ssh', ["default", "URL:ssh Protocol", "URL Protocol", ""]), [('ssh', ["default",
"URL:ssh Protocol",
"URL Protocol",
""]),
('ssh\\URL Protocol', ""), ('ssh\\URL Protocol', ""),
('ssh\\DefaultIcon', args.location+"cloud.ico"), ('ssh\\DefaultIcon', args.location+"cloud.ico"),
('ssh\\shell', {'open': { ('ssh\\shell', {'open': {
'command': "\"python.exe\" \"%s" % args.location+ 'command': "\"pythonw.exe\" \"%s" % args.location
"cloud.py\" \"%1\""}})]) + "cloud.py\" \"%1\""}})])
custom_protocol_register(custom_ssh) custom_protocol_register(custom_ssh)
custom_rdp = OrderedDict( custom_rdp = OrderedDict(
[('rdp', ["default", "URL:rdp Protocol", "URL Protocol", ""]), [('rdp', ["default",
"URL:rdp Protocol",
"URL Protocol",
""]),
('rdp\\URL Protocol', ""), ('rdp\\URL Protocol', ""),
('rdp\\DefaultIcon', args.location+"cloud.ico"), ('rdp\\DefaultIcon', args.location + "cloud.ico"),
('rdp\\shell', {'open': { ('rdp\\shell', {'open': {
'command': "\"python.exe\" \"%s" % args.location+ 'command': "\"pythonw.exe\" \"%s" % args.location
"cloud.py\" \"%1\""}})]) + "cloud.py\" \"%1\""}})])
custom_protocol_register(custom_rdp) custom_protocol_register(custom_rdp)
custom_nx = OrderedDict( custom_nx = OrderedDict(
[('nx', ["default", "URL:nx Protocol", "URL Protocol", ""]), [('nx', ["default",
"URL:nx Protocol",
"URL Protocol",
""]),
('nx\\URL Protocol', ""), ('nx\\URL Protocol', ""),
('nx\\DefaultIcon', args.location+"cloud.ico"), ('nx\\DefaultIcon', args.location + "cloud.ico"),
('nx\\shell', {'open': { ('nx\\shell', {'open': {
'command': "\"python.exe\" \"%s" % args.location+ 'command': "\"pythonw.exe\" \"%s" % args.location
"cloud.py\" \"%1\""}})]) + "cloud.py\" \"%1\""}})])
custom_protocol_register(custom_nx) custom_protocol_register(custom_nx)
except: except:
print "Error! URL Protocol handler installation aborted!" print "Error! URL Protocol handler installation aborted!"
except: except:
print "Unknown error occurred! Please contact the developers!" print "Unknown error occurred! Please contact the developers!"
if __name__ == "__main__": if __name__ == "__main__":
main() main()
\ No newline at end of file
...@@ -11,11 +11,12 @@ Currently here: ...@@ -11,11 +11,12 @@ Currently here:
import os import os
import argparse import argparse
import errno import errno
from _winreg import * from _winreg import * # noqa
try: try:
from collections import * from collections import * # noqa
except ImporError: except ImporError:
from OrderedDict import * from OrderedDict import * # noqa
def parse_arguments(): def parse_arguments():
""" """
...@@ -41,9 +42,11 @@ def parse_arguments(): ...@@ -41,9 +42,11 @@ def parse_arguments():
args = parser.parse_args() args = parser.parse_args()
return args return args
def main(): def main():
return RegistryHandler(parse_arguments()) return RegistryHandler(parse_arguments())
class Struct: class Struct:
""" """
Parameter bypassing struct Parameter bypassing struct
...@@ -53,13 +56,13 @@ class Struct: ...@@ -53,13 +56,13 @@ class Struct:
class RegistryHandler: class RegistryHandler:
""" """
Registry handling class, makes registry based queries and Registry handling class, makes registry based queries and
manipulations easier. manipulations easier.
This class can handle WOW64 based application differently and none This class can handle WOW64 based application differently and none
differently (default) differently (default)
""" """
def __init__(self, args = None): def __init__(self, args=None):
"""Initialise RegistryHandler """Initialise RegistryHandler
Keyword arguments: Keyword arguments:
...@@ -96,7 +99,7 @@ class RegistryHandler: ...@@ -96,7 +99,7 @@ class RegistryHandler:
elif self.args.registry == "HKCC": elif self.args.registry == "HKCC":
self.args.registry = HKEY_CURRENT_CONFIG self.args.registry = HKEY_CURRENT_CONFIG
else: else:
#print "Non supported registry type" # print "Non supported registry type"
raise AttributeError raise AttributeError
def connect_registry(self): def connect_registry(self):
...@@ -106,12 +109,12 @@ class RegistryHandler: ...@@ -106,12 +109,12 @@ class RegistryHandler:
Keyword arguments: Keyword arguments:
@return connected_registy -- Reference to the newly opened @return connected_registy -- Reference to the newly opened
registry registry
""" """
return ConnectRegistry(None,self.args.registry) return ConnectRegistry(None, self.args.registry)
def create_registry_from_dict_chain( def create_registry_from_dict_chain(
self, dict_chain, both = False, architect = KEY_WOW64_64KEY, self, dict_chain, both=False, architect=KEY_WOW64_64KEY,
needed_rights = KEY_ALL_ACCESS): needed_rights=KEY_ALL_ACCESS):
"""" """"
Create registry key and value multilevel tree by chained Create registry key and value multilevel tree by chained
dictionaries. dictionaries.
...@@ -183,9 +186,9 @@ class RegistryHandler: ...@@ -183,9 +186,9 @@ class RegistryHandler:
key -- Reference to the opened key -- Reference to the opened
key handler key handler
architect -- 0 for x86 architect -- 0 for x86
KEY_WOW64_32KEY or KEY_WOW64_32KEY or
KEY_WOW64_64KEY KEY_WOW64_64KEY
depending where we depending where we
found the key on x64 found the key on x64
""" """
connected_registy = self.connect_registry() connected_registy = self.connect_registry()
...@@ -208,14 +211,14 @@ class RegistryHandler: ...@@ -208,14 +211,14 @@ class RegistryHandler:
return [key, architect] return [key, architect]
def get_key_values( def get_key_values(
self, key_name, subkey_list, subroutine = False, self, key_name, subkey_list, subroutine=False,
depth = "subkeys"): depth="subkeys"):
""" """
Getting registry subkeys value by it's key's name and subkeys Getting registry subkeys value by it's key's name and subkeys
name name
Can raise LookupError exception if there are missing data Can raise LookupError exception if there are missing data
Can raise AttributeError exception if depth attribute is wrong Can raise AttributeError exception if depth attribute is wrong
Keyword arguments: Keyword arguments:
@param key_name -- The specific key name of which subkey's @param key_name -- The specific key name of which subkey's
we are interested in we are interested in
...@@ -224,7 +227,7 @@ class RegistryHandler: ...@@ -224,7 +227,7 @@ class RegistryHandler:
@param subroutine -- Whether suppress exception about not @param subroutine -- Whether suppress exception about not
having enough results or not having enough results or not
(default: False) (default: False)
@param depth -- How depth the search should go for @param depth -- How depth the search should go for
[options: key, subkeys, all] [options: key, subkeys, all]
(default: subkeys) (default: subkeys)
@return results{} -- Dictionary with the subkey_name - value @return results{} -- Dictionary with the subkey_name - value
...@@ -243,9 +246,9 @@ class RegistryHandler: ...@@ -243,9 +246,9 @@ class RegistryHandler:
key = key_and_architect[0] key = key_and_architect[0]
architect = key_and_architect[1] architect = key_and_architect[1]
except KeyError: except KeyError:
#print "%s doesn't exist in the registry" % key_name # print "%s doesn't exist in the registry" % key_name
raise LookupError raise LookupError
#print "%s found in the registry" % key_name # print "%s found in the registry" % key_name
results = {} results = {}
if int_depth >= 1: if int_depth >= 1:
for i in xrange(0, QueryInfoKey(key)[0]-1): for i in xrange(0, QueryInfoKey(key)[0]-1):
...@@ -261,24 +264,24 @@ class RegistryHandler: ...@@ -261,24 +264,24 @@ class RegistryHandler:
skey, subkey_name)[0] skey, subkey_name)[0]
except OSError as e: except OSError as e:
if e.errno == errno.ENOENT: if e.errno == errno.ENOENT:
#print ("%s doesn't exist in this" % subkey_name # print ("%s doesn't exist in this" % subkey_name
# " subkey") # " subkey")
pass pass
skey.Close() skey.Close()
if not results or len(results) != len(subkey_list): if not results or len(results) != len(subkey_list):
for subkey_name in subkey_list: for subkey_name in subkey_list:
try: try:
results[subkey_name] = QueryValueEx(key, subkey_name)[0] results[subkey_name] = QueryValueEx(key, subkey_name)[0]
except OSError as e: except OSError as e:
pass pass
key.Close() key.Close()
if len(results) != len(subkey_list): if len(results) != len(subkey_list):
#print "We are missing important variables" # print "We are missing important variables"
raise LookupError raise LookupError
return results return results
def get_key_value( def get_key_value(
self, key_name, subkey_name, subroutine = None, depth = None): self, key_name, subkey_name, subroutine=None, depth=None):
""" """
This is a wrapper for the get_key_values to be easier to use This is a wrapper for the get_key_values to be easier to use
for single subkeys. for single subkeys.
...@@ -296,14 +299,14 @@ class RegistryHandler: ...@@ -296,14 +299,14 @@ class RegistryHandler:
""" """
try: try:
if subroutine is None: if subroutine is None:
return self.get_key_values(key_name, return self.get_key_values(
[subkey_name])[subkey_name] key_name, [subkey_name])[subkey_name]
elif depth is None: elif depth is None:
return self.get_key_values(key_name, [subkey_name], return self.get_key_values(
subroutine)[subkey_name] key_name, [subkey_name], subroutine)[subkey_name]
else: else:
return self.get_key_values(key_name, [subkey_name], return self.get_key_values(
subroutine, depth)[subkey_name] key_name, [subkey_name], subroutine, depth)[subkey_name]
except: except:
raise raise
...@@ -313,18 +316,21 @@ class DecideArchitecture: ...@@ -313,18 +316,21 @@ class DecideArchitecture:
Helper class to get the true ProgramFiles directory. Helper class to get the true ProgramFiles directory.
This class doesn't depend on Phyton or Windows architecture. This class doesn't depend on Phyton or Windows architecture.
""" """
@staticmethod @staticmethod
def Is64Windows(): def Is64Windows():
return 'PROGRAMFILES(X86)' in os.environ return 'PROGRAMFILES(X86)' in os.environ
@staticmethod @staticmethod
def GetProgramFiles32(): def GetProgramFiles32():
if DecideArchitecture.Is64Windows(): if DecideArchitecture.Is64Windows():
return os.environ['PROGRAMFILES(X86)'] return os.environ['PROGRAMFILES(X86)']
else: else:
return os.environ['PROGRAMFILES'] return os.environ['PROGRAMFILES']
@staticmethod @staticmethod
def GetProgramFiles64(): def GetProgramFiles64():
if DecideArchitecture.Is64Windows(): if DecideArchitecture.Is64Windows():
return os.environ['PROGRAMW6432'] return os.environ['PROGRAMW6432']
else: else:
return None return None
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment