Skip to content

Instantly share code, notes, and snippets.

@muelli
Created April 7, 2012 00:03
Show Gist options
  • Save muelli/2324157 to your computer and use it in GitHub Desktop.
Save muelli/2324157 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import argparse
import sys
from pgpdump import BinaryData
def main(args):
parser = argparse.ArgumentParser(description='Process OpenPGP files')
#parser.add_argument('integers', metavar='N', type=int, nargs='+',
# help='an integer for the accumulator')
parser.add_argument('files', nargs='+',
help='filenames to be processed')
args = parser.parse_args()
for filename in args.files:
with open(filename, 'rb') as infile:
data = BinaryData(infile.read())
counter = 0
length = 0
for packet in data.packets():
counter += 1
print("Reading from byte %d" % length)
length += packet.length
try:
print(packet)
except:
print("Error after reading %d packets, totalling %d bytes" % (counter, length))
raise
print(length)
print(counter)
if __name__ == '__main__':
sys.exit(main(sys.argv))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment