Skip to content

kkatayama/Gee-Mail

Repository files navigation

Gee-Mail

A secure asynchronous (same-machine) message platform
All passwords are hashed (sha256) + salted + stretched
All messages are encrypted with AES-256-CFB_MODE and passphrase is hashed + salted + stretched


Test users

username: andy
password: #Andy1#

username: teddy
password: #Teddy1#

username: alp
password: #Alp1#

Test user passphrases for emails from 3 users

andy  | novocin
teddy | secret
alp   | alparslan
kevin | kevinzh

ubuntu (cloud 9)

Install Libraries

sudo apt-get install libcrypto++-dev libcrypto++-doc libcrypto++-utils
git clone https://github.com/kkatayama/Gee-Mail.git

osx

Install Libraries

brew install boost
NO LONGER WORKS: brew install cryptopp
wget https://github.com/weidai11/cryptopp/archive/refs/tags/CRYPTOPP_8_8_0.tar.gz
tar xvf cryptopp-CRYPTOPP_8_8_0.tar.gz
cd cryptopp-CRYPTOPP_8_8_0
make -j 8
sudo make install
cd ..

### Download Source

git clone https://github.com/kkatayama/Gee-Mail.git

compile and run

$ make

$ ./gee-mail
*********************************************************************************
* CPEG-676 Secure Systems: Project 4: Gee-Mail                                  *
*********************************** Authors *************************************
* Alparslan Sari                                                                *
* Kaoru (Teddy) Katayama                                                        *
* Pengcheng (Kevin) Zhou                                                        *
*********************************************************************************
+-------------------------------------------------------------------------------+
| GeeMail Messaging Platform: Welcome Page                                      |
+-------------------------------------------------------------------------------+
Would you like to login or register a new user?
[1] Login
[2] Register
[3] Quit
: 1
+-------------------------------------------------------------------------------+
| GeeMail Messaging Platform: Login Page                                        |
+-------------------------------------------------------------------------------+
username: teddy
password:
success...
+--------------------------------------------------------------+
| GeeMail Messaging Platform: Main Menu                        |
+--------------------------------------------------------------+
| Welcome teddy, you have 1 messages                           |
+--------------------------------------------------------------+
+-------------------------------------------------------------------------------------------------------+
|    SENDER    |  MESSAGE SENT DATE TIME  |  MESSAGE READ DATE TIME  |  STATUS  |     SUBJECT TITLE     |
+-------------------------------------------------------------------------------------------------------+
| andy         | Sat Jul 22 01:41:40 2023 |           -              | not read | Hi Teddy              |
+-------------------------------------------------------------------------------------------------------+

Would you like to read or write a message?
[1] Read Message
[2] Write Message
[3] Delete Message
[4] Logout
: 1
+-------------------------------------------------------------------------------+
| GeeMail Messaging Platform: Reading a message                                 |
+-------------------------------------------------------------------------------+
+--------------------------------------------------------------------------------------------------------------+
| [ID] |    SENDER    |  MESSAGE SENT DATE TIME  |  MESSAGE READ DATE TIME  |  STATUS  |     SUBJECT TITLE     |
+--------------------------------------------------------------------------------------------------------------+
  [ 1] | andy         | Sat Jul 22 01:41:40 2023 |           -              | not read | Hi Teddy              |
+--------------------------------------------------------------------------------------------------------------+

Which message would you like to read?
ID: 1

Enter the passphrase for this message
:
   From: andy
     To: teddy
  Title: Hi Teddy
Message: Test message for Teddy from Andy!

Press Enter to return to main menu...
+--------------------------------------------------------------+
| GeeMail Messaging Platform: Main Menu                        |
+--------------------------------------------------------------+
| Welcome teddy, you have 1 messages                           |
+--------------------------------------------------------------+
+-------------------------------------------------------------------------------------------------------+
|    SENDER    |  MESSAGE SENT DATE TIME  |  MESSAGE READ DATE TIME  |  STATUS  |     SUBJECT TITLE     |
+-------------------------------------------------------------------------------------------------------+
| andy         | Sat Jul 22 01:41:40 2023 | Sat Jul 22 01:42:13 2023 | read     | Hi Teddy              |
+-------------------------------------------------------------------------------------------------------+

Would you like to read or write a message?
[1] Read Message
[2] Write Message
[3] Delete Message
[4] Logout
: 2
+-------------------------------------------------------------------------------+
| GeeMail Messaging Platform: Writing a message                                 |
+-------------------------------------------------------------------------------+
|     Sender: teddy
Enter Recepient: andy
+-------------------------------------------------------------------------------+
| GeeMail Messaging Platform: Writing a message                                 |
+-------------------------------------------------------------------------------+
|     Sender: teddy
|  Recepient: andy
Enter a title for your message: Hello Andy!
+-------------------------------------------------------------------------------+
| GeeMail Messaging Platform: Writing a message                                 |
+-------------------------------------------------------------------------------+
|     Sender: teddy
|  Recepient: andy
|      title: Hello Andy!
Enter your message: This is a test message for Andy from Teddy!
+-------------------------------------------------------------------------------+
| GeeMail Messaging Platform: Writing a message                                 |
+-------------------------------------------------------------------------------+
|     Sender: teddy
|  Recepient: andy
|      title: Hello Andy!
|    message: This is a test message for Andy from Teddy!
Enter a passphrase: secret
+-------------------------------------------------------------------------------+
| GeeMail Messaging Platform: Writing a message                                 |
+-------------------------------------------------------------------------------+
|     Sender: teddy
|  Recepient: andy
|      title: Hello Andy!
|    message: This is a test message for Andy from Teddy!
| passphrase: secret
|  timestamp: Sat Jul 22 01:42:46 2023
took: 0.975831
Message successfully written.
Please remember your passphrase.

Press Enter to return to main menu...
+--------------------------------------------------------------+
| GeeMail Messaging Platform: Main Menu                        |
+--------------------------------------------------------------+
| Welcome teddy, you have 1 messages                           |
+--------------------------------------------------------------+
+-------------------------------------------------------------------------------------------------------+
|    SENDER    |  MESSAGE SENT DATE TIME  |  MESSAGE READ DATE TIME  |  STATUS  |     SUBJECT TITLE     |
+-------------------------------------------------------------------------------------------------------+
| andy         | Sat Jul 22 01:41:40 2023 | Sat Jul 22 01:42:13 2023 | read     | Hi Teddy              |
+-------------------------------------------------------------------------------------------------------+

Would you like to read or write a message?
[1] Read Message
[2] Write Message
[3] Delete Message
[4] Logout
: 4
*********************************************************************************
* CPEG-676 Secure Systems: Project 4: Gee-Mail                                  *
*********************************** Authors *************************************
* Alparslan Sari                                                                *
* Kaoru (Teddy) Katayama                                                        *
* Pengcheng (Kevin) Zhou                                                        *
*********************************************************************************
+-------------------------------------------------------------------------------+
| GeeMail Messaging Platform: Welcome Page                                      |
+-------------------------------------------------------------------------------+
Would you like to login or register a new user?
[1] Login
[2] Register
[3] Quit
: 1
+-------------------------------------------------------------------------------+
| GeeMail Messaging Platform: Login Page                                        |
+-------------------------------------------------------------------------------+
username: andy
password:
success...
+--------------------------------------------------------------+
| GeeMail Messaging Platform: Main Menu                        |
+--------------------------------------------------------------+
| Welcome andy, you have 1 messages                            |
+--------------------------------------------------------------+
+-------------------------------------------------------------------------------------------------------+
|    SENDER    |  MESSAGE SENT DATE TIME  |  MESSAGE READ DATE TIME  |  STATUS  |     SUBJECT TITLE     |
+-------------------------------------------------------------------------------------------------------+
| teddy        | Sat Jul 22 01:42:46 2023 |           -              | not read | Hello Andy!           |
+-------------------------------------------------------------------------------------------------------+

