Advertisement
Guest User

Untitled

a guest
Feb 21st, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.43 KB | None | 0 0
  1. import socket
  2. import subprocess
  3. import threading
  4.  
  5. s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  6. s.bind(("0.0.0.0", 3285))
  7. s.listen(1000)
  8. s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
  9.  
  10. def interpret(conn):
  11. while True:
  12. try:
  13. data = conn.recv(1024).strip()
  14. out = subprocess.check_output("python -c \"" + data + "\"", shell=True)
  15. conn.sendall(str(out))
  16. except Exception as e:
  17. conn.sendall(str(e))
  18. conn.sendall('\n')
  19. def serve(conn):
  20.  
  21. yesed = False
  22. viewed = False
  23. try:
  24. while True:
  25. if yesed == False:
  26. conn.sendall("Welcome to BockServe 2.0a! Please type 'yes' to agree to the terms and conditions, or 'view' to view the terms and conditions.\n")
  27.  
  28. data = conn.recv(1024)
  29. if 'view' in data:
  30. conn.sendall("This service is operated by BockManity. Throughout the service, the terms \"we\", \"us\", and \"our\" refer to BockManity. BockManity offers this service, BockServe, including all information, tools, and services available from this site to you. Please read these terms and conditions, including those additional terms and conditions and policies referenced herein. Those Terms of Service apply to all users of the site, including without limitation users who are browsers, vendors, customers, merchants, and/or contributors of content. \n\n Please read these Terms of Service carefully before accessing or using our website. By accessing or using any part of the site, you agree to be bound by these Terms of Service.\n\n Any new features or tools which are added to the current store shall also be subject to the Terms of Service. You can review the most current version of the Terms of Service any time here. We reserve the right to update, change, or replace any of these Terms of Service by posting updates and/or changes here. It is your responsibility to check this page periodically for changes. \n\n")
  31. viewed = True
  32. elif 'yes' in data:
  33. if viewed == False:
  34. conn.sendall("Please view the terms and conditions before using BockServe 2.0.\n")
  35. else:
  36. conn.sendall("Thank you for agreeing to the terms and conditions. BockServe 2.0 will now allow you to send any input and it will now interpret your input.\n")
  37. yesed = True
  38. interpret(conn)
  39. return
  40. else:
  41. interpret(conn)
  42. return
  43. except Exception as e:
  44. print e
  45.  
  46. while True:
  47. conn, addr = s.accept()
  48. t = threading.Thread(target = serve, args=(conn,))
  49. t.start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement