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