Skip to content

Commit 215182b

Browse files
committed
fix empty command loses cwd
1 parent fc0b3cf commit 215182b

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

mssql/mssql_shell.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
# To upload a file type: UPLOAD local_path remote_path
66
# e.g. UPLOAD myfile.txt C:\temp\myfile.txt
77
# If you omit the remote_path it uploads the file on the current working folder.
8+
# Be aware that pymssql has some serious memory leak issues when the connection fails (see: https://github.com/pymssql/pymssql/issues/512).
89
import _mssql
910
import base64
1011
import shlex
@@ -16,7 +17,7 @@
1617
except NameError: pass
1718

1819

19-
MSSQL_SERVER="10.13.38.11"
20+
MSSQL_SERVER="10.10.10.10"
2021
MSSQL_USERNAME = "Domain\\sa_user"
2122
MSSQL_PASSWORD = "**********"
2223
BUFFER_SIZE = 5*1024
@@ -49,7 +50,7 @@ def upload(mssql, stored_cwd, local_path, remote_path):
4950
data = f.read()
5051
md5sum = hashlib.md5(data).hexdigest()
5152
b64enc_data = b"".join(base64.encodestring(data).split()).decode()
52-
53+
5354
print("Data length (b64-encoded): "+str(len(b64enc_data)/1024)+"KB")
5455
for i in tqdm.tqdm(range(0, len(b64enc_data), BUFFER_SIZE), unit_scale=BUFFER_SIZE/1024, unit="KB"):
5556
cmd = 'echo '+b64enc_data[i:i+BUFFER_SIZE]+' >> "' + remote_path + '.b64"'
@@ -84,6 +85,8 @@ def shell():
8485

8586
while True:
8687
cmd = input("CMD "+username+"@"+computername+" "+cwd+"> ").rstrip("\n").replace("'", "''")
88+
if not cmd:
89+
cmd = "call" # Dummy cmd command
8790
if cmd.lower()[0:4] == "exit":
8891
mssql.close()
8992
return
@@ -107,5 +110,6 @@ def shell():
107110
if mssql:
108111
mssql.close()
109112

113+
110114
shell()
111115
sys.exit()

0 commit comments

Comments
 (0)