Szabolcs Hubai <szab.hu@gmail.com>
[vpnc.git] / cisco-decrypt.c
blobf66388a381dfb68e871aaa307c272b73d8f92a38
1 /* Decoder for password encoding of Cisco VPN client.
2 Copyright (C) 2005 Maurice Massar
4 Thanks to HAL-9000@evilscientists.de for decoding and posting the algorithm!
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 #include "decrypt-utils.h"
23 #include <stdio.h>
24 #include <stdlib.h>
25 #include <gcrypt.h>
26 #include <errno.h>
28 int main(int argc, char *argv[])
30 int i, len, ret = 0;
31 char *bin, *pw = NULL;
33 gcry_check_version(NULL);
35 if (argc == 1 || *argv[1] == '-') {
36 fprintf(stderr,
37 "\nUsage: %s DEADBEEF...012345678 424242...7261\n"
38 " Print decoded result to stdout\n\n",
39 argv[0]);
40 exit(1);
42 /* Hack for use in pcf2vpnc */
43 if (*argv[1] == 'q') {
44 exit(1);
47 for (i = 1; i < argc; i++) {
48 ret = hex2bin(argv[i], &bin, &len);
49 if (ret != 0) {
50 perror("decoding input");
51 continue;
53 ret = deobfuscate(bin, len, (const char **)&pw, NULL);
54 free(bin);
55 if (ret != 0) {
56 perror("decrypting input");
57 continue;
59 printf("%s\n", pw);
60 free(pw);
63 exit(ret != 0);