source: trunk/bin/bletchley-encode @ 24

Last change on this file since 24 was 20, checked in by tmorgan, 12 years ago

added simple encode/decode command line tools

fixed problem with percent encoding by allowing for a third result of tests

implemented (untested) resumption of decryption for POA

more POA documentation and logging

  • Property svn:executable set to *
File size: 1.6 KB
Line 
1#!/usr/bin/env python
2
3# Requires Python 2.7+
4
5'''
6Simple decoder script; useful in shell scripts
7
8Copyright (C) 2011-2012 Virtual Security Research, LLC
9Author: Timothy D. Morgan
10
11 This program is free software: you can redistribute it and/or modify
12 it under the terms of the GNU Lesser General Public License, version 3,
13 as published by the Free Software Foundation.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 GNU General Public License for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program.  If not, see <http://www.gnu.org/licenses/>.
22'''
23
24
25import sys
26import argparse
27from bletchley import blobtools
28
29
30parser = argparse.ArgumentParser(description='A simple encoder script that is useful in shell scripts.')
31parser.add_argument('input_file', nargs='?', default=None,
32                    help='File containing encrypted blobs to analyze, one per line. Omit to read from stdin.')
33parser.add_argument('-e', dest='encoding_chain', type=str, required=True,
34                    help='Comma-separated sequence of encoding formats used to encode the token, starting with the last encoding to apply.')
35options = parser.parse_args()
36
37input_file = sys.stdin
38if options.input_file is not None:
39    input_file = file(options.input_file, 'rb')
40
41blob = input_file.read()
42
43specified_encodings = options.encoding_chain.split(',')
44specified_encodings.reverse()
45sys.stdout.write(blobtools.encodeChain(specified_encodings, blob))
Note: See TracBrowser for help on using the repository browser.