Would you like to read or write a message?
[1] Read Message
[2] Write Message
[3] Delete Message
[4] Logout
: 1
+-------------------------------------------------------------------------------+
| GeeMail Messaging Platform: Reading a message                                 |
+-------------------------------------------------------------------------------+
+--------------------------------------------------------------------------------------------------------------+
| [ID] |    SENDER    |  MESSAGE SENT DATE TIME  |  MESSAGE READ DATE TIME  |  STATUS  |     SUBJECT TITLE     |
+--------------------------------------------------------------------------------------------------------------+
  [ 1] | teddy        | Sat Jul 22 01:42:46 2023 |           -              | not read | Hello Andy!           |
+--------------------------------------------------------------------------------------------------------------+

Which message would you like to read?
ID: 1

Enter the passphrase for this message
:
   From: teddy
     To: andy
  Title: Hello Andy!
Message: This is a test message for Andy from Teddy!

Press Enter to return to main menu...
+--------------------------------------------------------------+
| GeeMail Messaging Platform: Main Menu                        |
+--------------------------------------------------------------+
| Welcome andy, you have 1 messages                            |
+--------------------------------------------------------------+
+-------------------------------------------------------------------------------------------------------+
|    SENDER    |  MESSAGE SENT DATE TIME  |  MESSAGE READ DATE TIME  |  STATUS  |     SUBJECT TITLE     |
+-------------------------------------------------------------------------------------------------------+
| teddy        | Sat Jul 22 01:42:46 2023 | Sat Jul 22 01:49:27 2023 | read     | Hello Andy!           |
+-------------------------------------------------------------------------------------------------------+

Would you like to read or write a message?
[1] Read Message
[2] Write Message
[3] Delete Message
[4] Logout
: 4
*********************************************************************************
* CPEG-676 Secure Systems: Project 4: Gee-Mail                                  *
*********************************** Authors *************************************
* Alparslan Sari                                                                *
* Kaoru (Teddy) Katayama                                                        *
* Pengcheng (Kevin) Zhou                                                        *
*********************************************************************************
+-------------------------------------------------------------------------------+
| GeeMail Messaging Platform: Welcome Page                                      |
+-------------------------------------------------------------------------------+
Would you like to login or register a new user?
[1] Login
[2] Register
[3] Quit
: 3

GeeMail API

Sqlite Database Tables

users: |username|password|attempts|
messages: |messageid|sender|receiver|title|message|writetime|readtime|passphrase|

Helper Functions

string getTime()

returns datetime as a string with newline character removed

int getChoice()

returns int only if user inputs an integer

Login and Registraion

bool check_password(string pass)

returns true if password is strong
returns false if password is weak

int userRegister(string username, string password)

returns 0: successfully registered
returns 1: username is taken
returns 2: password is too weak

bool userLogin(string username, string pass)

returns true if login successful
returns false if login failed

Read, Write, and Delete Messages

int countMessages(string receiver)

returns number of messages for a given user

bool checkPassphrase(string messageid, string passphrase)

returns true if passphrase matches
returns false if bad passphrase

vector <string> getSenders(string receiver)

returns string array of unique senders

vector <string> getMessages(string sender, string receiver)

returns string array of all messages from a given sender
each string in the array is tab-delimeted
string format: writetime + "\t" + readtime +"\t" + messageid + "\t" + title

string getMessage(string messageid);

returns plaintext string of a message given its id

writeMessage(string username, string receiver, string title, string message, string writetime, string readtime, string passphrase);

saves a message into the database

deleteMessage(string messageid)

deletes a message given its id

Backend Functions

string secure_hash(string secret, string salt, int stretch);

returns sha256 string

string* encrypt(string plaintext, string passphrase);

returns AES-256 encrypted string array [iv, key, ciphertext]

string decrypt(string ciphertext, string key, string iv);

returns plaintext string

database db("<DATABASE_NAME>");

connects to sqlite3 database

command cmd(db, "INSERT INTO users (username, password) VALUES (:username, :password)");
cmd.bind(":username", username, nocopy);
cmd.bind(":password", password, nocopy);
cmd.execute();

executes db query with bind parameters

query qry(db, "SELECT password FROM users WHERE username = :user");
qry.bind(":user", username, nocopy);
for (auto v : qry) {
  string pw;
  v.getter() >> pw;
  cout << "\t" << pw << endl;  
}

get data from db query

About

A secure asynchronous (same-machine) message platform

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors