alecpl
2012-04-14 651da7934ed4c13e2cbc2e4a82caf2ebaba87373
commit | author | age
2471d3 1 #!/usr/bin/env php
A 2 <?php
3 /*
4
5  +-----------------------------------------------------------------------+
30aa4c 6  | bin/decrypt.sh                                                        |
2471d3 7  |                                                                       |
e019f2 8  | This file is part of the Roundcube Webmail client                     |
f5e7b3 9  | Copyright (C) 2005-2009, The Roundcube Dev Team                       |
7fe381 10  |                                                                       |
T 11  | Licensed under the GNU General Public License version 3 or            |
12  | any later version with exceptions for skins & plugins.                |
13  | See the README file for a full license statement.                     |
2471d3 14  |                                                                       |
A 15  | PURPOSE:                                                              |
16  |   Decrypt the encrypted parts of the HTTP Received: headers           |
17  |                                                                       |
18  +-----------------------------------------------------------------------+
19  | Author: Tomas Tevesz <ice@extreme.hu>                                 |
20  +-----------------------------------------------------------------------+
21
22  $Id$
23 */
24
25 /*-
26  * If http_received_header_encrypt is configured, the IP address and the
27  * host name of the added Received: header is encrypted with 3DES, to
28  * protect information that some could consider sensitve, yet their
29  * availability is a must in some circumstances.
30  *
31  * Such an encrypted Received: header might look like:
32  *
33  * Received: from DzgkvJBO5+bw+oje5JACeNIa/uSI4mRw2cy5YoPBba73eyBmjtyHnQ==
34  *     [my0nUbjZXKtl7KVBZcsvWOxxtyVFxza4]
35  *    with HTTP/1.1 (POST); Thu, 14 May 2009 19:17:28 +0200
36  *
37  * In this example, the two encrypted components are the sender host name
38  * (DzgkvJBO5+bw+oje5JACeNIa/uSI4mRw2cy5YoPBba73eyBmjtyHnQ==) and the IP
39  * address (my0nUbjZXKtl7KVBZcsvWOxxtyVFxza4).
40  *
41  * Using this tool, they can be decrypted into plain text:
42  *
30aa4c 43  * $ bin/decrypt.sh 'my0nUbjZXKtl7KVBZcsvWOxxtyVFxza4' \
2471d3 44  * > 'DzgkvJBO5+bw+oje5JACeNIa/uSI4mRw2cy5YoPBba73eyBmjtyHnQ=='
A 45  * 84.3.187.208
46  * 5403BBD0.catv.pool.telekom.hu
47  * $
48  *
49  * Thus it is known that this particular message was sent by 84.3.187.208,
50  * having, at the time of sending, the name of 5403BBD0.catv.pool.telekom.hu.
51  *
52  * If (most likely binary) junk is shown, then
53  *  - either the encryption password has, between the time the mail was sent
54  *    and `now', changed, or
55  *  - you are dealing with counterfeit header data.
56  */
57
58 define('INSTALL_PATH', realpath(dirname(__FILE__).'/..') . '/');
6cc3f5 59
A 60 require INSTALL_PATH . 'program/include/clisetup.php';
2471d3 61
A 62 if ($argc < 2) {
63     die("Usage: " . basename($argv[0]) . " encrypted-hdr-part [encrypted-hdr-part ...]\n");
64 }
65
66 $RCMAIL = rcmail::get_instance();
67
68 for ($i = 1; $i < $argc; $i++) {
69     printf("%s\n", $RCMAIL->decrypt($argv[$i]));
70 };