#!/usr/local/bin/perl -- # # opieprint - output postscript with 100 OPIE passwords credit card sized # $ver = "3.0"; # version of this program - opieprint $usage = "Usage: opieprint [-4|-5] [-o file] [-s seq] [-S seed] [user]\n". " output credit card sized postscript with 100 OPIE passwords\n". " this is opieprint v$ver\n"; # generate 100 passwords for "user" (default current user) # up to "max" seq number (default 100) # with either the specified "seed" of that of the "user" # using MD5 "-5" or MD4 "-4" (default depends on opie program) # to file "file" (default stdout) # # v1.0 - original code distributed with Wietse Venema's logdaemon 4.7 package # as keyprint, no author given # v2.0 - modified to use OPIE, with PS header in-lined, + opt cnt on cmdline # by Lawrie.Brown@adfa.oz.au / 11 Jan 96 # v2.1 - added flag to specify seed so can do remote printout of keys # by Lawrie.Brown@adfa.oz.au / 12 Jan 96 # v3.0 - totally rewrote postscript skeleton, handcrafted, much smaller, epsf # by Lawrie.Brown@adfa.oz.au / 10 Oct 96 ########################## Configurable Parameters ####################### $dir="/usr/local/bin"; # dir containing opieinfo & opiekey ########################################################################## $ENV{'PATH'}='/bin:/usr/bin:/usr/ucb'; $|=1; # unbuffer stdout $max = 100; # default max seq number is 100 $mdx = ""; # alg to use (system default if blank) $out = ""; # output file (stdout if blank) # process command-line while (@ARGV) { if ($ARGV[0] =~ /-4/) { $mdx = "-4"; shift @ARGV; next;} if ($ARGV[0] =~ /-5/) { $mdx = "-5"; shift @ARGV; next;} if ($ARGV[0] =~ /-o/) { shift @ARGV; $out = shift @ARGV; next;} if ($ARGV[0] =~ /-s/) { shift @ARGV; $max = shift @ARGV; next;} if ($ARGV[0] =~ /-S/) { shift @ARGV; $seed = shift @ARGV; next;} if ($ARGV[0] =~ /-[hv\?]/) { die "opieprint v$ver\n$usage\nstopped";} if ($ARGV[0] =~ /-/) { die "unknown flag $ARGV[0]\n$usage\nstopped";} last; # not a flag so must be user, drop out of loop } # get user from: cmdline or ENV or getlogin $username = $ARGV[0] || $ENV{'USER'} || $ENV{'LOGNAME'} || getlogin(); $username =~ /(\w+)/; $username = $1; # check max seq number for OPIE seed, and compute base seq no die "max seq no must be more than 100, stopped" if $max < 100; $base = $max - 100; # compute lowest seq number # if seed not given, obtain that of user if (!$seed) { # run opieinfo to get current seed for selected user open(NAMES, "$dir/opieinfo $username|") || die "can't run opieinfo: $!, stopped"; $seed = ; $seed =~ /^\d+\s+(\w+)/ || die "User $username not found. Make sure you have run opiepasswd, stopped"; $seed = $1; close(NAMES); } # open appropriate output stream to either specified file or stdout if ($out) { open(PRINTER, ">$out") || die "can't open $out: $!, stopped"; } else { open(PRINTER, ">-") || die "can't send output to STDOUT: $!, stopped"; } # run opiekey to generate the required number of keys and save them in %keys open(KEYS, "$dir/opiekey $mdx -n 100 $max $seed|") || die "can't run opiekey: $!, stopped"; system("stty -echo"); # yuck! Suppress echo of secret password while() { /^(\d+):\s(.+)$/ && do { $key{$1}=$2; next; }; }; system("stty echo"); # more yuck! close(KEYS); # now read postscript skeleton, filling in the keys at the numbered locations while() { s/OPIESEED/$seed/; # insert correct seed for top of card if (/^\((\d+):\)/) { # find slots for keys and fill them in $n = $1 + $base; # work out equiv key number for our seq s/^\((\d+):\)/($n: $key{$n})/; } print PRINTER $_; } # end of perl program, postscript skeleton follows, with key slots 1: to 100: ############################################################################# __END__ %!PS-Adobe-2.0 EPSF-2.0 %%Creator: Lawrie.Brown@adfa.oz.au %%CreationDate: Thu 10 Oct 1996 %%BoundingBox: 160 440 435 775 %%Pages: 1 %%EndComments % % Skeletal postscript code to output 100 OPIE passwords credit card sized % hand crafted from original Framemaker generated skeleton by Lawrie Brown % % display seed value for these opie passwords /Helvetica-Bold findfont 8 scalefont setfont 4 0 (OPIESEED) 261 763 moveto ashow % display list of 100 passwords, skeleton just has default numbers 1-100 /Helvetica findfont 5 scalefont setfont (1:) 183 756 moveto show (26:) 302 756 moveto show (2:) 183 750 moveto show (27:) 302 750 moveto show (3:) 183 744 moveto show (28:) 302 744 moveto show (4:) 183 738 moveto show (29:) 302 738 moveto show (5:) 183 732 moveto show (30:) 302 732 moveto show (6:) 183 726 moveto show (31:) 302 726 moveto show (7:) 183 720 moveto show (32:) 302 720 moveto show (8:) 183 714 moveto show (33:) 302 714 moveto show (9:) 183 708 moveto show (34:) 302 708 moveto show (10:) 183 702 moveto show (35:) 302 702 moveto show (11:) 183 695 moveto show (36:) 302 695 moveto show (12:) 183 689 moveto show (37:) 302 689 moveto show (13:) 183 683 moveto show (38:) 302 683 moveto show (14:) 183 677 moveto show (39:) 302 677 moveto show (15:) 183 671 moveto show (40:) 302 671 moveto show (16:) 183 665 moveto show (41:) 302 665 moveto show (17:) 183 659 moveto show (42:) 302 659 moveto show (18:) 183 653 moveto show (43:) 302 653 moveto show (19:) 183 647 moveto show (44:) 302 647 moveto show (20:) 183 641 moveto show (45:) 302 641 moveto show (21:) 183 634 moveto show (46:) 302 634 moveto show (22:) 183 628 moveto show (47:) 302 628 moveto show (23:) 183 622 moveto show (48:) 302 622 moveto show (24:) 183 616 moveto show (49:) 302 616 moveto show (25:) 183 610 moveto show (50:) 302 610 moveto show (51:) 183 600 moveto show (76:) 302 600 moveto show (52:) 183 594 moveto show (77:) 302 594 moveto show (53:) 183 588 moveto show (78:) 302 588 moveto show (54:) 183 582 moveto show (79:) 302 582 moveto show (55:) 183 576 moveto show (80:) 302 576 moveto show (56:) 183 569 moveto show (81:) 302 569 moveto show (57:) 183 563 moveto show (82:) 302 563 moveto show (58:) 183 557 moveto show (83:) 302 557 moveto show (59:) 183 551 moveto show (84:) 302 551 moveto show (60:) 183 545 moveto show (85:) 302 545 moveto show (61:) 183 539 moveto show (86:) 302 539 moveto show (62:) 183 533 moveto show (87:) 302 533 moveto show (63:) 183 527 moveto show (88:) 302 527 moveto show (64:) 183 521 moveto show (89:) 302 521 moveto show (65:) 183 515 moveto show (90:) 302 515 moveto show (66:) 183 508 moveto show (91:) 302 508 moveto show (67:) 183 502 moveto show (92:) 302 502 moveto show (68:) 183 496 moveto show (93:) 302 496 moveto show (69:) 183 490 moveto show (94:) 302 490 moveto show (70:) 183 484 moveto show (95:) 302 484 moveto show (71:) 183 478 moveto show (96:) 302 478 moveto show (72:) 183 472 moveto show (97:) 302 472 moveto show (73:) 183 466 moveto show (98:) 302 466 moveto show (74:) 183 460 moveto show (99:) 302 460 moveto show (75:) 183 454 moveto show (100:) 302 454 moveto show % draw boxes round each half 0.25 setlinewidth 0 setlinecap 178 761 moveto 178 608 lineto 416 608 lineto 416 761 lineto 178 761 lineto stroke 178 604 moveto 178 452 lineto 416 452 lineto 416 604 lineto 178 604 lineto stroke % now draw thin dashed lines 0.01 setlinewidth 2 setlinecap [1 3] 0 setdash % draw cutlines round outside 171 445 moveto 171 769 lineto 423 769 lineto 423 445 lineto 171 445 lineto stroke % draw fold line through middle 163 606 moveto 433 606 lineto stroke % display our handiwork showpage