commit 916b5bf7fa8cff0eee9623bdd188fa902ea49699 Author: Michel Oosterhof <michel@oosterhof.net> Date: Mon Apr 2 00:39:28 2018 +0400 string handling commit 1d52bb7a85cace371717e7db1f88cd1eff608e1c Author: Michel Oosterhof <michel@oosterhof.net> Date: Sun Apr 1 22:03:13 2018 +0400 arch already logged in server.py commit 2f4fee8bdf3b9f129cf4315bd6c20ef38e44d582 Author: Michel Oosterhof <michel@oosterhof.net> Date: Sun Apr 1 22:02:06 2018 +0400 get binary contents from file system commit 1043bde0328de9d54c72cdb00a20b5ccd6c3f4cc Author: Michel Oosterhof <michel@oosterhof.net> Date: Sun Apr 1 21:42:34 2018 +0400 use 'arch' as multi value architecture. commit 6d86d20acb7e4affa8cc690d45995c40d5f0542f Merge:201a923c9e5a44Author: Michel Oosterhof <michel@oosterhof.net> Date: Sun Apr 1 15:50:57 2018 +0400 Merge remote-tracking branch 'oliveriandrea/multi_arch' into multi-arch-michel commitc9e5a44a6aAuthor: oliveriandrea <oliveriandrea@gmail.com> Date: Wed Mar 28 17:57:52 2018 +0200 Introduction of self.arch = 'linux-x64-lsb' commitf54f9ae67dAuthor: oliveriandrea <oliveriandrea@gmail.com> Date: Wed Mar 28 17:56:59 2018 +0200 moved to server commita22bf01855Author: oliveriandrea <oliveriandrea@gmail.com> Date: Wed Mar 28 17:56:09 2018 +0200 fake_arch to arch, self.arch -> self.server.arch commit1c7ca09449Author: oliveriandrea <oliveriandrea@gmail.com> Date: Wed Mar 28 17:52:51 2018 +0200 fake_arch to arch commitf706f6568eAuthor: oliveriandrea <oliveriandrea@gmail.com> Date: Wed Mar 28 17:51:37 2018 +0200 fake_arch to arch commitaf95806cebAuthor: oliveriandrea <oliveriandrea@gmail.com> Date: Wed Mar 28 12:04:41 2018 +0200 move fake_arch and archs_emulated under [shell] commitbe72123228Author: oliveriandrea <oliveriandrea@gmail.com> Date: Wed Mar 28 11:55:49 2018 +0200 fake_arch now is under [shell] commit32609bf7ceAuthor: oliveriandrea <oliveriandrea@gmail.com> Date: Wed Mar 28 11:48:58 2018 +0200 Move fake arch configuration under [shell] commit952e87d0b9Author: oliveriandrea <oliveriandrea@gmail.com> Date: Thu Mar 22 10:48:52 2018 +0100 Update README commit8adde62f33Author: oliveriandrea <oliveriandrea@gmail.com> Date: Thu Mar 22 10:47:17 2018 +0100 Collection of dummy executables commite79c2d77c1Author: oliveriandrea <oliveriandrea@gmail.com> Date: Thu Mar 22 10:45:35 2018 +0100 Source code of the dummy executables commitdb2ccf5297Author: oliveriandrea <oliveriandrea@gmail.com> Date: Thu Mar 22 10:44:52 2018 +0100 README for the sources commit97d5dc2b3dAuthor: oliveriandrea <oliveriandrea@gmail.com> Date: Thu Mar 22 10:37:47 2018 +0100 Patch to cat,head,tail and dd in order to report fake arch commit05543a1490Author: oliveriandrea <oliveriandrea@gmail.com> Date: Thu Mar 22 10:36:31 2018 +0100 Update the configuration in order to support multiarch emulation commit81b29f2dd2Author: oliveriandrea <oliveriandrea@gmail.com> Date: Thu Mar 22 10:35:36 2018 +0100 Added param table in SQL schemas commit827c47ff71Author: oliveriandrea <oliveriandrea@gmail.com> Date: Thu Mar 22 10:34:47 2018 +0100 Added params table commitfa7b467950Author: oliveriandrea <oliveriandrea@gmail.com> Date: Thu Mar 22 10:27:15 2018 +0100 Generate random choice for the architecture
How to Send Cowrie Output to a MySQL Database
Prerequisites
- Working Cowrie installation
- MySQL Server installation
Installation
$ sudo apt-get install mysql-server libmysqlclient-dev python-mysqldb
$ su - cowrie
$ source cowrie/cowrie-env/bin/activate
$ pip install mysqlclient
Previously MySQL-python was used. Only if you run into isses with mysqlclient, try this instead:
$ pip install MySQL-python
MySQL Configuration
First create an empty database named 'cowrie'.
$ mysql -u root -p
CREATE DATABASE cowrie;
Create a cowrie user account for the database and grant access privileges:
All Privileges:
GRANT ALL ON cowrie.* TO 'cowrie'@'localhost' IDENTIFIED BY 'PASSWORD HERE';
Restricted Privileges:
Alternatively you can grant the cowrie account with less privileges. The following command grants the account with the bare minimum required for the output logging to function:
GRANT INSERT, SELECT, UPDATE ON cowrie.* TO 'cowrie'@'localhost' IDENTIFIED BY 'PASSWORD HERE';
Apply the privilege settings and exit mysql.
FLUSH PRIVILEGES;
exit
Next, log into the MySQL database using the cowrie account to verify proper access privileges and load the database schema provided in the doc/sql/ directory:
$ cd ~/cowrie/doc/sql/
$ mysql -u cowrie -p
USE cowrie;
source mysql.sql;
exit
Cowrie Configuration
Uncomment and update the following entries to ~/cowrie/cowrie.cfg under the Output Plugins section:
[output_mysql]
host = localhost
database = cowrie
username = cowrie
password = PASSWORD HERE
port = 3306
debug = false
Restart Cowrie
$ cd ~/cowrie/bin/
$ ./cowrie restart
Verify That the MySQL Output Engine Has Been Loaded
Check the end of the ~/cowrie/log/cowrie.log to make sure that the MySQL output engine has loaded successfully.
$ cd ~/cowrie/log/
$ tail cowrie.log
Example expected output:
2017-11-27T22:19:44-0600 [-] Loaded output engine: jsonlog
2017-11-27T22:19:44-0600 [-] Loaded output engine: mysql
...
2017-11-27T22:19:58-0600 [-] Ready to accept SSH connections
Confirm That Events are Logged to the MySQL Database
Wait patiently for a new login attempt to occur. Use tail like before to quickly check if any activity has been recorded in the cowrie.log file.
Once a login event has occurred, log back into the MySQL database and verify that the event was recorded:
$ mysql -u cowrie -p
USE cowrie;
SELECT * FROM auth;
Example output:
+----+--------------+---------+----------+-------------+---------------------+
| id | session | success | username | password | timestamp |
+----+--------------+---------+----------+-------------+---------------------+
| 1 | a551c0a74e06 | 0 | root | 12345 | 2017-11-27 23:15:56 |
| 2 | a551c0a74e06 | 0 | root | seiko2005 | 2017-11-27 23:15:58 |
| 3 | a551c0a74e06 | 0 | root | anko | 2017-11-27 23:15:59 |
| 4 | a551c0a74e06 | 0 | root | 123456 | 2017-11-27 23:16:00 |
| 5 | a551c0a74e06 | 0 | root | dreambox | 2017-11-27 23:16:01 |
...