Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #1394 #1396

Closed
wants to merge 1 commit into from
Closed

Fix #1394 #1396

wants to merge 1 commit into from

Conversation

zst123
Copy link

@zst123 zst123 commented Aug 10, 2020

This is the traceback of issue #1394 . The bug is in the standard library, ftplib.

2020-08-10T04:35:13+0000 [stderr#error] Traceback (most recent call last):
2020-08-10T04:35:13+0000 [stderr#error]   File "/cowrie/cowrie-git/src/cowrie/commands/ftpget.py", line 209, in ftp_download
2020-08-10T04:35:13+0000 [stderr#error]     ftp.connect(host=self.host, port=self.port, timeout=30)
2020-08-10T04:35:13+0000 [stderr#error]   File "/cowrie/cowrie-git/src/cowrie/commands/ftpget.py", line 39, in connect
2020-08-10T04:35:13+0000 [stderr#error]     self.welcome = self.getresp()
2020-08-10T04:35:13+0000 [stderr#error]   File "/usr/lib/python3.7/ftplib.py", line 236, in getresp
2020-08-10T04:35:13+0000 [stderr#error]     resp = self.getmultiline()
2020-08-10T04:35:13+0000 [stderr#error]   File "/usr/lib/python3.7/ftplib.py", line 222, in getmultiline
2020-08-10T04:35:13+0000 [stderr#error]     line = self.getline()
2020-08-10T04:35:13+0000 [stderr#error]   File "/usr/lib/python3.7/ftplib.py", line 213, in getline
2020-08-10T04:35:13+0000 [stderr#error]     elif line[-1:] in CRLF:
2020-08-10T04:35:13+0000 [stderr#error] TypeError: 'in <string>' requires string as left operand, not bytes

It does not occur on all FTP servers. It occurs only when the FTP server returns a byte message instead of a string. Ftplib expects a string and does not account for receiving a byte message.

This is a similar issue: ian-whitestone/khp-data#1
My pull request is the exact same as that fix. The modified ftplib will decode if needed instead of throwing an exception.

…strings

ftpget is a standard library, so a ftplib_mod is used instead.

Reference: ian-whitestone/khp-data#1
@sonarcloud
Copy link

sonarcloud bot commented Aug 10, 2020

Kudos, SonarCloud Quality Gate passed!

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities (and Security Hotspot 0 Security Hotspots to review)
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

@micheloosterhof
Copy link
Member

micheloosterhof commented Nov 10, 2020

This is a problem upstream in Python. Maybe better to report it at https://bugs.python.org/ ?

@micheloosterhof micheloosterhof added upstream Upstream problem (python library, etc) wontfix labels Nov 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
upstream Upstream problem (python library, etc) wontfix
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants