Fixing flake8 E2 (#796)

* flake8 E2 cowrie/insults/insults.py

flake8 --count --select=E1,E2 --statistics cowrie/insults/insults.py
cowrie/insults/insults.py:51:28: E261 at least two spaces before inline comment
cowrie/insults/insults.py:53:28: E261 at least two spaces before inline comment
cowrie/insults/insults.py:86:14: E261 at least two spaces before inline comment
cowrie/insults/insults.py:86:15: E262 inline comment should start with '# '
cowrie/insults/insults.py:115:13: E265 block comment should start with '# '
cowrie/insults/insults.py:181:47: E226 missing whitespace around arithmetic operator
cowrie/insults/insults.py:215:41: E226 missing whitespace around arithmetic operator
2     E226 missing whitespace around arithmetic operator
3     E261 at least two spaces before inline comment
1     E262 inline comment should start with '# '
1     E265 block comment should start with '# '
7

* flake8 E2  cowrie/telnet/session.py

flake8 --count --select=E1,E2 --statistics cowrie/telnet/session.py
cowrie/telnet/session.py:28:11: E261 at least two spaces before inline comment
cowrie/telnet/session.py:116:5: E265 block comment should start with '# '
1     E261 at least two spaces before inline comment
1     E265 block comment should start with '# '
2

* flake8 E2 cowrie/telnet/transport.py

flake8 --count --select=E1,E2 --statistics cowrie/telnet/transport.py
cowrie/telnet/transport.py:36:32: E226 missing whitespace around arithmetic operator
cowrie/telnet/transport.py:108:9: E265 block comment should start with '# '
cowrie/telnet/transport.py:144:53: E226 missing whitespace around arithmetic operator
cowrie/telnet/transport.py:197:13: E265 block comment should start with '# '
cowrie/telnet/transport.py:207:13: E265 block comment should start with '# '
cowrie/telnet/transport.py:208:13: E265 block comment should start with '# '
cowrie/telnet/transport.py:237:30: E226 missing whitespace around arithmetic operator
3     E226 missing whitespace around arithmetic operator
4     E265 block comment should start with '# '
7

* flake8 E2 cowrie/dblog/xmpp.py

 lake8 --count --select=E1,E2 --statistics cowrie/dblog/xmpp.py
cowrie/dblog/xmpp.py:20:20: E221 multiple spaces before operator
cowrie/dblog/xmpp.py:25:18: E221 multiple spaces before operator
cowrie/dblog/xmpp.py:26:18: E221 multiple spaces before operator
cowrie/dblog/xmpp.py:38:29: E202 whitespace before ')'
cowrie/dblog/xmpp.py:44:32: E202 whitespace before ')'
cowrie/dblog/xmpp.py:66:15: E221 multiple spaces before operator
cowrie/dblog/xmpp.py:67:13: E221 multiple spaces before operator
cowrie/dblog/xmpp.py:68:17: E221 multiple spaces before operator
cowrie/dblog/xmpp.py:69:12: E221 multiple spaces before operator
cowrie/dblog/xmpp.py:81:54: E231 missing whitespace after ','
cowrie/dblog/xmpp.py:81:59: E231 missing whitespace after ','
cowrie/dblog/xmpp.py:81:66: E231 missing whitespace after ','
cowrie/dblog/xmpp.py:88:46: E261 at least two spaces before inline comment
cowrie/dblog/xmpp.py:103:84: E203 whitespace before ','
cowrie/dblog/xmpp.py:109:33: E231 missing whitespace after ','
cowrie/dblog/xmpp.py:161:21: E221 multiple spaces before operator
2     E202 whitespace before ')'
1     E203 whitespace before ','
8     E221 multiple spaces before operator
4     E231 missing whitespace after ','
1     E261 at least two spaces before inline comment
16

* flake8 E2 cowrie/commands/ping.py

flake8 --count --select=E1,E2 --statistics cowrie/commands/ping.py
cowrie/commands/ping.py:57:21: E225 missing whitespace around operator
cowrie/commands/ping.py:64:29: E226 missing whitespace around arithmetic operator
1     E225 missing whitespace around operator
1     E226 missing whitespace around arithmetic operator
2

* flake8 E2 cowrie/commands/base.py

flake8 --count --select=E1,E2 --statistics cowrie/commands/base.py
./cowrie/commands/base.py:29:47: E226 missing whitespace around arithmetic operator
./cowrie/commands/base.py:115:45: E231 missing whitespace after ','
./cowrie/commands/base.py:246:46: E226 missing whitespace around arithmetic operator
./cowrie/commands/base.py:313:25: E226 missing whitespace around arithmetic operator
./cowrie/commands/base.py:402:29: E226 missing whitespace around arithmetic operator
./cowrie/commands/base.py:495:61: E226 missing whitespace around arithmetic operator
./cowrie/commands/base.py:511:43: E226 missing whitespace around arithmetic operator
./cowrie/commands/base.py:596:29: E226 missing whitespace around arithmetic operator
./cowrie/commands/base.py:640:29: E226 missing whitespace around arithmetic operator
8     E226 missing whitespace around arithmetic operator
1     E231 missing whitespace after ','
9

* flake8 E2 setup.py

flake8 --count --select=E1,E2 --statistics setup.py
./setup.py:5:6: E211 whitespace before '('
./setup.py:6:9: E251 unexpected spaces around keyword / parameter equals
./setup.py:6:9: E221 multiple spaces before operator
./setup.py:6:23: E251 unexpected spaces around keyword / parameter equals
./setup.py:7:12: E251 unexpected spaces around keyword / parameter equals
./setup.py:7:12: E221 multiple spaces before operator
./setup.py:7:23: E251 unexpected spaces around keyword / parameter equals
./setup.py:8:16: E251 unexpected spaces around keyword / parameter equals
./setup.py:8:16: E221 multiple spaces before operator
./setup.py:8:23: E251 unexpected spaces around keyword / parameter equals
./setup.py:9:15: E251 unexpected spaces around keyword / parameter equals
./setup.py:9:15: E221 multiple spaces before operator
./setup.py:9:23: E251 unexpected spaces around keyword / parameter equals
./setup.py:10:21: E251 unexpected spaces around keyword / parameter equals
./setup.py:10:23: E251 unexpected spaces around keyword / parameter equals
./setup.py:11:13: E251 unexpected spaces around keyword / parameter equals
./setup.py:11:13: E221 multiple spaces before operator
./setup.py:11:23: E251 unexpected spaces around keyword / parameter equals
./setup.py:12:8: E251 unexpected spaces around keyword / parameter equals
./setup.py:12:8: E221 multiple spaces before operator
./setup.py:12:23: E251 unexpected spaces around keyword / parameter equals
./setup.py:13:13: E251 unexpected spaces around keyword / parameter equals
./setup.py:13:13: E221 multiple spaces before operator
./setup.py:13:23: E251 unexpected spaces around keyword / parameter equals
./setup.py:15:17: E251 unexpected spaces around keyword / parameter equals
./setup.py:15:17: E221 multiple spaces before operator
./setup.py:15:23: E251 unexpected spaces around keyword / parameter equals
./setup.py:15:25: E201 whitespace after '{'
./setup.py:15:38: E202 whitespace before '}'
./setup.py:16:12: E251 unexpected spaces around keyword / parameter equals
./setup.py:16:12: E221 multiple spaces before operator
./setup.py:16:23: E251 unexpected spaces around keyword / parameter equals
./setup.py:21:21: E251 unexpected spaces around keyword / parameter equals
./setup.py:21:23: E251 unexpected spaces around keyword / parameter equals
./setup.py:35:17: E251 unexpected spaces around keyword / parameter equals
./setup.py:35:17: E221 multiple spaces before operator
./setup.py:35:23: E251 unexpected spaces around keyword / parameter equals
./setup.py:38:19: E251 unexpected spaces around keyword / parameter equals
./setup.py:38:19: E221 multiple spaces before operator
./setup.py:38:23: E251 unexpected spaces around keyword / parameter equals
./setup.py:38:25: E201 whitespace after '{'
1     E127 continuation line over-indented for visual indent
1     E201 whitespace after '{'
1     E202 whitespace before '}'
1     E211 whitespace before '('
26    E251 unexpected spaces around keyword / parameter equals
30

* flake8 E2 cowrie/shell/protocol.py

flake8 --count --select=E1,E2 --statistics cowrie/shell/protocol.py
cowrie/shell/protocol.py:63:119: E231 missing whitespace after ','
cowrie/shell/protocol.py:63:129: E231 missing whitespace after ','
cowrie/shell/protocol.py:139:29: E261 at least two spaces before inline comment
cowrie/shell/protocol.py:146:9: E265 block comment should start with '# '
cowrie/shell/protocol.py:231:9: E265 block comment should start with '# '
cowrie/shell/protocol.py:309:21: E241 multiple spaces after ':'
cowrie/shell/protocol.py:309:43: E261 at least two spaces before inline comment
cowrie/shell/protocol.py:310:21: E241 multiple spaces after ':'
cowrie/shell/protocol.py:310:43: E261 at least two spaces before inline comment
cowrie/shell/protocol.py:311:21: E241 multiple spaces after ':'
cowrie/shell/protocol.py:311:45: E261 at least two spaces before inline comment
cowrie/shell/protocol.py:312:21: E241 multiple spaces after ':'
cowrie/shell/protocol.py:312:45: E261 at least two spaces before inline comment
cowrie/shell/protocol.py:313:21: E241 multiple spaces after ':'
cowrie/shell/protocol.py:313:42: E261 at least two spaces before inline comment
cowrie/shell/protocol.py:314:21: E241 multiple spaces after ':'
cowrie/shell/protocol.py:314:44: E261 at least two spaces before inline comment
cowrie/shell/protocol.py:315:21: E241 multiple spaces after ':'
cowrie/shell/protocol.py:315:48: E261 at least two spaces before inline comment
cowrie/shell/protocol.py:316:21: E241 multiple spaces after ':'
cowrie/shell/protocol.py:317:21: E241 multiple spaces after ':'
cowrie/shell/protocol.py:317:45: E261 at least two spaces before inline comment
cowrie/shell/protocol.py:318:21: E241 multiple spaces after ':'
cowrie/shell/protocol.py:318:45: E261 at least two spaces before inline comment
cowrie/shell/protocol.py:319:21: E241 multiple spaces after ':'
cowrie/shell/protocol.py:319:43: E261 at least two spaces before inline comment
cowrie/shell/protocol.py:320:21: E241 multiple spaces after ':'
cowrie/shell/protocol.py:320:41: E261 at least two spaces before inline comment
cowrie/shell/protocol.py:321:21: E241 multiple spaces after ':'
cowrie/shell/protocol.py:321:45: E261 at least two spaces before inline comment
cowrie/shell/protocol.py:322:21: E241 multiple spaces after ':'
cowrie/shell/protocol.py:322:45: E261 at least two spaces before inline comment
cowrie/shell/protocol.py:323:21: E241 multiple spaces after ':'
cowrie/shell/protocol.py:323:42: E261 at least two spaces before inline comment
cowrie/shell/protocol.py:331:67: E226 missing whitespace around arithmetic operator
cowrie/shell/protocol.py:375:70: E226 missing whitespace around arithmetic operator
2     E226 missing whitespace around arithmetic operator
2     E231 missing whitespace after ','
15    E241 multiple spaces after ':'
15    E261 at least two spaces before inline comment
2     E265 block comment should start with '# '
36

* flake8 E2 cowrie/commands/scp.py

flake8 --count --select=E1,E2 --statistics cowrie/commands/scp.py
cowrie/commands/scp.py:235:48: E226 missing whitespace around arithmetic operator
1     E226 missing whitespace around arithmetic operator
1

* flake8 E2 cowrie/commands/ifconfig.py

flake8 --count --select=E1,E2 --statistics cowrie/commands/ifconfig.py
cowrie/commands/ifconfig.py:34:21: E226 missing whitespace around arithmetic operator
1     E226 missing whitespace around arithmetic operator
1

* flake8 E2 cowrie/commands/ssh.py

flake8 --count --select=E1,E2 --statistics cowrie/commands/ssh.py
cowrie/commands/ssh.py:58:29: E226 missing whitespace around arithmetic operator
1     E226 missing whitespace around arithmetic operator
1

* flake8 E2 cowrie/commands/iptables.py

flake8 --count --select=E1,E2 --statistics cowrie/commands/iptables.py
cowrie/commands/iptables.py:69:28: E231 missing whitespace after ','
cowrie/commands/iptables.py:69:36: E231 missing whitespace after ','
cowrie/commands/iptables.py:69:42: E231 missing whitespace after ','
cowrie/commands/iptables.py:71:24: E225 missing whitespace around operator
cowrie/commands/iptables.py:74:24: E225 missing whitespace around operator
cowrie/commands/iptables.py:75:38: E231 missing whitespace after ','
cowrie/commands/iptables.py:75:50: E231 missing whitespace after ','
cowrie/commands/iptables.py:320:41: E226 missing whitespace around arithmetic operator
cowrie/commands/iptables.py:359:43: E226 missing whitespace around arithmetic operator
2     E225 missing whitespace around operator
2     E226 missing whitespace around arithmetic operator
5     E231 missing whitespace after ','
9

* flake8 E2 cowrie/commands/python.py

flake8 --count --select=E1,E2 --statistics cowrie/commands/python.py
cowrie/commands/python.py:83:45: E222 multiple spaces after operator
1     E222 multiple spaces after operator
1

* flake8 E2 cowrie/commands/apt.py

flake8 --count --select=E1,E2 --statistics cowrie/commands/apt.py
cowrie/commands/apt.py:42:32: E251 unexpected spaces around keyword / parameter equals
cowrie/commands/apt.py:42:34: E251 unexpected spaces around keyword / parameter equals
cowrie/commands/apt.py:113:24: E231 missing whitespace after ','
cowrie/commands/apt.py:115:112: E231 missing whitespace after ','
cowrie/commands/apt.py:122:27: E241 multiple spaces after ':'
cowrie/commands/apt.py:126:24: E241 multiple spaces after ':'
2     E231 missing whitespace after ','
2     E241 multiple spaces after ':'
2     E251 unexpected spaces around keyword / parameter equals
6

* flake8 E2 cowrie/commands/fs.py

flake8 --count --select=E1,E2 --statistics cowrie/commands/fs.py
cowrie/commands/fs.py:36:35: E231 missing whitespace after ','
cowrie/commands/fs.py:45:20: E201 whitespace after '('
cowrie/commands/fs.py:46:20: E201 whitespace after '('
cowrie/commands/fs.py:47:20: E201 whitespace after '('
cowrie/commands/fs.py:48:20: E201 whitespace after '('
4     E201 whitespace after '('
1     E231 missing whitespace after ','
5

* flake8 E2 cowrie/commands/gcc.py

flake8 --count --select=E1,E2 --statistics cowrie/commands/gcc.py
cowrie/commands/gcc.py:21:13: E221 multiple spaces before operator
cowrie/commands/gcc.py:166:24: E226 missing whitespace around arithmetic operator
1     E221 multiple spaces before operator
1     E226 missing whitespace around arithmetic operator
2

* flake8 E2 cowrie/commands/last.py

flake8 --count --select=E1,E2 --statistics cowrie/commands/last.py
cowrie/commands/last.py:30:48: E231 missing whitespace after ','
cowrie/commands/last.py:36:81: E226 missing whitespace around arithmetic operator
cowrie/commands/last.py:36:93: E226 missing whitespace around arithmetic operator
cowrie/commands/last.py:36:102: E202 whitespace before ')'
cowrie/commands/last.py:36:105: E202 whitespace before ')'
2     E202 whitespace before ')'
2     E226 missing whitespace around arithmetic operator
1     E231 missing whitespace after ','
5

* flake8 E2 cowrie/commands/busybox.py

flake8 --count --select=E1,E2 --statistics cowrie/commands/busybox.py
cowrie/commands/busybox.py:6:50: E231 missing whitespace after ','
cowrie/commands/busybox.py:11:13: E225 missing whitespace around operator
cowrie/commands/busybox.py:62:31: E226 missing whitespace around arithmetic operator
1     E225 missing whitespace around operator
1     E226 missing whitespace around arithmetic operator
1     E231 missing whitespace after ','
3

* flake8 E2 cowrie/commands/netstat.py

flake8 --count --select=E1,E2 --statistics cowrie/commands/netstat.py
cowrie/commands/netstat.py:75:22: E226 missing whitespace around arithmetic operator
cowrie/commands/netstat.py:76:22: E226 missing whitespace around arithmetic operator
cowrie/commands/netstat.py:97:37: E226 missing whitespace around arithmetic operator
cowrie/commands/netstat.py:97:41: E226 missing whitespace around arithmetic operator
cowrie/commands/netstat.py:97:52: E226 missing whitespace around arithmetic operator
cowrie/commands/netstat.py:97:60: E226 missing whitespace around arithmetic operator
cowrie/commands/netstat.py:98:37: E226 missing whitespace around arithmetic operator
cowrie/commands/netstat.py:98:41: E226 missing whitespace around arithmetic operator
cowrie/commands/netstat.py:98:52: E226 missing whitespace around arithmetic operator
cowrie/commands/netstat.py:98:60: E226 missing whitespace around arithmetic operator
cowrie/commands/netstat.py💯25: E226 missing whitespace around arithmetic operator
11    E226 missing whitespace around arithmetic operator
11

* flake8 E2 cowrie/commands/free.py

flake8 --count --select=E1,E2 --statistics cowrie/commands/free.py
cowrie/commands/free.py:16:11: E225 missing whitespace around operator
cowrie/commands/free.py:21:10: E225 missing whitespace around operator
cowrie/commands/free.py:26:11: E225 missing whitespace around operator
cowrie/commands/free.py:60:15: E225 missing whitespace around operator
cowrie/commands/free.py:61:34: E226 missing whitespace around arithmetic operator
cowrie/commands/free.py:62:17: E225 missing whitespace around operator
cowrie/commands/free.py:63:33: E226 missing whitespace around arithmetic operator
cowrie/commands/free.py:64:17: E225 missing whitespace around operator
cowrie/commands/free.py:65:34: E226 missing whitespace around arithmetic operator
6     E225 missing whitespace around operator
3     E226 missing whitespace around arithmetic operator
9

* flake8 E2 cowrie/commands/ls.py

flake8 --count --select=E1,E2 --statistics cowrie/commands/ls.py
cowrie/commands/ls.py:189:25: E226 missing whitespace around arithmetic operator
1     E226 missing whitespace around arithmetic operator
1

* flake8 E2 cowrie/commands/cat.py

flake8 --count --select=E1,E2 --statistics cowrie/commands/cat.py
cowrie/commands/cat.py:79:28: E226 missing whitespace around arithmetic operator
1     E226 missing whitespace around arithmetic operator
1

* flake8 E2 cowrie/commands/tar.py

flake8 --count --select=E1,E2 --statistics cowrie/commands/tar.py
cowrie/commands/tar.py:75:34: E226 missing whitespace around arithmetic operator
1     E226 missing whitespace around arithmetic operator
1

* flake8 E2 cowrie/commands/sudo.py

flake8 --count --select=E1,E2 --statistics cowrie/commands/sudo.py
cowrie/commands/sudo.py:9:50: E231 missing whitespace after ','
cowrie/commands/sudo.py:13:15: E225 missing whitespace around operator
cowrie/commands/sudo.py:22:14: E225 missing whitespace around operator
cowrie/commands/sudo.py:66:31: E226 missing whitespace around arithmetic operator
cowrie/commands/sudo.py:74:31: E226 missing whitespace around arithmetic operator
cowrie/commands/sudo.py:95:29: E231 missing whitespace after ','
cowrie/commands/sudo.py:96:26: E222 multiple spaces after operator
cowrie/commands/sudo.py:101:45: E231 missing whitespace after ','
cowrie/commands/sudo.py:125:17: E265 block comment should start with '# '
cowrie/commands/sudo.py:128:70: E231 missing whitespace after ','
cowrie/commands/sudo.py:128:79: E231 missing whitespace after ','
cowrie/commands/sudo.py:128:106: E203 whitespace before ','
cowrie/commands/sudo.py:128:107: E231 missing whitespace after ','
1     E203 whitespace before ','
1     E222 multiple spaces after operator
2     E225 missing whitespace around operator
2     E226 missing whitespace around arithmetic operator
6     E231 missing whitespace after ','
1     E265 block comment should start with '# '
13

* flake8 E2 cowrie/commands/env.py

flake8 --count --select=E1,E2 --statistics cowrie/commands/env.py
cowrie/commands/env.py:41:39: E231 missing whitespace after ','
1     E231 missing whitespace after ','
1

* flake8 E2 cowrie/commands/curl.py

flake8 --count --select=E1,E2 --statistics cowrie/commands/curl.py
cowrie/commands/curl.py:85:12: E225 missing whitespace around operator
cowrie/commands/curl.py:294:14: E261 at least two spaces before inline comment
cowrie/commands/curl.py:349:46: E261 at least two spaces before inline comment
cowrie/commands/curl.py:351:25: E226 missing whitespace around arithmetic operator
cowrie/commands/curl.py:383:30: E261 at least two spaces before inline comment
cowrie/commands/curl.py:437:46: E226 missing whitespace around arithmetic operator
cowrie/commands/curl.py:437:64: E226 missing whitespace around arithmetic operator
cowrie/commands/curl.py:440:55: E226 missing whitespace around arithmetic operator
cowrie/commands/curl.py:464:41: E226 missing whitespace around arithmetic operator
1     E225 missing whitespace around operator
5     E226 missing whitespace around arithmetic operator
3     E261 at least two spaces before inline comment
9

* flake8 E2 cowrie/ssh/factory.py

flake8 --count --select=E1,E2 --statistics cowrie/ssh/factory.py
cowrie/ssh/factory.py:39:15: E261 at least two spaces before inline comment
cowrie/ssh/factory.py:45:32: E226 missing whitespace around arithmetic operator
1     E226 missing whitespace around arithmetic operator
1     E261 at least two spaces before inline comment
2

* flake8 E2 cowrie/ssh/session.py

flake8 --count --select=E1,E2 --statistics cowrie/ssh/session.py
cowrie/ssh/session.py:22:9: E265 block comment should start with '# '
1     E265 block comment should start with '# '
1

* flake8 E2 cowrie/ssh/channel.py

flake8 --count --select=E1,E2 --statistics cowrie/ssh/channel.py
cowrie/ssh/channel.py:81:40: E226 missing whitespace around arithmetic operator
cowrie/ssh/channel.py:82:37: E226 missing whitespace around arithmetic operator
2     E226 missing whitespace around arithmetic operator
2

* flake8 E2 cowrie/ssh/userauth.py

flake8 --count --select=E1,E2 --statistics cowrie/ssh/userauth.py
cowrie/ssh/userauth.py:133:26: E261 at least two spaces before inline comment
cowrie/ssh/userauth.py:135:28: E261 at least two spaces before inline comment
2     E261 at least two spaces before inline comment
2

* flake8 E2 cowrie/ssh/transport.py

flake8 --count --select=E1,E2 --statistics cowrie/ssh/transport.py
cowrie/ssh/transport.py:59:56: E226 missing whitespace around arithmetic operator
cowrie/ssh/transport.py:61:33: E226 missing whitespace around arithmetic operator
cowrie/ssh/transport.py:61:55: E226 missing whitespace around arithmetic operator
cowrie/ssh/transport.py:96:13: E265 block comment should start with '# '
cowrie/ssh/transport.py:107:38: E226 missing whitespace around arithmetic operator
4     E226 missing whitespace around arithmetic operator
1     E265 block comment should start with '# '
5

* flake8 E2 cowrie/output/mysql.py

flake8 --count --select=E1,E2 --statistics cowrie/output/mysql.py
cowrie/output/mysql.py:37:72: E225 missing whitespace around operator
cowrie/output/mysql.py:74:21: E251 unexpected spaces around keyword / parameter equals
cowrie/output/mysql.py:74:23: E251 unexpected spaces around keyword / parameter equals
cowrie/output/mysql.py:75:19: E251 unexpected spaces around keyword / parameter equals
cowrie/output/mysql.py:75:21: E251 unexpected spaces around keyword / parameter equals
cowrie/output/mysql.py:76:21: E251 unexpected spaces around keyword / parameter equals
cowrie/output/mysql.py:76:23: E251 unexpected spaces around keyword / parameter equals
cowrie/output/mysql.py:77:23: E251 unexpected spaces around keyword / parameter equals
cowrie/output/mysql.py:77:25: E251 unexpected spaces around keyword / parameter equals
cowrie/output/mysql.py:78:21: E251 unexpected spaces around keyword / parameter equals
cowrie/output/mysql.py:78:23: E251 unexpected spaces around keyword / parameter equals
cowrie/output/mysql.py:79:23: E251 unexpected spaces around keyword / parameter equals
cowrie/output/mysql.py:79:25: E251 unexpected spaces around keyword / parameter equals
cowrie/output/mysql.py:80:23: E251 unexpected spaces around keyword / parameter equals
cowrie/output/mysql.py:80:25: E251 unexpected spaces around keyword / parameter equals
cowrie/output/mysql.py:128:18: E222 multiple spaces after operator
1     E222 multiple spaces after operator
1     E225 missing whitespace around operator
14    E251 unexpected spaces around keyword / parameter equals
16

* flake8 E2 cowrie/output/hpfeeds3.py

flake8 --count --select=E1,E2 --statistics cowrie/output/hpfeeds3.py
cowrie/output/hpfeeds3.py:68:26: E231 missing whitespace after ':'
cowrie/output/hpfeeds3.py:70:26: E231 missing whitespace after ':'
cowrie/output/hpfeeds3.py:76:30: E231 missing whitespace after ':'
cowrie/output/hpfeeds3.py:77:27: E231 missing whitespace after ':'
cowrie/output/hpfeeds3.py:78:34: E231 missing whitespace after ':'
cowrie/output/hpfeeds3.py:79:23: E231 missing whitespace after ':'
6     E231 missing whitespace after ':'
6

* flake8 E2 cowrie/output/textlog.py

flake8 --count --select=E1,E2 --statistics cowrie/output/textlog.py
cowrie/output/textlog.py:63:53: E226 missing whitespace around arithmetic operator
cowrie/output/textlog.py:64:67: E226 missing whitespace around arithmetic operator
cowrie/output/textlog.py:66:53: E226 missing whitespace around arithmetic operator
cowrie/output/textlog.py:67:51: E226 missing whitespace around arithmetic operator
4     E226 missing whitespace around arithmetic operator
4

* flake8 E2 cowrie/output/sqlite.py

flake8 --count --select=E1,E2 --statistics cowrie/output/sqlite.py
cowrie/output/sqlite.py:36:25: E251 unexpected spaces around keyword / parameter equals
cowrie/output/sqlite.py:36:27: E251 unexpected spaces around keyword / parameter equals
cowrie/output/sqlite.py:86:18: E222 multiple spaces after operator
1     E222 multiple spaces after operator
2     E251 unexpected spaces around keyword / parameter equals
3

* flake8 E2 cowrie/output/hpfeeds.py

flake8 --count --select=E1,E2 --statistics cowrie/output/hpfeeds.py
cowrie/output/hpfeeds.py:33:9: E221 multiple spaces before operator
cowrie/output/hpfeeds.py:34:8: E221 multiple spaces before operator
cowrie/output/hpfeeds.py:35:8: E221 multiple spaces before operator
cowrie/output/hpfeeds.py:36:11: E221 multiple spaces before operator
cowrie/output/hpfeeds.py:37:13: E221 multiple spaces before operator
cowrie/output/hpfeeds.py:41:16: E226 missing whitespace around arithmetic operator
cowrie/output/hpfeeds.py:42:15: E226 missing whitespace around arithmetic operator
cowrie/output/hpfeeds.py:42:19: E226 missing whitespace around arithmetic operator
cowrie/output/hpfeeds.py:43:15: E226 missing whitespace around arithmetic operator
cowrie/output/hpfeeds.py:43:19: E226 missing whitespace around arithmetic operator
cowrie/output/hpfeeds.py:44:18: E226 missing whitespace around arithmetic operator
cowrie/output/hpfeeds.py:45:20: E226 missing whitespace around arithmetic operator
cowrie/output/hpfeeds.py:45:24: E226 missing whitespace around arithmetic operator
cowrie/output/hpfeeds.py:73:17: E226 missing whitespace around arithmetic operator
cowrie/output/hpfeeds.py:73:25: E226 missing whitespace around arithmetic operator
cowrie/output/hpfeeds.py:78:32: E226 missing whitespace around arithmetic operator
cowrie/output/hpfeeds.py:94:36: E226 missing whitespace around arithmetic operator
cowrie/output/hpfeeds.py:127:48: E226 missing whitespace around arithmetic operator
cowrie/output/hpfeeds.py:248:37: E226 missing whitespace around arithmetic operator
cowrie/output/hpfeeds.py:248:48: E226 missing whitespace around arithmetic operator
cowrie/output/hpfeeds.py:300:26: E231 missing whitespace after ':'
cowrie/output/hpfeeds.py:302:26: E231 missing whitespace after ':'
cowrie/output/hpfeeds.py:308:30: E231 missing whitespace after ':'
cowrie/output/hpfeeds.py:309:27: E231 missing whitespace after ':'
cowrie/output/hpfeeds.py:310:34: E231 missing whitespace after ':'
cowrie/output/hpfeeds.py:311:23: E231 missing whitespace after ':'
5     E221 multiple spaces before operator
15    E226 missing whitespace around arithmetic operator
6     E231 missing whitespace after ':'
26

* flake8 E2 cowrie/output/influx.py

flake8 --count --select=E1,E2 --statistics cowrie/output/influx.py
cowrie/output/influx.py:109:47: E231 missing whitespace after ','
1     E231 missing whitespace after ','
1

* flake8 E2 cowrie/output/virustotal.py

flake8 --count --select=E1,E2 --statistics cowrie/output/virustotal.py
cowrie/output/virustotal.py:93:13: E265 block comment should start with '# '
cowrie/output/virustotal.py:94:13: E265 block comment should start with '# '
cowrie/output/virustotal.py:95:13: E265 block comment should start with '# '
cowrie/output/virustotal.py:104:13: E265 block comment should start with '# '
cowrie/output/virustotal.py:105:13: E265 block comment should start with '# '
cowrie/output/virustotal.py:113:26: E226 missing whitespace around arithmetic operator
cowrie/output/virustotal.py:126:17: E265 block comment should start with '# '
cowrie/output/virustotal.py:180:17: E265 block comment should start with '# '
cowrie/output/virustotal.py:193:26: E226 missing whitespace around arithmetic operator
cowrie/output/virustotal.py:197:41: E226 missing whitespace around arithmetic operator
cowrie/output/virustotal.py:261:26: E226 missing whitespace around arithmetic operator
cowrie/output/virustotal.py:274:17: E265 block comment should start with '# '
cowrie/output/virustotal.py:329:26: E226 missing whitespace around arithmetic operator
cowrie/output/virustotal.py:330:23: E201 whitespace after '{'
1     E201 whitespace after '{'
5     E226 missing whitespace around arithmetic operator
8     E265 block comment should start with '# '
14

* flake8 E2 cowrie/output/jsonlog.py

flake8 --count --select=E1,E2 --statistics cowrie/output/jsonlog.py
cowrie/output/jsonlog.py:73:59: E225 missing whitespace around operator
1     E225 missing whitespace around operator
1

* flake8 E2 cowrie/output/dshield.py

flake8 --count --select=E1,E2 --statistics cowrie/output/dshield.py
cowrie/output/dshield.py:39:24: E261 at least two spaces before inline comment
cowrie/output/dshield.py:50:23: E203 whitespace before ':'
cowrie/output/dshield.py:51:23: E203 whitespace before ':'
cowrie/output/dshield.py:52:27: E203 whitespace before ':'
cowrie/output/dshield.py:53:28: E203 whitespace before ':'
cowrie/output/dshield.py:54:23: E203 whitespace before ':'
cowrie/output/dshield.py:55:27: E203 whitespace before ':'
cowrie/output/dshield.py:102:27: E231 missing whitespace after ':'
cowrie/output/dshield.py:104:9: E265 block comment should start with '# '
cowrie/output/dshield.py:111:19: E251 unexpected spaces around keyword / parameter equals
cowrie/output/dshield.py:112:16: E251 unexpected spaces around keyword / parameter equals
cowrie/output/dshield.py:112:18: E251 unexpected spaces around keyword / parameter equals
cowrie/output/dshield.py:113:20: E251 unexpected spaces around keyword / parameter equals
cowrie/output/dshield.py:113:22: E251 unexpected spaces around keyword / parameter equals
cowrie/output/dshield.py:114:20: E251 unexpected spaces around keyword / parameter equals
cowrie/output/dshield.py:114:22: E251 unexpected spaces around keyword / parameter equals
cowrie/output/dshield.py:115:17: E251 unexpected spaces around keyword / parameter equals
cowrie/output/dshield.py:115:19: E251 unexpected spaces around keyword / parameter equals
cowrie/output/dshield.py:132:57: E226 missing whitespace around arithmetic operator
6     E203 whitespace before ':'
1     E226 missing whitespace around arithmetic operator
1     E231 missing whitespace after ':'
9     E251 unexpected spaces around keyword / parameter equals
1     E261 at least two spaces before inline comment
1     E265 block comment should start with '# '
19

* flake8 E2 cowrie/output/elasticsearch.py

flake8 --count --select=E1,E2 --statistics cowrie/output/elasticsearch.py
cowrie/output/elasticsearch.py:22:21: E225 missing whitespace around operator
1     E225 missing whitespace around operator
1flake8 E2 cowrie/output/elasticsearch.py

flake8 --count --select=E1,E2 --statistics
cowrie/output/elasticsearch.py
cowrie/output/elasticsearch.py:22:21: E225 missing whitespace around
operator
1     E225 missing whitespace around operator
1flake8 E2 cowrie/output/elasticsearch.py

flake8 --count --select=E1,E2 --statistics
cowrie/output/elasticsearch.py
cowrie/output/elasticsearch.py:22:21: E225 missing whitespace around
operator
1     E225 missing whitespace around operator
1flake8 E2 cowrie/output/elasticsearch.py

flake8 --count --select=E1,E2 --statistics
cowrie/output/elasticsearch.py
cowrie/output/elasticsearch.py:22:21: E225 missing whitespace around
operator
1     E225 missing whitespace around operator
1flake8 E2 cowrie/output/elasticsearch.py

flake8 --count --select=E1,E2 --statistics
cowrie/output/elasticsearch.py
cowrie/output/elasticsearch.py:22:21: E225 missing whitespace around
operator
1     E225 missing whitespace around operator
1flake8 E2 cowrie/output/elasticsearch.py

flake8 --count --select=E1,E2 --statistics
cowrie/output/elasticsearch.py
cowrie/output/elasticsearch.py:22:21: E225 missing whitespace around
operator
1     E225 missing whitespace around operator
1flake8 E2 cowrie/output/elasticsearch.py

flake8 --count --select=E1,E2 --statistics
cowrie/output/elasticsearch.py
cowrie/output/elasticsearch.py:22:21: E225 missing whitespace around
operator
1     E225 missing whitespace around operator
1flake8 E2 cowrie/output/elasticsearch.py

flake8 --count --select=E1,E2 --statistics
cowrie/output/elasticsearch.py
cowrie/output/elasticsearch.py:22:21: E225 missing whitespace around
operator
1     E225 missing whitespace around operator
1

* flake8 E2 cowrie/output/xmpp.py

flake8 --count --select=E1,E2 --statistics cowrie/output/xmpp.py
cowrie/output/xmpp.py:19:20: E221 multiple spaces before operator
cowrie/output/xmpp.py:24:18: E221 multiple spaces before operator
cowrie/output/xmpp.py:25:18: E221 multiple spaces before operator
cowrie/output/xmpp.py:71:15: E221 multiple spaces before operator
cowrie/output/xmpp.py:72:13: E221 multiple spaces before operator
cowrie/output/xmpp.py:72:21: E222 multiple spaces after operator
cowrie/output/xmpp.py:73:17: E221 multiple spaces before operator
cowrie/output/xmpp.py:74:12: E221 multiple spaces before operator
cowrie/output/xmpp.py:79:44: E231 missing whitespace after ','
cowrie/output/xmpp.py:79:53: E231 missing whitespace after ','
cowrie/output/xmpp.py:79:58: E231 missing whitespace after ','
cowrie/output/xmpp.py:79:65: E231 missing whitespace after ','
cowrie/output/xmpp.py:86:46: E261 at least two spaces before inline comment
cowrie/output/xmpp.py:102:38: E231 missing whitespace after ','
7     E221 multiple spaces before operator
1     E222 multiple spaces after operator
5     E231 missing whitespace after ','
1     E261 at least two spaces before inline comment
14

* flake8 E2 cowrie/shell/honeypot.py

flake8 --count --select=E1,E2 --statistics cowrie/shell/honeypot.py
cowrie/shell/honeypot.py:210:9: E265 block comment should start with '# '
cowrie/shell/honeypot.py:347:32: E226 missing whitespace around arithmetic operator
cowrie/shell/honeypot.py:365:43: E226 missing whitespace around arithmetic operator
cowrie/shell/honeypot.py:366:29: E222 multiple spaces after operator
cowrie/shell/honeypot.py:397:33: E226 missing whitespace around arithmetic operator
cowrie/shell/honeypot.py:398:30: E226 missing whitespace around arithmetic operator
cowrie/shell/honeypot.py:402:9: E265 block comment should start with '# '
cowrie/shell/honeypot.py:403:9: E265 block comment should start with '# '
cowrie/shell/honeypot.py:408:45: E226 missing whitespace around arithmetic operator
cowrie/shell/honeypot.py:408:49: E226 missing whitespace around arithmetic operator
cowrie/shell/honeypot.py:408:72: E226 missing whitespace around arithmetic operator
cowrie/shell/honeypot.py:408:76: E226 missing whitespace around arithmetic operator
cowrie/shell/honeypot.py:414:35: E203 whitespace before ','
cowrie/shell/honeypot.py:440:19: E222 multiple spaces after operator
1     E203 whitespace before ','
2     E222 multiple spaces after operator
8     E226 missing whitespace around arithmetic operator
3     E265 block comment should start with '# '
14

* flake8 E2 cowrie/shell/fs.py

flake8 --count --select=E1,E2 --statistics cowrie/shell/fs.py
cowrie/shell/fs.py:229:63: E225 missing whitespace around operator
cowrie/shell/fs.py:377:13: E265 block comment should start with '# '
cowrie/shell/fs.py:416:13: E265 block comment should start with '# '
cowrie/shell/fs.py:457:36: E225 missing whitespace around operator
cowrie/shell/fs.py:558:23: E231 missing whitespace after ':'
cowrie/shell/fs.py:559:22: E231 missing whitespace after ':'
cowrie/shell/fs.py:560:22: E231 missing whitespace after ':'
cowrie/shell/fs.py:561:23: E231 missing whitespace after ':'
cowrie/shell/fs.py:562:23: E231 missing whitespace after ':'
cowrie/shell/fs.py:563:24: E231 missing whitespace after ':'
2     E225 missing whitespace around operator
6     E231 missing whitespace after ':'
2     E265 block comment should start with '# '
10

* flake8 E2 cowrie/shell/shlex.py

flake8 --count --select=E1,E2 --statistics cowrie/shell/shlex.py
cowrie/shell/shlex.py:70:13: E265 block comment should start with '# '
cowrie/shell/shlex.py:321:1: E265 block comment should start with '# '
2     E265 block comment should start with '# '
2

* flake8 E2 cowrie/shell/filetransfer.py

flake8 --count --select=E1,E2 --statistics cowrie/shell/filetransfer.py
cowrie/shell/filetransfer.py:83:43: E226 missing whitespace around arithmetic operator
cowrie/shell/filetransfer.py:116:33: E226 missing whitespace around arithmetic operator
cowrie/shell/filetransfer.py:309:9: E265 block comment should start with '# '
2     E226 missing whitespace around arithmetic operator
1     E265 block comment should start with '# '
3

* flake8 E2 cowrie/shell/session.py

flake8 --count --select=E1,E2 --statistics cowrie/shell/session.py
cowrie/shell/session.py:47:20: E225 missing whitespace around operator
cowrie/shell/session.py:48:33: E225 missing whitespace around operator
cowrie/shell/session.py:50:33: E225 missing whitespace around operator
3     E225 missing whitespace around operator
3

* flake8 E2 cowrie/shell/customparser.py

flake8 --count --select=E1,E2 --statistics cowrie/shell/customparser.py
cowrie/shell/customparser.py:56:27: E231 missing whitespace after ','
1     E231 missing whitespace after ','
1

* flake8 E2 cowrie/test/test_base_commands.py

flake8 --count --select=E1,E2 --statistics cowrie/test/test_base_commands.py
cowrie/test/test_base_commands.py:24:58: E211 whitespace before '('
cowrie/test/test_base_commands.py:33:41: E231 missing whitespace after ','
cowrie/test/test_base_commands.py:38:41: E231 missing whitespace after ','
cowrie/test/test_base_commands.py:43:42: E231 missing whitespace after ','
cowrie/test/test_base_commands.py:47:49: E231 missing whitespace after ','
cowrie/test/test_base_commands.py:52:49: E231 missing whitespace after ','
cowrie/test/test_base_commands.py:57:42: E231 missing whitespace after ','
cowrie/test/test_base_commands.py:74:42: E231 missing whitespace after ','
cowrie/test/test_base_commands.py:83:42: E231 missing whitespace after ','
cowrie/test/test_base_commands.py:87:42: E231 missing whitespace after ','
cowrie/test/test_base_commands.py:94:42: E231 missing whitespace after ','
cowrie/test/test_base_commands.py:114:49: E231 missing whitespace after ','
cowrie/test/test_base_commands.py:123:49: E231 missing whitespace after ','
cowrie/test/test_base_commands.py:134:42: E231 missing whitespace after ','
cowrie/test/test_base_commands.py:139:42: E231 missing whitespace after ','
cowrie/test/test_base_commands.py:144:42: E231 missing whitespace after ','
cowrie/test/test_base_commands.py:149:42: E231 missing whitespace after ','
cowrie/test/test_base_commands.py:154:42: E231 missing whitespace after ','
cowrie/test/test_base_commands.py:159:42: E231 missing whitespace after ','
cowrie/test/test_base_commands.py:164:42: E231 missing whitespace after ','
cowrie/test/test_base_commands.py:169:42: E231 missing whitespace after ','
cowrie/test/test_base_commands.py:174:42: E231 missing whitespace after ','
cowrie/test/test_base_commands.py:179:42: E231 missing whitespace after ','
cowrie/test/test_base_commands.py:184:42: E231 missing whitespace after ','
cowrie/test/test_base_commands.py:189:42: E231 missing whitespace after ','
cowrie/test/test_base_commands.py:193:42: E231 missing whitespace after ','
cowrie/test/test_base_commands.py:198:42: E231 missing whitespace after ','
1     E211 whitespace before '('
26    E231 missing whitespace after ','
27

* flake8 E2 cowrie/test/fake_transport.py

flake8 --count --select=E1,E2 --statistics cowrie/test/fake_transport.py
cowrie/test/fake_transport.py:8:42: E231 missing whitespace after ','
1     E231 missing whitespace after ','
1

* flake8 E2 cowrie/proxy/endpoints.py

flake8 --count --select=E1,E2 --statistics cowrie/proxy/endpoints.py
cowrie/proxy/endpoints.py:214:29: E226 missing whitespace around arithmetic operator
cowrie/proxy/endpoints.py:233:42: E226 missing whitespace around arithmetic operator
cowrie/proxy/endpoints.py:323:22: E231 missing whitespace after ','
cowrie/proxy/endpoints.py:323:25: E231 missing whitespace after ','
cowrie/proxy/endpoints.py:323:27: E231 missing whitespace after ','
cowrie/proxy/endpoints.py:323:30: E261 at least two spaces before inline comment
cowrie/proxy/endpoints.py:346:55: E226 missing whitespace around arithmetic operator
cowrie/proxy/endpoints.py:380:48: E226 missing whitespace around arithmetic operator
cowrie/proxy/endpoints.py:824:24: E222 multiple spaces after operator
cowrie/proxy/endpoints.py:992:24: E222 multiple spaces after operator
2     E222 multiple spaces after operator
4     E226 missing whitespace around arithmetic operator
3     E231 missing whitespace after ','
1     E261 at least two spaces before inline comment
10

* flake8 E2 cowrie/proxy/avatar.py

flake8 --count --select=E1,E2 --statistics cowrie/proxy/avatar.py
cowrie/proxy/avatar.py:14:1: E265 block comment should start with '# '
cowrie/proxy/avatar.py:38:9: E265 block comment should start with '# '
cowrie/proxy/avatar.py:41:9: E265 block comment should start with '# '
cowrie/proxy/avatar.py:59:1: E265 block comment should start with '# '
4     E265 block comment should start with '# '
4

* Add TODO for checking SFTP support

I removed code which was never used in this version of cowrie. But for
me it looks like there is no SFTP support anymore? Look the previous
commit message for more details.

* flake8 E2 cowrie/proxy/session.py

flake8 --count --select=E1,E2 --statistics cowrie/proxy/session.py
cowrie/proxy/session.py:15:1: E265 block comment should start with '# '
cowrie/proxy/session.py:60:21: E261 at least two spaces before inline comment
cowrie/proxy/session.py:61:18: E261 at least two spaces before inline comment
cowrie/proxy/session.py:62:14: E261 at least two spaces before inline comment
cowrie/proxy/session.py:71:13: E265 block comment should start with '# '
cowrie/proxy/session.py:83:30: E226 missing whitespace around arithmetic operator
cowrie/proxy/session.py:83:42: E226 missing whitespace around arithmetic operator
cowrie/proxy/session.py:83:59: E226 missing whitespace around arithmetic operator
cowrie/proxy/session.py:91:37: E226 missing whitespace around arithmetic operator
cowrie/proxy/session.py:146:9: E265 block comment should start with '# '
cowrie/proxy/session.py:168:32: E226 missing whitespace around arithmetic operator
cowrie/proxy/session.py:169:26: E226 missing whitespace around arithmetic operator
cowrie/proxy/session.py:170:26: E226 missing whitespace around arithmetic operator
cowrie/proxy/session.py:171:26: E226 missing whitespace around arithmetic operator
cowrie/proxy/session.py:185:28: E226 missing whitespace around arithmetic operator
cowrie/proxy/session.py:189:23: E226 missing whitespace around arithmetic operator
cowrie/proxy/session.py:250:9: E265 block comment should start with '# '
cowrie/proxy/session.py:322:13: E265 block comment should start with '# '
10    E226 missing whitespace around arithmetic operator
3     E261 at least two spaces before inline comment
5     E265 block comment should start with '# '
18

* flake8 E2 cowire/core/dblog.py

flake8 --count --select=E1,E2 --statistics cowrie/core/dblog.py
cowrie/core/dblog.py:27:9: E265 block comment should start with '# '
1     E265 block comment should start with '# '
1

* flake8 E2 cowrie/core/output.py

flake8 --count --select=E1,E2 --statistics cowrie/core/output.py
cowrie/core/output.py:172:9: E265 block comment should start with '# '
cowrie/core/output.py:174:13: E265 block comment should start with '# '
cowrie/core/output.py:175:13: E265 block comment should start with '# '
cowrie/core/output.py:176:13: E265 block comment should start with '# '
cowrie/core/output.py:177:13: E265 block comment should start with '# '
cowrie/core/output.py:188:32: E226 missing whitespace around arithmetic operator
cowrie/core/output.py:192:36: E226 missing whitespace around arithmetic operator
2     E226 missing whitespace around arithmetic operator
5     E265 block comment should start with '# '
7

* flake8 E2 cowrie/core/realm.py

flake8 --count --select=E1,E2 --statistics cowrie/core/realm.py
cowrie/core/realm.py:72:9: E265 block comment should start with '# '
1     E265 block comment should start with '# '
1

* flake8 E2 cowrie/core/utils.py

flake8 --count --select=E1,E2 --statistics cowrie/core/utils.py
cowrie/core/utils.py:35:55: E226 missing whitespace around arithmetic operator
cowrie/core/utils.py:38:56: E226 missing whitespace around arithmetic operator
cowrie/core/utils.py:57:22: E226 missing whitespace around arithmetic operator
cowrie/core/utils.py:58:45: E226 missing whitespace around arithmetic operator
cowrie/core/utils.py:59:35: E226 missing whitespace around arithmetic operator
5     E226 missing whitespace around arithmetic operator
5

* Enable flake8 E1 and E2 checks in travis

Prevent bad code style of fixed flake8 errors again in the code.

* Fixing missspelled variable
This commit is contained in:
Florian Pelgrim 2018-07-05 20:46:00 +02:00 committed by Michel Oosterhof
parent a0ed8135ea
commit 170ce3d5e3
58 changed files with 350 additions and 420 deletions

View File

@ -11,7 +11,7 @@ install: pip install -r requirements.txt
before_script:
- pip install flake8 twistedchecker # pytest # add another testing frameworks later
# stop the build if there are Python syntax errors or undefined names
- flake8 . --count --select=E901,E999,F821,F822,F823 --show-source --statistics
- flake8 . --count --select=E1,E2,E901,E999,F821,F822,F823 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
# ignore E3xx errors, Twisted has different empty line convention
- flake8 . --count --ignore=E3 --exit-zero --max-complexity=10 --max-line-length=127 --statistics

View File

@ -39,7 +39,7 @@ class command_aptget(HoneyPotCommand):
else:
self.do_locked()
def sleep(self, time, time2 = None):
def sleep(self, time, time2=None):
d = defer.Deferred()
if time2:
time = random.randint(time * 100, time2 * 100) / 100.0
@ -110,20 +110,18 @@ pages for more information and options.
return
@inlineCallbacks
def do_install(self,*args):
def do_install(self, *args):
if len(self.args) <= 1:
self.write('0 upgraded, 0 newly installed, 0 to remove and %s not upgraded.\n' % random.randint(200,300))
msg = '0 upgraded, 0 newly installed, 0 to remove and {0} not upgraded.\n'
self.write(msg.format(random.randint(200, 300)))
self.exit()
return
packages = {}
for y in [re.sub('[^A-Za-z0-9]', '', x) for x in self.args[1:]]:
packages[y] = {
'version': '%d.%d-%d' %
(random.choice((0, 1)),
random.randint(1, 40),
random.randint(1, 10)),
'size': random.randint(100, 900)
'version': '{0}.{1}-{2}'.format(random.choice(0, 1), random.randint(1, 40), random.randint(1, 10)),
'size': random.randint(100, 900)
}
totalsize = sum([packages[x]['size'] for x in packages])

View File

@ -26,7 +26,7 @@ class command_whoami(HoneyPotCommand):
def call(self):
"""
"""
self.write(self.protocol.user.username+'\n')
self.write('{0}\n'.format(self.protocol.user.username))
commands['/usr/bin/whoami'] = command_whoami
commands['/usr/bin/users'] = command_whoami
@ -112,7 +112,7 @@ class command_who(HoneyPotCommand):
"""
self.write('%-8s pts/0 %s %s (%s)\n' %
(self.protocol.user.username,
time.strftime('%Y-%m-%d',time.localtime(self.protocol.logintime)),
time.strftime('%Y-%m-%d', time.localtime(self.protocol.logintime)),
time.strftime('%H:%M', time.localtime(self.protocol.logintime)),
self.protocol.clientIP))
commands['/usr/bin/who'] = command_who
@ -243,7 +243,7 @@ class command_hostname(HoneyPotCommand):
else:
self.write("hostname: you must be root to change the host name\n")
else:
self.write(self.protocol.hostname+'\n')
self.write('{0}\n'.format(self.protocol.hostname))
commands['/bin/hostname'] = command_hostname
@ -310,7 +310,7 @@ class command_ps(HoneyPotCommand):
s = ''.join([output[i][x] for x in l])
if 'w' not in args:
s = s[:80]
self.write(s+'\n')
self.write('{0}\n'.format(s))
commands['/bin/ps'] = command_ps
@ -399,7 +399,7 @@ class command_shutdown(HoneyPotCommand):
"** the \"time\" argument is mandatory! (try \"now\") **",
)
for l in output:
self.write(l+'\n')
self.write('{0}\n'.format(l))
self.exit()
elif len(self.args) > 1 and self.args[0].strip().count('-h') \
and self.args[1].strip().count('now'):
@ -492,7 +492,7 @@ class command_date(HoneyPotCommand):
"""
"""
time = datetime.datetime.utcnow()
self.write(time.strftime("%a %b %d %H:%M:%S UTC %Y")+'\n')
self.write('{0}\n'.format(time.strftime("%a %b %d %H:%M:%S UTC %Y")))
commands['/bin/date'] = command_date
class command_yes(HoneyPotCommand):
@ -508,7 +508,7 @@ class command_yes(HoneyPotCommand):
"""
"""
if len(self.args):
self.write(' '.join(self.args)+'\n')
self.write("{0}{1}".format(' '.join(self.args, '\n')))
else:
self.write('y\n')
self.scheduled = reactor.callLater(0.01, self.y)
@ -593,7 +593,7 @@ class command_php(HoneyPotCommand):
'Copyright (c) 1997-2010 The PHP Group'
)
for l in output:
self.write(l+'\n')
self.write('{0}\n'.format(l))
self.exit()
elif self.args[0] == '-h':
output = (
@ -637,7 +637,7 @@ class command_php(HoneyPotCommand):
''
)
for l in output:
self.write(l+'\n')
self.write('{0}\n'.format(l))
self.exit()
else:
self.exit()

View File

@ -3,12 +3,12 @@
from __future__ import division, absolute_import
from cowrie.shell.honeypot import HoneyPotCommand,StdOutStdErrEmulationProtocol
from cowrie.shell.honeypot import HoneyPotCommand, StdOutStdErrEmulationProtocol
from twisted.python import log
commands = {}
busybox_help=('''
busybox_help = ('''
BusyBox v1.20.2 (Debian 1:1.20.0-7) multi-call binary.
Copyright (C) 1998-2011 Erik Andersen, Rob Landley, Denys Vlasenko
and others. Licensed under GPLv2.
@ -59,7 +59,7 @@ class command_busybox(HoneyPotCommand):
"""
"""
for ln in busybox_help:
self.errorWrite(ln+'\n')
self.errorWrite('{0}\n'.format(ln))
def call(self):

View File

@ -76,7 +76,7 @@ class command_cat(HoneyPotCommand):
if self.number:
self.write("{:>6} ".format(self.linenumber))
self.linenumber = self.linenumber + 1
self.write(line+"\n")
self.write("{0}\n".format(line))
def lineReceived(self, line):

View File

@ -82,7 +82,7 @@ class command_curl(HoneyPotCommand):
self.exit()
return
url=url.encode('ascii')
url = url.encode('ascii')
self.url = url
self.limit_size = 0
if CONFIG.has_option('honeypot', 'download_limit_size'):
@ -291,7 +291,7 @@ Options: (H) means HTTP/HTTPS only, (F) means FTP only
contextFactory = ssl.ClientContextFactory()
contextFactory.method = SSL.SSLv23_METHOD
reactor.connectSSL(host, port, factory, contextFactory, bindAddress=out_addr)
else: # Can only be http
else: # Can only be http
self.connection = reactor.connectTCP(
host, port, factory, bindAddress=out_addr)
@ -346,12 +346,9 @@ Options: (H) means HTTP/HTTPS only, (F) means FTP only
def error(self, error, url):
"""
"""
if hasattr(error, 'getErrorMessage'): # Exceptions
if hasattr(error, 'getErrorMessage'): # Exceptions
error = error.getErrorMessage()
self.write(error+'\n')
# Real curl also adds this:
# self.write('%s ERROR 404: Not Found.\n' % \
# time.strftime('%Y-%m-%d %T'))
self.write('{0}\n'.format(error))
self.protocol.logDispatch(eventid='cowrie.session.file_download.failed',
format='Attempt to download file(s) from URL (%(url)s) failed',
url=self.url)
@ -380,8 +377,9 @@ class HTTPProgressDownloader(client.HTTPDownloader):
self.nomore = False
def noPage(self, reason): # Called for non-200 responses
def noPage(self, reason):
"""
Called for non-200 responses
"""
if self.status == '304':
client.HTTPDownloader.page(self, '')
@ -434,10 +432,10 @@ class HTTPProgressDownloader(client.HTTPDownloader):
if (time.time() - self.lastupdate) < 0.5:
return client.HTTPDownloader.pagePart(self, data)
if self.totallength:
percent = (self.currentlength/self.totallength)*100
spercent = "%i%%" % (percent,)
percent = (self.currentlength / self.totallength) * 100
spercent = "{0}%%".format(percent)
else:
spercent = '%dK' % (self.currentlength/1000)
spercent = '{0}K'.format(self.currentlength / 1000)
percent = 0
self.speed = self.currentlength / (time.time() - self.started)
self.lastupdate = time.time()
@ -461,7 +459,7 @@ class HTTPProgressDownloader(client.HTTPDownloader):
self.curl.safeoutfile)
else:
with open(self.curl.safeoutfile, 'r') as f:
self.curl.write(f.read()+'\n')
self.curl.write('{0}\n'.format(f.read()))
self.curl.fileName = self.fileName
return client.HTTPDownloader.pageEnd(self)

View File

@ -38,7 +38,7 @@ class command_env(HoneyPotCommand):
"""
"""
for i in list(self.environ.keys()):
self.write(b"%s=%s\n" % (i,self.environ[i]))
self.write(b'{0}={1}\n'.format(i, self.environ[i]))
commands['/usr/bin/env'] = command_env

View File

@ -13,17 +13,17 @@ from cowrie.shell.honeypot import HoneyPotCommand
commands = {}
FREE_BYTES=""" total used free shared buffers cached
FREE_BYTES = """ total used free shared buffers cached
Mem: 8069256 7872920 196336 0 410340 5295748
-/+ buffers/cache: 2166832 5902424
Swap: 3764220 133080 3631140"""
FREE_MEGA=""" total used free shared buffers cached
FREE_MEGA = """ total used free shared buffers cached
Mem: 7880 7690 189 0 400 5171
-/+ buffers/cache: 2118 5761
Swap: 3675 129 3546"""
FREE_HUMAN=""" total used free shared buffers cached
FREE_HUMAN = """ total used free shared buffers cached
Mem: 7.7G 7.5G 189M 0B 400M 5.1G
-/+ buffers/cache: 2.1G 5.6G
Swap: 3.6G 129M 3.5G"""
@ -57,12 +57,12 @@ class command_free(HoneyPotCommand):
"""
print free statistics
"""
if fmt=='bytes':
self.write(FREE_BYTES+'\n')
elif fmt=='megabytes':
self.write(FREE_MEGA+'\n')
elif fmt=='human':
self.write(FREE_HUMAN+'\n')
if fmt == 'bytes':
self.write('{0}\n'.format(FREE_BYTES))
elif fmt == 'megabytes':
self.write('{0}\n'.format(FREE_MEGA))
elif fmt == 'human':
self.write('{0}\n'.format(FREE_HUMAN))
commands['/usr/bin/free'] = command_free

View File

@ -33,7 +33,7 @@ class command_grep(HoneyPotCommand):
def grep_application(self, contents, match):
match = path.basename(match)
match = match.replace("\"","")
match = match.replace("\"", "")
contentsplit = contents.split('\n')
matches = re.compile(".*" + match + ".*")
for line in contentsplit:
@ -42,10 +42,10 @@ class command_grep(HoneyPotCommand):
def help(self):
self.write( 'usage: grep [-abcDEFGHhIiJLlmnOoPqRSsUVvwxZ] [-A num] [-B num] [-C[num]]\n')
self.write( '\t[-e pattern] [-f file] [--binary-files=value] [--color=when]\n')
self.write( '\t[--context[=num]] [--directories=action] [--label] [--line-buffered]\n')
self.write( '\t[--null] [pattern] [file ...]\n')
self.write('usage: grep [-abcDEFGHhIiJLlmnOoPqRSsUVvwxZ] [-A num] [-B num] [-C[num]]\n')
self.write('\t[-e pattern] [-f file] [--binary-files=value] [--color=when]\n')
self.write('\t[--context[=num]] [--directories=action] [--label] [--line-buffered]\n')
self.write('\t[--null] [pattern] [file ...]\n')
def start(self):

View File

@ -18,7 +18,7 @@ commands = {}
class command_gcc(HoneyPotCommand):
# Name of program. Under OSX, you might consider i686-apple-darwin11-llvm-gcc-X.X
APP_NAME = "gcc"
APP_NAME = "gcc"
# GCC verson, used in help, version and the commandline name gcc-X.X
APP_VERSION = (4, 7, 2)
@ -163,7 +163,7 @@ Thread model: posix
gcc version %s (Debian %s-5)""" % (version, version_short, version_short, version_short, version, version))
# Write
self.write(data+'\n')
self.write('{0}\n'.format(data))
self.exit()
def generate_file(self, outfile):

View File

@ -31,7 +31,7 @@ lo Link encap:Local Loopback
RX bytes:19932 (19.9 KB) TX bytes:19932 (19.9 KB)""" % \
(self.protocol.kippoIP,
self.protocol.kippoIP.rsplit('.', 1)[0])
self.write(l+'\n')
self.write('{0}\n'.format(l))
commands['/sbin/ifconfig'] = command_ifconfig

View File

@ -66,13 +66,13 @@ class command_iptables(HoneyPotCommand):
# Utils
def optional_arg(arg_default):
def func(option,opt_str,value,parser):
def func(option, opt_str, value, parser):
if parser.rargs and not parser.rargs[0].startswith('-'):
val=parser.rargs[0]
val = parser.rargs[0]
parser.rargs.pop(0)
else:
val=arg_default
setattr(parser.values,option.dest,val)
val = arg_default
setattr(parser.values, option.dest, val)
return func
# Initialize options
@ -317,7 +317,7 @@ Options:
output.append("-P %s ACCEPT" % chain)
# Done
self.write("\n".join(output)+'\n')
self.write('{0}\n'.format('\n'.join(output)))
self.exit()
else:
self.no_permission()
@ -356,7 +356,7 @@ Options:
output.append("\n".join(chain_output))
# Done
self.write("\n\n".join(output)+'\n')
self.write("{0}\n".format('\n\n'.join(output)))
self.exit()
else:
self.no_permission()

View File

@ -27,13 +27,13 @@ class command_last(HoneyPotCommand):
numlines = int(l.pop(0))
self.write('%-8s %-12s %-16s %s still logged in\n' %
(self.protocol.user.username,"pts/0", self.protocol.clientIP,
(self.protocol.user.username, "pts/0", self.protocol.clientIP,
time.strftime('%a %b %d %H:%M', time.localtime(self.protocol.logintime))))
self.write("\n")
self.write("wtmp begins %s\n" %
time.strftime('%a %b %d %H:%M:%S %Y',
time.localtime(self.protocol.logintime // (3600*24) * (3600*24) + 63 )) )
time.localtime(self.protocol.logintime // (3600 * 24) * (3600 * 24) + 63)))
commands['/usr/bin/last'] = command_last

View File

@ -186,7 +186,7 @@ class command_ls(HoneyPotCommand):
file[A_NAME],
linktarget)
self.write(l+'\n')
self.write('{0}\n'.format(l))
commands['/bin/ls'] = command_ls
commands['/bin/dir'] = command_ls

View File

@ -72,8 +72,8 @@ Destination Gateway Genmask Flags MSS Window irtt Iface\n
l2 = "%s%s255.255.255.0 U 0 0 0 eth0" % \
('{:<16}'.format(destination),
'{:<16}'.format(lgateway))
self.write(l1+'\n')
self.write(l2+'\n')
self.write('{0}\n'.format(l1))
self.write('{0}\n'.format(l2))
def do_netstat_normal(self):
self.write("""Active Internet connections (w/o servers)
@ -94,10 +94,10 @@ Proto Recv-Q Send-Q Local Address Foreign Address State\n""")
self.write("tcp 0 0 *:ssh *:* LISTEN\n")
if not self.show_listen or self.show_all:
l = 'tcp 0 308 %s:%s%s%s:%s%s%s' % \
(s_name, s_port, " "*(24-len(s_name+s_port)-1),
c_name, c_port, " "*(24-len(c_name+c_port)-1),
(s_name, s_port, " " * (24 - len(s_name + s_port) - 1),
c_name, c_port, " " * (24 - len(c_name + c_port) - 1),
"ESTABLISHED")
self.write(l+'\n')
self.write('{0}\n'.format(l))
if self.show_listen or self.show_all:
self.write("tcp6 0 0 [::]:ssh [::]:* LISTEN\n")
self.write("""Active UNIX domain sockets (only servers)

View File

@ -54,14 +54,14 @@ class command_ping(HoneyPotCommand):
self.exit()
return
if len(args)==0:
if len(args) == 0:
for l in (
'Usage: ping [-LRUbdfnqrvVaA] [-c count] [-i interval] [-w deadline]',
' [-p pattern] [-s packetsize] [-t ttl] [-I interface or address]',
' [-M mtu discovery hint] [-S sndbuf]',
' [ -T timestamp option ] [ -Q tos ] [hop1 ...] destination',
):
self.write(l+'\n')
self.write('{0}\n'.format(l))
self.exit()
return
self.host = args[0].strip()

View File

@ -80,7 +80,7 @@ class command_python(HoneyPotCommand):
try:
opts, args = getopt.gnu_getopt(self.args, 'BdEhiORsStuvVx3c:m:Q:W:', ['help', 'version'])
except getopt.GetoptError as err:
self.write("Unknown option: -" + err.opt + "\n")
self.write("Unknown option: -{0}\n".format(err.opt))
self.write("usage: python [option] ... [-c cmd | -m mod | file | -] [arg] ... \n")
self.write("Try `python -h' for more information.\n")
self.exit()

View File

@ -232,7 +232,7 @@ class command_scp(HoneyPotCommand):
data = f.read()
header = data[:data.find('\n')]
if re.match('C0[\d]{3} [\d]+ [^\s]+', header):
data = data[data.find('\n')+1:]
data = data[data.find('\n') + 1:]
else:
data = ''

View File

@ -55,7 +55,7 @@ class command_ssh(HoneyPotCommand):
' [-R [bind_address:]port:host:hostport] [-S ctl_path]',
' [-w local_tun[:remote_tun]] [user@]hostname [command]',
):
self.write(l+'\n')
self.write('{0}\n'.format(l))
self.exit()
return
user, host = 'root', args[0]

View File

@ -6,11 +6,11 @@ import getopt
from twisted.python import log
from cowrie.shell.honeypot import HoneyPotCommand,StdOutStdErrEmulationProtocol
from cowrie.shell.honeypot import HoneyPotCommand, StdOutStdErrEmulationProtocol
commands = {}
sudo_shorthelp=('''
sudo_shorthelp = ('''
sudo: Only one of the -e, -h, -i, -K, -l, -s, -v or -V options may be specified
usage: sudo [-D level] -h | -K | -k | -V
usage: sudo -v [-AknS] [-D level] [-g groupname|#gid] [-p prompt] [-u user name|#uid]
@ -19,7 +19,7 @@ usage: sudo [-AbEHknPS] [-r role] [-t type] [-C fd] [-D level] [-g groupname|#gi
usage: sudo -e [-AknS] [-r role] [-t type] [-C fd] [-D level] [-g groupname|#gid] [-p prompt] [-u user name|#uid] file ...
''').strip().split('\n')
sudo_longhelp=('''
sudo_longhelp = ('''
sudo - execute a command as another user
usage: sudo [-D level] -h | -K | -k | -V
@ -63,7 +63,7 @@ class command_sudo(HoneyPotCommand):
"""
"""
for ln in sudo_shorthelp:
self.errorWrite(ln+'\n')
self.errorWrite('{0}\n'.format(ln))
self.exit()
@ -71,7 +71,7 @@ class command_sudo(HoneyPotCommand):
"""
"""
for ln in sudo_longhelp:
self.errorWrite(ln+'\n')
self.errorWrite('{0}\n'.format(ln))
self.exit()
@ -92,13 +92,13 @@ class command_sudo(HoneyPotCommand):
"""
start_value = None
parsed_arguments = []
for count in range(0,len(self.args)):
class_found = self.protocol.getCommand(self.args[count], self.environ['PATH'].split(':'))
for count in range(0, len(self.args)):
class_found = self.protocol.getCommand(self.args[count], self.environ['PATH'].split(':'))
if class_found:
start_value = count
break
if start_value is not None:
for index_2 in range(start_value,len(self.args)):
for index_2 in range(start_value, len(self.args)):
parsed_arguments.append(self.args[index_2])
try:
@ -122,10 +122,7 @@ class command_sudo(HoneyPotCommand):
cmdclass = self.protocol.getCommand(cmd, self.environ['PATH'].split(':'))
if cmdclass:
#log.msg(eventid='cowrie.command.success',
# input=line,
# format='Command found: %(input)s')
command = StdOutStdErrEmulationProtocol(self.protocol,cmdclass,parsed_arguments[1:], None ,None)
command = StdOutStdErrEmulationProtocol(self.protocol, cmdclass, parsed_arguments[1:], None, None)
self.protocol.pp.insert_command(command)
# this needs to go here so it doesn't write it out....
if self.input_data:

View File

@ -72,7 +72,7 @@ class command_tar(HoneyPotCommand):
for f in t:
dest = self.fs.resolve_path(f.name.strip('/'), self.protocol.cwd)
if verbose:
self.write(f.name+'\n')
self.write('{0}\n'.format(f.name))
if not extract or not len(dest):
continue
if f.isdir():

View File

@ -23,8 +23,6 @@ class DBLogger(object):
self.sessions = {}
self.ttylogs = {}
# FIXME figure out what needs to be done here regarding
# HoneyPotTransport renamed to HoneyPotSSHTransport
#:* Handles ipv6
self.re_sessionlog = re.compile(
r'.*HoneyPotSSHTransport,([0-9]+),[:a-f0-9.]+$')

View File

@ -168,14 +168,6 @@ class Output(object):
except:
pass
# On disconnect add the tty log
#if ev['eventid'] == 'cowrie.log.closed':
# FIXME: file is read for each output plugin
#f = file(ev['ttylog'])
#ev['ttylog'] = f.read(10485760)
#f.close()
#pass
# Explicit sessionno (from logDispatch) overrides from 'system'
if 'sessionno' in ev:
sessionno = ev['sessionno']
@ -185,11 +177,11 @@ class Output(object):
sessionno = 0
telnetmatch = self.telnetRegex.match(ev['system'])
if telnetmatch:
sessionno = 'T'+str(telnetmatch.groups()[0])
sessionno = 'T'.format(telnetmatch.groups()[0])
else:
sshmatch = self.sshRegex.match(ev['system'])
if sshmatch:
sessionno = 'S'+str(sshmatch.groups()[0])
sessionno = 'S'.format(sshmatch.groups()[0])
if sessionno == 0:
return

View File

@ -58,25 +58,10 @@ class HoneyPotRealm(object):
def __init__(self):
pass
# self.servers = {}
def requestAvatar(self, avatarId, mind, *interfaces):
"""
"""
# if mind in self.servers:
# log.msg( "Using existing server for mind %s" % mind)
# for i in self.servers[mind].avatars:
# log.msg( "attached avatar: %s" % repr(i))
#else:
# log.msg( "Starting new server for mind %s" % mind)
# self.servers[mind] = server.CowrieServer(self.cfg)
# for i in list(self.servers.keys()):
# log.msg( "REFCOUNT: key: %s, refcount %d" % ( i, sys.getrefcount(self.servers[i])))
# log.msg( "Refer: %s" % repr( gc.get_referrers(self.servers[i])))
try:
backend = CONFIG.get('honeypot', 'backend')
except:

View File

@ -32,16 +32,16 @@ def durationHuman(seconds):
duration = []
if years > 0:
duration.append('{} year'.format(syears) + 's'*(years != 1) + ' ')
duration.append('{0} year{1} '.format(syears, 's' * (years != 1)))
else:
if days > 0:
duration.append('{} day'.format(days) + 's'*(days != 1) + ' ')
duration.append('{0} day{1} '.format(days, 's' * (days != 1)))
if hours > 0:
duration.append('{}:'.format(shours))
duration.append('{0}:'.format(shours))
if minutes >= 0:
duration.append('{}:'.format(sminutes))
duration.append('{0}:'.format(sminutes))
if seconds >= 0:
duration.append('{}'.format(sseconds))
duration.append('{0}'.format(sseconds))
return ''.join(duration)
@ -54,9 +54,9 @@ def tail(the_file, lines_2find=20):
the_file.seek(0, 2)
bytes_in_file = the_file.tell()
lines_found, total_bytes_scanned = 0, 0
while lines_2find+1 > lines_found and bytes_in_file > total_bytes_scanned:
byte_block = min(1024, bytes_in_file-total_bytes_scanned)
the_file.seek(-(byte_block+total_bytes_scanned), 2)
while lines_2find + 1 > lines_found and bytes_in_file > total_bytes_scanned:
byte_block = min(1024, bytes_in_file - total_bytes_scanned)
the_file.seek(-(byte_block + total_bytes_scanned), 2)
total_bytes_scanned += byte_block
lines_found += the_file.read(1024).count('\n')
the_file.seek(-total_bytes_scanned, 2)

View File

@ -17,13 +17,13 @@ class XMPPLoggerProtocol(muc.MUCClient):
def __init__(self, rooms, server, nick):
muc.MUCClient.__init__(self)
self.server = rooms.host
self.server = rooms.host
self.jrooms = rooms
self._roomOccupantMap = {}
log.msg(rooms.user)
log.msg(rooms.host)
self.nick = nick
self.last = {}
self.nick = nick
self.last = {}
self.activity = None
def connectionInitialized(self):
@ -35,13 +35,13 @@ class XMPPLoggerProtocol(muc.MUCClient):
log.msg('Joined room %s' % room.name)
def connectionMade(self):
log.msg('Connected!' )
log.msg('Connected!')
# send initial presence
self.send(AvailablePresence())
def connectionLost(self, reason):
log.msg('Disconnected!' )
log.msg('Disconnected!')
def onMessage(self, msg):
pass
@ -63,10 +63,10 @@ class DBLogger(dblog.DBLogger):
from random import choice
import string
server = CONFIG.get('database_xmpp', 'server')
user = CONFIG.get('database_xmpp', 'user')
password = CONFIG.get('database_xmpp', 'password')
muc = CONFIG.get('database_xmpp', 'muc')
server = CONFIG.get('database_xmpp', 'server')
user = CONFIG.get('database_xmpp', 'user')
password = CONFIG.get('database_xmpp', 'password')
muc = CONFIG.get('database_xmpp', 'muc')
channels = {}
for i in ('createsession', 'connectionlost', 'loginfailed',
'loginsucceeded', 'command', 'clientversion'):
@ -78,14 +78,14 @@ class DBLogger(dblog.DBLogger):
resource = ''.join([choice(string.ascii_letters) for i in range(8)])
jid = user + '/' + resource
application = service.Application('honeypot')
self.run(application, jid, password, JID(None,[muc,server,None]), channels)
self.run(application, jid, password, JID(None, [muc, server, None]), channels)
def run(self, application, jidstr, password, muc, channels, anon=True):
self.xmppclient = XMPPClient(JID(jidstr), password)
if CONFIG.has_option('database_xmpp', 'debug') and \
CONFIG.getboolean('database_xmpp', 'debug') == True:
self.xmppclient.logTraffic = True # DEBUG HERE
self.xmppclient.logTraffic = True # DEBUG HERE
(user, host, resource) = jid.parse(jidstr)
self.muc = XMPPLoggerProtocol(
muc, list(channels.keys()), user + '-' + resource)
@ -100,13 +100,13 @@ class DBLogger(dblog.DBLogger):
def broadcast(self, msgtype, msg):
if msgtype in self.signals:
self.report(msgtype, '%s@%s' % (self.signals[msgtype], self.muc.server) , msg)
self.report(msgtype, '{}@{}'.format(self.signals[msgtype], self.muc.server), msg)
def report(self, msgtype, to, xmsg):
msg = {}
msg['type'] = msgtype
msg['message'] = xmsg
msgJson = json.dumps(msg,indent=5)
msgJson = json.dumps(msg, indent=5)
self.muc.groupChat(self.muc.jrooms, msgJson)
# We have to return an unique ID
@ -158,7 +158,7 @@ class DBLogger(dblog.DBLogger):
ses = {}
ses['session'] = session
ses['command'] = 'unknown'
ses['input'] = args['input']
ses['input'] = args['input']
self.broadcast('command', ses)
def handleInput(self, session, args):

View File

@ -48,9 +48,9 @@ class LoggingServerProtocol(insults.ServerProtocol):
self.bytesReceivedLimit = 0
if prot is protocol.HoneyPotExecProtocol:
self.type = 'e' # Execcmd
self.type = 'e' # Execcmd
else:
self.type = 'i' # Interactive
self.type = 'i' # Interactive
def getSessionId(self):
@ -83,7 +83,7 @@ class LoggingServerProtocol(insults.ServerProtocol):
if self.type == 'e':
self.stdinlogOpen = True
else: #i
else:
self.stdinlogOpen = False
insults.ServerProtocol.connectionMade(self)
@ -112,7 +112,6 @@ class LoggingServerProtocol(insults.ServerProtocol):
self.bytesReceived += len(data)
if self.bytesReceivedLimit and self.bytesReceived > self.bytesReceivedLimit:
log.msg(format='Data upload limit reached')
#self.loseConnection()
self.eofReceived()
return
@ -178,7 +177,7 @@ class LoggingServerProtocol(insults.ServerProtocol):
if rp[1]:
url = rp[1]
else:
url = rf[rf.find('redir_')+len('redir_'):]
url = rf[rf.find('redir_') + len('redir_'):]
try:
if not os.path.exists(rf):
@ -212,7 +211,7 @@ class LoggingServerProtocol(insults.ServerProtocol):
format='Closing TTY Log: %(ttylog)s after %(duration)d seconds',
ttylog=self.ttylogFile,
size=self.ttylogSize,
duration=time.time()-self.startTime)
duration=time.time() - self.startTime)
ttylog.ttylog_close(self.ttylogFile, time.time())
self.ttylogOpen = False

View File

@ -36,7 +36,7 @@ class Output(cowrie.core.output.Output):
def start(self):
self.batch = [] # This is used to store login attempts in batches
self.batch = [] # This is used to store login attempts in batches
def stop(self):
@ -47,12 +47,12 @@ class Output(cowrie.core.output.Output):
if entry["eventid"] == 'cowrie.login.success' or entry["eventid"] == 'cowrie.login.failed':
date = dateutil.parser.parse(entry["timestamp"])
self.batch.append({
'date' : date.date().__str__(),
'time' : date.time().strftime("%H:%M:%S"),
'timezone' : time.strftime("%z"),
'source_ip' : entry['src_ip'],
'user' : entry['username'],
'password' : entry['password'],
'date': date.date().__str__(),
'time': date.time().strftime("%H:%M:%S"),
'timezone': time.strftime("%z"),
'source_ip': entry['src_ip'],
'user': entry['username'],
'password': entry['password'],
})
if len(self.batch) >= self.batch_size:
@ -99,20 +99,19 @@ class Output(cowrie.core.output.Output):
auth_header = 'credentials={0} nonce={1} userid={2}'.format(digest, _nonceb64, self.userid)
headers = {
'X-ISC-Authorization': auth_header,
'Content-Type':'text/plain'
'Content-Type': 'text/plain'
}
#log.msg(headers)
if self.debug:
log.msg('dshield: posting: {}'.format(log_output))
req = threads.deferToThread(
requests.request,
method ='PUT',
url = 'https://secure.dshield.org/api/file/sshlog',
headers = headers,
timeout = 10,
data = log_output
method='PUT',
url='https://secure.dshield.org/api/file/sshlog',
headers=headers,
timeout=10,
data=log_output
)
@ -129,7 +128,7 @@ class Output(cowrie.core.output.Output):
sha1_match = sha1_regex.search(response)
if sha1_match is None:
log.err('dshield: ERROR: Could not find sha1checksum in response')
log.err('dshield: ERROR: Response: '+repr(response))
log.err('dshield: ERROR: Response: {0}'.format(repr(response)))
failed = True
sha1_local = hashlib.sha1()
sha1_local.update(log_output)

View File

@ -19,7 +19,7 @@ class Output(cowrie.core.output.Output):
"""
self.host = CONFIG.get('output_elasticsearch', 'host')
self.port = CONFIG.get('output_elasticsearch', 'port')
self.index =CONFIG.get('output_elasticsearch', 'index')
self.index = CONFIG.get('output_elasticsearch', 'index')
self.type = CONFIG.get('output_elasticsearch', 'type')
self.pipeline = CONFIG.get('output_elasticsearch', 'pipeline')
cowrie.core.output.Output.__init__(self)

View File

@ -30,19 +30,19 @@ From https://github.com/threatstream/kippo/blob/master/kippo/dblog/hpfeeds.py
BUFSIZ = 16384
OP_ERROR = 0
OP_INFO = 1
OP_AUTH = 2
OP_PUBLISH = 3
OP_SUBSCRIBE = 4
OP_ERROR = 0
OP_INFO = 1
OP_AUTH = 2
OP_PUBLISH = 3
OP_SUBSCRIBE = 4
MAXBUF = 1024**2
MAXBUF = 1024 ** 2
SIZES = {
OP_ERROR: 5+MAXBUF,
OP_INFO: 5+256+20,
OP_AUTH: 5+256+20,
OP_PUBLISH: 5+MAXBUF,
OP_SUBSCRIBE: 5+256*2,
OP_ERROR: 5 + MAXBUF,
OP_INFO: 5 + 256 + 20,
OP_AUTH: 5 + 256 + 20,
OP_PUBLISH: 5 + MAXBUF,
OP_SUBSCRIBE: 5 + 256 * 2,
}
COWRIECHAN = 'cowrie.sessions'
@ -70,12 +70,12 @@ def strpack8(x):
# unpacks a string with 1 byte length field
def strunpack8(x):
l = x[0]
return x[1:1+l], x[1+l:]
return x[1:1 + l], x[1 + l:]
def msghdr(op, data):
return struct.pack('!iB', 5+len(data), op) + data
return struct.pack('!iB', 5 + len(data), op) + data
@ -91,7 +91,7 @@ def msgsubscribe(ident, chan):
def msgauth(rand, ident, secret):
hash = hashlib.sha1(bytes(rand)+secret).digest()
hash = hashlib.sha1(bytes(rand) + secret).digest()
return msghdr(OP_AUTH, strpack8(ident) + hash)
@ -124,7 +124,7 @@ class FeedUnpack(object):
if len(self.buf) < ml:
raise StopIteration('No message.')
data = bytearray(buffer(self.buf, 5, ml-5))
data = bytearray(buffer(self.buf, 5, ml - 5))
del self.buf[:ml]
return opcode, data
@ -245,7 +245,7 @@ class hpclient(object):
self.filehandle = open(filepath, 'rb')
fsize = os.stat(filepath).st_size
headc = strpack8(self.ident) + strpack8(COWRIECHAN)
headh = struct.pack('!iB', 5+len(headc)+fsize, OP_PUBLISH)
headh = struct.pack('!iB', 5 + len(headc) + fsize, OP_PUBLISH)
self.send(headh + headc)
@ -297,18 +297,18 @@ class Output(cowrie.core.output.Output):
session = entry["session"]
if entry["eventid"] == 'cowrie.session.connect':
self.meta[session] = {
'session':session,
'session': session,
'startTime': entry["timestamp"],
'endTime':'',
'endTime': '',
'peerIP': entry["src_ip"],
'peerPort': entry["src_port"],
'hostIP': entry["dst_ip"],
'hostPort': entry["dst_port"],
'loggedin': None,
'credentials':[],
'commands':[],
'unknownCommands':[],
'urls':[],
'credentials': [],
'commands': [],
'unknownCommands': [],
'urls': [],
'version': None,
'ttylog': None,
'hashes': set(),

View File

@ -65,18 +65,18 @@ class Output(cowrie.core.output.Output):
session = entry["session"]
if entry["eventid"] == 'cowrie.session.connect':
self.meta[session] = {
'session':session,
'session': session,
'startTime': entry["timestamp"],
'endTime':'',
'endTime': '',
'peerIP': entry["src_ip"],
'peerPort': entry["src_port"],
'hostIP': entry["dst_ip"],
'hostPort': entry["dst_port"],
'loggedin': None,
'credentials':[],
'commands':[],
'unknownCommands':[],
'urls':[],
'credentials': [],
'commands': [],
'unknownCommands': [],
'urls': [],
'version': None,
'ttylog': None,
'hashes': set(),

View File

@ -106,7 +106,7 @@ class Output(cowrie.core.output.Output):
# measurement init
m = {
'measurement': eventid.replace('.','_'),
'measurement': eventid.replace('.', '_'),
'tags': {
'session': entry['session'],
'src_ip': entry['src_ip']

View File

@ -70,7 +70,7 @@ class Output(cowrie.core.output.Output):
"""
for i in list(logentry.keys()):
# Remove twisted 15 legacy keys
if i.startswith('log_') or i == 'time' or i =='system':
if i.startswith('log_') or i == 'time' or i == 'system':
del logentry[i]
json.dump(logentry, self.outfile)
self.outfile.write('\n')

View File

@ -34,7 +34,7 @@ class ReconnectingConnectionPool(adbapi.ConnectionPool):
self, interaction, *args, **kw)
except MySQLdb.OperationalError as e:
if e[0] not in (2003, 2006, 2013):
raise log.msg("RCP: got error %s, retrying operation" %(e,))
raise log.msg("RCP: got error {0}, retrying operation".format(e))
conn = self.connections.get(self.threadID())
self.disconnect(conn)
# Try the interaction again
@ -71,13 +71,13 @@ class Output(cowrie.core.output.Output):
try:
self.db = ReconnectingConnectionPool(
'MySQLdb',
host = CONFIG.get('output_mysql', 'host'),
db = CONFIG.get('output_mysql', 'database'),
user = CONFIG.get('output_mysql', 'username'),
passwd = CONFIG.get('output_mysql', 'password', raw=True),
port = port,
cp_min = 1,
cp_max = 1
host=CONFIG.get('output_mysql', 'host'),
db=CONFIG.get('output_mysql', 'database'),
user=CONFIG.get('output_mysql', 'username'),
passwd=CONFIG.get('output_mysql', 'password', raw=True),
port=port,
cp_min=1,
cp_max=1
)
except MySQLdb.Error as e:
log.msg("output_mysql: Error %d: %s" % (e.args[0], e.args[1]))
@ -125,7 +125,7 @@ class Output(cowrie.core.output.Output):
sensorid = int(r[0][0])
self.simpleQuery(
"INSERT INTO `sessions` (`id`, `starttime`, `sensor`, `ip`)"
+ " VALUES (%s, FROM_UNIXTIME(%s), %s, %s)",
+ " VALUES (%s, FROM_UNIXTIME(%s), %s, %s)",
(entry["session"], entry["time"], sensorid, entry["src_ip"]))
elif entry["eventid"] == 'cowrie.login.success':

View File

@ -33,7 +33,7 @@ class Output(cowrie.core.output.Output):
try:
self.db = adbapi.ConnectionPool(
'sqlite3',
database = sqliteFilename,
database=sqliteFilename,
check_same_thread=False
)
except sqlite3.OperationalError as e:
@ -83,7 +83,7 @@ class Output(cowrie.core.output.Output):
sensorid = int(r[0][0])
self.simpleQuery(
"INSERT INTO `sessions` (`id`, `starttime`, `sensor`, `ip`)"
+ " VALUES (?, ?, ?, ?)",
+ " VALUES (?, ?, ?, ?)",
(entry["session"], entry["timestamp"],
sensorid, entry["src_ip"]))

View File

@ -60,10 +60,10 @@ class Output(cowrie.core.output.Output):
"""
"""
if self.format == 'cef':
self.outfile.write(logentry['timestamp']+" ")
self.outfile.write(cowrie.core.cef.formatCef(logentry)+'\n')
self.outfile.write('{0} '.format(logentry['timestamp']))
self.outfile.write('{0}\n'.format(cowrie.core.cef.formatCef(logentry)))
else:
self.outfile.write(logentry['timestamp']+" ")
self.outfile.write(logentry['message']+"\n")
self.outfile.write('{0} '.format(logentry['timestamp']))
self.outfile.write('{0}\n'.format(logentry['message']))
self.outfile.flush()

View File

@ -90,10 +90,7 @@ class Output(cowrie.core.output.Output):
"""
"""
if entry["eventid"] == 'cowrie.session.file_download':
#TODO: RENABLE
#log.msg("Sending url to VT")
#self.scanurl(entry["url"])
# TODO: RENABLE file upload to virustotal (git commit 6546f1ee)
log.msg("Checking scan report at VT")
self.scanfile(entry)
@ -101,16 +98,12 @@ class Output(cowrie.core.output.Output):
log.msg("Checking scan report at VT")
self.scanfile(entry["shasum"])
#log.msg("Sending file to VT")
#self.postfile(entry["outfile"], entry["filename"])
def scanfile(self, entry):
"""
Check file scan report for a hash
Argument is full event so we can access full file later on
"""
vtUrl = VTAPI_URL+b'file/report'
vtUrl = b'{0}file/report'.format(VTAPI_URL)
headers = http_headers.Headers({'User-Agent': [COWRIE_USER_AGENT]})
fields = {'apikey': self.apiKey, 'resource': entry["shasum"]}
body = StringProducer(urlencode(fields).encode("utf-8"))
@ -123,7 +116,6 @@ class Output(cowrie.core.output.Output):
if response.code == 200:
d = client.readBody(response)
d.addCallback(cbBody)
#d.addErrback(cbPartial)
return d
else:
log.msg("VT Request failed: {} {}".format(response.code, response.phrase))
@ -177,7 +169,6 @@ class Output(cowrie.core.output.Output):
log.msg("VT: {}/{} bad; permalink: {}".format(j["positives"], j["total"], j["permalink"]))
elif j["response_code"] == -2:
log.msg("VT: response=-2: this has been queued for analysis already")
#log.msg("VT: permalink: {}".format(j["permalink"]))
else:
log.msg("VT: unexpected response code".format(j["response_code"]))
@ -190,11 +181,11 @@ class Output(cowrie.core.output.Output):
"""
Send a file to VirusTotal
"""
vtUrl = VTAPI_URL+b'file/scan'
vtUrl = b'{0}file/scan'.format(VTAPI_URL)
fields = {('apikey', self.apiKey)}
files = {('file', fileName, open(artifact, 'rb'))}
if self.debug:
log.msg("submitting to VT: "+repr(files))
log.msg("submitting to VT: {0}".format(repr(files)))
contentType, body = encode_multipart_formdata(fields, files)
producer = StringProducer(body)
headers = http_headers.Headers({
@ -258,7 +249,7 @@ class Output(cowrie.core.output.Output):
"""
Check url scan report for a hash
"""
vtUrl = VTAPI_URL+b'url/report'
vtUrl = b'{0}url/report'.format(VTAPI_URL)
headers = http_headers.Headers({'User-Agent': [COWRIE_USER_AGENT]})
fields = {'apikey': self.apiKey, 'resource': url, 'scan': 1}
body = StringProducer(urlencode(fields).encode("utf-8"))
@ -271,7 +262,6 @@ class Output(cowrie.core.output.Output):
if response.code == 200:
d = client.readBody(response)
d.addCallback(cbBody)
#d.addErrback(cbPartial)
return d
else:
log.msg("VT Request failed: {} {}".format(response.code, response.phrase))
@ -326,10 +316,12 @@ class Output(cowrie.core.output.Output):
"""
Send a comment to VirusTotal with Twisted
"""
vtUrl = VTAPI_URL+b'comments/put'
parameters = { "resource": resource,
"comment": self.commenttext,
"apikey": self.apiKey}
vtUrl = b'{0}comments/put'.format(VTAPI_URL)
parameters = {
"resource": resource,
"comment": self.commenttext,
"apikey": self.apiKey
}
headers = http_headers.Headers({'User-Agent': [COWRIE_USER_AGENT]})
body = StringProducer(urlencode(parameters).encode("utf-8"))
d = self.agent.request(b'POST', vtUrl, headers, body)

View File

@ -16,13 +16,13 @@ class XMPPLoggerProtocol(muc.MUCClient):
def __init__(self, rooms, server, nick):
muc.MUCClient.__init__(self)
self.server = rooms.host
self.server = rooms.host
self.jrooms = rooms
self._roomOccupantMap = {}
log.msg(rooms.user)
log.msg(rooms.host)
self.nick = nick
self.last = {}
self.nick = nick
self.last = {}
self.activity = None
def connectionInitialized(self):
@ -68,22 +68,22 @@ class Output(cowrie.core.output.Output):
from random import choice
import string
server = CONFIG.get('output_xmpp', 'server')
user = CONFIG.get('output_xmpp', 'user')
password = CONFIG.get('output_xmpp', 'password')
muc = CONFIG.get('output_xmpp', 'muc')
server = CONFIG.get('output_xmpp', 'server')
user = CONFIG.get('output_xmpp', 'user')
password = CONFIG.get('output_xmpp', 'password')
muc = CONFIG.get('output_xmpp', 'muc')
resource = ''.join([choice(string.ascii_letters)
for i in range(8)])
jid = user + '/' + resource
application = service.Application('honeypot')
self.run(application, jid, password,JID(None,[muc,server,None]), server)
self.run(application, jid, password, JID(None, [muc, server, None]), server)
def run(self, application, jidstr, password, muc, server):
self.xmppclient = XMPPClient(JID(jidstr), password)
if CONFIG.has_option('output_xmpp', 'debug') and \
CONFIG.getboolean('output_xmpp', 'debug') == True:
self.xmppclient.logTraffic = True # DEBUG HERE
self.xmppclient.logTraffic = True # DEBUG HERE
(user, host, resource) = jid.parse(jidstr)
self.muc = XMPPLoggerProtocol(
muc, server, user + '-' + resource)
@ -99,7 +99,7 @@ class Output(cowrie.core.output.Output):
del logentry[i]
elif i == "time":
del logentry[i]
msgJson = json.dumps(logentry,indent=5)
msgJson = json.dumps(logentry, indent=5)
self.muc.groupChat(self.muc.jrooms, msgJson)

View File

@ -11,7 +11,6 @@ from zope.interface import implementer
from twisted.conch import avatar
from twisted.conch.interfaces import IConchUser, ISession, ISFTPServer
#from twisted.conch.ssh import filetransfer as conchfiletransfer
from twisted.python import log, components
from cowrie.ssh import session as sshsession
@ -34,12 +33,7 @@ class CowrieUser(avatar.ConchUser):
self.channelLookup[b'session'] = proxysession.ProxySSHSession
# SFTP support enabled only when option is explicitly set
#try:
# if CONFIG.getboolean('ssh', 'sftp_enabled') == True:
# self.subsystemLookup[b'sftp'] = conchfiletransfer.FileTransferServer
#except ValueError as e:
# pass
# TODO: Is SFTP still supported? Check git commit 30949e0 for cleaned up code
# SSH forwarding disabled only when option is explicitly set
self.channelLookup[b'direct-tcpip'] = forwarding.cowrieOpenConnectForwardingClient
@ -55,7 +49,5 @@ class CowrieUser(avatar.ConchUser):
"""
log.msg('avatar {} logging out'.format(self.username))
#components.registerAdapter(filetransfer.SFTPServerForCowrieUser, CowrieUser, ISFTPServer)
components.registerAdapter(shellsession.SSHSessionForCowrieUser, CowrieUser, ISession)

View File

@ -211,7 +211,7 @@ class _CommandChannel(SSHChannel):
@param ignored: The (ignored) result of the execute request
"""
log.msg("command = "+self._command)
log.msg("command = {0}".format(self._command))
self._protocol = self._protocolFactory.buildProtocol(
SSHCommandAddress(
@ -230,7 +230,7 @@ class _CommandChannel(SSHChannel):
@param data: The bytes from the command's stdout.
@type data: L{bytes}
"""
log.msg("command output received"+repr(data))
log.msg("command output received{0}".format(repr(data)))
self._protocol.dataReceived(data)
@ -320,7 +320,7 @@ class _ShellChannel(SSHSession):
def ttyRequest(self, something):
log.msg("tty-request")
term = "vt100"
winSize = (25,80,0,0) # struct.unpack('4H', winsz)
winSize = (25, 80, 0, 0) # struct.unpack('4H', winsz)
ptyReqData = packRequest_pty_req(term, winSize, '')
req = self.conn.sendRequest(self, b'pty-req', ptyReqData, wantReply=True)
req.addCallback(self.shellRequest)
@ -343,7 +343,7 @@ class _ShellChannel(SSHSession):
@param reason: The cause of the shell opening failure.
@type reason: L{Failure}
"""
log.msg("failed to connect to proxy backend: "+reason)
log.msg("failed to connect to proxy backend: {0}".format(reason))
self._shellConnected.errback(reason)
@ -377,7 +377,7 @@ class _ShellChannel(SSHSession):
@param data: The bytes from the command's stdout.
@type data: L{bytes}
"""
log.msg("client-session dataReceived: "+repr(data))
log.msg("client-session dataReceived: {0}".format(repr(data)))
self._protocol.dataReceived(data)
@ -821,7 +821,7 @@ class SSHShellClientEndpoint(object):
def disconnectOnFailure(passthrough):
# Close the connection immediately in case of cancellation, since
# that implies user wants it gone immediately (e.g. a timeout):
immediate = passthrough.check(CancelledError)
immediate = passthrough.check(CancelledError)
self._creator.cleanupConnection(connection, immediate)
return passthrough
shellConnected.addErrback(disconnectOnFailure)
@ -989,7 +989,7 @@ class SSHCommandClientEndpoint(object):
def disconnectOnFailure(passthrough):
# Close the connection immediately in case of cancellation, since
# that implies user wants it gone immediately (e.g. a timeout):
immediate = passthrough.check(CancelledError)
immediate = passthrough.check(CancelledError)
self._creator.cleanupConnection(connection, immediate)
return passthrough
commandConnected.addErrback(disconnectOnFailure)

View File

@ -12,7 +12,6 @@ from twisted.python import log
from twisted.conch.ssh import common, keys, session
from twisted.conch.client.knownhosts import KnownHostsFile
from twisted.conch.ssh.common import getNS
#from twisted.conch import endpoints
from cowrie.core.config import CONFIG
from cowrie.proxy import endpoints
@ -57,9 +56,9 @@ class InBetween(protocol.Protocol):
SSH client on the other side
"""
transport = None # Transport is the back-end the ssh-server
client = None # Client is the front-end, the ssh-client
buf = b"" # buffer to send to back-end
transport = None # Transport is the back-end the ssh-server
client = None # Client is the front-end, the ssh-client
buf = b"" # buffer to send to back-end
def makeConnection(self, transport):
protocol.Protocol.makeConnection(self, transport)
@ -68,7 +67,6 @@ class InBetween(protocol.Protocol):
def connectionMade(self):
log.msg("IB: connection Made")
if len(self.buf) and self.transport != None:
#self.transport.dataReceived(self.buf)
self.transport.write(self.buf)
self.buf = None
@ -80,7 +78,7 @@ class InBetween(protocol.Protocol):
if not self.transport:
self.buf += bytes
return
log.msg("IB: write: "+repr(bytes)+" to transport "+repr(self.transport))
log.msg("IB: write: {0} to transport {1}".format(repr(bytes), repr(self.transport)))
self.transport.write(bytes)
@ -88,7 +86,7 @@ class InBetween(protocol.Protocol):
"""
This is data going from the back-end to the end-user
"""
log.msg("IB: dataReceived: "+repr(data))
log.msg("IB: dataReceived: {0}".format(repr(data)))
self.client.write(data)
@ -143,7 +141,6 @@ class ProxySSHSession(channel.CowrieSSHChannel):
def __init__(self, *args, **kw):
channel.CowrieSSHChannel.__init__(self, *args, **kw)
#self.__dict__['request_auth_agent_req@openssh.com'] = self.request_agent
keyPath = CONFIG.get('proxy', 'private_key')
self.keys.append(keys.Key.fromFile(keyPath))
@ -165,10 +162,10 @@ class ProxySSHSession(channel.CowrieSSHChannel):
except:
self.password = None
log.msg("knownHosts = "+repr(self.knownHosts))
log.msg("host = "+self.host)
log.msg("port = "+str(self.port))
log.msg("user = "+self.user)
log.msg("knownHosts = {0}".format(repr(self.knownHosts)))
log.msg("host = {0}".format(self.host))
log.msg("port = {0}".format(self.port))
log.msg("user = {0}".format(self.user))
self.client = ProxyClient(self)
@ -182,11 +179,11 @@ class ProxySSHSession(channel.CowrieSSHChannel):
log.msg("channelOpen")
helper = endpoints._NewConnectionHelper(reactor, self.host, self.port, self.user, self.keys,
self.password, None, self.knownHosts, None)
log.msg("helper = "+repr(helper))
log.msg("helper = {0}".format(repr(helper)))
d = helper.secureConnection()
d.addCallback(self._cbConnect)
d.addErrback(self._ebConnect)
log.msg("d = "+repr(d))
log.msg("d = {0}".format(repr(d)))
return d
@ -247,7 +244,6 @@ class ProxySSHSession(channel.CowrieSSHChannel):
cmd, data = common.getNS(data)
log.msg('request_exec "{}"'.format(cmd))
pf = _ProtocolFactory(self.client.transport)
#ep = endpoints.SSHCommandClientEndpoint.existingConnection(self.conn, cmd).connect(pf)
ep = endpoints.SSHCommandClientEndpoint.newConnection(reactor, cmd, self.user, self.host,
port=self.port, password=self.password).connect(pf)
return 1
@ -319,7 +315,6 @@ class ProxySSHSession(channel.CowrieSSHChannel):
def dataReceived(self, data):
if not self.client:
#self.conn.sendClose(self)
self.buf += data
return
self.client.transport.write(data)

View File

@ -53,7 +53,7 @@ class CustomParser(argparse.ArgumentParser):
def _print_message(self, message, file=None):
super(CustomParser,self)._print_message(message, self.protocol)
super(CustomParser, self)._print_message(message, self.protocol)
def error(self, message):
self.print_usage(self.protocol)

View File

@ -80,7 +80,7 @@ class CowrieSFTPFile(object):
def readChunk(self, offset, length):
"""
"""
return self.contents[offset:offset+length]
return self.contents[offset:offset + length]
def writeChunk(self, offset, data):
@ -113,7 +113,7 @@ class CowrieSFTPDirectory(object):
def __init__(self, server, directory):
self.server = server
self.files = server.fs.listdir(directory)
self.files = [".", ".."]+self.files
self.files = [".", ".."] + self.files
self.dir = directory
@ -306,7 +306,6 @@ class SFTPServerForCowrieUser(object):
def realPath(self, path):
"""
"""
#log.msg("SFTP realPath: {}".format(path))
return self.fs.realpath(self._absPath(path))

View File

@ -226,7 +226,7 @@ class HoneyPotFilesystem(object):
return False
for x in p[A_CONTENTS]:
if x[A_NAME] == piece:
if piece == pieces[-1] and follow_symlinks==False:
if piece == pieces[-1] and follow_symlinks == False:
p = x
elif x[A_TYPE] == T_LINK:
if x[A_TARGET][0] == '/':
@ -374,7 +374,6 @@ class HoneyPotFilesystem(object):
time.strftime('%Y%m%d-%H%M%S'),
re.sub('[^A-Za-z0-9]', '_', filename)
)
#log.msg("fs.open file for writing, saving to %s" % safeoutfile)
self.mkfile(filename, 0, 0, 0, stat.S_IFREG | mode)
fd = os.open(hostfile, openFlags, hostmode)
self.update_realfile(self.getfile(filename), hostfile)
@ -413,7 +412,6 @@ class HoneyPotFilesystem(object):
os.remove(self.tempfiles[fd])
else:
os.rename(self.tempfiles[fd], shasumfile)
#os.symlink(shasum, self.tempfiles[fd])
self.update_realfile(self.getfile(self.filenames[fd]), shasumfile)
log.msg(format='SFTP Uploaded file \"%(filename)s\" to %(outfile)s',
eventid='cowrie.session.file_upload',
@ -454,7 +452,7 @@ class HoneyPotFilesystem(object):
raise OSError(errno.EEXIST, os.strerror(errno.EEXIST), path)
if dir[A_TYPE] != T_DIR:
raise OSError(errno.ENOTDIR, os.strerror(errno.ENOTDIR), path)
if len(self.get_path(path))>0:
if len(self.get_path(path)) > 0:
raise OSError(errno.ENOTEMPTY, os.strerror(errno.ENOTEMPTY), path)
pdir = self.get_path(parent, follow_symlinks=True)
for i in pdir[:]:
@ -555,12 +553,12 @@ class HoneyPotFilesystem(object):
"""
if (path == "/"):
p = {
A_TYPE:T_DIR,
A_UID:0,
A_GID:0,
A_SIZE:4096,
A_MODE:16877,
A_CTIME:time.time()
A_TYPE: T_DIR,
A_UID: 0,
A_GID: 0,
A_SIZE: 4096,
A_MODE: 16877,
A_CTIME: time.time()
}
else:
p = self.getfile(path, follow_symlinks=follow_symlinks)

View File

@ -207,7 +207,6 @@ class HoneyPotShell(object):
"""
"""
log.msg(eventid='cowrie.command.input', input=line, format='CMD: %(input)s')
#line = b"".join(line)
self.lexer = shlex.shlex(instream=line, punctuation_chars=True)
tokens = []
while True:
@ -344,7 +343,7 @@ class HoneyPotShell(object):
for index, pipe_indice in enumerate(pipe_indices):
multipleCmdArgs.append(cmdAndArgs[start:pipe_indice])
start = pipe_indice+1
start = pipe_indice + 1
cmd['rargs'] = parse_file_arguments(multipleCmdArgs.pop(0))
cmd_array.append(cmd)
@ -362,8 +361,8 @@ class HoneyPotShell(object):
cmdclass = self.protocol.getCommand(cmd['command'], environ['PATH'].split(':'))
if cmdclass:
log.msg(input=cmd['command'] + " " + ' '.join(cmd['rargs']), format='Command found: %(input)s')
if index == len(cmd_array)-1:
lastpp = StdOutStdErrEmulationProtocol(self.protocol, cmdclass, cmd['rargs'], None, None)
if index == len(cmd_array) - 1:
lastpp = StdOutStdErrEmulationProtocol(self.protocol, cmdclass, cmd['rargs'], None, None)
pp = lastpp
else:
pp = StdOutStdErrEmulationProtocol(self.protocol, cmdclass, cmd['rargs'], None, lastpp)
@ -394,24 +393,19 @@ class HoneyPotShell(object):
homelen = len(self.protocol.user.avatar.home)
if cwd == self.protocol.user.avatar.home:
cwd = '~'
elif len(cwd) > (homelen+1) and \
cwd[:(homelen+1)] == self.protocol.user.avatar.home + '/':
elif len(cwd) > (homelen + 1) and \
cwd[:(homelen + 1)] == self.protocol.user.avatar.home + '/':
cwd = '~' + cwd[homelen:]
# Uncomment the three lines below for a 'better' CentOS look.
# Rather than '[root@svr03 /var/log]#' is shows '[root@svr03 log]#'.
#cwd = cwd.rsplit('/', 1)[-1]
#if not cwd:
# cwd = '/'
# Example: [root@svr03 ~]# (More of a "CentOS" feel)
# Example: root@svr03:~# (More of a "Debian" feel)
prompt = self.protocol.user.username+'@'+self.protocol.hostname+':'+cwd
prompt = '{0}@{1}:{2}'.format(self.protocol.user.username, self.pr.hostname, cwd)
if not self.protocol.user.uid:
prompt += '# ' # "Root" user
else:
prompt += '$ ' # "Non-Root" user
self.protocol.terminal.write(prompt)
self.protocol.ps = (prompt , '> ')
self.protocol.ps = (prompt, '> ')
def eofReceived(self):
@ -437,7 +431,7 @@ class HoneyPotShell(object):
"""
log.msg('Received CTRL-D, exiting..')
cmdclass = self.protocol.commands['exit']
cmdclass = self.protocol.commands['exit']
pp = StdOutStdErrEmulationProtocol(self.protocol, cmdclass, None, None, None)
self.protocol.call_command(pp, self.protocol.commands['exit'])

View File

@ -60,7 +60,7 @@ class HoneyPotBaseProtocol(insults.TerminalProtocol, TimeoutMixin):
self.commands.update(module.commands)
except Exception as e:
exc_type, exc_value, exc_traceback = sys.exc_info()
log.err("Failed to import command {}: {}: {}".format(c, e, ''.join(traceback.format_exception(exc_type,exc_value,exc_traceback))))
log.err("Failed to import command {}: {}: {}".format(c, e, ''.join(traceback.format_exception(exc_type, exc_value, exc_traceback))))
self.password_input = False
self.cmdstack = []
@ -136,15 +136,13 @@ class HoneyPotBaseProtocol(insults.TerminalProtocol, TimeoutMixin):
"""
self.setTimeout(None)
insults.TerminalProtocol.connectionLost(self, reason)
self.terminal = None # (this should be done by super above)
self.terminal = None # (this should be done by super above)
self.cmdstack = []
del self.commands
self.fs = None
self.pp = None
self.user = None
self.environ = None
#log.msg("honeypot terminal protocol connection lost {}".format(reason))
def txtcmd(self, txt):
"""
@ -228,8 +226,6 @@ class HoneyPotBaseProtocol(insults.TerminalProtocol, TimeoutMixin):
"""
pt = self.getProtoTransport()
r = time.time() - pt.factory.starttime
#if reset:
# pt.factory.starttime = reset
return r
@ -306,21 +302,21 @@ class HoneyPotInteractiveProtocol(HoneyPotBaseProtocol, recvline.HistoricRecvLin
self.cmdstack = [honeypot.HoneyPotShell(self)]
self.keyHandlers.update({
b'\x01': self.handle_HOME, # CTRL-A
b'\x02': self.handle_LEFT, # CTRL-B
b'\x03': self.handle_CTRL_C, # CTRL-C
b'\x04': self.handle_CTRL_D, # CTRL-D
b'\x05': self.handle_END, # CTRL-E
b'\x06': self.handle_RIGHT, # CTRL-F
b'\x08': self.handle_BACKSPACE, # CTRL-H
b'\x09': self.handle_TAB,
b'\x0b': self.handle_CTRL_K, # CTRL-K
b'\x0c': self.handle_CTRL_L, # CTRL-L
b'\x0e': self.handle_DOWN, # CTRL-N
b'\x10': self.handle_UP, # CTRL-P
b'\x15': self.handle_CTRL_U, # CTRL-U
b'\x16': self.handle_CTRL_V, # CTRL-V
b'\x1b': self.handle_ESC, # ESC
b'\x01': self.handle_HOME, # CTRL-A
b'\x02': self.handle_LEFT, # CTRL-B
b'\x03': self.handle_CTRL_C, # CTRL-C
b'\x04': self.handle_CTRL_D, # CTRL-D
b'\x05': self.handle_END, # CTRL-E
b'\x06': self.handle_RIGHT, # CTRL-F
b'\x08': self.handle_BACKSPACE, # CTRL-H
b'\x09': self.handle_TAB,
b'\x0b': self.handle_CTRL_K, # CTRL-K
b'\x0c': self.handle_CTRL_L, # CTRL-L
b'\x0e': self.handle_DOWN, # CTRL-N
b'\x10': self.handle_UP, # CTRL-P
b'\x15': self.handle_CTRL_U, # CTRL-U
b'\x16': self.handle_CTRL_V, # CTRL-V
b'\x1b': self.handle_ESC, # ESC
})
@ -328,8 +324,7 @@ class HoneyPotInteractiveProtocol(HoneyPotBaseProtocol, recvline.HistoricRecvLin
"""
"""
try:
self.terminal.write(self.fs.file_contents('/etc/motd')+'\n')
self.terminal.write('{0}\n'.format(self.fs.file_contents('/etc/motd')))
except:
pass
@ -372,7 +367,7 @@ class HoneyPotInteractiveProtocol(HoneyPotBaseProtocol, recvline.HistoricRecvLin
if self.mode == 'insert':
self.lineBuffer.insert(self.lineBufferIndex, ch)
else:
self.lineBuffer[self.lineBufferIndex:self.lineBufferIndex+1] = [ch]
self.lineBuffer[self.lineBufferIndex:self.lineBufferIndex + 1] = [ch]
self.lineBufferIndex += 1
if not self.password_input:
self.terminal.write(ch)

View File

@ -44,10 +44,10 @@ class SSHSessionForCowrieUser(object):
'USER': self.username,
'HOME': self.avatar.home,
'TMOUT': '1800'}
if self.uid==0:
self.environ['PATH']='/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'
if self.uid == 0:
self.environ['PATH'] = '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'
else:
self.environ['PATH']='/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games'
self.environ['PATH'] = '/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games'
self.server.initFileSystem()

View File

@ -67,7 +67,7 @@ class shlex:
self._pushback_chars = deque()
# these chars added because allowed in file names, args, wildcards
self.wordchars += '@%{}~-./*?=$:+^'
#remove any punctuation chars from wordchars
# remove any punctuation chars from wordchars
self.wordchars = ''.join(c for c in self.wordchars if c not in
self.punctuation_chars)
for c in punctuation_chars:
@ -318,7 +318,7 @@ def split(s, comments=False, posix=True):
return list(lex)
#_find_unsafe = re.compile(r'[^\w@%+=:,./-]', re.ASCII).search
# No ASCII in P2.x
_find_unsafe = re.compile(r'[^\w@%+=:,./-]').search

View File

@ -78,8 +78,8 @@ class CowrieSSHChannel(channel.SSHChannel):
log.msg(eventid='cowrie.log.closed',
format="Closing TTY Log: %(ttylog)s after %(duration)d seconds",
ttylog=self.ttylogFile,
size=self.bytesReceived+self.bytesWritten,
duration=time.time()-self.startTime)
size=self.bytesReceived + self.bytesWritten,
duration=time.time() - self.startTime)
ttylog.ttylog_close(self.ttylogFile, time.time())
channel.SSHChannel.closed(self)

View File

@ -36,13 +36,13 @@ class CowrieSSHFactory(factory.SSHFactory):
privateKeys = None
publicKeys = None
primes = None
tac = None # gets set later
tac = None # gets set later
def logDispatch(self, *msg, **args):
"""
Special delivery to the loggers to avoid scope problems
"""
args['sessionno'] = 'S'+str(args['sessionno'])
args['sessionno'] = 'S{0}'.format(args['sessionno'])
for dblog in self.tac.dbloggers:
dblog.logDispatch(*msg, **args)
for output in self.tac.output_plugins:

View File

@ -19,8 +19,6 @@ class HoneyPotSSHSession(session.SSHSession):
def __init__(self, *args, **kw):
session.SSHSession.__init__(self, *args, **kw)
#self.__dict__['request_auth_agent_req@openssh.com'] = self.request_agent
def request_env(self, data):
"""

View File

@ -52,13 +52,19 @@ class HoneyPotSSHTransport(transport.SSHServerTransport, TimeoutMixin):
if ipv4_search != None:
src_ip = ipv4_search.group(1)
log.msg(eventid='cowrie.session.connect',
format="New connection: %(src_ip)s:%(src_port)s (%(dst_ip)s:%(dst_port)s) [session: %(session)s]",
src_ip=src_ip, src_port=self.transport.getPeer().port,
dst_ip=self.transport.getHost().host, dst_port=self.transport.getHost().port,
session=self.transportId, sessionno='S'+str(self.transport.sessionno), protocol='ssh')
log.msg(
eventid='cowrie.session.connect',
format="New connection: %(src_ip)s:%(src_port)s (%(dst_ip)s:%(dst_port)s) [session: %(session)s]",
src_ip=src_ip,
src_port=self.transport.getPeer().port,
dst_ip=self.transport.getHost().host,
dst_port=self.transport.getHost().port,
session=self.transportId,
sessionno='S{0}'.format(self.transport.sessionno),
protocol='ssh'
)
self.transport.write(b''+self.ourVersionString+b'\r\n')
self.transport.write(b'{0}\r\n'.format(self.ourVersionString))
self.currentEncryptions = transport.SSHCiphers(b'none', b'none', b'none', b'none')
self.currentEncryptions.setKeys(b'', b'', b'', b'', b'', b'')
self.setTimeout(120)
@ -93,7 +99,6 @@ class HoneyPotSSHTransport(transport.SSHServerTransport, TimeoutMixin):
if not self.gotVersion:
if not b'\n' in self.buf:
return
#self.otherVersionString = self.buf.split(b'\n')[0].strip().encode('string-escape')
self.otherVersionString = self.buf.split(b'\n')[0].strip()
log.msg(eventid='cowrie.client.version', version=self.otherVersionString,
format="Remote SSH version: %(version)s")
@ -104,7 +109,7 @@ class HoneyPotSSHTransport(transport.SSHServerTransport, TimeoutMixin):
self._unsupportedVersionReceived(remoteVersion)
return
i = self.buf.index(b'\n')
self.buf = self.buf[i+1:]
self.buf = self.buf[i + 1:]
self.sendKexInit()
else:
self.transport.write(b'Protocol mismatch.\n')

View File

@ -130,9 +130,9 @@ class HoneyPotSSHUserAuthServer(userauth.SSHUserAuthServer):
"""
resp = []
for message, kind in items:
if kind == 1: # Password
if kind == 1: # Password
resp.append((message, 0))
elif kind == 2: # Text
elif kind == 2: # Text
resp.append((message, 1))
elif kind in (3, 4):
return defer.fail(error.ConchError(

View File

@ -25,7 +25,7 @@ class HoneyPotTelnetSession(TelnetBootstrapProtocol):
"""
"""
id = 0 # telnet can only have 1 simultaneous session, unlike SSH
id = 0 # telnet can only have 1 simultaneous session, unlike SSH
windowSize = [40, 80]
def __init__(self, username, server):
@ -112,13 +112,6 @@ class TelnetSessionProcessProtocol(protocol.ProcessProtocol):
self.session = sess
self.lostOutOrErrFlag = False
# FIXME probably no such thing such as buffering in Telnet protocol
#def connectionMade(self):
# if self.session.buf:
# self.session.write(self.session.buf)
# self.session.buf = None
def outReceived(self, data):
self.session.write(data)

View File

@ -33,7 +33,7 @@ class HoneyPotTelnetFactory(protocol.ServerFactory):
"""
Special delivery to the loggers to avoid scope problems
"""
args['sessionno'] = 'T'+str(args['sessionno'])
args['sessionno'] = 'T{0}'.format(str(args['sessionno']))
for dblog in self.tac.dbloggers:
dblog.logDispatch(*msg, **args)
for output in self.tac.output_plugins:
@ -105,7 +105,6 @@ class HoneyPotTelnetAuthProtocol(AuthenticatingTelnetProtocol):
"""
self.username = line # .decode()
# only send ECHO option if we are chatting with a real Telnet client
#if self.transport.options: <-- doesn't work
self.transport.willChain(ECHO)
# FIXME: this should be configurable or provided via filesystem
self.transport.write(self.passwordPrompt)
@ -141,7 +140,7 @@ class HoneyPotTelnetAuthProtocol(AuthenticatingTelnetProtocol):
def telnet_Command(self, command):
"""
"""
self.transport.protocol.dataReceived(command+b'\r')
self.transport.protocol.dataReceived(command + b'\r')
return "Command"
@ -192,9 +191,9 @@ class HoneyPotTelnetAuthProtocol(AuthenticatingTelnetProtocol):
"""
if opt == ECHO:
return True
# TODO: check if twisted now supports SGA (see git commit c58056b0)
elif opt == SGA:
return False
#return True
else:
return False
@ -202,10 +201,9 @@ class HoneyPotTelnetAuthProtocol(AuthenticatingTelnetProtocol):
def enableRemote(self, opt):
"""
"""
# TODO: check if twisted now supports LINEMODE (see git commit c58056b0)
if opt == LINEMODE:
return False
#self.transport.requestNegotiation(LINEMODE, MODE + chr(TRAPSIG))
#return True
elif opt == NAWS:
return True
elif opt == SGA:
@ -234,7 +232,7 @@ class CowrieTelnetTransport(TelnetTransport, TimeoutMixin):
dst_ip=self.transport.getHost().host,
dst_port=self.transport.getHost().port,
session=self.transportId,
sessionno='T'+str(sessionno),
sessionno='T{0}'.format(str(sessionno)),
protocol='telnet')
TelnetTransport.connectionMade(self)

View File

@ -5,7 +5,7 @@
from __future__ import division, absolute_import
from twisted.conch.insults import insults,helper
from twisted.conch.insults import insults, helper
from twisted.test import proto_helpers

View File

@ -21,8 +21,7 @@ class ShellBaseCommandsTests(unittest.TestCase):
with open('../cowrie/test/expected_results.json') as data_file:
self.data = json.load(data_file)
self.cfg = config.readConfigFile("../cowrie/test/unittests.cfg")
self.proto = protocol.HoneyPotInteractiveProtocol \
(fake_server.FakeAvatar(fake_server.FakeServer(self.cfg)))
self.proto = protocol.HoneyPotInteractiveProtocol(fake_server.FakeAvatar(fake_server.FakeServer(self.cfg)))
self.tr = fake_transport.FakeTransport("1.1.1.1", "1111")
self.proto.makeConnection(self.tr)
self.tr.clear()
@ -30,31 +29,31 @@ class ShellBaseCommandsTests(unittest.TestCase):
def test_whoami_command(self):
self.proto.lineReceived('whoami \n')
self.assertEqual(self.tr.value(),self.data['results']['whoami'])
self.assertEqual(self.tr.value(), self.data['results']['whoami'])
def test_users_command(self):
self.proto.lineReceived('users \n')
self.assertEqual(self.tr.value(),self.data['results']['users'])
self.assertEqual(self.tr.value(), self.data['results']['users'])
def test_help_command(self):
self.proto.lineReceived('help \n')
self.assertEquals(self.tr.value(),"\n".join(self.data['results']['help']))
self.assertEquals(self.tr.value(), "\n".join(self.data['results']['help']))
def test_w_command(self):
self.proto.lineReceived('w \n')
self.assertRegexpMatches(self.tr.value(),("\n").join(self.data['results']['w']))
self.assertRegexpMatches(self.tr.value(), ("\n").join(self.data['results']['w']))
def test_who_command(self):
self.proto.lineReceived('who \n')
self.assertRegexpMatches(self.tr.value(),"\n".join(self.data['results']['who']))
self.assertRegexpMatches(self.tr.value(), "\n".join(self.data['results']['who']))
def test_echo_command(self):
self.proto.lineReceived('echo "test worked correctly" \n')
self.assertEquals(self.tr.value(),"\n".join(self.data['results']['echo']))
self.assertEquals(self.tr.value(), "\n".join(self.data['results']['echo']))
def test_exit_command(self):
@ -71,7 +70,7 @@ class ShellBaseCommandsTests(unittest.TestCase):
def test_hostname_command(self):
self.proto.lineReceived('hostname unitChanged\n')
self.assertEquals(self.tr.value(),"\n".join(self.data['results']['hostname']))
self.assertEquals(self.tr.value(), "\n".join(self.data['results']['hostname']))
def test_reset_command(self):
@ -80,18 +79,18 @@ class ShellBaseCommandsTests(unittest.TestCase):
def test_ps_command(self):
self.proto.lineReceived('ps\n')
self.assertEquals(self.tr.value(),"\n".join(self.data['results']['ps']))
self.assertEquals(self.tr.value(), "\n".join(self.data['results']['ps']))
def test_id_command(self):
self.proto.lineReceived('id\n')
self.assertEquals(self.tr.value(),"\n".join(self.data['results']['id']))
self.assertEquals(self.tr.value(), "\n".join(self.data['results']['id']))
def test_passwd_command(self):
self.proto.lineReceived('passwd\n')
self.proto.lineReceived('changeme\n')
self.proto.lineReceived('changeme\n')
self.assertEquals(self.tr.value(),"\n".join(self.data['results']['passwd']))
self.assertEquals(self.tr.value(), "\n".join(self.data['results']['passwd']))
def test_shutdown_command(self):
@ -111,7 +110,7 @@ class ShellBaseCommandsTests(unittest.TestCase):
def test_date_command(self):
self.proto.lineReceived('date\n')
self.assertRegexpMatches(self.tr.value(),("\n").join(self.data['results']['date']))
self.assertRegexpMatches(self.tr.value(), ("\n").join(self.data['results']['date']))
def test_bash_command(self):
@ -120,7 +119,7 @@ class ShellBaseCommandsTests(unittest.TestCase):
def test_sh_command(self):
self.proto.lineReceived('sh -c who\n')
self.assertRegexpMatches(self.tr.value(),"\n".join(self.data['results']['who']))
self.assertRegexpMatches(self.tr.value(), "\n".join(self.data['results']['who']))
def test_php_command(self):
@ -131,71 +130,71 @@ class ShellBaseCommandsTests(unittest.TestCase):
def test_chattr_command(self):
self.proto.lineReceived('chattr\n')
self.assertEquals(self.tr.value(),"\n".join(self.data['results']['chattr']))
self.assertEquals(self.tr.value(), "\n".join(self.data['results']['chattr']))
def test_umask_command(self):
self.proto.lineReceived('umask\n')
self.assertEquals(self.tr.value(),"\n".join(self.data['results']['umask']))
self.assertEquals(self.tr.value(), "\n".join(self.data['results']['umask']))
def test_set_command(self):
self.proto.lineReceived('set\n')
self.assertEquals(self.tr.value(),"\n".join(self.data['results']['set']))
self.assertEquals(self.tr.value(), "\n".join(self.data['results']['set']))
def test_unset_command(self):
self.proto.lineReceived('unset\n')
self.assertEquals(self.tr.value(),"\n".join(self.data['results']['unset']))
self.assertEquals(self.tr.value(), "\n".join(self.data['results']['unset']))
def test_export_command(self):
self.proto.lineReceived('export\n')
self.assertEquals(self.tr.value(),"\n".join(self.data['results']['export']))
self.assertEquals(self.tr.value(), "\n".join(self.data['results']['export']))
def test_alias_command(self):
self.proto.lineReceived('alias\n')
self.assertEquals(self.tr.value(),"\n".join(self.data['results']['alias']))
self.assertEquals(self.tr.value(), "\n".join(self.data['results']['alias']))
def test_jobs_command(self):
self.proto.lineReceived('jobs\n')
self.assertEquals(self.tr.value(),"\n".join(self.data['results']['jobs']))
self.assertEquals(self.tr.value(), "\n".join(self.data['results']['jobs']))
def test_kill_command(self):
self.proto.lineReceived('/bin/kill\n')
self.assertEquals(self.tr.value(),"\n".join(self.data['results']['kill']))
self.assertEquals(self.tr.value(), "\n".join(self.data['results']['kill']))
def test_pkill_command(self):
self.proto.lineReceived('/bin/pkill\n')
self.assertEquals(self.tr.value(),"\n".join(self.data['results']['kill']))
self.assertEquals(self.tr.value(), "\n".join(self.data['results']['kill']))
def test_killall_command(self):
self.proto.lineReceived('/bin/killall\n')
self.assertEquals(self.tr.value(),"\n".join(self.data['results']['kill']))
self.assertEquals(self.tr.value(), "\n".join(self.data['results']['kill']))
def test_killall5_command(self):
self.proto.lineReceived('/bin/killall5\n')
self.assertEquals(self.tr.value(),"\n".join(self.data['results']['kill']))
self.assertEquals(self.tr.value(), "\n".join(self.data['results']['kill']))
def test_su_command(self):
self.proto.lineReceived('su\n')
self.assertEquals(self.tr.value(),"\67n".join(self.data['results']['su']))
self.assertEquals(self.tr.value(), "\67n".join(self.data['results']['su']))
def test_chown_command(self):
self.proto.lineReceived('chown\n')
self.assertEquals(self.tr.value(),"\n".join(self.data['results']['chown']))
self.assertEquals(self.tr.value(), "\n".join(self.data['results']['chown']))
def test_chgrp_command(self):
self.proto.lineReceived('chgrp\n')
self.assertEquals(self.tr.value(),"\n".join(self.data['results']['chgrp']))
self.assertEquals(self.tr.value(), "\n".join(self.data['results']['chgrp']))
def tearDown(self):

View File

@ -2,48 +2,54 @@
from setuptools import setup, find_packages
setup (
name = "Cowrie",
version = "1.0",
description = "Cowrie SSH/Telnet Honeypot.",
maintainer = "Michel Oosterhof",
maintainer_email = "michel@oosterhof.net",
keywords = "ssh telnet honeypot",
url = "https://github.com/micheloosterhof/cowrie",
packages = find_packages(),
setup(
name="Cowrie",
version="1.0",
description="Cowrie SSH/Telnet Honeypot.",
maintainer="Michel Oosterhof",
maintainer_email="michel@oosterhof.net",
keywords="ssh telnet honeypot",
url="https://github.com/micheloosterhof/cowrie",
packages=find_packages(),
include_package_data=True,
package_data = { '': ['*.md'] },
scripts = ["bin/fsctl",
"bin/asciinema",
"bin/cowrie",
"bin/createfs",
"bin/playlog"],
install_requires = ["twisted>=17.1.0",
"cryptography>=0.9.1",
"configparser",
"pyopenssl",
"pyparsing",
"packaging",
"appdirs>=1.4.0",
"python-pyasn1",
"python-gmpy2",
"python-mysqldb",
"klein>=15.0.0",
"treq>=15.0.0",
"python-dateutil",
"service_identity>=14.0.0"],
entry_points = {'console_scripts':
['run-the-app = deployme:main']},
package_data={'': ['*.md']},
scripts=[
"bin/fsctl",
"bin/asciinema",
"bin/cowrie",
"bin/createfs",
"bin/playlog"
],
install_requires=[
"twisted>=17.1.0",
"cryptography>=0.9.1",
"configparser",
"pyopenssl",
"pyparsing",
"packaging",
"appdirs>=1.4.0",
"python-pyasn1",
"python-gmpy2",
"python-mysqldb",
"klein>=15.0.0",
"treq>=15.0.0",
"python-dateutil",
"service_identity>=14.0.0"
],
entry_points={
'console_scripts': ['run-the-app = deployme:main']
},
extras_require = { 'csirtg': ["csirtgsdk>=0.0.0a17"],
'dshield': ["requests"],
'elasticsearch': ["pyes"],
'mysql': ["mysqlclient"],
'mongodb': ["pymongo"],
'rethinkdblog': ["rethinkdb"],
's3': ["botocore"],
'slack': ["slackclient"],
'splunklegacy': ["splunk-sdk"],
'influxdb': ["influxdb"]}
extras_require={
'csirtg': ["csirtgsdk>=0.0.0a17"],
'dshield': ["requests"],
'elasticsearch': ["pyes"],
'mysql': ["mysqlclient"],
'mongodb': ["pymongo"],
'rethinkdblog': ["rethinkdb"],
's3': ["botocore"],
'slack': ["slackclient"],
'splunklegacy': ["splunk-sdk"],
'influxdb': ["influxdb"]
}
)