Re: Hashcash
On Fri, Apr 15, 2011 at 03:47:35PM +0200, Simon Ruderich wrote: > I'm not entirely sure what you're trying to do. But > $display_filter should just read the message from stdin and pass > it to stdout. From what I can see that's what your program does > so it should be fine. https://github.com/atoponce/Penny-Red -- . o . o . o . . o o . . . o . . . o . o o o . o . o o . . o o o o . o . . o o o o . o o o signature.asc Description: Digital signature
Re: Hashcash
On Sun, Mar 27, 2011 at 03:10:19PM -0600, Aaron Toponce wrote: > [snip] > > # converting a list to a file-type object for parsing rfc822 headers > original = sys.stdin.readlines() > email = StringIO.StringIO(''.join(original)) > message = rfc822.Message(email) > > # ... snip ... > > # reprint the original mail, as well as the status of the hashcash check > for line in original: > if len(line) == 1 and len(token_status) > 0: > print > for status in token_status: > print status > token_status = [] > else: > print line, > > Thanks again. Hi, I'm not entirely sure what you're trying to do. But $display_filter should just read the message from stdin and pass it to stdout. From what I can see that's what your program does so it should be fine. To test it just run it in a shell: python verify_hashcash.py < path/to/mbox/file/with/one/mail The following script is the simplest $display_filter doing nothing: #!/bin/sh cat If it works in the shell, it should work fine as $display_filter, if not, please tell us. Regards, Simon -- + privacy is necessary + using gnupg http://gnupg.org + public key id: 0x92FEFDB7E44C32F9 pgpcrLFbpJmCu.pgp Description: PGP signature
Re: Hashcash
On Sun, Mar 27, 2011 at 02:59:12PM -0600, Aaron Toponce wrote: > original = sys.stdin.readlines() > email = StringIO.StringIO(''.join(original)) > message = rfc822.Message(email) > > # ... snip several lines of code ... > > for line in original: > if len(line) == 1 and len(token_status) > 0: > print > for status in token_status: > print status > token_status = [] > else: > print line, Somehow, the code lost its formatting, and I forgot to attach the Python script. Let's try this again: # converting a list to a file-type object for parsing rfc822 headers original = sys.stdin.readlines() email = StringIO.StringIO(''.join(original)) message = rfc822.Message(email) # ... snip ... # reprint the original mail, as well as the status of the hashcash check for line in original: if len(line) == 1 and len(token_status) > 0: print for status in token_status: print status token_status = [] else: print line, Thanks again. -- . o . o . o . . o o . . . o . . . o . o o o . o . o o . . o o o o . o . . o o o o . o o o #!/usr/bin/env python import rfc822 import StringIO import subprocess import sys tokens = [] token_status = [] # converting a list to a file-type object for parsing rfc822 headers original = sys.stdin.readlines() email = StringIO.StringIO(''.join(original)) message = rfc822.Message(email) # check for the presence of "X-Hashcash" and "Hashcash" headers if message.has_key("X-Hashcash"): for list in message.getheaders("X-Hashcash"): tokens.append(list) if message.has_key("Hashcash"): for list in message.getheaders("Hashcash"): tokens.append(list) # check each token if len(tokens) > 0: for token in tokens: bits = token.split(":")[1] resource = token.split(":")[3] token_status.append(subprocess.call("hashcash -cdb %s -r %s -f /home/aaron/.mutt/hashcash.db %s" % (bits,resource,token), shell=True, stdout=subprocess.PIPE)) # reprint the original mail, as well as the status of the hashcash check for line in original: if len(line) == 1 and len(token_status) > 0: print for status in token_status: print status token_status = [] else: print line, #subprocess.Popen("less", shell=True) signature.asc Description: Digital signature
Re: Hashcash
On Fri, Mar 25, 2011 at 07:10:19AM -0600, Aaron Toponce wrote: > Now to start working on the verification process. I figure I can use > $display_filter for that, and just not filter anything, but execute another > Python script. So, now I'm working on the verification script, and I'm struggling getting it to work with $display_filter. It's a Python script. When the script doesn't have anything in it, the message isn't displayed. This isn't what I would expect. I would expect the message to still display, unless the script has logic that performs otherwise. I haven't tested this with a shell script just running sed against the file, so maybe I should try that. However, it seems that I have to reprint the entire message with Python (which is fine, because I want to add lines to the output, based on some logic in the Python script). Here's the relevent logic: original = sys.stdin.readlines() email = StringIO.StringIO(''.join(original)) message = rfc822.Message(email) # ... snip several lines of code ... for line in original: if len(line) == 1 and len(token_status) > 0: print for status in token_status: print status token_status = [] else: print line, The "original" variable is the original message, read from STDIN, as $display_filter does. The "email" variable is the message, converted to a file-type object, so I can use the rcf822 module, getting access to the headers easily. The "for" loop at the end is reprinting the mail, putting the status of "hashcash" in the "status" variable in the message, right after the headers, and before the body of the mail. I'm looking for a blank line, as per RFC822 (and subsequent follow-up RFCs), there bust exist a blank line before the body after the headers. I'm looking for this line to print my message to the user. The problem I'm experiencing, I think, is with the $PAGER. Everything displays fine, except when I wish to PGUP/PGDN the message doesn't display correctly, and gets all jumbled up. I'm assuming it has something to do with writing the message line-by-line, but I'm not sure. Can someone help me with this? I've attached what I've come up with so far, and I believe all logic is sound, minus writing the masseg to screen (which I would think you write the message, THEN the $PAGER displays it, keeping everything in tact- guess not). Any hlep would be appreciated. Thanks in advance! -- . o . o . o . . o o . . . o . . . o . o o o . o . o o . . o o o o . o . . o o o o . o o o signature.asc Description: Digital signature
Re: Hashcash
On Thu, Mar 03, 2011 at 05:23:43PM -0700, Aaron Toponce wrote: > So, has anyone successfully implemented Hashcash into Mutt, and if so, how? Here is what I came up with. It's a Python script that runs as my default editor. The script calls Vim, after which, it parses the headers and adds the necessary tokens. I haven't found any bugs yet, but I'm sure I will soon enough. I also blogged about it here: http://pthree.org/2011/03/24/hashcash-and-mutt/ Now to start working on the verification process. I figure I can use $display_filter for that, and just not filter anything, but execute another Python script. Anyway, thought I'd post an update. -- . o . o . o . . o o . . . o . . . o . o o o . o . o o . . o o o o . o . . o o o o . o o o #!/usr/bin/env python import csv import fileinput import rfc822 import subprocess import sys subprocess.call("vim %s" % sys.argv[1], shell=True) file = open(sys.argv[1], 'r') headers = rfc822.Message(file) to_emails = headers.getaddrlist("To") cc_emails = headers.getaddrlist("Cc") email_addrs = [] tokens = [] # Harvest all email addresses from the header for email in to_emails: email_addrs.append(email[1]) for email in cc_emails: email_addrs.append(email[1]) # Remove duplicate emails from the list, requires Python 2.5 and later email_addrs = list(set(email_addrs)) # Check if an appropriate token is already generated for the mail if headers.has_key("X-Hashcash"): for list in headers.getheaders("X-Hashcash"): email_addrs.remove(list.split(":")[3]) if headers.has_key("Hashcash"): for list in headers.getheaders("Hashcash"): email_addrs.remove(list.split(":")[3]) # Call the hashcash function from the operating system to mint tokens for email in email_addrs: t = subprocess.Popen("hashcash -m %s -X -Z 2" % email, shell=True, stdout=subprocess.PIPE) tokens.append(t.stdout.read()) # Write the newly minted tokens to the header f = fileinput.FileInput(sys.argv[1], inplace=1) for line in f: line = line.strip() if f.lineno() == 1: for token in tokens: print token, print line continue else: print line file.close() signature.asc Description: Digital signature
Re: Hashcash
On Tue, Mar 22, 2011 at 09:48:26AM +0100, Clément Bœsch wrote: > On Tue, Mar 22, 2011 at 08:39:16AM +, Jamie Paul Griffin wrote: > > > > Oh, and I love your .signature! > > > > > > Heh. Total geek. I dig it. > > > > > > -- > > > . o . o . o . . o o . . . o . > > > . . o . o o o . o . o o . . o > > > o o o . o . . o o o o . o o o > > > > sorry to change the topic but can i ask, what does that signature mean? is > > it like braille or something? > > > > Looks like a glider in the game of life It is the glider. See: http://www.catb.org/hacker-emblem/ and http://en.wikipedia.org/wiki/Glider_(Conway's_Life). Braille on the other hand is 3 rows by 2 columns. -- . o . o . o . . o o . . . o . . . o . o o o . o . o o . . o o o o . o . . o o o o . o o o signature.asc Description: Digital signature
Re: Hashcash
On Mon, Mar 21, 2011 at 08:43:12PM -0600, Aaron Toponce wrote: > [snip] > > Come to think of it, I should have Vim call an external script that > works on the temp file when closing. This would give me the opportunity > to add the necessary addresses to the header before the script executes. Just perform the hashcash processing after Vim exits, and use this script as $editor. #!/bin/sh vim "$1" hashcash-stuff-here Regards, Simon -- + privacy is necessary + using gnupg http://gnupg.org + public key id: 0x92FEFDB7E44C32F9 pgpQyEpd72FP3.pgp Description: PGP signature
Re: Hashcash
On Tue, Mar 22, 2011 at 08:39:16AM +, Jamie Paul Griffin wrote: > > > Oh, and I love your .signature! > > > > Heh. Total geek. I dig it. > > > > -- > > . o . o . o . . o o . . . o . > > . . o . o o o . o . o o . . o > > o o o . o . . o o o o . o o o > > sorry to change the topic but can i ask, what does that signature mean? is it > like braille or something? > Looks like a glider in the game of life -- Clément B.
Re: Hashcash
> > Oh, and I love your .signature! > > Heh. Total geek. I dig it. > > -- > . o . o . o . . o o . . . o . > . . o . o o o . o . o o . . o > o o o . o . . o o o o . o o o sorry to change the topic but can i ask, what does that signature mean? is it like braille or something? jamie
Re: Hashcash
On Tue, Mar 22, 2011 at 10:37:35AM +0900, Dan Drake wrote: > One idea: write a script (shell, Python, etc) that parses the temp file, > adds the hashcash stuff, and then spawns vim. Then in Mutt, you set your > editor to be that script: > >set editor = my_hashcash_script > > The nice thing about that is you can write it using whatever you like, > instead of Vim's scripting language, and perhaps use email parsing > libraries and so on. Actually, that's not a bad idea. I'm struggling working my way through vimscript, and it's a shame that I have to reinvent everything myself. Calling already existing libraries and modules is definitely the way to go. Let's see if that makes my job easier. The only hiccup I see, is I might not have all the addresses added to the mail before composition. If I add addresses later, this means I would need to re-edit the temp file, so the script can reparse the addresses and add each token to the header. Then again, this was an issue anyway. Come to think of it, I should have Vim call an external script that works on the temp file when closing. This would give me the opportunity to add the necessary addresses to the header before the script executes. > Oh, and I love your .signature! Heh. Total geek. I dig it. -- . o . o . o . . o o . . . o . . . o . o o o . o . o o . . o o o o . o . . o o o o . o o o signature.asc Description: Digital signature
Re: Hashcash
On Mon, 21 Mar 2011 at 09:19AM -0600, Aaron Toponce wrote: > I've set "edit_headers=yes" in my ~/.muttrc so I can edit the headers > with Vim, my preferred editor. I can select a new line, then from > command mode, run "! hashcash -m resource -X -Z 2" to add the line to > the header, as I've done with this message. Then, I can continue to > compose my message, save, quit and send. > > Rather than calling the external command manually, I would like to > automate the process with a macro. So, the macro should be able to > parse the "To:", "Cc:" and "Bcc:" lines, which would contain a > comma-separated list of addresses, and run the hashcash command for > each address, putting each result on its own line. I'm not sure how > to handle Bcc: addresses, so we can ignore that for the time being. One idea: write a script (shell, Python, etc) that parses the temp file, adds the hashcash stuff, and then spawns vim. Then in Mutt, you set your editor to be that script: set editor = my_hashcash_script The nice thing about that is you can write it using whatever you like, instead of Vim's scripting language, and perhaps use email parsing libraries and so on. Oh, and I love your .signature! Dan -- --- Dan Drake - http://mathsci.kaist.ac.kr/~drake --- signature.asc Description: Digital signature
Re: Hashcash
On Thu, Mar 03, 2011 at 05:23:43PM -0700, Aaron Toponce wrote: > I'm curious if anyone has gotten hashcash working with Mutt. > http://hashcash.org/mail/mua/mutt/ seems to explain a background process > and a foreground process. > > The hashcash-sendmail script page (the background process) is down, and > I can't seem to find a copy of it anywhere online, and it's not in > Debian packages. The Perl script (the foreground process) written by Tim > Ruddick doesn't have any documentation on how to implement it into your > ~/.muttrc. > > I've got the Penny Post extension in Icedove 3.0, but apparently it > doesn't support 3.1, which I'm sure will come down the update pipes in > Sid soon enough. I'd rather stick with Mutt as my main MUA anyhow. > > So, has anyone successfully implemented Hashcash into Mutt, and if so, how? I have made some progress, although I must do everything manually. I'm looking to automate the process with Vim, so if someone could help me with this, that would be awesome. I've set "edit_headers=yes" in my ~/.muttrc so I can edit the headers with Vim, my preferred editor. I can select a new line, then from command mode, run "! hashcash -m resource -X -Z 2" to add the line to the header, as I've done with this message. Then, I can continue to compose my message, save, quit and send. Rather than calling the external command manually, I would like to automate the process with a macro. So, the macro should be able to parse the "To:", "Cc:" and "Bcc:" lines, which would contain a comma-separated list of addresses, and run the hashcash command for each address, putting each result on its own line. I'm not sure how to handle Bcc: addresses, so we can ignore that for the time being. Any idea how I can create this macro? I guess asking a Vim mailing list would be more appropriate, but I figured because I'm looking to implement this into Mutt, it is still considered "on-topic" here. Of course, this is only minting the appropriate tokens, and not verifying and storing them, which is a separate issue entirely, and also needs to be addressed (even though I doubt anyone besides me is really interested in Hashcash for mail). If anyone could help me with this, that would be great. Thanks, -- . o . o . o . . o o . . . o . . . o . o o o . o . o o . . o o o o . o . . o o o o . o o o signature.asc Description: Digital signature
Hashcash
I'm curious if anyone has gotten hashcash working with Mutt. http://hashcash.org/mail/mua/mutt/ seems to explain a background process and a foreground process. The hashcash-sendmail script page (the background process) is down, and I can't seem to find a copy of it anywhere online, and it's not in Debian packages. The Perl script (the foreground process) written by Tim Ruddick doesn't have any documentation on how to implement it into your ~/.muttrc. I've got the Penny Post extension in Icedove 3.0, but apparently it doesn't support 3.1, which I'm sure will come down the update pipes in Sid soon enough. I'd rather stick with Mutt as my main MUA anyhow. So, has anyone successfully implemented Hashcash into Mutt, and if so, how? -- . o . o . o . . o o . . . o . . . o . o o o . o . o o . . o o o o . o . . o o o o . o o o *** This email has been stamped using Penny Post. Stamping email helps combat spam. Find out more about stamping your email at: http://pennypost.sourceforge.net signature.asc Description: OpenPGP digital signature