Last active
September 1, 2017 19:32
-
-
Save studiawan/02aba8a9479f9db99831 to your computer and use it in GitHub Desktop.
Connect to FTP server using raw socket
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import socket | |
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
s.connect (('localhost', 21)) | |
commands = ['USER hudan\r\n', 'PASS 123\r\n', 'HELP\r\n', 'QUIT\r\n'] | |
i = 1 | |
while True: | |
try: | |
if i > len(commands): | |
msg = str(s.recv(1024)) | |
print msg.strip() | |
break | |
s.send(commands[i-1]) | |
msg = str(s.recv(1024)) | |
print msg.strip() | |
i += 1 | |
except socket.error, exc: | |
# print exc | |
s.close() | |
break |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
"socket.SOCK_STREAM" <-- does not look like a RAW socket to me