Debian Codegraph @

src/bnpass/bnpass.cpp

raw symbols SCIP
1 /*
2 * Copyright (C) 1999 Ross Combs ([email protected])
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 */
18 #include "common/setup_before.h"cxx . . $ `<file>/src/common/setup_before.h`/
19 #include <cstdlib>
20 #include <cstring>
21 #include <cctype>
22
23 #include "common/eventlog.h"cxx . . $ `<file>/src/common/eventlog.h`/
24 #include "common/bnethash.h"cxx . . $ `<file>/src/common/bnethash.h`/
25 #include "common/version.h"cxx . . $ `<file>/src/common/version.h`/
26 #include "common/xstring.h"cxx . . $ `<file>/src/common/xstring.h`/
27 #include "common/setup_after.h"cxx . . $ `<file>/src/common/setup_after.h`/
28
29 using namespace pvpgn;
30
31 namespacecxx . . $ `$anonymous_namespace_src/bnpass/bnpass.cpp`/
32 {
33
34 void usagecxx . . $ `$anonymous_namespace_src/bnpass/bnpass.cpp`/usage(85c52e162fed56f9).(char const * progname)
35 {
36 stdcxx . . $ std/::fprintfcxx . . $ std/fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!,
37 "usage: %s [<options>] [--] [<cleartextpassword>]\n"
38 " -h, --help, --usage show this information and exit\n"
39 " -v, --version print version number and exit\n", progname);
40
41 stdcxx . . $ std/::exit(EXIT_FAILUREcxx . . $ `<external>/10696550936717951914/stdlib.h:92:9`!);
42 }
43
44 }
45
46 extern int maincxx . . $ main(afcd3168fc1188a4).(int argc, char * argv[])
47 {
48
49 char const * pass = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!;
50 int a;
51 int forcepass = 0;
52
53 if (argc < 1 || !argv || !argv[0])
54 {
55 stdcxx . . $ std/::fprintfcxx . . $ std/fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "bad arguments\n");
56 return EXIT_FAILUREcxx . . $ `<external>/10696550936717951914/stdlib.h:92:9`!;
57 }
58
59 for (a = 1; a < argc; a++)
60 if (forcepass && !pass)
61 pass = argv[a];
62 else if (stdcxx . . $ std/::strcmp(argv[a], "-") == 0 && !pass)
63 pass = argv[a];
64 else if (argv[a][0] != '-' && !pass)
65 pass = argv[a];
66 else if (forcepass || argv[a][0] != '-' || stdcxx . . $ std/::strcmp(argv[a], "-") == 0)
67 {
68 stdcxx . . $ std/::fprintfcxx . . $ std/fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "%s: extra password argument \"%s\"\n", argv[0], argv[a]);
69 usagecxx . . $ `$anonymous_namespace_src/bnpass/bnpass.cpp`/usage(85c52e162fed56f9).(argv[0]);
70 }
71 else if (stdcxx . . $ std/::strcmp(argv[a], "--") == 0)
72 forcepass = 1;
73 else if (stdcxx . . $ std/::strcmp(argv[a], "-v") == 0 || stdcxx . . $ std/::strcmp(argv[a], "--version") == 0)
74 {
75 stdcxx . . $ std/::printfcxx . . $ std/printf(581fddd72a8db8fc).("version " PVPGN_VERSIONcxx . . $ `src/common/version.h:23:9`! "\n");
76 return EXIT_SUCCESScxx . . $ `<external>/10696550936717951914/stdlib.h:93:9`!;
77 }
78 else if (stdcxx . . $ std/::strcmp(argv[a], "-h") == 0 || stdcxx . . $ std/::strcmp(argv[a], "--help") == 0 || stdcxx . . $ std/::strcmp(argv[a], "--usage")
79 == 0)
80 usagecxx . . $ `$anonymous_namespace_src/bnpass/bnpass.cpp`/usage(85c52e162fed56f9).(argv[0]);
81 else
82 {
83 stdcxx . . $ std/::fprintfcxx . . $ std/fprintf(bc216f8e5b1ebeac).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!, "%s: unknown option \"%s\"\n", argv[0], argv[a]);
84 usagecxx . . $ `$anonymous_namespace_src/bnpass/bnpass.cpp`/usage(85c52e162fed56f9).(argv[0]);
85 }
86
87 {
88 char buff[256];
89 t_hashcxx . . $ pvpgn/t_hash# hash;
90
91 eventlog_setcxx . . $ pvpgn/eventlog_set(8d4262d45fc644ab).(stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!); /* bnet_hash() and friends use eventlog */
92
93 if (!pass)
94 {
95 stdcxx . . $ std/::printfcxx . . $ std/printf(581fddd72a8db8fc).("Enter password to hash: ");
96 stdcxx . . $ std/::fflushcxx . . $ std/fflush(89bc1efcdac0ca22).(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!);
97 stdcxx . . $ std/::fgetscxx . . $ std/fgets(efb0aaba7ac866ae).(buff, 256, stdincxx . . $ `<external>/232824719582829767/stdio.h:153:9`!);
98 if (buff[0] != '\0')
99 buff[stdcxx . . $ std/::strlen(buff) - 1] = '\0';
100 }
101 else
102 {
103 stdcxx . . $ std/::strncpy(buff, pass, sizeof(buff));
104 buff[sizeof(buff)-1] = '\0';
105 }
106
107 /* FIXME: what is the max password length? */
108 strtolowercxx . . $ pvpgn/strtolower(7a9722d75b371431).(buff);
109
110 bnet_hashcxx . . $ pvpgn/bnet_hash(2a8392f275be648).(&hash, stdcxx . . $ std/::strlen(buff), buff);
111 stdcxx . . $ std/::printfcxx . . $ std/printf(581fddd72a8db8fc).("\"BNET\\\\acct\\\\passhash1\"=\"%s\"\n", hash_get_strcxx . . $ pvpgn/hash_get_str(d917ea147d03f908).(hash));
112 }
113
114 return EXIT_SUCCESScxx . . $ `<external>/10696550936717951914/stdlib.h:93:9`!;
115 }