Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

End to End Encryption for using K-9 Mail/Open Keychain #71

Open
DanielLester83 opened this issue Sep 13, 2020 · 0 comments
Open

End to End Encryption for using K-9 Mail/Open Keychain #71

DanielLester83 opened this issue Sep 13, 2020 · 0 comments

Comments

@DanielLester83
Copy link

DanielLester83 commented Sep 13, 2020

I made a simple bodged example of how I made a "encrypt, sign and forward everything to 1 email" setup for reading on K-9 Mail/Open Keychain which didn't like zeyple's attachment style of encryption. I used "os.popen" instead of the gpg module (which seems lacking). (Using curl with Gmail also requires allowing less secure transfers for the account which isn't ideal).

Perhaps this will be helpful in making a more robust solution as I'm not really familiar with python.

/usr/local/bin/zeyple.py

#!/usr/bin/env python                                                                               
# -*- coding: utf-8 -*-                                                                             
import sys                                                                                          
import os
                                                                          
try:                                                                                                    
     from configparser import SafeConfigParser  # Python 3
except ImportError:
     from ConfigParser import SafeConfigParser  # Python 2
                                                                                                           
# Boiler plate to avoid dependency on six                                                           
# BBB: Python 2.7 support                                                                           
PY3K = sys.version_info > (3, 0)

#if __name__ == '__main__':                                                                         
if True:                                                                                                
    recipients = sys.argv[1:]
    # BBB: Python 2.7 support
    binary_stdin = sys.stdin.buffer if PY3K else sys.stdin
                                              
    message = binary_stdin.read()

    f = open("/home/zeyple/.gnupg/message.enc", "w")

    text = message                                                                                      
    posa = text.find("Subject: ")
    subject = text[posa:].split("\n",1)                                                                 
    subject = subject[0]

    text = text.partition("\n\n")          
                                                             
    f.write( text[2] )                                                                                 
    f.close()                                                                                           

    os.popen("gpg --homedir /home/zeyple/.gnupg --batch --yes  --passphrase=CERTPASSGOESHERE --pinentry-mode loopback --always-trust -ea --sign -u \"John Smith <[email protected]>\" -r \"John Smith <[email protected]>\" -o - /home/zeyple/.gnupg/message.enc > /home/zeyple/.gnupg/message2.enc")

 #Needed for curl
    os.popen('sed -i -E \":a;N;$!ba;s/\r{0,1}\n/\\n/g\" /home/zeyple/.gnupg/message2.enc')

    f = open("/home/zeyple/.gnupg/message2.enc", "r")

    text = f.read()                                                                                    
    text = text.partition("-----")
    body = text[2]                                                                                      

    f.close()

    os.popen("echo \"" + subject + " \n\n-----" + body + "\" | /usr/bin/cur l--retry 5 --url smtps://smtp.gmail.com:465 --mail-from [email protected] --mail-rcpt [email protected] --user [email protected]:fakeemailpassword --ssl-reqd --insecure --silent --ciphers ECDHE-RSA-AES128-GCM-SHA256 -T -")

    os.remove('/home/zeyple/.gnupg/message.enc')                                                        
    os.remove('/home/zeyple/.gnupg/message2.enc')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant