运行python 2.7
读取文件并发送:
with open(payload) as f:
for line in f:
syslog.syslog("Send script line: " + data)
sock.send(line)
收到:
while True:
data = self._client_sock.recv(1024)
syslog.syslog("Script line: " + data)
我发送的内容:
raspiducky.py: Send script line: GUI d
raspiducky.py: Send script line: DELAY 50
raspiducky.py: Send script line: WINDOWS
raspiducky.py: Send script line: DELAY 50
raspiducky.py: Send script line: STRING terminal
raspiducky.py: Send script line: ENTER
raspiducky.py: Send script line: DELAY 2000
我收到什么:
raspiducky.py: Script line: GUI d
raspiducky.py: Script line: DELAY 50#012WINDOWS#012DELAY 50#012STRING terminal#012ENTER#012DELAY 2000
仅按预期接收第一行。其余的台词我做错了什么?
已解决
发送:
with open(payload) as f:
for line in f:
sock.send(struct.pack('!I', len(line)))
sock.send(line)
收到:
while True:
lengthbuf = self._client_sock.recv(4)
length, = struct.unpack('!I', lengthbuf)
data = self._client_sock.recv(length)