-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathftp-connect.py
36 lines (32 loc) · 1.1 KB
/
ftp-connect.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
###############################################################################
### Basic FTP connection with authentication & send command. ###
### Author: Conor Richard ###
###############################################################################
import socket
import sys
def ftpConnect(host, port, username, password):
# Try to authenticate and send a command
try:
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((host, port))
rBuff = s.recv(1000)
print('[-] {rBuff}\n[+] Sending username'.format(rBuff = rBuff))
s.send('user {username}\r\n'.format(username = username))
rBuff = s.recv(1000)
print('[-] {rBuff}\n[+] Sending password'.format(rBuff = rBuff))
s.send('pass {password}\r\n'.format(password = password))
rBuff = s.recv(1000)
print('[-] {rBuff}'.format(rBuff = rBuff))
s.close()
except:
print('Somthing went wrong.')
sys.exit(-1)
def main():
host = '127.0.0.1'
port = 21
username = 'anonymous'
password = 'anon@somehost.com'
ftpConnect(host, port, username, password)
sys.exit(0)
if __name__ == '__main__':
sys.exit(main())