mirror of
https://github.com/cowrie/cowrie.git
synced 2025-07-01 18:07:27 -04:00
command_ftpget: Wrap ftp.quit() into try/except (#576)
This commit is contained in:
@ -8,6 +8,7 @@ import re
|
|||||||
import time
|
import time
|
||||||
import getopt
|
import getopt
|
||||||
import hashlib
|
import hashlib
|
||||||
|
import socket
|
||||||
from ftplib import FTP
|
from ftplib import FTP
|
||||||
|
|
||||||
from twisted.python import log
|
from twisted.python import log
|
||||||
@ -169,7 +170,10 @@ Download a file via FTP
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
log.msg('FTP login failed: user=%s, passwd=%s, err=%s' % (self.username, self.password, str(e)))
|
log.msg('FTP login failed: user=%s, passwd=%s, err=%s' % (self.username, self.password, str(e)))
|
||||||
self.write('ftpget: unexpected server response to USER: %s\n' % str(e))
|
self.write('ftpget: unexpected server response to USER: %s\n' % str(e))
|
||||||
ftp.quit()
|
try:
|
||||||
|
ftp.quit()
|
||||||
|
except socket.timeout:
|
||||||
|
pass
|
||||||
return False
|
return False
|
||||||
|
|
||||||
# download
|
# download
|
||||||
@ -185,7 +189,10 @@ Download a file via FTP
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
log.msg('FTP retrieval failed: %s' % str(e))
|
log.msg('FTP retrieval failed: %s' % str(e))
|
||||||
self.write('ftpget: unexpected server response to USER: %s\n' % str(e))
|
self.write('ftpget: unexpected server response to USER: %s\n' % str(e))
|
||||||
ftp.quit()
|
try:
|
||||||
|
ftp.quit()
|
||||||
|
except socket.timeout:
|
||||||
|
pass
|
||||||
return False
|
return False
|
||||||
|
|
||||||
# quit
|
# quit
|
||||||
@ -193,7 +200,11 @@ Download a file via FTP
|
|||||||
self.write('ftpget: cmd (null) (null)\n')
|
self.write('ftpget: cmd (null) (null)\n')
|
||||||
self.write('ftpget: cmd QUIT (null)\n')
|
self.write('ftpget: cmd QUIT (null)\n')
|
||||||
|
|
||||||
ftp.quit()
|
try:
|
||||||
|
ftp.quit()
|
||||||
|
except socket.timeout:
|
||||||
|
pass
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user