Last active
March 31, 2016 21:37
-
-
Save Hainish/09b964c117590122a17863ca4661846d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import fileinput | |
import re | |
import subprocess | |
contents = "" | |
for line in fileinput.input(): | |
contents = contents + line | |
from_address = re.match('(From )([^\s]+) ', contents).group(2) | |
p = subprocess.Popen(['gpg2','--decrypt'], stdin=subprocess.PIPE, stderr=subprocess.PIPE) | |
p.stdin.write(contents) | |
gpg_err = p.communicate()[1] | |
p.stdin.close() | |
reply = """-----BEGIN PGP SIGNED MESSAGE----- | |
Hash: SHA1 | |
<begin canned response> | |
Hello! | |
It looks like you've sent me an email encrypted to my old PGP key. Please be informed that I have a new key. Follow the below instructions to use it: | |
Command Line: | |
gpg2 --recv-keys 977A04EC512A9D0DB4A56E0ECDCAE8ED6842C592 | |
gpg2 --delete-keys 3CCDBB7355D1758F549354D20B123309D3366755 | |
OSX (I think this works): | |
Go into your GPG Keychain app, right-click and delete my key. Then, download the new key from here: | |
https://www.eff.org/files/2015/06/06/6842c592.txt | |
Save it as a .pgp file on your desktop, and drag it into to your GPG Keychain app window. | |
Thanks! | |
Bill | |
<end canned response> | |
-----BEGIN PGP SIGNATURE----- | |
Version: GnuPG v2 | |
iQEcBAEBAgAGBQJW/ZV7AAoJEAsSMwnTNmdVYD0H/ip24it5Y8ZejPgPYBoYpYHJ | |
7/nxIvSeiVsCGaxJCjJ3jWjCsA6QuEVQhzZFRPNALZKb22D0WNQ0dGtGo1oKl0s7 | |
GTUNTda5bsyJ19IxJgfdqD41aNbFGCdJAMfdnaW9luHid3LAzjfqdEhaKHB/Ik7s | |
VNb8XYtR8z+fnZ0H8Nk/yE/u//Gq399m1G9+ZDYmf28uDGIHSin1G1PqAaatgBgX | |
AwG6wr6WbNNSThw9nz7Ensa+zIdxh6xr2f/RczvE0+ZC8YF2dalPmvNWvJmdFj8b | |
OaT09okeV6iqOc0yTmuQCjqaxofP+e1M9n+aDdCUGn4YV2C3Ijilg3jI3jiR46U= | |
=n6va | |
-----END PGP SIGNATURE----- | |
""" | |
if re.search("encrypted with RSA key, ID 130933BE", gpg_err): | |
if not re.search("encrypted with RSA key, ID E1368FB5", gpg_err): | |
p = subprocess.Popen("mail -s 'Please use my new PGP key' " + from_address, shell=True, stdin=subprocess.PIPE) | |
p.stdin.write(reply) | |
p.stdin.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment