Changeset 7c9db24
- Timestamp:
- 2010-03-08T02:10:41Z (15 years ago)
- Branches:
- master
- Children:
- 3e1ef92c
- Parents:
- b52e478
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
Makefile
rb52e478 r7c9db24 49 49 50 50 clean: $(subdirs) 51 rm -f *.o $(OUTFILE) core utils/bitlbeed encode decode51 rm -f *.o $(OUTFILE) core utils/bitlbeed 52 52 $(MAKE) -C tests clean 53 53 … … 124 124 endif 125 125 126 encode: crypting.c127 $(CC) crypting.c lib/md5.c $(CFLAGS) -o encode -DCRYPTING_MAIN $(CFLAGS) $(EFLAGS) $(LFLAGS)128 129 decode: encode130 cp encode decode131 132 126 ctags: 133 127 ctags `find . -name "*.c"` `find . -name "*.h"` -
conf.c
rb52e478 r7c9db24 127 127 { 128 128 printf( "Usage: bitlbee [-D/-F [-i <interface>] [-p <port>] [-n] [-v]] [-I]\n" 129 " [-c <file>] [-d <dir>] [- h]\n"129 " [-c <file>] [-d <dir>] [-x] [-h]\n" 130 130 "\n" 131 131 "An IRC-to-other-chat-networks gateway\n" … … 143 143 " -c Load alternative configuration file\n" 144 144 " -d Specify alternative user configuration directory\n" 145 " -x Command-line interface to password encryption/hashing\n" 145 146 " -h Show this help page.\n" ); 146 147 return NULL; -
crypting.c
rb52e478 r7c9db24 132 132 return (rv); 133 133 } 134 135 #ifdef CRYPTING_MAIN136 137 /* A little main() function for people who want a stand-alone program to138 encode/decode BitlCrypted files. */139 140 int main( int argc, char *argv[] )141 {142 char *hash, *action, line[256];143 char* (*func)( char *, const char * );144 145 if( argc < 2 )146 {147 fprintf( stderr, "Usage: %s <password>\n\n"148 "Reads from stdin, writes to stdout.\n"149 "Call as \"encode\" to encode, \"decode\" to decode.\n", argv[0] );150 return( 1 );151 }152 153 hash = hashpass( argv[1] );154 action = argv[0] + strlen( argv[0] ) - strlen( "encode" );155 156 if( strcmp( action, "encode" ) == 0 )157 {158 fwrite( hash, 32, 1, stdout );159 func = obfucrypt;160 }161 else if( strcmp( action, "decode" ) == 0 )162 {163 char hash2[32];164 165 fread( hash2, 32, 1, stdin );166 if( memcmp( hash, hash2, 32 ) != 0 )167 {168 fprintf( stderr, "Passwords don't match. Can't decode.\n" );169 return( 1 );170 }171 func = deobfucrypt;172 }173 else174 {175 return( main( 0, NULL ) );176 }177 178 while( fscanf( stdin, "%[^\n]255s", line ) > 0 )179 {180 char *out;181 182 /* Flush the newline */183 fgetc( stdin );184 185 out = func( line, argv[1] );186 printf( "%s\n", out );187 g_free( out );188 }189 190 return( 0 );191 }192 193 #endif -
unix.c
rb52e478 r7c9db24 25 25 26 26 #include "bitlbee.h" 27 28 #include "arc.h" 29 #include "base64.h" 27 30 #include "commands.h" 28 #include "crypting.h"29 31 #include "protocols/nogaim.h" 30 32 #include "help.h" 31 33 #include "ipc.h" 34 #include "md5.h" 35 #include "misc.h" 32 36 #include <signal.h> 33 37 #include <unistd.h> … … 40 44 static void sighandler( int signal ); 41 45 46 static int crypt_main( int argc, char *argv[] ); 47 42 48 int main( int argc, char *argv[] ) 43 49 { … … 45 51 char *old_cwd = NULL; 46 52 struct sigaction sig, old; 53 54 if( argc > 1 && strcmp( argv[1], "-x" ) == 0 ) 55 return crypt_main( argc, argv ); 47 56 48 57 log_init(); … … 159 168 } 160 169 170 static int crypt_main( int argc, char *argv[] ) 171 { 172 int pass_len; 173 unsigned char *pass_cr, *pass_cl; 174 175 if( argc < 3 ) 176 { 177 printf( "Supported:\n" 178 " %s -x enc <key> <cleartext password>\n" 179 " %s -x dec <key> <encrypted password>\n" 180 " %s -x hash <cleartext password>\n" 181 " %s -x unhash <hashed password>\n" 182 " %s -x chkhash <hashed password> <cleartext password>\n", 183 argv[0], argv[0], argv[0], argv[0], argv[0] ); 184 } 185 else if( strcmp( argv[2], "enc" ) == 0 ) 186 { 187 pass_len = arc_encode( argv[4], strlen( argv[4] ), (unsigned char**) &pass_cr, argv[3], 12 ); 188 printf( "%s\n", base64_encode( pass_cr, pass_len ) ); 189 } 190 else if( strcmp( argv[2], "dec" ) == 0 ) 191 { 192 pass_len = base64_decode( argv[4], (unsigned char**) &pass_cr ); 193 arc_decode( pass_cr, pass_len, (char**) &pass_cl, argv[3] ); 194 printf( "%s\n", pass_cl ); 195 } 196 else if( strcmp( argv[2], "hash" ) == 0 ) 197 { 198 md5_byte_t pass_md5[21]; 199 md5_state_t md5_state; 200 201 random_bytes( pass_md5 + 16, 5 ); 202 md5_init( &md5_state ); 203 md5_append( &md5_state, (md5_byte_t*) argv[3], strlen( argv[3] ) ); 204 md5_append( &md5_state, pass_md5 + 16, 5 ); /* Add the salt. */ 205 md5_finish( &md5_state, pass_md5 ); 206 207 printf( "%s\n", base64_encode( pass_md5, 21 ) ); 208 } 209 else if( strcmp( argv[2], "unhash" ) == 0 ) 210 { 211 printf( "Hash %s submitted to a massive Beowulf cluster of\n" 212 "overclocked 486s. Expect your answer next year somewhere around this time. :-)\n", argv[3] ); 213 } 214 else if( strcmp( argv[2], "chkhash" ) == 0 ) 215 { 216 int st = md5_verify_password( argv[4], argv[3] ); 217 218 printf( "Hash %s given password.\n", st == 0 ? "matches" : "does not match" ); 219 220 return st; 221 } 222 223 return 0; 224 } 225 161 226 static void sighandler( int signal ) 162 227 { … … 214 279 return( (double) time->tv_sec + (double) time->tv_usec / 1000000 ); 215 280 } 216 217
Note: See TracChangeset
for help on using the changeset viewer.