-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathftp_client.py
executable file
·71 lines (64 loc) · 1.54 KB
/
ftp_client.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/usr/bin/python
import kippo
import ftplib
from ftplib import FTP
from sys import argv,exit
import logging
logging.basicConfig(level=logging.DEBUG)
logger = logging.getLogger(__name__)
port=21
usr='anonymous'
pas='123'
def check(cmd):
global ftp
print(ftp.sendcmd(cmd))
print(ftp.getwelcome())
ftp.login()
try:
print(ftp.nlst())
print(ftp.sendcmd('umask'))
print(ftp.dir())
check('idle')
check('tenex')
check('open')
except Exception as error:
print(str(error))
try:
print(ftp.nlst())
print(ftp.sendcmd('umask'))
print(ftp.dir())
check('idle')
check('tenex')
check('open')
except Exception as error:
print(str(error))
def scan(ip):
ftp = FTP(ip)
print(ftp.getwelcome())
ftp.login()
try:
print(ftp.nlst())
print(ftp.sendcmd('umask'))
print(ftp.dir())
check('idle')
check('open')
check('tenex')
except Exception as error:
if 'implemented' in str(error):
print('honeyscore 5: unimplemented commands')
kippo.scan(ip)
print("Kippo honeyscore is %s ...", kippo.hs['honeyscore'])
if __name__ == '__main__':
ip = '127.0.0.1'
if len(argv) >= 2:
ip = argv[1]
if len(argv) >= 3:
port = int(argv[2])
if len(argv) >= 4:
user = argv[3]
if len(argv) == 5:
passwd = argv[4]
if len(argv) < 2:
print("Usage ftp_client.py <host_address=127.0.0.1> <port_no=21> <username=anonymous> <passwd=123>")
exit()
scan(ip)