Bitcoin Forum
September 24, 2018, 04:50:00 AM *
News: ♦♦ New info! Bitcoin Core users absolutely must upgrade to previously-announced 0.16.3 [Torrent]. All Bitcoin users should temporarily trust confirmations slightly less. More info.
   Home   Help Search Donate Login Register  
Pages: [1]
Author Topic: VPS script for GPG & Gmail  (Read 579 times)
Hero Member
Offline Offline

Activity: 902
Merit: 1000

Crypto Geek

View Profile
January 16, 2013, 11:36:26 PM

 Now FireGPG is dead if you want to quickly verify a message and sender easily you will need to use Crome-cr or get copy and pasting.

It would be much more portable to have a VPS (or home server or Raspberry Pi) checking your drafts folder every 10 seconds for trigger commands such as **SIGN** or just scanning your inbox for .asc attachments, verifying and then labelling as such.

 I tried to do this before but I've lost the code.

  Good idea?

  I know a lot of Bitcoin users use GPG both for emails on important things and also for #Bitcoin-otc. It would be useful to have a portable interface for this - no more risking carrying around your private key on USB and you can access gmail via 2 factor auth so this would be really handy. You are then only risking your comms with USA big corp and quangos (Google, FBI, NSA) and the private key is still on your server so that should be enough for a lot of people.

 So, what would be the tool to start with that can be easily scripted for checking email servers?

 I would love to see a script pasted into here eventually. Perhaps the first goal should be checking the inbox for .asc attachments

Crypto supporter!
Hero Member
Offline Offline

Posts: 1537764600

View Profile Personal Message (Offline)

Reply with quote  #2

Report to moderator
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
Hero Member
Offline Offline

Activity: 902
Merit: 1000

Crypto Geek

View Profile
January 16, 2013, 11:43:44 PM

#!/usr/bin/env python
import imaplib, os, sys, re, time, email, random, string


srv = imaplib.IMAP4_SSL('', 993)
srv.login(username, password)
status, count ='[Google Mail]/Drafts')
for mailNum in count:
        if (mailNum == '0'):
                print "No matching emails found"

        typ, msgData = srv.fetch(mailNum, '(RFC822)')
        for response_part in msgData:
                if isinstance(response_part, tuple):
                        msg = email.message_from_string(response_part[1])
                        payload = msg.get_payload()
                        subject = msg['subject']
                        toLine = msg['to']
                        fromLine = msg['from']

        regex = re.compile('.*\*\*SIGN\*\*')
        m = regex.match(subject)

        if not m:
                print "Message \"%s\" does not match our search" % (subject)
                print "Message \"%s\" matches our search" % (subject)

        randStr = ''.join(random.choice(string.ascii_uppercase) for x in range(4))
        plainFileName = '/tmp/imap-signer-'+randStr
        msgFile = open(plainFileName,'w')
        os.system('gpg --clearsign ' + plainFileName)

        gpgFH = open(plainFileName+'.asc', 'r')
        newPayload =

        newEmail = email.message.Message()
        newEmail['Subject'] = subject[0:subject.find('**SIGN**')]+'**SIGNED**'
        newEmail['From'] = fromLine
        newEmail['To'] = toLine
        newEmail.set_payload(newPayload+'\n'), '+FLAGS', r'(\Deleted)')
        srv.append('[Google Mail]/Drafts', '',
imaplib.Time2Internaldate(time.time()), str(newEmail))


Crypto supporter!
Pages: [1]
Jump to:  

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!