python - Print ftp name and password data -
i using python 2.7 script hear on port 21. need echo username , password when user tries connect via ftp client. should alter in script?
import socket import sys host = '' # symbolic name, meaning available interfaces port = 21 # arbitrary non-privileged port s = socket.socket(socket.af_inet, socket.sock_stream) print 'socket created' #bind socket local host , port try: s.bind((host, port)) except socket.error msg: print 'bind failed. error code : ' + str(msg[0]) + ' message ' + msg[1] sys.exit() print 'socket bind complete' #start listening on socket s.listen(10) print 'socket listening' #now maintain talking client while 1: #wait take connection - blocking phone call conn, addr = s.accept() print 'connected ' + addr[0] + ':' + str(addr[1]) s.close()
to receive info client, can utilize recv()
. socket module proposes other similar functions. can refer documentation more precisions.
as @ low level, have interpret ftp protocol (list of commands).
python ftp
No comments:
Post a Comment