Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 51442 | Differences between
and this patch

Collapse All | Expand All

(-)john-1.6.orig/debian/CONFIG.mailer (+59 lines)
Line 0 Link Here
1
This version of john has two new conffiles for the mailer script:
2
3
/etc/john-mail.conf
4
---------------------
5
6
This is where you define the command used to send messages to users,
7
and the shells to be ignored when sending the messages. A working
8
example is already installed.
9
10
You can set the shells to be ignored, for example:
11
12
shells=-,/bin/false,/dev/null,/bin/sync,/usr/bin/falselogin
13
14
The default is set to:
15
16
shells=-,/bin/false,/dev/null,/bin/sync
17
18
And you may set the command used to send the message (the message
19
will be piped into this command):
20
21
mailcmd=/usr/sbin/sendmail
22
23
That is the default. If you use sendmail, or if your mailer provides
24
a "sendmail" executable, you may use the above line.
25
26
And if you want to pass extra arguments to your mailer, set
27
mailargs:
28
29
mailargs= ...
30
31
The default is not to define mailargs.
32
33
/etc/john-mail.msg
34
------------------
35
36
This is the message template to be sent to the user. In the message,
37
the strings @LOGIN and @HOSTNAME will be substituted for the user's
38
login and the host name.
39
40
If you use sendmail as mail command, you may include the headers
41
at the top of the template message, like this:
42
43
44
=============================================================
45
Subject: Gotcha!
46
Cc: root
47
48
Just cracked your password for account @LOGIN at @HOSTNAME.
49
Please change it.
50
51
John the Ripper.
52
=============================================================
53
54
You may also use some binary of yours as the mail command; then it
55
will be called, and the template (with the variables already
56
substituted) will be piped into it. This may be useful if you want
57
to use complex logging (using a DBMS, for example), or if you
58
want to automatically run scripts (that block the account,
59
perhaps?)
(-)john-1.6.orig/debian/changelog (+126 lines)
Line 0 Link Here
1
john (1.6-17) unstable; urgency=low
2
3
  * Rewording of comments in config file. (Closes: #115556)
4
    (Thanks to Martin F Krafft)
5
  * Included hack to remove cronjob if needed. (Closes: #114835,#117034)
6
7
 -- Christian Kurz <shorty@debian.org>  Sun, 14 Oct 2001 20:14:42 +0200
8
9
john (1.6-16) unstable; urgency=low
10
11
  * Integrated patch from Damyan Ivanov to fix unquoted sed 
12
    expressions. (Closes: #113557)
13
14
 -- Christian Kurz <shorty@debian.org>  Wed, 26 Sep 2001 12:57:53 +0200
15
16
john (1.6-15) unstable; urgency=low
17
18
  * Fixed typo in debconf templates. (Closes: #112058,#113166)
19
  * Should fix another problem with the lock-file. (Closes: #113332)
20
21
 -- Christian Kurz <shorty@debian.org>  Wed, 12 Sep 2001 16:08:30 +0200
22
23
john (1.6-14) unstable; urgency=low
24
25
  * Added german debconf translation from Sebastian Feltel.
26
    (Closes: #109980)
27
  * Fixed two typos in the john.1 manpage, noted by Stephen Frost.
28
  * Applied patch from Daniel Kobras to fix two oversights in the
29
    cronjob script. (Closes: #110272)
30
  * Applied patch from Jeronimo Pellegrini to fix some small problems
31
    in the scripts. (Closes: #110957)
32
33
 -- Christian Kurz <shorty@debian.org>  Sat, 25 Aug 2001 09:09:18 +0200
34
35
john (1.6-13) unstable; urgency=low
36
37
  * We'll gzip the example file, which is about 12k. But the other files
38
    which are just 2-6k will be stay uncompressed, until some very good
39
    reasons are presented to convince me. (Closes: #96650)
40
  * Integration of Patch from Jeronimo Pellegrini to support the
41
    installation and deinstallation of a cronjob. (Closes: #101970)
42
43
 -- Christian Kurz <shorty@debian.org>  Thu, 12 Jul 2001 22:55:09 +0200
44
45
john (1.6-12) unstable; urgency=low
46
47
  * Now we finally added manpages for john which have been written by
48
    Jordi Mallach and Jeronimo Pellegrini. (Closes: #62498)
49
  * Applied a patch from Jeronimo Pellegrini to make the mailer script
50
    more configurable. (Closes: #101968)
51
52
 -- Christian Kurz <shorty@debian.org>  Sun, 20 May 2001 10:18:56 +0200
53
54
john (1.6-11) unstable; urgency=low
55
56
  * Fixed Symlinks for $ARCHITECURE != i386. (Closes: #92280)
57
58
 -- Christian Kurz <shorty@debian.org>  Sat, 31 Mar 2001 18:34:42 +0200
59
60
john (1.6-10) unstable; urgency=low
61
62
  * Fixed the symlinks, since we didn't notice that we broke them with 
63
    the 1.6-8 release. Now, it should work fine again. (Closes: #91824)
64
65
 -- Christian Kurz <shorty@debian.org>  Wed, 28 Mar 2001 08:22:18 +0200
66
67
john (1.6-9) unstable; urgency=low
68
69
  * Fixed the name of the override file for john and also it'
70
    location. (Closes: #81218)
71
72
 -- Christian Kurz <shorty@debian.org>  Sun, 25 Mar 2001 00:30:33 +0100
73
74
john (1.6-8) unstable; urgency=low
75
76
  * Fixed the startup script for john to correctly use bash.
77
78
 -- Christian Kurz <shorty@debian.org>  Thu,  1 Mar 2001 20:00:13 +0100
79
80
john (1.6-7) unstable; urgency=low
81
82
  * Fixed a typo to build john also on Alpha (Closes: #83696)
83
84
 -- Christian Kurz <shorty@debian.org>  Sat, 27 Jan 2001 09:13:13 +0100
85
86
john (1.6-6) unstable; urgency=low
87
88
  * Added sparc-fix from Solar Designer (Closes: #81756).
89
  * Changed rules file to build two different versions of john, one with
90
    mmx extensions, and one without.
91
  * Added wrapper script to start john.
92
93
 -- Christian Kurz <shorty@debian.org>  Fri, 12 Jan 2001 22:31:05 +0100
94
95
john (1.6-5) unstable; urgency=low
96
97
  * Moved overrides file to correct location (Closes: 81218).
98
  * Added 3 lines to overrides file for the symlinks.
99
100
 -- Christian Kurz <shorty@debian.org>  Thu,  4 Jan 2001 20:51:32 +0100
101
102
john (1.6-4) unstable; urgency=low
103
104
  * Hopefully I fixed now the logfile-path-bug.
105
106
 -- Christian Kurz <shorty@debian.org>  Fri,  8 Dec 2000 22:26:26 +0100
107
108
john (1.6-3) unstable; urgency=low
109
110
  * Fixed pre-rm to allow removal of package (Closes: 74091).
111
112
 -- Christian Kurz <shorty@debian.org>  Thu,  5 Oct 2000 21:55:51 +0200
113
114
john (1.6-2) unstable; urgency=low
115
116
  * Changed debian/rules to be faster and more portable.
117
  * Fixed prerm-script to run only on purges.
118
  * Fixed some pathes to better defaults.
119
120
 -- Christian Kurz <shorty@getuid.com>  Mon, 15 May 2000 19:37:07 +0200
121
122
john (1.6-1) unstable; urgency=low
123
124
  * First Debian release.
125
126
 -- Christian Kurz <shorty@debian.org>  Sat,  1 Apr 2000 12:23:57 +0200
(-)john-1.6.orig/debian/conffiles (+3 lines)
Line 0 Link Here
1
/etc/john.ini
2
/etc/john-mail.conf
3
/etc/john-mail.msg
(-)john-1.6.orig/debian/config (+5 lines)
Line 0 Link Here
1
#!/bin/sh -e
2
3
. /usr/share/debconf/confmodule
4
db_input medium john/cronjob || true
5
db_go
(-)john-1.6.orig/debian/control (+15 lines)
Line 0 Link Here
1
Source: john
2
Section: admin
3
Priority: optional
4
Maintainer: Christian Kurz <shorty@debian.org>
5
Origin: debian
6
Bugs: debbugs://bugs.debian.org
7
Standards-Version: 3.5.6
8
9
Package: john
10
Architecture: i386 alpha sparc 
11
Depends: ${shlibs:Depends}
12
Description: An active password cracking tool
13
 john, normally called john the ripper, is a tool to find
14
 weak passwords of your users, and even mail them automatically 
15
 if you want.
(-)john-1.6.orig/debian/copyright (+26 lines)
Line 0 Link Here
1
This is a Debian prepackaged version of john the ripper. The package has
2
been created by Christian Kurz <shorty@debian.org>.
3
4
Source code was obtained from:
5
		http://www.openwall.com/john/
6
7
The following copyright applies to this package:
8
9
 Copyright (c) 2000 Solar Designer <solar@false.com>.
10
 All rights reserved.
11
12
 This program is free software; you can redistribute it and/or modify it
13
 under the terms of the GNU General Public License as published by the Free
14
 Software Foundation; either version 2 of the License, or (at your option)
15
 any later version.
16
17
 This program is distributed in the hope that it will be useful, but WITHOUT
18
 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
19
 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
20
 more details.
21
22
 You should have received a copy of the GNU General Public License along
23
 with this program; if not, write to the Free Software Foundation, Inc.,
24
 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
25
26
 A complete version of the  GPL can be found in /usr/share/common-licenses/GPL.
(-)john-1.6.orig/debian/john (+12 lines)
Line 0 Link Here
1
#!/bin/bash -e
2
3
if [ -d /proc ]; then
4
	if grep -q '^flags.* mmx' /proc/cpuinfo; then
5
		exec -a john /usr/sbin/john-mmx $*
6
	else
7
		exec -a john /usr/sbin/john-any $*
8
	fi
9
else
10
	echo "Proc File System not available. Can't run john."
11
fi
12
exit 0
(-)john-1.6.orig/debian/john-cronjob (+28 lines)
Line 0 Link Here
1
#!/bin/sh
2
3
usage() {
4
    echo "Usage: john-cronjob [ install | remove ]"
5
}
6
7
if [ $# -ne 1 ];then
8
    usage
9
    exit 0
10
fi
11
12
case "$1" in
13
    remove)
14
        if [ -f /etc/cron.daily/john -a ! -L /etc/cron.daily/john ]; then
15
            rm /etc/cron.daily/john
16
        fi
17
        ;;
18
    install)
19
        if [ ! -e /etc/cron.daily/john -a ! -L /etc/cron.daily/john ]; then
20
            cp /usr/share/john/john-dailyscript /etc/cron.daily/john
21
            chmod u+x,og-rwx  /etc/cron.daily/john
22
        fi
23
        ;;
24
    *)
25
        usage
26
        exit 0
27
        ;;
28
esac
(-)john-1.6.orig/debian/john-cronjob.1 (+43 lines)
Line 0 Link Here
1
\"                                      Hey, EMACS: -*- nroff -*-
2
\"
3
.\" john.1 is copyright 1999-2001 by
4
.\" Jeronimo Pellegrini <pellegrini@mpcnet.com.br>
5
.\" This is free documentation, see the latest version of the GNU General
6
.\" Public License for copying conditions. There is NO warranty.
7
.TH JOHN-CRONJOB 1 "August 21, 2001" john
8
.\" Please adjust this date whenever revising the manpage.
9
.SH NAME
10
john-cronjob \- installs or removes the john cronjob
11
.SH SYNOPSIS
12
.B john-cronjob
13
install | remove
14
.SH DESCRIPTION
15
This manual page describes the john-cronjob script, an add-on to the john
16
package. \fBjohn-cronjob\fP is used to install or remove a cronjob that will
17
run automatically every day, trying to crack passwords (a script will be
18
placed
19
under \fI/etc/cron.daily\fP). When the script is called, it will check if an
20
instance of john is already running. If not, it will start a new \fBjohn\fP(1)
21
process, and then run the \fBmailer\fP(1) script.
22
.br
23
When installing or removing the cronjob, this script will never touch a 
24
symlink.
25
.SH SEE ALSO
26
.BR mailer (1),
27
.BR john (1),
28
.BR unafs (1),
29
.BR unique (1),
30
.BR unshadow (1),
31
.BR john.ini (5)
32
.PP
33
The programs are documented fully by John's documentation,
34
which should be available in \fI/usr/share/doc/john\fP or other
35
location, depending on your system.
36
.SH AUTHOR
37
This manual page was written by Jeronimo  Pellegrini
38
<pellegrini@mpcnet.com.br>, for the Debian GNU/Linux system (but 
39
may be used by others).
40
.br
41
John the Ripper was written by Solar Designer <solar@openwall.com>.
42
The complete list of contributors can be found in the CREDITS file
43
in the documentation directory.
(-)john-1.6.orig/debian/john-dailyscript (+48 lines)
Line 0 Link Here
1
#!/bin/sh
2
#
3
# This script runs every day, trying to crack passwords, and then calls
4
# mailer to warn the users (and maybe also root) about that.
5
6
JOHNDIR=/usr/sbin
7
PASSWD=/etc/passwd
8
SHADOW=/etc/shadow
9
10
PASSFILE=`grep -e "[ ]*passfile[ ]*=[ ]*" /etc/john-mail.conf |
11
          sed -e "s/#.*//" -e "s/.*=[ ]*//"`
12
13
if [ -z $PASSFILE ]; then
14
       mail -s "John cronjob is not configured yet!" root <<EOF
15
John was set up to run every day, but it needs you to specify a
16
temporary file, with a "passfile=" line in /etc/john-mail.conf.
17
18
Thank you,
19
20
John the Ripper, an automated password cracking tool.
21
EOF
22
       exit 0
23
fi
24
25
TMPFILE=`mktemp $PASSFILE.XXXXXX` || exit 1
26
27
chmod og-rwx $TMPFILE
28
29
30
if [ -f $SHADOW ]; then
31
       $JOHNDIR/unshadow $PASSWD $SHADOW >> $TMPFILE
32
else
33
       cat $PASSWD >> $TMPFILE
34
fi
35
36
37
if [ ! -f /var/lock/john ]; then
38
       touch /var/lock/john
39
       $JOHNDIR/john -single $TMPFILE
40
       rm -f /var/lock/john
41
       $JOHNDIR/mailer $TMPFILE
42
       rm -f $TMPFILE
43
else
44
       mail -s "John is running" root <<EOF
45
John is running at $HOSTNAME -- either the cronjob lasted too long,
46
or someone else is running john.
47
EOF
48
fi
(-)john-1.6.orig/debian/john-mail.conf (+21 lines)
Line 0 Link Here
1
# Sample configuration file for john.
2
#
3
4
# These are the shells that should be ignored by john. If you
5
# install falselogin, for example, you may want to add it to
6
# the list.
7
shells=-,/bin/false,/dev/null,/bin/sync
8
9
# This is the mail command. You may actually use any program
10
# here; the message in /etc/john.msg will be piped into it,
11
# with the login name and host name substituted.
12
# You may want to use a program to log information about
13
# weak passwords (but that means sensitive information would be
14
# kept somewhere - be careful!)
15
mailcmd=/usr/sbin/sendmail
16
17
# This is the passfile, which defines a temporary file that contains
18
# the content of /etc/passwd and /etc/shadow while the cronjob is run.
19
# Since this file contains sensible data, no default is provided and
20
# you need to specify a file name to be used."
21
# passfile=
(-)john-1.6.orig/debian/john-mail.msg (+8 lines)
Line 0 Link Here
1
Subject: Bad password!
2
3
Hello!
4
5
Your password for account @LOGIN at host @HOSTNAME is too easy!
6
Please change it as soon as possible.
7
8
John the Ripper, an automated password cracker.
(-)john-1.6.orig/debian/john.1 (+204 lines)
Line 0 Link Here
1
.\"                                      Hey, EMACS: -*- nroff -*-
2
.\"
3
.\" john.1 is copyright 1999-2001 by
4
.\" Jordi Mallach <jordi@debian.org>
5
.\" This is free documentation, see the latest version of the GNU General
6
.\" Public License for copying conditions. There is NO warranty.
7
.TH JOHN 1 "June 25, 2001" john
8
.\" Please adjust this date whenever revising the manpage.
9
.SH NAME
10
john \- a tool to find weak passwords of your users
11
.SH SYNOPSIS
12
.B john
13
.RI [ options ] " password-files"
14
.SH DESCRIPTION
15
This manual page documents briefly the
16
.B john
17
command.
18
This manual page was written for the Debian GNU/Linux distribution
19
because the original program does not have a manual page.
20
\fBjohn\fP, better known as John the Ripper, is a tool to find weak
21
passwords of users in a server. John can use a dictionary or some search
22
pattern as well as a password file to check for passwords. John supports
23
different cracking modes and understands many ciphertext formats, like
24
several DES variants, MD5 and blowfish. It can also be used to extract AFS
25
and Windows NT passwords.
26
.SH USAGE
27
To use John, you just need to supply it a password file and the desired
28
options. If no mode is specified, john will try "single" first, then
29
"wordlist" and finally "incremental".
30
.P
31
Once John finds a password, it will be printed to the terminal and saved
32
into a file called ~/john.pot. John will read this file when it restarts
33
so it doesn't try to crack already done passwords.
34
.P
35
To see the cracked passwords, use
36
.P
37
john -show passwd
38
.P
39
While cracking, you can press any key for status, or Ctrl+C to abort the
40
session, saving point information to a file (
41
.I ~/restore
42
by default). By the
43
way, if you press Ctrl+C twice John will abort immediately without saving.
44
The point information is also saved every 10 minutes (configurable in the
45
configuration file,
46
.I ~/john.ini
47
) in case of a crash.
48
.P
49
To continue an interrupted session, run:
50
.P
51
john -restore
52
.P
53
Now, you may notice that many accounts have a disabled shell, you can make
54
John ignore these (assume that shell is called '
55
.I /etc/expired
56
'):
57
.P
58
john -show -shells:-/etc/expired passwd
59
.P
60
You might want to mail all the users who got weak passwords,
61
to tell them to change the passwords. It's not always a good idea though
62
(unfortunately, lots of people seem to ignore such mail, it can be used
63
as a hint for crackers, etc), but anyway, I'll assume you know what you're
64
doing. Get a copy of the 'mailer' script supplied with John, so you won't
65
change anything that's under
66
.I /usr/bin
67
; edit the message it sends, and
68
possibly the mail command inside it (especially if the password file is
69
from a different box than you got John running on).
70
Then run:
71
.P
72
 ./mailer passwd
73
.P
74
Anyway, you probably should have a look at
75
.I /usr/share/doc/john/OPTIONS
76
for a list of all the command line options, and at
77
.I /usr/share/doc/john/EXAMPLES
78
for more John usage examples with other cracking modes.
79
.SH OPTIONS
80
All the options recognized by john start with a single dash (`-').
81
A summary of options is included below.
82
.TP
83
.B \-external:MODE
84
Enables an external mode, using external functions defined in ~/john.ini's
85
[List.External:MODE] section.
86
.TP
87
.B \-format:NAME
88
Allows you to override the ciphertext format detection. Currently, valid
89
format names are DES, BSDI, MD5, BF, AFS, LM. You can use this option when
90
cracking or with '-test'. Note that John can't crack password files with
91
different ciphertext formats at the same time.
92
.TP
93
.B \-groups:[-]GID[,..]
94
Tells John to load users of the specified group(s) only.
95
.TP
96
.B \-incremental[:MODE]
97
Enables the incremental mode, using the specified ~/john.ini definition
98
(section [Incremental:MODE], or [Incremental:All] by default).
99
.TP
100
.B \-makechars:FILE
101
Generates a charset file, based on character frequencies from ~/john.pot,
102
for use with the incremental mode. The entire ~/john.pot will be used for
103
the charset file unless you specify some password files. You can also use
104
an external filter() routine with this option.
105
.TP
106
.B \-restore[:FILE]
107
Continues an interrupted cracking session, reading point information from
108
the specified file (~/restore by default).
109
.TP
110
.B \-rules
111
Enables wordlist rules, that are read from [List.Rules:Wordlist].
112
.TP
113
.B \-salts:[-]COUNT
114
This feature sometimes allows to achieve better performance. For example
115
you can crack only some salts using '-salts:2' faster, and then crack the
116
rest using '-salts:-2'. Total cracking time will be about the same, but
117
you will get some passwords cracked earlier.
118
.TP
119
.B \-savemem:LEVEL
120
You might need this option if you don't have enough memory, or don't want
121
John to affect other processes too much. Level 1 tells John not to waste
122
memory on login names, so you won't see them while cracking. Higher levels
123
have a performance impact: you should probably avoid using them unless John
124
doesn't work or gets into swap otherwise.
125
.TP
126
.B \-session:FILE
127
Allows you to specify another point information file's name to use for
128
this cracking session. This is useful for running multiple instances of
129
John in parallel, or just to be able to recover an older session later,
130
not always continue the latest one.
131
.TP
132
.B \-shells:[-]SHELL[,..]
133
This option is useful to load accounts with a valid shell only, or not to
134
load accounts with a bad shell. You can omit the path before a shell name,
135
so '-shells:csh' will match both '/bin/csh' and '/usr/bin/csh', while
136
'-shells:/bin/csh' will only match '/bin/csh'.
137
.TP
138
.B \-show
139
Shows the cracked passwords in a convenient form. You should also specify
140
the password files. You can use this option while another John is cracking,
141
to see what it did so far.
142
.TP
143
.B \-single
144
Enables the "single crack" mode, using rules from [List.Rules:Single].
145
.TP
146
.B \-status[:FILE]
147
Prints status of an interrupted or running session. To get an up to date
148
status information of a detached running session, send that copy of John
149
a SIGHUP before using this option.
150
.TP
151
.B \-stdin
152
These are used to enable the wordlist mode (reading from stdin).
153
.TP
154
.B \-stdout[:LENGTH]
155
When used with a cracking mode, except for "single crack", makes John
156
print the words it generates to stdout instead of cracking. While applying
157
wordlist rules, the significant password length is assumed to be LENGTH,
158
or unlimited by default.
159
.TP
160
.B \-test
161
Benchmarks all the enabled ciphertext format crackers, and tests them for
162
correct operation at the same time.
163
.TP
164
.B \-users:[-]LOGIN|UID[,..]
165
Allows you to filter a few accounts for cracking, etc. A dash before the
166
list can be used to invert the check (that is, load all the users that
167
aren't listed).
168
.TP
169
.B \-wordfile:FILE
170
These are used to enable the wordlist mode, reading words from FILE.
171
.SH MODES
172
John can work in the following modes:
173
.TP
174
\fBWordlist\fP
175
John will simply use a file with a list of words that will be checked
176
against the passwords. See RULES for the format of wordlist files.
177
.TP
178
\fBSingle crack\fP
179
In this mode, john will try to crack the password using the login/GECOS
180
information as passwords.
181
.TP
182
\fBIncremental\fP
183
This is the most powerful mode. John will try any character combination
184
to resolve the password.
185
Details about these modes can be found in the MODES file in john's
186
documentation, including how to define your own cracking methods.
187
.SH SEE ALSO
188
.BR mailer (1),
189
.BR unafs (1),
190
.BR unique (1),
191
.BR unshadow (1),
192
.BR john.ini (5)
193
.PP
194
The programs are documented fully by John's documentation,
195
which should be available in \fI/usr/share/doc/john\fP or other
196
location, depending on your system.
197
.SH AUTHOR
198
This manual page was written by Jordi Mallach <jordi@debian.org>
199
and Jeronimo  Pellegrini <pellegrini@mpcnet.com.br>, for the
200
Debian GNU/Linux system (but may be used by others).
201
.br
202
John the Ripper was written by Solar Designer <solar@openwall.com>.
203
The complete list of contributors can be found in the CREDITS file
204
in the documentation directory.
(-)john-1.6.orig/debian/mailer (+50 lines)
Line 0 Link Here
1
#!/bin/sh
2
#
3
# This file is part of John the Ripper password cracker,
4
# Copyright (c) 1996-98 by Solar Designer
5
#
6
7
if [ $# -ne 1 ]; then
8
	echo "Usage: $0 PASSWORD-FILE"
9
	exit 0
10
fi
11
12
if [ ! -f /etc/john-mail.conf ]; then
13
       echo "Couldn't find /etc/john-mail.conf -- stopping!"
14
       exit 0
15
fi
16
17
if [ ! -f /etc/john-mail.msg ]; then
18
        echo "Couldn't find /etc/john-mail.msg -- stopping!"
19
        exit 0
20
fi
21
22
# In Debian, john should be in /usr/sbin. "john" binaries in other
23
# locations should not be used.
24
JOHNDIR=/usr/sbin
25
26
# Let's get stuff from conf file:
27
SHELLS=`grep   -e "shells[ ]*=[ ]*"  /etc/john-mail.conf | sed "s/.*=[ ]*//"`
28
MAILCMD=`grep  -e "mailcmd[ ]*=[ ]*" /etc/john-mail.conf | sed "s/.*=[ ]*//"`
29
MAILARGS=`grep -e "mailargs[ ]*=[ ]*" /etc/john-mail.conf | sed "s/.*=[ ]*//"`
30
31
# Let's start
32
$JOHNDIR/john -show "$1" -shells:$SHELLS | sed -n 's/:.*//p' |
33
(
34
	SENT=0
35
36
	while read LOGIN; do
37
		echo Sending mail to "$LOGIN"...
38
39
# Sends a message to each user; a template is in /etc/john.msg
40
# Subject, Reply-to, and other header lines should be put
41
# at the top of that file.
42
        sed -e 's/@LOGIN/'$LOGIN'/g' \
43
            -e 's/@HOSTNAME/'$HOSTNAME'/g' /etc/john-mail.msg |
44
        $MAILCMD $MAILARGS $LOGIN
45
46
		SENT=$(($SENT+1))
47
	done
48
49
	echo $SENT messages sent
50
)
(-)john-1.6.orig/debian/mailer.1 (+45 lines)
Line 0 Link Here
1
.\"                                      Hey, EMACS: -*- nroff -*-
2
.\"
3
.\" mailer.1 is copyright 1999-2001 by
4
.\" Jordi Mallach <jordi@debian.org>
5
.\" This is free documentation, see the latest version of the GNU General
6
.\" Public License for copying conditions. There is NO warranty.
7
.TH MAILER 1 "May 19, 2001" john
8
.\" Please adjust this date whenever revising the manpage.
9
.SH NAME
10
mailer \- script to warn users about their week passwords
11
.SH SYNOPSIS
12
.B mailer
13
\fIpassword-files\fP
14
.SH DESCRIPTION
15
This manual page documents briefly the
16
.B mailer
17
command, which is part of the john package.
18
This manual page was written for the Debian GNU/Linux distribution
19
because the original program does not have a manual page.
20
\fBjohn\fP, better known as John the Ripper, is a tool to find weak
21
passwords of users in a server.
22
.br
23
The \fBmailer\fP tool is useful to inform users which have been found to
24
be using weak passwords by mail.
25
.P
26
You should edit the message mailer will send to the users, but remember to
27
copy the script to a safe place before editing it, as it's
28
generally a bad idea to modify things living in /usr.
29
.SH SEE ALSO
30
.BR john (1),
31
.BR unafs (1),
32
.BR unique (1),
33
.BR unshadow (1),
34
.BR john.ini (5)
35
.PP
36
The programs are documented fully by John's documentation,
37
which should be available in \fI/usr/share/doc/john\fP or other
38
location, depending on your system.
39
.SH AUTHOR
40
This manual page was written by Jordi Mallach <jordi@debian.org>,
41
for the Debian GNU/Linux system (but may be used by others).
42
.br
43
John the Ripper and mailer were written by Solar Designer
44
<solar@openwall.com>. The complete list of contributors can be found in
45
the CREDITS file in the documentation directory.
(-)john-1.6.orig/debian/overrides.Lintian (+4 lines)
Line 0 Link Here
1
john: interpreter-not-absolute ./usr/share/john/password.lst #!comment:
2
john: script-not-executable ./usr/share/john/password.lst
3
john: unusual-interpreter ./usr/share/john/password.lst #!comment:
4
john: missing-debconf-dependency
(-)john-1.6.orig/debian/postinst (+37 lines)
Line 0 Link Here
1
#!/bin/sh -e
2
if [ "$1" = "configure" ]; then
3
        if [ -d /usr/doc -a ! -e /usr/doc/john -a -d /usr/share/doc/john ]; then
4
                ln -sf ../share/doc/john /usr/doc/john
5
        fi
6
fi
7
8
if [ -f /usr/share/debconf/confmodule ]; then
9
	. /usr/share/debconf/confmodule
10
11
	db_get john/cronjob ; INSTCRON="$RET"
12
	if [ "$INSTCRON" = "true" ]; then
13
		john-cronjob install
14
	else
15
		john-cronjob remove
16
	fi
17
else
18
	cat <<%END%
19
 I can install a cronjob for you that will run periodically, trying
20
 to crack passwords, and then mail users with weak passwords.
21
 You will have to configure the path and name of the temporary
22
 file in /etc/john-mailer.conf.
23
 .
24
 If you decide not to install now, you can always run
25
 "john.cron install" to install it if you change your mind.
26
27
Should I install the cronjob?
28
%END%
29
	read a
30
	case "$a" in
31
		[yY]*)
32
			john-cronjob install
33
			;;
34
		[nN]*)
35
			john-cronjob remove
36
	esac
37
fi
(-)john-1.6.orig/debian/postrm (+6 lines)
Line 0 Link Here
1
#!/bin/sh
2
3
if [ "$1" = purge -a -e /usr/share/debconf/confmodule ]; then
4
        . /usr/share/debconf/confmodule
5
        db_purge
6
fi
(-)john-1.6.orig/debian/prerm (+14 lines)
Line 0 Link Here
1
#!/bin/sh
2
3
# Remove runtime file when purging john.
4
5
[ "$1" = "remove" ] && rm -f /usr/share/john/restore
6
7
if [ \( "$1" = "upgrade" -o "$1" = "remove" \) -a -L /usr/doc/john ]; then
8
	rm -f /usr/doc/john
9
fi
10
11
# Check if a cronjob was installed and if yes, remove it.
12
if [ -f /etc/cron.daily/john ]; then
13
	/usr/sbin/john-cronjob remove
14
fi
(-)john-1.6.orig/debian/rules (+126 lines)
Line 0 Link Here
1
#!/usr/bin/make -f
2
3
PACKAGE := john
4
TARGET:=$(shell dpkg --print-architecture | sed 's/i386/linux-x86-any-elf/;s/alpha/linux-alpha/;s/sparc/linux-sparc/')
5
ARCHITECURE:=$(shell dpkg --print-architecture)
6
7
build: build-stamp
8
build-stamp:
9
		test -e debian/control
10
ifeq ($(ARCHITECURE),i386)
11
			cd $(CURDIR)/src && make $(TARGET)
12
			mv run/john run/john-any
13
			cd $(CURDIR)/src && make clean
14
			cd $(CURDIR)/src && make linux-x86-mmx-elf
15
			mv run/john run/john-mmx
16
else	
17
		cd $(CURDIR)/src && make $(TARGET)
18
endif
19
		touch build-stamp
20
21
clean:
22
		test -e debian/control
23
		test 0 = "`id -u`" || (echo need root privileges; exit 1)
24
		rm -f build-stamp install-stamp
25
		-$(MAKE) clean
26
		rm -rf debian/substvars debian/files debian/tmp
27
28
# Build architecture-independent files here.
29
binary-indep: build
30
# We have nothing to do by default.
31
32
# Build architecture-dependent files here.
33
binary-arch: build debian/control
34
		test -e debian/control
35
		test 0 = "`id -u`" || (echo need root privileges; exit 1)
36
		rm -rf debian/substvars debian/tmp
37
		install -d --mode=0755 debian/tmp
38
		install -d --mode=0755 "debian/tmp/usr/share/doc/$(PACKAGE)"
39
		install -d --mode=0755 "debian/tmp/usr/share/man/man1"
40
		install -d --mode=0755 "debian/tmp/usr/share/lintian/overrides"
41
		install -d --mode=0755 "debian/tmp/usr/share/$(PACKAGE)"
42
		install -d --mode=0755 "debian/tmp/usr/sbin"
43
		install -d --mode=0755 "debian/tmp/etc"
44
		install -m 644 run/john.ini debian/tmp/etc
45
		install -m 644 run/all.chr debian/tmp/usr/share/john
46
		install -m 644 run/alpha.chr debian/tmp/usr/share/john
47
		install -m 644 run/digits.chr debian/tmp/usr/share/john
48
		install -m 644 run/lanman.chr debian/tmp/usr/share/john
49
		install -m 644 run/password.lst debian/tmp/usr/share/john
50
51
		# Extra Stuff that should be removed after the next
52
		# upstream release of john the ripper
53
		install -m 644 debian/john-mail.msg debian/tmp/etc
54
		install -m 644 debian/john-mail.conf debian/tmp/etc
55
		install -m 644 debian/CONFIG.mailer debian/tmp/usr/share/doc/$(PACKAGE)
56
		install -m 755 debian/mailer debian/tmp/usr/sbin
57
		install -m 755 debian/john-cronjob debian/tmp/usr/sbin
58
		install -m 755 debian/john-dailyscript debian/tmp/usr/share/$(PACKAGE)
59
60
ifeq (i386,$(ARCHITECURE))
61
		install -s run/john-any debian/tmp/usr/sbin/john-any
62
		install -s run/john-mmx debian/tmp/usr/sbin/john-mmx
63
		install -m 755 debian/john debian/tmp/usr/sbin/john
64
else
65
		install -s run/john debian/tmp/usr/sbin/john
66
endif
67
		
68
		#Commented out, because currently we'll use a special
69
		#hacked version. Comment it in after new upstream release.
70
		#install run/mailer debian/tmp/usr/sbin
71
72
ifeq (i386,$(ARCHITECURE))
73
		(cd debian/tmp/usr/sbin; ln -s john-any unafs; ln -s john-any unique; \
74
		ln -s john-any unshadow)
75
else
76
		(cd debian/tmp/usr/sbin; ln -s john unafs; ln -s john unique; \
77
		ln -s john unshadow)
78
endif
79
		install --mode=0644 debian/overrides.Lintian \
80
			debian/tmp/usr/share/lintian/overrides/john
81
		install --mode=0644 debian/copyright \
82
			"debian/tmp/usr/share/doc/$(PACKAGE)"
83
		install --mode=0644 doc/CONFIG doc/CREDITS doc/EXAMPLES doc/EXTERNAL doc/README \
84
		   "debian/tmp/usr/share/doc/$(PACKAGE)"
85
		install --mode=0644 doc/FAQ doc/MODES doc/OPTIONS doc/RULES doc/NEWS \
86
		   "debian/tmp/usr/share/doc/$(PACKAGE)"
87
		install --mode=0644 debian/changelog \
88
			"debian/tmp/usr/share/doc/$(PACKAGE)/changelog.Debian"
89
		mv debian/tmp/usr/share/doc/$(PACKAGE)/NEWS \
90
		   debian/tmp/usr/share/doc/$(PACKAGE)/changelog
91
		install --mode=0644 debian/john.1 "debian/tmp/usr/share/man/man1"
92
		install --mode=0644 debian/mailer.1 "debian/tmp/usr/share/man/man1"
93
		install --mode=0644 debian/unafs.1 "debian/tmp/usr/share/man/man1"
94
		install --mode=0644 debian/unique.1 "debian/tmp/usr/share/man/man1"
95
		install --mode=0644 debian/unshadow.1 "debian/tmp/usr/share/man/man1"
96
		install --mode=0644 debian/john-cronjob.1 "debian/tmp/usr/share/man/man1"
97
		gzip -9 debian/tmp/usr/share/doc/$(PACKAGE)/changelog
98
		gzip -9 debian/tmp/usr/share/doc/$(PACKAGE)/changelog.Debian
99
		gzip -9 debian/tmp/usr/share/doc/$(PACKAGE)/EXAMPLES
100
		gzip -9 debian/tmp/usr/share/man/man1/john.1
101
		gzip -9 debian/tmp/usr/share/man/man1/mailer.1
102
		gzip -9 debian/tmp/usr/share/man/man1/unafs.1
103
		gzip -9 debian/tmp/usr/share/man/man1/unique.1
104
		gzip -9 debian/tmp/usr/share/man/man1/unshadow.1
105
		gzip -9 debian/tmp/usr/share/man/man1/john-cronjob.1
106
ifeq (i386,$(ARCHITECURE))
107
		strip --remove-section=.comment --remove-section=.note debian/tmp/usr/sbin/john-any
108
		strip --remove-section=.comment --remove-section=.note debian/tmp/usr/sbin/john-mmx
109
else
110
		strip --remove-section=.comment --remove-section=.note debian/tmp/usr/sbin/john
111
endif
112
		install -d --mode=0755 debian/tmp/DEBIAN
113
		install --mode=0755 debian/prerm debian/postinst debian/tmp/DEBIAN
114
		install --mode=0644 debian/conffiles debian/tmp/DEBIAN
115
		install --mode=0755 debian/config debian/tmp/DEBIAN
116
		install --mode=0644 debian/templates debian/tmp/DEBIAN
117
		install --mode=0755 debian/postinst debian/tmp/DEBIAN
118
		dpkg-shlibdeps debian/tmp/usr/sbin/*
119
		dpkg-gencontrol -isp
120
		dpkg --build debian/tmp ..
121
122
source diff:
123
		@echo >&2 'source and diff are obsolete - use dpkg-source -b'; false
124
125
binary: binary-indep binary-arch
126
.PHONY: build clean binary-indep binary-arch binary
(-)john-1.6.orig/debian/templates (+21 lines)
Line 0 Link Here
1
Template: john/cronjob
2
Type: boolean
3
Default: false
4
Description: Should John run periodically and mail users?
5
 I can install a cronjob for you that will run periodically, trying
6
 to crack passwords, and then mail users with weak passwords.
7
 You will have to configure the path and name of the temporary
8
 file in /etc/john-mail.conf.
9
 .
10
 If you decide not to install now, you can always run
11
 "john.cron install" to install it if you change your mind.
12
 Should I install the cronjob?
13
Description-de: John regelmäßig ausführen und Nutzer anmailen?
14
 Es kann ein Cron-Job installiert werden, der John regelmäßig ausführt,
15
 und versucht Passwörter zu knacken. Nutzer mit zu einfachen Passwörtern
16
 werden dann per eMail darüber informiert. Sie müsssen dazu den Pfad und
17
 Namen einer temporären Datei in /etc/john-mail.conf angeben.
18
 .
19
 Wenn Sie dies jetzt nicht tun möchten, dann können Sie jederzeit
20
 "john.cron install" ausführen, um den Cron-Job nachträglich zu
21
 installieren
(-)john-1.6.orig/debian/unafs.1 (+40 lines)
Line 0 Link Here
1
.\"                                      Hey, EMACS: -*- nroff -*-
2
.\"
3
.\" unafs.1 is copyright 1999-2001 by
4
.\" Jordi Mallach <jordi@debian.org>
5
.\" This is free documentation, see the latest version of the GNU General
6
.\" Public License for copying conditions. There is NO warranty.
7
.TH UNAFS 1 "May 19, 2001" john
8
.\" Please adjust this date whenever revising the manpage.
9
.SH NAME
10
unafs \- script to warn users about their week passwords
11
.SH SYNOPSIS
12
.B unafs
13
\fIpassword-files cell-name\fP
14
.SH DESCRIPTION
15
This manual page documents briefly the
16
.B unafs
17
command, which is part of the john package.
18
This manual page was written for the Debian GNU/Linux distribution
19
because the original program does not have a manual page.
20
\fBjohn\fP, better known as John the Ripper, is a tool to find weak
21
passwords of users in a server.
22
.br The \fBunafs\fP tool gets password hashes out of the binary AFS
23
database, and produces a file usable by John.
24
.SH SEE ALSO
25
.BR john (1),
26
.BR mailer (1),
27
.BR unique (1),
28
.BR unshadow (1),
29
.BR john.ini (5)
30
.PP
31
The programs are documented fully by John's documentation,
32
which should be available in \fI/usr/share/doc/john\fP or other
33
location, depending on your system.
34
.SH AUTHOR
35
This manual page was written by Jordi Mallach <jordi@debian.org>,
36
for the Debian GNU/Linux system (but may be used by others).
37
.br
38
John the Ripper and mailer were written by Solar Designer
39
<solar@openwall.com>. The complete list of contributors can be found in
40
the CREDITS file in the documentation directory.
(-)john-1.6.orig/debian/unique.1 (+41 lines)
Line 0 Link Here
1
.\"                                      Hey, EMACS: -*- nroff -*-
2
.\"
3
.\" unique.1 is copyright 1999-2001 by
4
.\" Jordi Mallach <jordi@debian.org>
5
.\" This is free documentation, see the latest version of the GNU General
6
.\" Public License for copying conditions. There is NO warranty.
7
.TH UNIQUE 1 "May 19, 2001" john
8
.\" Please adjust this date whenever revising the manpage.
9
.SH NAME
10
unique \- removes duplicates from a wordlist
11
.SH SYNOPSIS
12
.B unique
13
\fIoutput-file\fP
14
.SH DESCRIPTION
15
This manual page documents briefly the
16
.B unique
17
command, which is part of the john package.
18
This manual page was written for the Debian GNU/Linux distribution
19
because the original program does not have a manual page.
20
\fBjohn\fP, better known as John the Ripper, is a tool to find weak
21
passwords of users in a server.
22
.br The \fBunique\fP tool finds and removes duplicate entries from a
23
wordlist (read from stdin), without changing the order. This is important
24
to increase the performance of john when using the wordlist method.
25
.SH SEE ALSO
26
.BR john (1),
27
.BR mailer (1),
28
.BR unafs (1),
29
.BR unshadow (1),
30
.BR john.ini (5)
31
.PP
32
The programs are documented fully by John's documentation,
33
which should be available in \fI/usr/share/doc/john\fP or other
34
location, depending on your system.
35
.SH AUTHOR
36
This manual page was written by Jordi Mallach <jordi@debian.org>,
37
for the Debian GNU/Linux system (but may be used by others).
38
.br
39
John the Ripper and mailer were written by Solar Designer
40
<solar@openwall.com>. The complete list of contributors can be found in
41
the CREDITS file in the documentation directory.
(-)john-1.6.orig/debian/unshadow.1 (+43 lines)
Line 0 Link Here
1
.\"                                      Hey, EMACS: -*- nroff -*-
2
.\"
3
.\" unshadow.1 is copyright 1999-2001 by
4
.\" Jordi Mallach <jordi@debian.org>
5
.\" This is free documentation, see the latest version of the GNU General
6
.\" Public License for copying conditions. There is NO warranty.
7
.TH UNSHADOW 1 "May 19, 2001" john
8
.\" Please adjust this date whenever revising the manpage.
9
.SH NAME
10
unshadow \- combines passwd and shadow files
11
.SH SYNOPSIS
12
.B unshadow
13
\fIpassword-file shadow-file\fP
14
.SH DESCRIPTION
15
This manual page documents briefly the
16
.B unshadow
17
command, which is part of the john package.
18
This manual page was written for the Debian GNU/Linux distribution
19
because the original program does not have a manual page.
20
\fBjohn\fP, better known as John the Ripper, is a tool to find weak
21
passwords of users in a server.
22
.br The \fBunshadow\fP tool combines the passwd and shadow files so John can
23
use them. You might need this since if you only used your shadow file, the
24
GECOS information wouldn't be used by the "single crack" mode, and also you
25
wouldn't be able to use the '-shells' option. On a normal system you'll need
26
to run unshadow as root to be able to read the shadow file.
27
.SH SEE ALSO
28
.BR john (1),
29
.BR mailer (1),
30
.BR unafs (1),
31
.BR unique (1),
32
.BR john.ini (5)
33
.PP
34
The programs are documented fully by John's documentation,
35
which should be available in \fI/usr/share/doc/john\fP or other
36
location, depending on your system.
37
.SH AUTHOR
38
This manual page was written by Jordi Mallach <jordi@debian.org>,
39
for the Debian GNU/Linux system (but may be used by others).
40
.br
41
John the Ripper and mailer were written by Solar Designer
42
<solar@openwall.com>. The complete list of contributors can be found in
43
the CREDITS file in the documentation directory.
(-)john-1.6.orig/doc/COPYING (+342 lines)
Line 0 Link Here
1
		    GNU GENERAL PUBLIC LICENSE
2
		       Version 2, June 1991
3
4
 Copyright (C) 1989, 1991 Free Software Foundation, Inc.
5
                       59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
6
 Everyone is permitted to copy and distribute verbatim copies
7
 of this license document, but changing it is not allowed.
8
9
			    Preamble
10
11
  The licenses for most software are designed to take away your
12
freedom to share and change it.  By contrast, the GNU General Public
13
License is intended to guarantee your freedom to share and change free
14
software--to make sure the software is free for all its users.  This
15
General Public License applies to most of the Free Software
16
Foundation's software and to any other program whose authors commit to
17
using it.  (Some other Free Software Foundation software is covered by
18
the GNU Library General Public License instead.)  You can apply it to
19
your programs, too.
20
21
  When we speak of free software, we are referring to freedom, not
22
price.  Our General Public Licenses are designed to make sure that you
23
have the freedom to distribute copies of free software (and charge for
24
this service if you wish), that you receive source code or can get it
25
if you want it, that you can change the software or use pieces of it
26
in new free programs; and that you know you can do these things.
27
28
  To protect your rights, we need to make restrictions that forbid
29
anyone to deny you these rights or to ask you to surrender the rights.
30
These restrictions translate to certain responsibilities for you if you
31
distribute copies of the software, or if you modify it.
32
33
  For example, if you distribute copies of such a program, whether
34
gratis or for a fee, you must give the recipients all the rights that
35
you have.  You must make sure that they, too, receive or can get the
36
source code.  And you must show them these terms so they know their
37
rights.
38
39
  We protect your rights with two steps: (1) copyright the software, and
40
(2) offer you this license which gives you legal permission to copy,
41
distribute and/or modify the software.
42
43
  Also, for each author's protection and ours, we want to make certain
44
that everyone understands that there is no warranty for this free
45
software.  If the software is modified by someone else and passed on, we
46
want its recipients to know that what they have is not the original, so
47
that any problems introduced by others will not reflect on the original
48
authors' reputations.
49
50
  Finally, any free program is threatened constantly by software
51
patents.  We wish to avoid the danger that redistributors of a free
52
program will individually obtain patent licenses, in effect making the
53
program proprietary.  To prevent this, we have made it clear that any
54
patent must be licensed for everyone's free use or not licensed at all.
55
56
  The precise terms and conditions for copying, distribution and
57
modification follow.
58
59
		    GNU GENERAL PUBLIC LICENSE
60
   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
61
62
  0. This License applies to any program or other work which contains
63
a notice placed by the copyright holder saying it may be distributed
64
under the terms of this General Public License.  The "Program", below,
65
refers to any such program or work, and a "work based on the Program"
66
means either the Program or any derivative work under copyright law:
67
that is to say, a work containing the Program or a portion of it,
68
either verbatim or with modifications and/or translated into another
69
language.  (Hereinafter, translation is included without limitation in
70
the term "modification".)  Each licensee is addressed as "you".
71
72
Activities other than copying, distribution and modification are not
73
covered by this License; they are outside its scope.  The act of
74
running the Program is not restricted, and the output from the Program
75
is covered only if its contents constitute a work based on the
76
Program (independent of having been made by running the Program).
77
Whether that is true depends on what the Program does.
78
79
  1. You may copy and distribute verbatim copies of the Program's
80
source code as you receive it, in any medium, provided that you
81
conspicuously and appropriately publish on each copy an appropriate
82
copyright notice and disclaimer of warranty; keep intact all the
83
notices that refer to this License and to the absence of any warranty;
84
and give any other recipients of the Program a copy of this License
85
along with the Program.
86
87
You may charge a fee for the physical act of transferring a copy, and
88
you may at your option offer warranty protection in exchange for a fee.
89
90
  2. You may modify your copy or copies of the Program or any portion
91
of it, thus forming a work based on the Program, and copy and
92
distribute such modifications or work under the terms of Section 1
93
above, provided that you also meet all of these conditions:
94
95
    a) You must cause the modified files to carry prominent notices
96
    stating that you changed the files and the date of any change.
97
98
    b) You must cause any work that you distribute or publish, that in
99
    whole or in part contains or is derived from the Program or any
100
    part thereof, to be licensed as a whole at no charge to all third
101
    parties under the terms of this License.
102
103
    c) If the modified program normally reads commands interactively
104
    when run, you must cause it, when started running for such
105
    interactive use in the most ordinary way, to print or display an
106
    announcement including an appropriate copyright notice and a
107
    notice that there is no warranty (or else, saying that you provide
108
    a warranty) and that users may redistribute the program under
109
    these conditions, and telling the user how to view a copy of this
110
    License.  (Exception: if the Program itself is interactive but
111
    does not normally print such an announcement, your work based on
112
    the Program is not required to print an announcement.)
113
114
These requirements apply to the modified work as a whole.  If
115
identifiable sections of that work are not derived from the Program,
116
and can be reasonably considered independent and separate works in
117
themselves, then this License, and its terms, do not apply to those
118
sections when you distribute them as separate works.  But when you
119
distribute the same sections as part of a whole which is a work based
120
on the Program, the distribution of the whole must be on the terms of
121
this License, whose permissions for other licensees extend to the
122
entire whole, and thus to each and every part regardless of who wrote it.
123
124
Thus, it is not the intent of this section to claim rights or contest
125
your rights to work written entirely by you; rather, the intent is to
126
exercise the right to control the distribution of derivative or
127
collective works based on the Program.
128
129
In addition, mere aggregation of another work not based on the Program
130
with the Program (or with a work based on the Program) on a volume of
131
a storage or distribution medium does not bring the other work under
132
the scope of this License.
133
134
  3. You may copy and distribute the Program (or a work based on it,
135
under Section 2) in object code or executable form under the terms of
136
Sections 1 and 2 above provided that you also do one of the following:
137
138
    a) Accompany it with the complete corresponding machine-readable
139
    source code, which must be distributed under the terms of Sections
140
    1 and 2 above on a medium customarily used for software interchange; or,
141
142
    b) Accompany it with a written offer, valid for at least three
143
    years, to give any third party, for a charge no more than your
144
    cost of physically performing source distribution, a complete
145
    machine-readable copy of the corresponding source code, to be
146
    distributed under the terms of Sections 1 and 2 above on a medium
147
    customarily used for software interchange; or,
148
149
    c) Accompany it with the information you received as to the offer
150
    to distribute corresponding source code.  (This alternative is
151
    allowed only for noncommercial distribution and only if you
152
    received the program in object code or executable form with such
153
    an offer, in accord with Subsection b above.)
154
155
The source code for a work means the preferred form of the work for
156
making modifications to it.  For an executable work, complete source
157
code means all the source code for all modules it contains, plus any
158
associated interface definition files, plus the scripts used to
159
control compilation and installation of the executable.  However, as a
160
special exception, the source code distributed need not include
161
anything that is normally distributed (in either source or binary
162
form) with the major components (compiler, kernel, and so on) of the
163
operating system on which the executable runs, unless that component
164
itself accompanies the executable.
165
166
If distribution of executable or object code is made by offering
167
access to copy from a designated place, then offering equivalent
168
access to copy the source code from the same place counts as
169
distribution of the source code, even though third parties are not
170
compelled to copy the source along with the object code.
171
172
  4. You may not copy, modify, sublicense, or distribute the Program
173
except as expressly provided under this License.  Any attempt
174
otherwise to copy, modify, sublicense or distribute the Program is
175
void, and will automatically terminate your rights under this License.
176
However, parties who have received copies, or rights, from you under
177
this License will not have their licenses terminated so long as such
178
parties remain in full compliance.
179
180
  5. You are not required to accept this License, since you have not
181
signed it.  However, nothing else grants you permission to modify or
182
distribute the Program or its derivative works.  These actions are
183
prohibited by law if you do not accept this License.  Therefore, by
184
modifying or distributing the Program (or any work based on the
185
Program), you indicate your acceptance of this License to do so, and
186
all its terms and conditions for copying, distributing or modifying
187
the Program or works based on it.
188
189
  6. Each time you redistribute the Program (or any work based on the
190
Program), the recipient automatically receives a license from the
191
original licensor to copy, distribute or modify the Program subject to
192
these terms and conditions.  You may not impose any further
193
restrictions on the recipients' exercise of the rights granted herein.
194
You are not responsible for enforcing compliance by third parties to
195
this License.
196
197
  7. If, as a consequence of a court judgment or allegation of patent
198
infringement or for any other reason (not limited to patent issues),
199
conditions are imposed on you (whether by court order, agreement or
200
otherwise) that contradict the conditions of this License, they do not
201
excuse you from the conditions of this License.  If you cannot
202
distribute so as to satisfy simultaneously your obligations under this
203
License and any other pertinent obligations, then as a consequence you
204
may not distribute the Program at all.  For example, if a patent
205
license would not permit royalty-free redistribution of the Program by
206
all those who receive copies directly or indirectly through you, then
207
the only way you could satisfy both it and this License would be to
208
refrain entirely from distribution of the Program.
209
210
If any portion of this section is held invalid or unenforceable under
211
any particular circumstance, the balance of the section is intended to
212
apply and the section as a whole is intended to apply in other
213
circumstances.
214
215
It is not the purpose of this section to induce you to infringe any
216
patents or other property right claims or to contest validity of any
217
such claims; this section has the sole purpose of protecting the
218
integrity of the free software distribution system, which is
219
implemented by public license practices.  Many people have made
220
generous contributions to the wide range of software distributed
221
through that system in reliance on consistent application of that
222
system; it is up to the author/donor to decide if he or she is willing
223
to distribute software through any other system and a licensee cannot
224
impose that choice.
225
226
This section is intended to make thoroughly clear what is believed to
227
be a consequence of the rest of this License.
228
229
  8. If the distribution and/or use of the Program is restricted in
230
certain countries either by patents or by copyrighted interfaces, the
231
original copyright holder who places the Program under this License
232
may add an explicit geographical distribution limitation excluding
233
those countries, so that distribution is permitted only in or among
234
countries not thus excluded.  In such case, this License incorporates
235
the limitation as if written in the body of this License.
236
237
  9. The Free Software Foundation may publish revised and/or new versions
238
of the General Public License from time to time.  Such new versions will
239
be similar in spirit to the present version, but may differ in detail to
240
address new problems or concerns.
241
242
Each version is given a distinguishing version number.  If the Program
243
specifies a version number of this License which applies to it and "any
244
later version", you have the option of following the terms and conditions
245
either of that version or of any later version published by the Free
246
Software Foundation.  If the Program does not specify a version number of
247
this License, you may choose any version ever published by the Free Software
248
Foundation.
249
250
  10. If you wish to incorporate parts of the Program into other free
251
programs whose distribution conditions are different, write to the author
252
to ask for permission.  For software which is copyrighted by the Free
253
Software Foundation, write to the Free Software Foundation; we sometimes
254
make exceptions for this.  Our decision will be guided by the two goals
255
of preserving the free status of all derivatives of our free software and
256
of promoting the sharing and reuse of software generally.
257
258
			    NO WARRANTY
259
260
  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
261
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
262
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
263
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
264
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
265
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
266
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
267
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
268
REPAIR OR CORRECTION.
269
270
  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
271
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
272
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
273
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
274
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
275
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
276
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
277
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
278
POSSIBILITY OF SUCH DAMAGES.
279
280
		     END OF TERMS AND CONDITIONS
281
282
	    How to Apply These Terms to Your New Programs
283
284
  If you develop a new program, and you want it to be of the greatest
285
possible use to the public, the best way to achieve this is to make it
286
free software which everyone can redistribute and change under these terms.
287
288
  To do so, attach the following notices to the program.  It is safest
289
to attach them to the start of each source file to most effectively
290
convey the exclusion of warranty; and each file should have at least
291
the "copyright" line and a pointer to where the full notice is found.
292
293
    <one line to give the program's name and a brief idea of what it does.>
294
    Copyright (C) <year>  <name of author>
295
296
    This program is free software; you can redistribute it and/or modify
297
    it under the terms of the GNU General Public License as published by
298
    the Free Software Foundation; either version 2 of the License, or
299
    (at your option) any later version.
300
301
    This program is distributed in the hope that it will be useful,
302
    but WITHOUT ANY WARRANTY; without even the implied warranty of
303
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
304
    GNU General Public License for more details.
305
306
    You should have received a copy of the GNU General Public License
307
    along with this program; if not, write to the Free Software
308
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
309
310
311
Also add information on how to contact you by electronic and paper mail.
312
313
If the program is interactive, make it output a short notice like this
314
when it starts in an interactive mode:
315
316
    Gnomovision version 69, Copyright (C) year name of author
317
    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
318
    This is free software, and you are welcome to redistribute it
319
    under certain conditions; type `show c' for details.
320
321
The hypothetical commands `show w' and `show c' should show the appropriate
322
parts of the General Public License.  Of course, the commands you use may
323
be called something other than `show w' and `show c'; they could even be
324
mouse-clicks or menu items--whatever suits your program.
325
326
You should also get your employer (if you work as a programmer) or your
327
school, if any, to sign a "copyright disclaimer" for the program, if
328
necessary.  Here is a sample; alter the names:
329
330
  Yoyodyne, Inc., hereby disclaims all copyright interest in the program
331
  `Gnomovision' (which makes passes at compilers) written by James Hacker.
332
333
  <signature of Ty Coon>, 1 April 1989
334
  Ty Coon, President of Vice
335
336
This General Public License does not permit incorporating your program into
337
proprietary programs.  If your program is a subroutine library, you may
338
consider it more useful to permit linking proprietary applications with the
339
library.  If this is what you want to do, use the GNU Library General
340
Public License instead of this License.
341
342
(-)john-1.6.orig/doc/NTLM-FAQ (+33 lines)
Line 0 Link Here
1
2
Q: What's this?
3
A: It's a patch to Solar Designer's "john the ripper" password cracker.
4
5
Q: What's it good for, then?
6
A: It enables john to crack Windows NT/2000 MD4 (case-sensitive) password hashes.
7
8
Q: Who made this?
9
A: This patch was thrown together on a boring Sunday by Olle Segerdahl.
10
   It uses Andrew Tridgell's NTLM and MD4 code stolen from samba-2.0.7 .
11
12
Q: How do I install it?
13
A: I assume you are able to install john from a source distribution,
14
   if you are not, PLEASE read john's documentation. Put the files enclosed
15
   in this archive in the "src" subdirectory, run 'patch < john-ntlm.diff'
16
   and then 'make (your-system-type-here)' ....
17
18
Q: How do I use john to crack NT password hashes?
19
A: Use pwdump2 or L0phtcrack to dump the password hashes into a file,
20
   then run 'john pwfile -format:NT' to start cracking!
21
22
Q: Didn't it used to be '-format:NTLM' ?
23
A: Yes, but this has changed so as not to confuse people who have trouble
24
   understanding the difference between LM (DES) and NT (md4) hashes.
25
26
Q: I get all kinds of compile errors!
27
A: This patch was made against john-1.6.31-dev, lots of stuff might have broken
28
   source compatibility since then... Use something closer to john-1.6.31-dev.
29
30
Q: I have a question not covered by this FAQ!
31
A: Make sure you have read all there is to read about john, then
32
   mail me at olle@nxs.se with "JOHN-NTLM" in the subject.
33
(-)john-1.6.orig/run/john.ini (-5 / +5 lines)
Lines 5-11 Link Here
5
5
6
[Options]
6
[Options]
7
# Wordlist file name, to be used in batch mode
7
# Wordlist file name, to be used in batch mode
8
Wordfile = ~/password.lst
8
Wordfile = /usr/share/john/password.lst
9
# Use idle cycles only
9
# Use idle cycles only
10
Idle = N
10
Idle = N
11
# Crash recovery file saving delay in seconds
11
# Crash recovery file saving delay in seconds
Lines 314-338 Link Here
314
314
315
# Incremental modes
315
# Incremental modes
316
[Incremental:All]
316
[Incremental:All]
317
File = ~/all.chr
317
File = /usr/share/john/all.chr
318
MinLen = 0
318
MinLen = 0
319
MaxLen = 8
319
MaxLen = 8
320
CharCount = 95
320
CharCount = 95
321
321
322
[Incremental:Alpha]
322
[Incremental:Alpha]
323
File = ~/alpha.chr
323
File = /usr/share/john/alpha.chr
324
MinLen = 1
324
MinLen = 1
325
MaxLen = 8
325
MaxLen = 8
326
CharCount = 26
326
CharCount = 26
327
327
328
[Incremental:Digits]
328
[Incremental:Digits]
329
File = ~/digits.chr
329
File = /usr/share/john/digits.chr
330
MinLen = 1
330
MinLen = 1
331
MaxLen = 8
331
MaxLen = 8
332
CharCount = 10
332
CharCount = 10
333
333
334
[Incremental:LanMan]
334
[Incremental:LanMan]
335
File = ~/lanman.chr
335
File = /usr/share/john/lanman.chr
336
MinLen = 0
336
MinLen = 0
337
MaxLen = 7
337
MaxLen = 7
338
CharCount = 69
338
CharCount = 69
(-)john-1.6.orig/src/BFEgg_fmt.c (+119 lines)
Line 0 Link Here
1
/*
2
 * This file is part of Eggdrop blowfish patch for John The Ripper.
3
 * Copyright (c) 2002 by Sun-Zero <sun-zero@freemail.hu>
4
 * This is a free software distributable under terms of the GNU GPL. 
5
 * See the file COPYING for details.  
6
 */
7
8
#include <string.h>
9
10
#include "misc.h"
11
#include "formats.h"
12
#include "common.h"
13
#include "blowfish.c"
14
15
#define FORMAT_LABEL			"bfegg"
16
#define FORMAT_NAME			"Eggdrop"
17
#define ALG_NAME			"blowfish"
18
19
#define BENCHMARK_COMMENT		""
20
#define BENCHMARK_LENGTH		-1
21
22
#define PLAINTEXT_LENGTH		31
23
#define CIPHERTEXT_LENGTH		33
24
25
#define BINARY_SIZE			13
26
#define SALT_SIZE			0
27
28
#define MIN_KEYS_PER_CRYPT		1
29
#define MAX_KEYS_PER_CRYPT		1
30
31
static struct fmt_tests tests[] = {
32
    {"+Yug.E/gQk2S0", "ajto123"},
33
    {"+hG/XQ18czl5.", "ablak123"},
34
    {"+IaISR0x4ZY/.", "szek123"},
35
    {"+9VMVs/L1st7/", "konyha"},
36
    {"+EEHgy/MBLDd0", "walkman"},
37
    {"+vPBrs07OTXE/", "tesztuser"},
38
    {NULL}
39
};
40
41
static char crypt_key[BINARY_SIZE];
42
static char saved_key[PLAINTEXT_LENGTH + 1];
43
44
static int valid(char *ciphertext) {
45
    if (strncmp(ciphertext, "+", 1) != 0) return 0;
46
    if (strlen(ciphertext) != 13) return 0;
47
    
48
    return 1;
49
}
50
51
void init() {
52
    blowfish_first_init();
53
}
54
55
56
static void set_key(char *key, int index) {
57
  strnzcpy(saved_key, key, PLAINTEXT_LENGTH+1);
58
}
59
60
static char *get_key(int index) {
61
  return saved_key;
62
}
63
64
static int cmp_all(void *binary, int index) {
65
  return !memcmp(binary, crypt_key, BINARY_SIZE);
66
}
67
68
static int cmp_exact(char *source, int index) {
69
  return 1;
70
}
71
72
static void set_salt(void *salt) { }
73
74
static void crypt_all(int count) {  
75
    blowfish_encrypt_pass(saved_key, crypt_key);
76
}
77
78
struct fmt_main fmt_BFEgg = {
79
  {
80
    FORMAT_LABEL,
81
    FORMAT_NAME,
82
    ALG_NAME,
83
    BENCHMARK_COMMENT,
84
    BENCHMARK_LENGTH,
85
    PLAINTEXT_LENGTH,
86
    BINARY_SIZE,
87
    SALT_SIZE,
88
    MIN_KEYS_PER_CRYPT,
89
    MAX_KEYS_PER_CRYPT,
90
    FMT_CASE | FMT_8_BIT,
91
    tests
92
  }, {
93
    init,
94
    valid,
95
    fmt_default_split,
96
    fmt_default_binary,
97
    fmt_default_salt,
98
    {
99
	fmt_default_binary_hash,
100
	fmt_default_binary_hash,
101
	fmt_default_binary_hash,
102
    },
103
	fmt_default_salt_hash,
104
	set_salt,
105
	set_key,
106
	get_key,
107
	// fmt_default_clear_keys,
108
	crypt_all, 
109
	{
110
	    fmt_default_get_hash,
111
	    fmt_default_get_hash,
112
	    fmt_default_get_hash,
113
	},
114
	    cmp_all,
115
	    cmp_all,
116
	    cmp_exact
117
  }
118
};
119
(-)john-1.6.orig/src/KRB4_fmt.c (+288 lines)
Line 0 Link Here
1
/*
2
  KRB4_fmt.c
3
4
  AFS/krb4 TGT dictionary attack module for Solar Designer's John the Ripper.
5
6
  tgtsnarf files should only contain entries for one cell/realm.
7
  
8
  Copyright (c) 1999 Dug Song <dugsong@monkey.org>
9
  All rights reserved, all wrongs reversed.
10
11
  Redistribution and use in source and binary forms, with or without
12
  modification, are permitted provided that the following conditions
13
  are met:
14
15
  1. Redistributions of source code must retain the above copyright
16
     notice, this list of conditions and the following disclaimer.
17
  2. Redistributions in binary form must reproduce the above copyright
18
     notice, this list of conditions and the following disclaimer in the
19
     documentation and/or other materials provided with the distribution.
20
  3. The name of author may not be used to endorse or promote products
21
     derived from this software without specific prior written permission.
22
23
  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
24
  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
25
  AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
26
  THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
27
  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
28
  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
29
  OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
30
  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
31
  OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
32
  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33
*/
34
35
#include <string.h>
36
#include <ctype.h>
37
#define OPENSSL_ENABLE_OLD_DES_SUPPORT
38
#include <des.h>
39
40
#include "arch.h"
41
#include "DES_std.h"
42
#include "KRB4_std.h"
43
#include "misc.h"
44
#include "common.h"
45
#include "formats.h"
46
47
#define TGT_LENGTH		16	/* 2 des_cblock's */
48
49
#define FORMAT_LABEL		"krb4"
50
#define FORMAT_NAME		"Kerberos v4 TGT"
51
#define ALGORITHM_NAME		DES_STD_ALGORITHM_NAME
52
#define BENCHMARK_COMMENT	""
53
#define BENCHMARK_LENGTH	-1
54
#define PLAINTEXT_LENGTH	32
55
#define BINARY_SIZE		0
56
#define SALT_SIZE		TGT_LENGTH + REALM_SZ
57
#define MIN_KEYS_PER_CRYPT	1
58
#define MAX_KEYS_PER_CRYPT	1
59
60
static struct fmt_tests krb4_tests[] = {
61
	{"$af$UMICH.EDU$bb46613c503ad92e649d99d038efddb2", "w00w00"},
62
	{"$af$UMICH.EDU$95cd4367d4828d117b745ed63b9229be", "asdfjkl;"},
63
	{"$af$UMICH.EDU$000084efbde96969fd54d1a2ec8c287d", "hello!"},
64
	{"$af$UMICH.EDU$e9660a21b280875a7ecfc68aa771e34a", "a12345"},
65
	{"$af$UMICH.EDU$566f2b8629b9be36680866b0e613f239", "a1b2c3"},
66
	{"$af$UMICH.EDU$bebcedf43f7f2aa78cf9c0639e494c92", "abcdefg12345678"},
67
	{"$af$ENGIN.UMICH.EDU$9ef1034301e1f1fcf1516cb65aa1cc79", "asdfjkl;"},
68
	{"$af$ENGIN.UMICH.EDU$02ad23a6364df67a4db473de053cacbb", "a1b2c3"},
69
	{"$af$ENGIN.UMICH.EDU$14d0a59a2f9e746f1a3bf02ec4fb447e", "abc123!"},
70
	{"$af$ENGIN.UMICH.EDU$44feffd06e68e30bc8890e253760858d", "12345"},
71
	{NULL}
72
};
73
74
static const unsigned char odd_parity[256]={
75
	1,  1,  2,  2,  4,  4,  7,  7,  8,  8, 11, 11, 13, 13, 14, 14,
76
       16, 16, 19, 19, 21, 21, 22, 22, 25, 25, 26, 26, 28, 28, 31, 31,
77
       32, 32, 35, 35, 37, 37, 38, 38, 41, 41, 42, 42, 44, 44, 47, 47,
78
       49, 49, 50, 50, 52, 52, 55, 55, 56, 56, 59, 59, 61, 61, 62, 62,
79
       64, 64, 67, 67, 69, 69, 70, 70, 73, 73, 74, 74, 76, 76, 79, 79,
80
       81, 81, 82, 82, 84, 84, 87, 87, 88, 88, 91, 91, 93, 93, 94, 94,
81
       97, 97, 98, 98,100,100,103,103,104,104,107,107,109,109,110,110,
82
      112,112,115,115,117,117,118,118,121,121,122,122,124,124,127,127,
83
      128,128,131,131,133,133,134,134,137,137,138,138,140,140,143,143,
84
      145,145,146,146,148,148,151,151,152,152,155,155,157,157,158,158,
85
      161,161,162,162,164,164,167,167,168,168,171,171,173,173,174,174,
86
      176,176,179,179,181,181,182,182,185,185,186,186,188,188,191,191,
87
      193,193,194,194,196,196,199,199,200,200,203,203,205,205,206,206,
88
      208,208,211,211,213,213,214,214,217,217,218,218,220,220,223,223,
89
      224,224,227,227,229,229,230,230,233,233,234,234,236,236,239,239,
90
      241,241,242,242,244,244,247,247,248,248,251,251,253,253,254,254
91
};
92
93
static struct salt_st {
94
	u_char			tgt[TGT_LENGTH];
95
	char			realm[REALM_SZ];
96
} *saved_salt;
97
98
static struct key_st {
99
	des_cblock		key;
100
	des_key_schedule	sched;
101
	char			string[PLAINTEXT_LENGTH];
102
} saved_key;
103
104
105
static int
106
krb4_valid(char *ciphertext)
107
{
108
	char *p, *tgt;
109
110
	if (strncmp(ciphertext, "$k4$", 4) != 0 &&
111
	    strncmp(ciphertext, "$af$", 4) != 0)
112
		return 0;
113
114
	tgt = strchr(ciphertext + 4, '$') + 1;
115
	
116
	for (p = tgt; p && *p != '\0'; p++)
117
		if (!isxdigit((int)*p)) return 0;
118
119
	if (p - tgt != TGT_LENGTH * 2)
120
		return 0;
121
	
122
	return 1;
123
}
124
125
static int
126
hex_decode(char *src, u_char *dst, int outsize)
127
{
128
	char *p, *pe;
129
	u_char *q, *qe, ch, cl;
130
	
131
	pe = src + strlen(src);
132
	qe = dst + outsize;
133
	
134
	for (p = src, q = dst; p < pe && q < qe && isxdigit((int)*p); p += 2) {
135
		ch = tolower(p[0]);
136
		cl = tolower(p[1]);
137
		
138
		if ((ch >= '0') && (ch <= '9')) ch -= '0';
139
		else if ((ch >= 'a') && (ch <= 'f')) ch -= 'a' - 10;
140
		else return (-1);
141
		
142
		if ((cl >= '0') && (cl <= '9')) cl -= '0';
143
		else if ((cl >= 'a') && (cl <= 'f')) cl -= 'a' - 10;
144
		else return (-1);
145
		
146
		*q++ = (ch << 4) | cl;
147
	}
148
	return (q - dst);
149
}
150
151
static void *
152
krb4_salt(char *ciphertext)
153
{
154
	static struct salt_st salt;
155
	char *p;
156
157
	if (strncmp(ciphertext, "$af$", 4) == 0) {
158
		ciphertext += 4;
159
		p = strchr(ciphertext, '$');
160
		strnzcpy(salt.realm, ciphertext, (p - ciphertext) + 1);
161
		ciphertext = p + 1;
162
	}
163
	else {
164
		salt.realm[0] = '\0';
165
		ciphertext += 4;
166
	}
167
	if (hex_decode(ciphertext, salt.tgt, sizeof(salt.tgt)) !=
168
	    sizeof(salt.tgt))
169
		return (NULL);
170
	
171
	return (&salt);
172
}
173
174
static void
175
krb4_set_salt(void *salt)
176
{
177
	saved_salt = (struct salt_st *)salt;
178
}
179
180
static void
181
krb4_set_key(char *key, int index)
182
{
183
	if (saved_salt->realm[0] != '\0')
184
		afs_string_to_key(key, saved_salt->realm, &saved_key.key);
185
	else
186
		des_string_to_key(key, &saved_key.key);
187
188
	strnzcpy(saved_key.string, key, sizeof(saved_key.string));
189
}
190
191
static char *
192
krb4_get_key(int index)
193
{
194
	return (saved_key.string);
195
}
196
197
static void
198
krb4_crypt_all(int count)
199
{
200
	/* XXX - NOOP */
201
}
202
203
static int
204
krb4_check_parity(des_cblock *key)
205
{
206
	int i;
207
	
208
	for (i = 0; i < DES_KEY_SZ; i++) {
209
		if ((*key)[i] != odd_parity[(*key)[i]])
210
			return (0);
211
	}
212
	return (1);
213
}
214
215
static int
216
krb4_cmp_all(void *binary, int count)
217
{
218
	des_cblock tmp;
219
220
	des_set_key(&saved_key.key, saved_key.sched);
221
222
	des_pcbc_encrypt((des_cblock *)saved_salt->tgt, &tmp,
223
	                 sizeof(des_cblock), saved_key.sched,
224
	                &saved_key.key, DES_DECRYPT);
225
226
	return (krb4_check_parity(&tmp));
227
}
228
229
static int
230
krb4_cmp_one(void *binary, int count)
231
{
232
	u_char text[TGT_LENGTH];
233
234
	des_pcbc_encrypt((des_cblock *)saved_salt->tgt, (des_cblock *)text,
235
	                 sizeof(text), saved_key.sched, &saved_key.key,
236
	                 DES_DECRYPT);
237
	
238
	return (memcmp(text + 8, "krbtgt", 6) == 0);
239
}
240
241
static int
242
krb4_cmp_exact(char *source, int index)
243
{
244
	return (1);	/* XXX - fallthrough from krb4_cmp_one() */
245
}
246
247
struct fmt_main fmt_KRB4 = {
248
	{
249
		FORMAT_LABEL,
250
		FORMAT_NAME,
251
		ALGORITHM_NAME,
252
		BENCHMARK_COMMENT,
253
		BENCHMARK_LENGTH,
254
		PLAINTEXT_LENGTH,
255
		BINARY_SIZE,
256
		SALT_SIZE,
257
		MIN_KEYS_PER_CRYPT,
258
		MAX_KEYS_PER_CRYPT,
259
		FMT_CASE | FMT_8_BIT,
260
		krb4_tests
261
	}, {
262
		fmt_default_init,
263
		krb4_valid,
264
		fmt_default_split,
265
		fmt_default_binary,
266
		krb4_salt,
267
		{
268
			fmt_default_binary_hash,
269
			fmt_default_binary_hash,
270
			fmt_default_binary_hash
271
		},
272
		fmt_default_salt_hash,
273
		krb4_set_salt,
274
		krb4_set_key,
275
		krb4_get_key,
276
		krb4_crypt_all,
277
		{
278
			fmt_default_get_hash,
279
			fmt_default_get_hash,
280
			fmt_default_get_hash
281
		},
282
		krb4_cmp_all,
283
		krb4_cmp_one,
284
		krb4_cmp_exact
285
	}
286
};
287
288
/* 5000. */
(-)john-1.6.orig/src/KRB4_std.c (+122 lines)
Line 0 Link Here
1
/*
2
  KRB4_std.c
3
  
4
  Kerberos v4 jonks, from KTH krb4.
5
  
6
  $OpenBSD: str2key.c,v 1.6 1998/06/22 15:22:27 beck Exp $
7
  $KTH: str2key.c,v 1.10 1997/03/23 03:53:19 joda Exp $
8
*/
9
10
/* This defines the Andrew string_to_key function.  It accepts a password
11
 * string as input and converts its via a one-way encryption algorithm to a DES
12
 * encryption key.  It is compatible with the original Andrew authentication
13
 * service password database.
14
 */
15
16
#include <stdio.h>
17
#include <stdlib.h>
18
#include <string.h>
19
#define OPENSSL_ENABLE_OLD_DES_SUPPORT
20
#include <des.h>
21
22
#include "KRB4_std.h"
23
24
#ifndef des_fixup_key_parity
25
#define des_fixup_key_parity	des_set_odd_parity
26
#endif
27
28
static void
29
mklower(char *s)
30
{
31
    for (; s[0] != '\0'; s++)
32
        if ('A' <= *s && *s <= 'Z')
33
            *s = *s - 'A' + 'a';
34
}
35
36
/*
37
 * Short passwords, i.e 8 characters or less.
38
 */
39
static void
40
afs_cmu_StringToKey (char *str, char *cell, des_cblock *key)
41
{
42
    char  password[8+1];	/* crypt is limited to 8 chars anyway */
43
    int   i;
44
    int   passlen;
45
46
    memset(key, 0, sizeof(key));
47
    memset(password, 0, sizeof(password));
48
49
    strncpy (password, cell, 8);
50
    password[8] = '\0';
51
    passlen = strlen (str);
52
    if (passlen > 8) passlen = 8;
53
54
    for (i=0; i<passlen; i++)
55
        password[i] = str[i] ^ cell[i];	/* make sure cell is zero padded */
56
57
    for (i=0; i<8; i++)
58
        if (password[i] == '\0') password[i] = 'X';
59
60
    /* crypt only considers the first 8 characters of password but for some
61
       reason returns eleven characters of result (plus the two salt chars). */
62
    strncpy((char *)key, crypt(password, "p1") + 2, sizeof(des_cblock));
63
64
    /* parity is inserted into the LSB so leftshift each byte up one bit.  This
65
       allows ascii characters with a zero MSB to retain as much significance
66
       as possible. */
67
    {   char *keybytes = (char *)key;
68
        unsigned int temp;
69
70
        for (i = 0; i < 8; i++) {
71
            temp = (unsigned int) keybytes[i];
72
            keybytes[i] = (unsigned char) (temp << 1);
73
        }
74
    }
75
    des_fixup_key_parity (key);
76
}
77
78
/*
79
 * Long passwords, i.e 9 characters or more.
80
 */
81
static void
82
afs_transarc_StringToKey (char *str, char *cell, des_cblock *key)
83
{
84
    des_key_schedule schedule;
85
    des_cblock temp_key;
86
    des_cblock ivec;
87
    char password[512];
88
    int  passlen;
89
90
    strncpy (password, str, sizeof(password));
91
    password[sizeof(password)-1] = '\0';
92
    if ((passlen = strlen (password)) < sizeof(password)-1)
93
        strncat (password, cell, sizeof(password)-passlen);
94
    if ((passlen = strlen(password)) > sizeof(password)) passlen = sizeof(password);
95
96
    memcpy(&ivec, "kerberos", 8);
97
    memcpy(&temp_key, "kerberos", 8);
98
    des_fixup_key_parity (&temp_key);
99
    des_key_sched (&temp_key, schedule);
100
    des_cbc_cksum ((des_cblock *)password, &ivec, passlen, schedule, &ivec);
101
102
    memcpy(&temp_key, &ivec, 8);
103
    des_fixup_key_parity (&temp_key);
104
    des_key_sched (&temp_key, schedule);
105
    des_cbc_cksum ((des_cblock *)password, key, passlen, schedule, &ivec);
106
107
    des_fixup_key_parity (key);
108
}
109
110
void
111
afs_string_to_key(char *str, char *cell, des_cblock *key)
112
{
113
    char realm[REALM_SZ+1];
114
    strncpy(realm, cell, REALM_SZ);
115
    realm[REALM_SZ] = 0;
116
    mklower(realm);
117
118
    if (strlen(str) > 8)
119
        afs_transarc_StringToKey (str, realm, key);
120
    else
121
        afs_cmu_StringToKey (str, realm, key);
122
}
(-)john-1.6.orig/src/KRB4_std.h (+16 lines)
Line 0 Link Here
1
/*
2
 * KRB4_std.h
3
 *
4
 * Kerberos v4 jonks, from KTH krb4.
5
 *
6
 * Dug Song <dugsong@monkey.org>
7
 */
8
9
#ifndef KRB4_STD_H
10
#define KRB4_STD_H
11
12
#define REALM_SZ	40
13
14
void afs_string_to_key(char *str, char *cell, des_cblock *key);
15
16
#endif /* KRB4_STD_H */
(-)john-1.6.orig/src/MYSQL_fmt.c (+241 lines)
Line 0 Link Here
1
////////////////////////////////////////////////////////////////
2
// MySQL password cracker - v1.0 - 16.1.2003
3
//
4
//    by Andrew Hintz <http://guh.nu> drew@overt.org
5
//  
6
//    This production has been brought to you by
7
//    4tphi <http://4tphi.net> and violating <http://violating.us>
8
//
9
// This file is an add-on to John the Ripper <http://www.openwall.com/john/> 
10
//
11
// Part of this code is based on the MySQL brute password cracker
12
//   mysqlpassword.c by Chris Given
13
// This program executes about 75% faster than mysqlpassword.c
14
// John the ripper also performs sophisticated password guessing.
15
//
16
// John the Ripper will expect the MySQL password file to be
17
// in the following format (without the leading // ):
18
// dumb_user:5d2e19393cc5ef67
19
// another_luser:28ff8d49159ffbaf
20
21
#include <string.h>
22
#include <stdio.h>
23
#include <stdlib.h>
24
#include <math.h>
25
26
// johntr includes
27
#include "arch.h"
28
#include "misc.h"
29
#include "formats.h"
30
#include "common.h"
31
32
//johntr defines
33
#define FORMAT_LABEL "mysql"
34
#define FORMAT_NAME "mysql"
35
#define ALGORITHM_NAME "mysql"
36
37
#define BENCHMARK_COMMENT ""
38
#define BENCHMARK_LENGTH -1
39
40
// Increase the PLAINTEXT_LENGTH value for longer passwords.
41
// You can also set it to 8 when using MySQL systems that truncate 
42
//  the password to only 8 characters.
43
#define PLAINTEXT_LENGTH 32
44
45
#define CIPHERTEXT_LENGTH 16
46
47
#define BINARY_SIZE 16
48
#define SALT_SIZE 0
49
50
#define MIN_KEYS_PER_CRYPT 1
51
#define MAX_KEYS_PER_CRYPT 1
52
53
54
//used for mysql scramble function
55
struct rand_struct {
56
  unsigned long seed1,seed2,max_value;
57
  double max_value_dbl;
58
};
59
60
61
void make_scrambled_password(char *,const char *);
62
char *scramble(char *,const char *,const char *, int);
63
64
//test cases
65
static struct fmt_tests mysql_tests[] = {
66
  {"30f098972cc8924d", "http://guh.nu"},
67
  {"3fc56f6037218993", "Andrew Hintz"},
68
  {"697a7de87c5390b2", "drew"},
69
  {"1eb71cf460712b3e", "http://4tphi.net"},
70
  {"28ff8d49159ffbaf", "http://violating.us"},
71
  {"5d2e19393cc5ef67", "password"},
72
  {NULL}
73
};
74
75
76
//stores the ciphertext for value currently being tested
77
static char crypt_key[BINARY_SIZE+1];
78
79
//used by set_key
80
static char saved_key[PLAINTEXT_LENGTH + 1];
81
82
static int mysql_valid(char *ciphertext) { //returns 0 for invalid ciphertexts
83
84
  int i; //used as counter in loop
85
  
86
  //ciphertext is 16 characters
87
  if (strlen(ciphertext) != 16) return 0;  
88
89
  //ciphertext is ASCII representation of hex digits
90
  for (i = 0; i < 16; i++){
91
    if (!(  ((48 <= ciphertext[i])&&(ciphertext[i] <= 57)) ||
92
	    ((97 <= ciphertext[i])&&(ciphertext[i] <= 102))  ))
93
      return 0;
94
  }
95
96
  return 1;
97
}
98
99
static void mysql_set_salt(void *salt) { }
100
101
static void mysql_set_key(char *key, int index) {
102
  strnzcpy(saved_key, key, PLAINTEXT_LENGTH+1);
103
}
104
105
static char *mysql_get_key(int index) {
106
    return saved_key;
107
}
108
109
static int mysql_cmp_all(void *binary, int index) { //also is mysql_cmp_one
110
  return !memcmp(binary, crypt_key, BINARY_SIZE);
111
}
112
113
static int mysql_cmp_exact(char *source, int count){
114
  return (1); //  mysql_cmp_all fallthrough?
115
}
116
117
static void mysql_crypt_all(int count) {  
118
  // get plaintext input in saved_key put it into ciphertext crypt_key
119
  make_scrambled_password(crypt_key,saved_key);
120
}
121
122
////////////////////////////////////////////////////////////////
123
//begin mysql code
124
// This code was copied from mysqlpassword.c by Chris Given
125
// He probably copied it from password.c in the MySQL source
126
// The code is GPLed
127
128
void randominit(struct rand_struct *rand_st,ulong seed1, ulong seed2) {
129
  rand_st->max_value= 0x3FFFFFFFL;
130
  rand_st->max_value_dbl=(double) rand_st->max_value;
131
  rand_st->seed1=seed1%rand_st->max_value ;
132
  rand_st->seed2=seed2%rand_st->max_value;
133
}
134
static void old_randominit(struct rand_struct *rand_st,ulong seed1) {
135
  rand_st->max_value= 0x01FFFFFFL;
136
  rand_st->max_value_dbl=(double) rand_st->max_value;
137
  seed1%=rand_st->max_value;
138
  rand_st->seed1=seed1 ; rand_st->seed2=seed1/2;
139
}
140
double rnd(struct rand_struct *rand_st) {
141
  rand_st->seed1=(rand_st->seed1*3+rand_st->seed2) %
142
    rand_st->max_value;
143
  rand_st->seed2=(rand_st->seed1+rand_st->seed2+33) %
144
    rand_st->max_value;
145
  return(((double) rand_st->seed1)/rand_st->max_value_dbl);
146
}
147
void hash_password(ulong *result, const char *password) {
148
  register ulong nr=1345345333L, add=7, nr2=0x12345671L;
149
  ulong tmp;
150
  for (; *password ; password++) {
151
    if (*password == ' ' || *password == '\t')
152
      continue;
153
    tmp= (ulong) (unsigned char) *password;
154
    nr^= (((nr & 63)+add)*tmp)+ (nr << 8);
155
    nr2+=(nr2 << 8) ^ nr;
156
    add+=tmp;
157
  }
158
  result[0]=nr & (((ulong) 1L << 31) -1L); /* Don't use sign bit
159
					      (str2int) */;
160
  result[1]=nr2 & (((ulong) 1L << 31) -1L);
161
  return;
162
}
163
void make_scrambled_password(char *to,const char *password) {
164
  ulong hash_res[2];
165
  hash_password(hash_res,password);
166
  sprintf(to,"%08lx%08lx",hash_res[0],hash_res[1]);
167
}
168
static inline uint char_val(char X) {
169
  return (uint) (X >= '0' && X <= '9' ? X-'0' : X >= 'A' && X <= 'Z' ?
170
		 X-'A'+10 : X-'a'+10);
171
}
172
char *scramble(char *to,const char *message,const char *password, int
173
	       old_ver) {
174
  struct rand_struct rand_st;
175
  ulong hash_pass[2],hash_message[2];
176
  if(password && password[0]) {
177
    char *to_start=to;
178
    hash_password(hash_pass,password);
179
    hash_password(hash_message,message);
180
    if (old_ver)
181
      old_randominit(&rand_st,hash_pass[0] ^
182
		     hash_message[0]);
183
    else
184
      randominit(&rand_st,hash_pass[0] ^ hash_message[0],
185
		 hash_pass[1] ^ hash_message[1]);
186
    while (*message++)
187
      *to++= (char) (floor(rnd(&rand_st)*31)+64);
188
    if (!old_ver) {
189
      char extra=(char) (floor(rnd(&rand_st)*31));
190
      while(to_start != to)
191
        *(to_start++)^=extra;
192
    }
193
  }
194
  *to=0;
195
  return to;
196
}
197
198
//end mysql code
199
////////////////////////////////////////////////////////////////
200
201
struct fmt_main fmt_MYSQL = {
202
  {
203
    FORMAT_LABEL,
204
    FORMAT_NAME,
205
    ALGORITHM_NAME,
206
    BENCHMARK_COMMENT,
207
    BENCHMARK_LENGTH,
208
    PLAINTEXT_LENGTH,
209
    BINARY_SIZE,
210
    SALT_SIZE,
211
    MIN_KEYS_PER_CRYPT,
212
    MAX_KEYS_PER_CRYPT,
213
    FMT_CASE | FMT_8_BIT,
214
    mysql_tests
215
    }, {
216
      fmt_default_init,
217
      mysql_valid, 
218
      fmt_default_split,
219
      fmt_default_binary,
220
      fmt_default_salt,
221
      {
222
	fmt_default_binary_hash,
223
	fmt_default_binary_hash,
224
	fmt_default_binary_hash
225
      },
226
      fmt_default_salt_hash,
227
      mysql_set_salt,
228
      mysql_set_key,
229
      mysql_get_key,
230
      //fmt_default_clear_keys,
231
      mysql_crypt_all,
232
      {
233
	fmt_default_get_hash,
234
	fmt_default_get_hash,
235
	fmt_default_get_hash
236
      },
237
      mysql_cmp_all,
238
      mysql_cmp_all, //should it be the same as cmp_all or same as cmp_exact?
239
      mysql_cmp_exact //fallthrough
240
    }
241
};
(-)john-1.6.orig/src/Makefile (-7 / +28 lines)
Lines 13-23 Link Here
13
SED = sed
13
SED = sed
14
NULL = /dev/null
14
NULL = /dev/null
15
CPPFLAGS = -E
15
CPPFLAGS = -E
16
CFLAGS = -c -Wall -O2 -fomit-frame-pointer
16
CFLAGS = -c -Wall -O2 -fomit-frame-pointer -I/usr/include/openssl
17
ASFLAGS = -c
17
ASFLAGS = -c
18
LDFLAGS = -s
18
LDFLAGS = -s
19
OPT_NORMAL = -funroll-loops
19
OPT_NORMAL = -funroll-loops
20
OPT_INLINE = -finline-functions
20
OPT_INLINE = -finline-functions
21
LIBS = -lskey -lcrypto -lcrypt
21
22
22
JOHN_VERSION = 1.6
23
JOHN_VERSION = 1.6
23
JOHN_ARCHIVE = john-$(JOHN_VERSION)
24
JOHN_ARCHIVE = john-$(JOHN_VERSION)
Lines 35-47 Link Here
35
	MD5_fmt.o MD5_std.o \
36
	MD5_fmt.o MD5_std.o \
36
	BF_fmt.o BF_std.o \
37
	BF_fmt.o BF_std.o \
37
	AFS_fmt.o \
38
	AFS_fmt.o \
38
	LM_fmt.o \
39
	LM_fmt.o NT_fmt.o \
40
	MYSQL_fmt.o \
41
	md4.o smbencrypt.o \
42
	SKEY_fmt.o \
43
	KRB4_fmt.o KRB4_std.o \
44
	BFEgg_fmt.o \
39
	batch.o bench.o charset.o common.o compiler.o config.o cracker.o \
45
	batch.o bench.o charset.o common.o compiler.o config.o cracker.o \
40
	external.o formats.o getopt.o idle.o inc.o john.o list.o loader.o \
46
	external.o formats.o getopt.o idle.o inc.o john.o list.o loader.o \
41
	logger.o math.o memory.o misc.o options.o params.o path.o recovery.o \
47
	logger.o math.o memory.o misc.o options.o params.o path.o recovery.o \
42
	rpp.o rules.o signals.o single.o status.o tty.o wordlist.o \
48
	rpp.o rules.o signals.o single.o status.o tty.o wordlist.o \
43
	unshadow.o \
49
	unshadow.o \
44
	unafs.o \
50
	unafs.o \
51
	undrop.o \
45
	unique.o
52
	unique.o
46
53
47
JOHN_OBJS = \
54
JOHN_OBJS = \
Lines 70-80 Link Here
70
	bench.o best.o common.o config.o formats.o memory.o misc.o params.o \
77
	bench.o best.o common.o config.o formats.o memory.o misc.o params.o \
71
	path.o signals.o tty.o
78
	path.o signals.o tty.o
72
79
73
PROJ = ../run/john ../run/unshadow ../run/unafs ../run/unique
80
PROJ = ../run/john ../run/unshadow ../run/unafs ../run/unique ../run/undrop ../run/tgtsnarf
74
PROJ_DOS = ../run/john.bin ../run/john.com \
81
PROJ_DOS = ../run/john.bin ../run/john.com \
75
	../run/unshadow.com ../run/unafs.com ../run/unique.com
82
	../run/unshadow.com ../run/unafs.com ../run/unique.com ../run/undrop.com
76
PROJ_WIN32 = ../run/john.exe \
83
PROJ_WIN32 = ../run/john.exe \
77
	../run/unshadow.exe ../run/unafs.exe ../run/unique.exe
84
	../run/unshadow.exe ../run/unafs.exe ../run/unique.exe ../run/undrop.exe
78
85
79
default:
86
default:
80
	@echo "To build John the Ripper, type:"
87
	@echo "To build John the Ripper, type:"
Lines 147-153 Link Here
147
		JOHN_OBJS="$(JOHN_OBJS) alpha.o"
154
		JOHN_OBJS="$(JOHN_OBJS) alpha.o"
148
155
149
linux-sparc:
156
linux-sparc:
150
	$(MAKE) HAMMER=use-linux-sparc sparc.h
157
	$(MAKE) use-linux-sparc HAMMER=use-linux-sparc NAIL=sparc.h
151
	ln -s sparc.h arch.h
158
	ln -s sparc.h arch.h
152
	$(MAKE) use-linux-sparc NAIL="$(PROJ)"
159
	$(MAKE) use-linux-sparc NAIL="$(PROJ)"
153
160
Lines 397-404 Link Here
397
bench: $(BENCH_OBJS)
404
bench: $(BENCH_OBJS)
398
	$(LD) $(LDFLAGS) $(BENCH_OBJS) -o bench
405
	$(LD) $(LDFLAGS) $(BENCH_OBJS) -o bench
399
406
407
../run/tgtsnarf: tgtsnarf.o
408
	$(LD) $(LDFLAGS) tgtsnarf.o -o ../run/tgtsnarf
409
400
../run/john: $(JOHN_OBJS)
410
../run/john: $(JOHN_OBJS)
401
	$(LD) $(LDFLAGS) $(JOHN_OBJS) -o ../run/john
411
	$(LD) $(LDFLAGS) $(JOHN_OBJS) -o ../run/john $(LIBS)
402
412
403
../run/unshadow: ../run/john
413
../run/unshadow: ../run/john
404
	ln -s john ../run/unshadow
414
	ln -s john ../run/unshadow
Lines 406-411 Link Here
406
../run/unafs: ../run/john
416
../run/unafs: ../run/john
407
	ln -s john ../run/unafs
417
	ln -s john ../run/unafs
408
418
419
../run/undrop: ../run/john
420
	$(RM) ../run/undrop
421
	ln -s john ../run/undrop
422
409
../run/unique: ../run/john
423
../run/unique: ../run/john
410
	ln -s john ../run/unique
424
	ln -s john ../run/unique
411
425
Lines 423-428 Link Here
423
../run/unafs.com: john.com
437
../run/unafs.com: john.com
424
	copy john.com ..\run\unafs.com
438
	copy john.com ..\run\unafs.com
425
439
440
../run/undrop.com: john.com
441
	copy john.com ..\run\undrop.com
442
426
../run/unique.com: john.com
443
../run/unique.com: john.com
427
	copy john.com ..\run\unique.com
444
	copy john.com ..\run\unique.com
428
445
Lines 441-446 Link Here
441
	$(CC) symlink.c -o ../run/unafs.exe
458
	$(CC) symlink.c -o ../run/unafs.exe
442
	strip ../run/unafs.exe
459
	strip ../run/unafs.exe
443
460
461
../run/undrop.exe: symlink.c
462
	$(CC) symlink.c -o ../run/undrop.exe
463
	strip ../run/undrop.exe
464
444
../run/unique.exe: symlink.c
465
../run/unique.exe: symlink.c
445
	$(CC) symlink.c -o ../run/unique.exe
466
	$(CC) symlink.c -o ../run/unique.exe
446
	strip ../run/unique.exe
467
	strip ../run/unique.exe
(-)john-1.6.orig/src/NT_fmt.c (+187 lines)
Line 0 Link Here
1
/*
2
 * NTLM patch for john version 0.2
3
 *
4
 * (C) 2001 Olle Segerdahl <olle@nxs.se>
5
 *
6
 * liscense: GPL <http://www.gnu.org/>
7
 *
8
 * This file is based on code from John the Ripper,
9
 * Copyright (c) 1996-99 by Solar Designer
10
 *
11
 */
12
13
#include <string.h>
14
15
#include "arch.h"
16
#include "memory.h"
17
#include "common.h"
18
#include "formats.h"
19
20
#ifndef uchar
21
#define uchar unsigned char
22
#endif
23
24
#define FORMAT_LABEL			"nt"
25
#define FORMAT_NAME			"NT MD4"
26
27
#define BENCHMARK_COMMENT		""
28
#define BENCHMARK_LENGTH		-1
29
30
#define PLAINTEXT_LENGTH		54
31
#define CIPHERTEXT_LENGTH		36
32
33
34
static struct fmt_tests tests[] = {
35
	{"$NT$b7e4b9022cd45f275334bbdb83bb5be5", "John the Ripper"},
36
	{"$NT$8846f7eaee8fb117ad06bdd830b7586c", "password"},
37
	{"$NT$0cb6948805f797bf2a82807973b89537", "test"},
38
	{"$NT$31d6cfe0d16ae931b73c59d7e0c089c0", ""},
39
	{NULL}
40
};
41
42
#define ALGORITHM_NAME			"TridgeMD4"
43
44
#define BINARY_SIZE			16
45
#define SALT_SIZE			0
46
47
#define MIN_KEYS_PER_CRYPT		1
48
#define MAX_KEYS_PER_CRYPT		1
49
50
uchar saved_plain[PLAINTEXT_LENGTH + 1];
51
uchar output[BINARY_SIZE + 1];
52
53
extern void E_md4hash(uchar *passwd, uchar *p16);
54
55
56
static int valid(char *ciphertext)
57
{
58
        char *pos;
59
60
	if (strncmp(ciphertext, "$NT$", 4)!=0) return 0;
61
62
        for (pos = &ciphertext[4]; atoi16[(ARCH_INDEX)*pos] != 0x7F; pos++);
63
64
        if (!*pos && pos - ciphertext == CIPHERTEXT_LENGTH)
65
		return 1;
66
        else
67
        	return 0;
68
69
}
70
71
static void *get_binary(char *ciphertext)
72
{
73
	static uchar binary[BINARY_SIZE];
74
	int i;
75
76
	ciphertext+=4;
77
	for (i=0; i<BINARY_SIZE; i++)
78
	   {
79
 		binary[i] = (atoi16[(ARCH_INDEX) ciphertext[i*2]])<<4;
80
 		binary[i] |= (atoi16[(ARCH_INDEX) ciphertext[i*2+1]]);
81
	   }
82
83
	return binary;
84
}
85
86
static int binary_hash_0(void *binary)
87
{
88
	return ((uchar *)binary)[0] & 0x0F;
89
}
90
91
static int binary_hash_1(void *binary)
92
{
93
	return ((uchar *)binary)[0];
94
}
95
96
static int binary_hash_2(void *binary)
97
{
98
	return (((uchar *)binary)[0] << 4) + (((uchar *)binary)[1] & 0x0F);
99
}
100
101
static int get_hash_0(int index)
102
{
103
	return output[0] & 0x0F;
104
}
105
106
static int get_hash_1(int index)
107
{
108
	return output[0];
109
}
110
111
static int get_hash_2(int index)
112
{
113
	return (output[0] << 4) + (output[1] & 0x0F);
114
}
115
116
static void crypt_all(int count)
117
{
118
	E_md4hash(saved_plain, output);
119
}
120
121
static int cmp_all(void *binary, int count)
122
{
123
	return !memcmp(output, binary, BINARY_SIZE);
124
125
}
126
127
static int cmp_exact(char *source, int index)
128
{
129
	return !memcmp(output, get_binary(source), BINARY_SIZE);
130
}
131
132
static void set_salt(void *salt)
133
{
134
}
135
136
static void set_key(char *key, int index)
137
{
138
	strncpy(saved_plain, key, PLAINTEXT_LENGTH);
139
	saved_plain[PLAINTEXT_LENGTH] = 0;
140
}
141
142
static char *get_key(int index)
143
{
144
	return saved_plain;
145
}
146
147
struct fmt_main fmt_NT = {
148
	{
149
		FORMAT_LABEL,
150
		FORMAT_NAME,
151
		ALGORITHM_NAME,
152
		BENCHMARK_COMMENT,
153
		BENCHMARK_LENGTH,
154
		PLAINTEXT_LENGTH,
155
		BINARY_SIZE,
156
		SALT_SIZE,
157
		MIN_KEYS_PER_CRYPT,
158
		MAX_KEYS_PER_CRYPT,
159
		FMT_CASE | FMT_8_BIT,
160
		tests
161
	}, {
162
		fmt_default_init,
163
		valid,
164
		fmt_default_split,
165
		get_binary,
166
		fmt_default_salt,
167
		{
168
			binary_hash_0,
169
			binary_hash_1,
170
			binary_hash_2
171
		},
172
		fmt_default_salt_hash,
173
		set_salt,
174
		set_key,
175
		get_key,
176
		// fmt_default_clear_keys,
177
		crypt_all,
178
		{
179
			get_hash_0,
180
			get_hash_1,
181
			get_hash_2
182
		},
183
		cmp_all,
184
		cmp_all,
185
		cmp_exact
186
	}
187
};
(-)john-1.6.orig/src/SKEY_fmt.c (+255 lines)
Line 0 Link Here
1
/*
2
  SKEY_fmt.c
3
  
4
  S/Key dictionary attack module for Solar Designer's John the Ripper.
5
  
6
  skeykeys files should be fed through sed 's/ /:/' first.
7
  
8
  Copyright (c) 2000 Dug Song <dugsong@monkey.org>
9
  All rights reserved, all wrongs reversed.
10
 
11
  Redistribution and use in source and binary forms, with or without
12
  modification, are permitted provided that the following conditions
13
  are met:
14
  
15
  1. Redistributions of source code must retain the above copyright
16
  notice, this list of conditions and the following disclaimer.
17
  2. Redistributions in binary form must reproduce the above copyright
18
  notice, this list of conditions and the following disclaimer in the
19
  documentation and/or other materials provided with the distribution.
20
  3. The name of author may not be used to endorse or promote products
21
  derived from this software without specific prior written permission.
22
  
23
  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
24
  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
25
  AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
26
  THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
27
  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
28
  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
29
  OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
30
  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
31
  OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
32
  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33
*/
34
35
#include <stdio.h>
36
#include <stdlib.h>
37
#include <string.h>
38
#include <ctype.h>
39
#include <skey.h>
40
41
#include "arch.h"
42
#include "misc.h"
43
#include "common.h"
44
#include "formats.h"
45
46
#define FORMAT_LABEL		"skey"
47
#define FORMAT_NAME		"S/Key"
48
#define ALGORITHM_NAME		"MD4/MD5/SHA1/RMD160"
49
#define BENCHMARK_COMMENT	""
50
#define BENCHMARK_LENGTH	-1
51
#define PLAINTEXT_LENGTH	32
52
#define BINARY_SIZE		0
53
#define SALT_SIZE		sizeof(struct skey_salt_st)
54
#define MIN_KEYS_PER_CRYPT	1
55
#define MAX_KEYS_PER_CRYPT	1
56
57
static struct fmt_tests skey_tests[] = {
58
	{"0096 luky451004  b519dcfe18eb7aab", "w00w00 v00d00"},
59
  	{"md5 0099 luky451001  93b3774544ba92a3", "swirling zagnuts"},
60
	{"sha1 0042 luky451002  d4f0b50e17b29310", "abcdefg12345678"},
61
	{"rmd160 0099 luky451006  2dbcbb728e8bb456", "squeamish ossifrage"},
62
	{NULL}
63
};
64
65
/* Saved state. */
66
static struct skey_salt_st {
67
	int	num;
68
	char	type[SKEY_MAX_HASHNAME_LEN + 1];
69
	char	seed[SKEY_MAX_SEED_LEN + 1];
70
	u_char	hash[SKEY_BINKEY_SIZE];
71
} saved_salt;
72
static u_char	saved_key[SKEY_BINKEY_SIZE];
73
static char	saved_pass[PLAINTEXT_LENGTH];
74
75
static int
76
skey_valid(char *ciphertext)
77
{
78
	char *p, *q, buf[24];
79
80
	if (*ciphertext == '#')
81
		return (0);
82
	
83
	strnzcpy(buf, ciphertext, sizeof(buf));
84
	
85
	if ((p = strchr(buf, ' ')) == NULL)
86
		return (0);
87
	*p++ = '\0';
88
	
89
	if (isalpha(*buf)) {
90
		if (skey_set_algorithm(buf) == NULL ||
91
		    (q = strchr(p, ' ')) == NULL)
92
			return (0);
93
		*q = '\0';
94
	}
95
	else p = buf;
96
97
	for ( ; *p; p++) {
98
		if (!isdigit(*p))
99
			return (0);
100
	}
101
	return (1);
102
}
103
104
static int
105
hex_decode(char *src, u_char *dst, int outsize)
106
{
107
	char *p, *pe;
108
	u_char *q, *qe, ch, cl;
109
	
110
	pe = src + strlen(src);
111
	qe = dst + outsize;
112
	
113
	for (p = src, q = dst; p < pe && q < qe && isxdigit((int)*p); p += 2) {
114
		ch = tolower(p[0]);
115
		cl = tolower(p[1]);
116
		
117
		if ((ch >= '0') && (ch <= '9')) ch -= '0';
118
		else if ((ch >= 'a') && (ch <= 'f')) ch -= 'a' - 10;
119
		else return (-1);
120
		
121
		if ((cl >= '0') && (cl <= '9')) cl -= '0';
122
		else if ((cl >= 'a') && (cl <= 'f')) cl -= 'a' - 10;
123
		else return (-1);
124
		
125
		*q++ = (ch << 4) | cl;
126
	}
127
	return (q - dst);
128
}
129
130
static void *
131
skey_salt(char *ciphertext)
132
{
133
	static struct skey_salt_st salt;
134
	static char buf[128];
135
	char *p;
136
	
137
	strnzcpy(buf, ciphertext, sizeof(buf));
138
	
139
	if ((p = strtok(buf, " \t")) == NULL)
140
		return (NULL);
141
	
142
	if (isalpha(*p)) {
143
		strnzcpy(salt.type, p, sizeof(salt.type));
144
		if ((p = strtok(NULL, " \t")) == NULL)
145
			return (NULL);
146
	}
147
	else strnzcpy(salt.type, "md4", sizeof(salt.type));
148
	
149
	salt.num = atoi(p);
150
	
151
	if ((p = strtok(NULL, " \t")) == NULL)
152
		return (NULL);
153
	
154
	strnzcpy(salt.seed, p, sizeof(salt.seed) - 1);
155
	
156
	if ((p = strtok(NULL, " \t")) == NULL)
157
		return (NULL);
158
	
159
	hex_decode(p, salt.hash, sizeof(salt.hash));
160
161
	return (&salt);
162
}
163
164
static void
165
skey_set_salt(void *salt)
166
{
167
	memcpy((u_char *)&saved_salt, (u_char *)salt, sizeof(saved_salt));
168
}
169
170
static void
171
skey_set_key(char *key, int index)
172
{
173
	strnzcpy(saved_pass, key, sizeof(saved_pass) - 1);
174
	hex_decode(key, saved_key, sizeof(saved_key));
175
}
176
177
static char *
178
skey_get_key(int index)
179
{
180
	return (saved_pass);
181
}
182
183
static void
184
skey_crypt_all(int count)
185
{
186
	int i;
187
	
188
	skey_set_algorithm(saved_salt.type);
189
	
190
	keycrunch(saved_key, saved_salt.seed, saved_pass);
191
	
192
	for (i = 0; i < saved_salt.num; i++)
193
		f(saved_key);
194
}
195
196
static int
197
skey_cmp_all(void *binary, int count)
198
{
199
	return (memcmp(saved_key, saved_salt.hash, sizeof(saved_salt.hash)) == 0);
200
}
201
202
static int
203
skey_cmp_one(void *binary, int count)
204
{
205
	return (1);	/* XXX - fallthrough from skey_cmp_all() */
206
}
207
208
static int
209
skey_cmp_exact(char *source, int count)
210
{
211
	return (1);	/* XXX - fallthrough from skey_cmp_one() */
212
}
213
214
struct fmt_main fmt_SKEY = {
215
	{
216
		FORMAT_LABEL,
217
		FORMAT_NAME,
218
		ALGORITHM_NAME,
219
		BENCHMARK_COMMENT,
220
		BENCHMARK_LENGTH,
221
		PLAINTEXT_LENGTH,
222
		BINARY_SIZE,
223
		SALT_SIZE,
224
		MIN_KEYS_PER_CRYPT,
225
		MAX_KEYS_PER_CRYPT,
226
		FMT_CASE | FMT_8_BIT,
227
		skey_tests
228
	}, {
229
		fmt_default_init,
230
		skey_valid,
231
		fmt_default_split,
232
		fmt_default_binary,
233
		skey_salt,
234
		{
235
			fmt_default_binary_hash,
236
			fmt_default_binary_hash,
237
			fmt_default_binary_hash
238
		},
239
		fmt_default_salt_hash,
240
		skey_set_salt,
241
		skey_set_key,
242
		skey_get_key,
243
		skey_crypt_all,
244
		{
245
			fmt_default_get_hash,
246
			fmt_default_get_hash,
247
			fmt_default_get_hash
248
		},
249
		skey_cmp_all,
250
		skey_cmp_one,
251
		skey_cmp_exact
252
	}
253
};
254
255
/* 5000. */
(-)john-1.6.orig/src/bf_tab.h (+277 lines)
Line 0 Link Here
1
/* bf_tab.h: Blowfish P-box and S-box tables */
2
#ifndef _H_TAB_BF
3
#define _H_TAB_BF
4
5
static UWORD_32bits initbf_P[bf_N + 2] =
6
{
7
  0x243f6a88, 0x85a308d3, 0x13198a2e, 0x03707344,
8
  0xa4093822, 0x299f31d0, 0x082efa98, 0xec4e6c89,
9
  0x452821e6, 0x38d01377, 0xbe5466cf, 0x34e90c6c,
10
  0xc0ac29b7, 0xc97c50dd, 0x3f84d5b5, 0xb5470917,
11
  0x9216d5d9, 0x8979fb1b,
12
};
13
static UWORD_32bits initbf_S[4][256] =
14
{
15
  {
16
    0xd1310ba6, 0x98dfb5ac, 0x2ffd72db, 0xd01adfb7,
17
    0xb8e1afed, 0x6a267e96, 0xba7c9045, 0xf12c7f99,
18
    0x24a19947, 0xb3916cf7, 0x0801f2e2, 0x858efc16,
19
    0x636920d8, 0x71574e69, 0xa458fea3, 0xf4933d7e,
20
    0x0d95748f, 0x728eb658, 0x718bcd58, 0x82154aee,
21
    0x7b54a41d, 0xc25a59b5, 0x9c30d539, 0x2af26013,
22
    0xc5d1b023, 0x286085f0, 0xca417918, 0xb8db38ef,
23
    0x8e79dcb0, 0x603a180e, 0x6c9e0e8b, 0xb01e8a3e,
24
    0xd71577c1, 0xbd314b27, 0x78af2fda, 0x55605c60,
25
    0xe65525f3, 0xaa55ab94, 0x57489862, 0x63e81440,
26
    0x55ca396a, 0x2aab10b6, 0xb4cc5c34, 0x1141e8ce,
27
    0xa15486af, 0x7c72e993, 0xb3ee1411, 0x636fbc2a,
28
    0x2ba9c55d, 0x741831f6, 0xce5c3e16, 0x9b87931e,
29
    0xafd6ba33, 0x6c24cf5c, 0x7a325381, 0x28958677,
30
    0x3b8f4898, 0x6b4bb9af, 0xc4bfe81b, 0x66282193,
31
    0x61d809cc, 0xfb21a991, 0x487cac60, 0x5dec8032,
32
    0xef845d5d, 0xe98575b1, 0xdc262302, 0xeb651b88,
33
    0x23893e81, 0xd396acc5, 0x0f6d6ff3, 0x83f44239,
34
    0x2e0b4482, 0xa4842004, 0x69c8f04a, 0x9e1f9b5e,
35
    0x21c66842, 0xf6e96c9a, 0x670c9c61, 0xabd388f0,
36
    0x6a51a0d2, 0xd8542f68, 0x960fa728, 0xab5133a3,
37
    0x6eef0b6c, 0x137a3be4, 0xba3bf050, 0x7efb2a98,
38
    0xa1f1651d, 0x39af0176, 0x66ca593e, 0x82430e88,
39
    0x8cee8619, 0x456f9fb4, 0x7d84a5c3, 0x3b8b5ebe,
40
    0xe06f75d8, 0x85c12073, 0x401a449f, 0x56c16aa6,
41
    0x4ed3aa62, 0x363f7706, 0x1bfedf72, 0x429b023d,
42
    0x37d0d724, 0xd00a1248, 0xdb0fead3, 0x49f1c09b,
43
    0x075372c9, 0x80991b7b, 0x25d479d8, 0xf6e8def7,
44
    0xe3fe501a, 0xb6794c3b, 0x976ce0bd, 0x04c006ba,
45
    0xc1a94fb6, 0x409f60c4, 0x5e5c9ec2, 0x196a2463,
46
    0x68fb6faf, 0x3e6c53b5, 0x1339b2eb, 0x3b52ec6f,
47
    0x6dfc511f, 0x9b30952c, 0xcc814544, 0xaf5ebd09,
48
    0xbee3d004, 0xde334afd, 0x660f2807, 0x192e4bb3,
49
    0xc0cba857, 0x45c8740f, 0xd20b5f39, 0xb9d3fbdb,
50
    0x5579c0bd, 0x1a60320a, 0xd6a100c6, 0x402c7279,
51
    0x679f25fe, 0xfb1fa3cc, 0x8ea5e9f8, 0xdb3222f8,
52
    0x3c7516df, 0xfd616b15, 0x2f501ec8, 0xad0552ab,
53
    0x323db5fa, 0xfd238760, 0x53317b48, 0x3e00df82,
54
    0x9e5c57bb, 0xca6f8ca0, 0x1a87562e, 0xdf1769db,
55
    0xd542a8f6, 0x287effc3, 0xac6732c6, 0x8c4f5573,
56
    0x695b27b0, 0xbbca58c8, 0xe1ffa35d, 0xb8f011a0,
57
    0x10fa3d98, 0xfd2183b8, 0x4afcb56c, 0x2dd1d35b,
58
    0x9a53e479, 0xb6f84565, 0xd28e49bc, 0x4bfb9790,
59
    0xe1ddf2da, 0xa4cb7e33, 0x62fb1341, 0xcee4c6e8,
60
    0xef20cada, 0x36774c01, 0xd07e9efe, 0x2bf11fb4,
61
    0x95dbda4d, 0xae909198, 0xeaad8e71, 0x6b93d5a0,
62
    0xd08ed1d0, 0xafc725e0, 0x8e3c5b2f, 0x8e7594b7,
63
    0x8ff6e2fb, 0xf2122b64, 0x8888b812, 0x900df01c,
64
    0x4fad5ea0, 0x688fc31c, 0xd1cff191, 0xb3a8c1ad,
65
    0x2f2f2218, 0xbe0e1777, 0xea752dfe, 0x8b021fa1,
66
    0xe5a0cc0f, 0xb56f74e8, 0x18acf3d6, 0xce89e299,
67
    0xb4a84fe0, 0xfd13e0b7, 0x7cc43b81, 0xd2ada8d9,
68
    0x165fa266, 0x80957705, 0x93cc7314, 0x211a1477,
69
    0xe6ad2065, 0x77b5fa86, 0xc75442f5, 0xfb9d35cf,
70
    0xebcdaf0c, 0x7b3e89a0, 0xd6411bd3, 0xae1e7e49,
71
    0x00250e2d, 0x2071b35e, 0x226800bb, 0x57b8e0af,
72
    0x2464369b, 0xf009b91e, 0x5563911d, 0x59dfa6aa,
73
    0x78c14389, 0xd95a537f, 0x207d5ba2, 0x02e5b9c5,
74
    0x83260376, 0x6295cfa9, 0x11c81968, 0x4e734a41,
75
    0xb3472dca, 0x7b14a94a, 0x1b510052, 0x9a532915,
76
    0xd60f573f, 0xbc9bc6e4, 0x2b60a476, 0x81e67400,
77
    0x08ba6fb5, 0x571be91f, 0xf296ec6b, 0x2a0dd915,
78
    0xb6636521, 0xe7b9f9b6, 0xff34052e, 0xc5855664,
79
    0x53b02d5d, 0xa99f8fa1, 0x08ba4799, 0x6e85076a},
80
  {
81
    0x4b7a70e9, 0xb5b32944, 0xdb75092e, 0xc4192623,
82
    0xad6ea6b0, 0x49a7df7d, 0x9cee60b8, 0x8fedb266,
83
    0xecaa8c71, 0x699a17ff, 0x5664526c, 0xc2b19ee1,
84
    0x193602a5, 0x75094c29, 0xa0591340, 0xe4183a3e,
85
    0x3f54989a, 0x5b429d65, 0x6b8fe4d6, 0x99f73fd6,
86
    0xa1d29c07, 0xefe830f5, 0x4d2d38e6, 0xf0255dc1,
87
    0x4cdd2086, 0x8470eb26, 0x6382e9c6, 0x021ecc5e,
88
    0x09686b3f, 0x3ebaefc9, 0x3c971814, 0x6b6a70a1,
89
    0x687f3584, 0x52a0e286, 0xb79c5305, 0xaa500737,
90
    0x3e07841c, 0x7fdeae5c, 0x8e7d44ec, 0x5716f2b8,
91
    0xb03ada37, 0xf0500c0d, 0xf01c1f04, 0x0200b3ff,
92
    0xae0cf51a, 0x3cb574b2, 0x25837a58, 0xdc0921bd,
93
    0xd19113f9, 0x7ca92ff6, 0x94324773, 0x22f54701,
94
    0x3ae5e581, 0x37c2dadc, 0xc8b57634, 0x9af3dda7,
95
    0xa9446146, 0x0fd0030e, 0xecc8c73e, 0xa4751e41,
96
    0xe238cd99, 0x3bea0e2f, 0x3280bba1, 0x183eb331,
97
    0x4e548b38, 0x4f6db908, 0x6f420d03, 0xf60a04bf,
98
    0x2cb81290, 0x24977c79, 0x5679b072, 0xbcaf89af,
99
    0xde9a771f, 0xd9930810, 0xb38bae12, 0xdccf3f2e,
100
    0x5512721f, 0x2e6b7124, 0x501adde6, 0x9f84cd87,
101
    0x7a584718, 0x7408da17, 0xbc9f9abc, 0xe94b7d8c,
102
    0xec7aec3a, 0xdb851dfa, 0x63094366, 0xc464c3d2,
103
    0xef1c1847, 0x3215d908, 0xdd433b37, 0x24c2ba16,
104
    0x12a14d43, 0x2a65c451, 0x50940002, 0x133ae4dd,
105
    0x71dff89e, 0x10314e55, 0x81ac77d6, 0x5f11199b,
106
    0x043556f1, 0xd7a3c76b, 0x3c11183b, 0x5924a509,
107
    0xf28fe6ed, 0x97f1fbfa, 0x9ebabf2c, 0x1e153c6e,
108
    0x86e34570, 0xeae96fb1, 0x860e5e0a, 0x5a3e2ab3,
109
    0x771fe71c, 0x4e3d06fa, 0x2965dcb9, 0x99e71d0f,
110
    0x803e89d6, 0x5266c825, 0x2e4cc978, 0x9c10b36a,
111
    0xc6150eba, 0x94e2ea78, 0xa5fc3c53, 0x1e0a2df4,
112
    0xf2f74ea7, 0x361d2b3d, 0x1939260f, 0x19c27960,
113
    0x5223a708, 0xf71312b6, 0xebadfe6e, 0xeac31f66,
114
    0xe3bc4595, 0xa67bc883, 0xb17f37d1, 0x018cff28,
115
    0xc332ddef, 0xbe6c5aa5, 0x65582185, 0x68ab9802,
116
    0xeecea50f, 0xdb2f953b, 0x2aef7dad, 0x5b6e2f84,
117
    0x1521b628, 0x29076170, 0xecdd4775, 0x619f1510,
118
    0x13cca830, 0xeb61bd96, 0x0334fe1e, 0xaa0363cf,
119
    0xb5735c90, 0x4c70a239, 0xd59e9e0b, 0xcbaade14,
120
    0xeecc86bc, 0x60622ca7, 0x9cab5cab, 0xb2f3846e,
121
    0x648b1eaf, 0x19bdf0ca, 0xa02369b9, 0x655abb50,
122
    0x40685a32, 0x3c2ab4b3, 0x319ee9d5, 0xc021b8f7,
123
    0x9b540b19, 0x875fa099, 0x95f7997e, 0x623d7da8,
124
    0xf837889a, 0x97e32d77, 0x11ed935f, 0x16681281,
125
    0x0e358829, 0xc7e61fd6, 0x96dedfa1, 0x7858ba99,
126
    0x57f584a5, 0x1b227263, 0x9b83c3ff, 0x1ac24696,
127
    0xcdb30aeb, 0x532e3054, 0x8fd948e4, 0x6dbc3128,
128
    0x58ebf2ef, 0x34c6ffea, 0xfe28ed61, 0xee7c3c73,
129
    0x5d4a14d9, 0xe864b7e3, 0x42105d14, 0x203e13e0,
130
    0x45eee2b6, 0xa3aaabea, 0xdb6c4f15, 0xfacb4fd0,
131
    0xc742f442, 0xef6abbb5, 0x654f3b1d, 0x41cd2105,
132
    0xd81e799e, 0x86854dc7, 0xe44b476a, 0x3d816250,
133
    0xcf62a1f2, 0x5b8d2646, 0xfc8883a0, 0xc1c7b6a3,
134
    0x7f1524c3, 0x69cb7492, 0x47848a0b, 0x5692b285,
135
    0x095bbf00, 0xad19489d, 0x1462b174, 0x23820e00,
136
    0x58428d2a, 0x0c55f5ea, 0x1dadf43e, 0x233f7061,
137
    0x3372f092, 0x8d937e41, 0xd65fecf1, 0x6c223bdb,
138
    0x7cde3759, 0xcbee7460, 0x4085f2a7, 0xce77326e,
139
    0xa6078084, 0x19f8509e, 0xe8efd855, 0x61d99735,
140
    0xa969a7aa, 0xc50c06c2, 0x5a04abfc, 0x800bcadc,
141
    0x9e447a2e, 0xc3453484, 0xfdd56705, 0x0e1e9ec9,
142
    0xdb73dbd3, 0x105588cd, 0x675fda79, 0xe3674340,
143
    0xc5c43465, 0x713e38d8, 0x3d28f89e, 0xf16dff20,
144
    0x153e21e7, 0x8fb03d4a, 0xe6e39f2b, 0xdb83adf7},
145
  {
146
    0xe93d5a68, 0x948140f7, 0xf64c261c, 0x94692934,
147
    0x411520f7, 0x7602d4f7, 0xbcf46b2e, 0xd4a20068,
148
    0xd4082471, 0x3320f46a, 0x43b7d4b7, 0x500061af,
149
    0x1e39f62e, 0x97244546, 0x14214f74, 0xbf8b8840,
150
    0x4d95fc1d, 0x96b591af, 0x70f4ddd3, 0x66a02f45,
151
    0xbfbc09ec, 0x03bd9785, 0x7fac6dd0, 0x31cb8504,
152
    0x96eb27b3, 0x55fd3941, 0xda2547e6, 0xabca0a9a,
153
    0x28507825, 0x530429f4, 0x0a2c86da, 0xe9b66dfb,
154
    0x68dc1462, 0xd7486900, 0x680ec0a4, 0x27a18dee,
155
    0x4f3ffea2, 0xe887ad8c, 0xb58ce006, 0x7af4d6b6,
156
    0xaace1e7c, 0xd3375fec, 0xce78a399, 0x406b2a42,
157
    0x20fe9e35, 0xd9f385b9, 0xee39d7ab, 0x3b124e8b,
158
    0x1dc9faf7, 0x4b6d1856, 0x26a36631, 0xeae397b2,
159
    0x3a6efa74, 0xdd5b4332, 0x6841e7f7, 0xca7820fb,
160
    0xfb0af54e, 0xd8feb397, 0x454056ac, 0xba489527,
161
    0x55533a3a, 0x20838d87, 0xfe6ba9b7, 0xd096954b,
162
    0x55a867bc, 0xa1159a58, 0xcca92963, 0x99e1db33,
163
    0xa62a4a56, 0x3f3125f9, 0x5ef47e1c, 0x9029317c,
164
    0xfdf8e802, 0x04272f70, 0x80bb155c, 0x05282ce3,
165
    0x95c11548, 0xe4c66d22, 0x48c1133f, 0xc70f86dc,
166
    0x07f9c9ee, 0x41041f0f, 0x404779a4, 0x5d886e17,
167
    0x325f51eb, 0xd59bc0d1, 0xf2bcc18f, 0x41113564,
168
    0x257b7834, 0x602a9c60, 0xdff8e8a3, 0x1f636c1b,
169
    0x0e12b4c2, 0x02e1329e, 0xaf664fd1, 0xcad18115,
170
    0x6b2395e0, 0x333e92e1, 0x3b240b62, 0xeebeb922,
171
    0x85b2a20e, 0xe6ba0d99, 0xde720c8c, 0x2da2f728,
172
    0xd0127845, 0x95b794fd, 0x647d0862, 0xe7ccf5f0,
173
    0x5449a36f, 0x877d48fa, 0xc39dfd27, 0xf33e8d1e,
174
    0x0a476341, 0x992eff74, 0x3a6f6eab, 0xf4f8fd37,
175
    0xa812dc60, 0xa1ebddf8, 0x991be14c, 0xdb6e6b0d,
176
    0xc67b5510, 0x6d672c37, 0x2765d43b, 0xdcd0e804,
177
    0xf1290dc7, 0xcc00ffa3, 0xb5390f92, 0x690fed0b,
178
    0x667b9ffb, 0xcedb7d9c, 0xa091cf0b, 0xd9155ea3,
179
    0xbb132f88, 0x515bad24, 0x7b9479bf, 0x763bd6eb,
180
    0x37392eb3, 0xcc115979, 0x8026e297, 0xf42e312d,
181
    0x6842ada7, 0xc66a2b3b, 0x12754ccc, 0x782ef11c,
182
    0x6a124237, 0xb79251e7, 0x06a1bbe6, 0x4bfb6350,
183
    0x1a6b1018, 0x11caedfa, 0x3d25bdd8, 0xe2e1c3c9,
184
    0x44421659, 0x0a121386, 0xd90cec6e, 0xd5abea2a,
185
    0x64af674e, 0xda86a85f, 0xbebfe988, 0x64e4c3fe,
186
    0x9dbc8057, 0xf0f7c086, 0x60787bf8, 0x6003604d,
187
    0xd1fd8346, 0xf6381fb0, 0x7745ae04, 0xd736fccc,
188
    0x83426b33, 0xf01eab71, 0xb0804187, 0x3c005e5f,
189
    0x77a057be, 0xbde8ae24, 0x55464299, 0xbf582e61,
190
    0x4e58f48f, 0xf2ddfda2, 0xf474ef38, 0x8789bdc2,
191
    0x5366f9c3, 0xc8b38e74, 0xb475f255, 0x46fcd9b9,
192
    0x7aeb2661, 0x8b1ddf84, 0x846a0e79, 0x915f95e2,
193
    0x466e598e, 0x20b45770, 0x8cd55591, 0xc902de4c,
194
    0xb90bace1, 0xbb8205d0, 0x11a86248, 0x7574a99e,
195
    0xb77f19b6, 0xe0a9dc09, 0x662d09a1, 0xc4324633,
196
    0xe85a1f02, 0x09f0be8c, 0x4a99a025, 0x1d6efe10,
197
    0x1ab93d1d, 0x0ba5a4df, 0xa186f20f, 0x2868f169,
198
    0xdcb7da83, 0x573906fe, 0xa1e2ce9b, 0x4fcd7f52,
199
    0x50115e01, 0xa70683fa, 0xa002b5c4, 0x0de6d027,
200
    0x9af88c27, 0x773f8641, 0xc3604c06, 0x61a806b5,
201
    0xf0177a28, 0xc0f586e0, 0x006058aa, 0x30dc7d62,
202
    0x11e69ed7, 0x2338ea63, 0x53c2dd94, 0xc2c21634,
203
    0xbbcbee56, 0x90bcb6de, 0xebfc7da1, 0xce591d76,
204
    0x6f05e409, 0x4b7c0188, 0x39720a3d, 0x7c927c24,
205
    0x86e3725f, 0x724d9db9, 0x1ac15bb4, 0xd39eb8fc,
206
    0xed545578, 0x08fca5b5, 0xd83d7cd3, 0x4dad0fc4,
207
    0x1e50ef5e, 0xb161e6f8, 0xa28514d9, 0x6c51133c,
208
    0x6fd5c7e7, 0x56e14ec4, 0x362abfce, 0xddc6c837,
209
    0xd79a3234, 0x92638212, 0x670efa8e, 0x406000e0},
210
  {
211
    0x3a39ce37, 0xd3faf5cf, 0xabc27737, 0x5ac52d1b,
212
    0x5cb0679e, 0x4fa33742, 0xd3822740, 0x99bc9bbe,
213
    0xd5118e9d, 0xbf0f7315, 0xd62d1c7e, 0xc700c47b,
214
    0xb78c1b6b, 0x21a19045, 0xb26eb1be, 0x6a366eb4,
215
    0x5748ab2f, 0xbc946e79, 0xc6a376d2, 0x6549c2c8,
216
    0x530ff8ee, 0x468dde7d, 0xd5730a1d, 0x4cd04dc6,
217
    0x2939bbdb, 0xa9ba4650, 0xac9526e8, 0xbe5ee304,
218
    0xa1fad5f0, 0x6a2d519a, 0x63ef8ce2, 0x9a86ee22,
219
    0xc089c2b8, 0x43242ef6, 0xa51e03aa, 0x9cf2d0a4,
220
    0x83c061ba, 0x9be96a4d, 0x8fe51550, 0xba645bd6,
221
    0x2826a2f9, 0xa73a3ae1, 0x4ba99586, 0xef5562e9,
222
    0xc72fefd3, 0xf752f7da, 0x3f046f69, 0x77fa0a59,
223
    0x80e4a915, 0x87b08601, 0x9b09e6ad, 0x3b3ee593,
224
    0xe990fd5a, 0x9e34d797, 0x2cf0b7d9, 0x022b8b51,
225
    0x96d5ac3a, 0x017da67d, 0xd1cf3ed6, 0x7c7d2d28,
226
    0x1f9f25cf, 0xadf2b89b, 0x5ad6b472, 0x5a88f54c,
227
    0xe029ac71, 0xe019a5e6, 0x47b0acfd, 0xed93fa9b,
228
    0xe8d3c48d, 0x283b57cc, 0xf8d56629, 0x79132e28,
229
    0x785f0191, 0xed756055, 0xf7960e44, 0xe3d35e8c,
230
    0x15056dd4, 0x88f46dba, 0x03a16125, 0x0564f0bd,
231
    0xc3eb9e15, 0x3c9057a2, 0x97271aec, 0xa93a072a,
232
    0x1b3f6d9b, 0x1e6321f5, 0xf59c66fb, 0x26dcf319,
233
    0x7533d928, 0xb155fdf5, 0x03563482, 0x8aba3cbb,
234
    0x28517711, 0xc20ad9f8, 0xabcc5167, 0xccad925f,
235
    0x4de81751, 0x3830dc8e, 0x379d5862, 0x9320f991,
236
    0xea7a90c2, 0xfb3e7bce, 0x5121ce64, 0x774fbe32,
237
    0xa8b6e37e, 0xc3293d46, 0x48de5369, 0x6413e680,
238
    0xa2ae0810, 0xdd6db224, 0x69852dfd, 0x09072166,
239
    0xb39a460a, 0x6445c0dd, 0x586cdecf, 0x1c20c8ae,
240
    0x5bbef7dd, 0x1b588d40, 0xccd2017f, 0x6bb4e3bb,
241
    0xdda26a7e, 0x3a59ff45, 0x3e350a44, 0xbcb4cdd5,
242
    0x72eacea8, 0xfa6484bb, 0x8d6612ae, 0xbf3c6f47,
243
    0xd29be463, 0x542f5d9e, 0xaec2771b, 0xf64e6370,
244
    0x740e0d8d, 0xe75b1357, 0xf8721671, 0xaf537d5d,
245
    0x4040cb08, 0x4eb4e2cc, 0x34d2466a, 0x0115af84,
246
    0xe1b00428, 0x95983a1d, 0x06b89fb4, 0xce6ea048,
247
    0x6f3f3b82, 0x3520ab82, 0x011a1d4b, 0x277227f8,
248
    0x611560b1, 0xe7933fdc, 0xbb3a792b, 0x344525bd,
249
    0xa08839e1, 0x51ce794b, 0x2f32c9b7, 0xa01fbac9,
250
    0xe01cc87e, 0xbcc7d1f6, 0xcf0111c3, 0xa1e8aac7,
251
    0x1a908749, 0xd44fbd9a, 0xd0dadecb, 0xd50ada38,
252
    0x0339c32a, 0xc6913667, 0x8df9317c, 0xe0b12b4f,
253
    0xf79e59b7, 0x43f5bb3a, 0xf2d519ff, 0x27d9459c,
254
    0xbf97222c, 0x15e6fc2a, 0x0f91fc71, 0x9b941525,
255
    0xfae59361, 0xceb69ceb, 0xc2a86459, 0x12baa8d1,
256
    0xb6c1075e, 0xe3056a0c, 0x10d25065, 0xcb03a442,
257
    0xe0ec6e0e, 0x1698db3b, 0x4c98a0be, 0x3278e964,
258
    0x9f1f9532, 0xe0d392df, 0xd3a0342b, 0x8971f21e,
259
    0x1b0a7441, 0x4ba3348c, 0xc5be7120, 0xc37632d8,
260
    0xdf359f8d, 0x9b992f2e, 0xe60b6f47, 0x0fe3f11d,
261
    0xe54cda54, 0x1edad891, 0xce6279cf, 0xcd3e7e6f,
262
    0x1618b166, 0xfd2c1d05, 0x848fd2c5, 0xf6fb2299,
263
    0xf523f357, 0xa6327623, 0x93a83531, 0x56cccd02,
264
    0xacf08162, 0x5a75ebb5, 0x6e163697, 0x88d273cc,
265
    0xde966292, 0x81b949d0, 0x4c50901b, 0x71c65614,
266
    0xe6c6c7bd, 0x327a140a, 0x45e1d006, 0xc3f27b9a,
267
    0xc9aa53fd, 0x62a80f00, 0xbb25bfe2, 0x35bdd2f6,
268
    0x71126905, 0xb2040222, 0xb6cbcf7c, 0xcd769c2b,
269
    0x53113ec0, 0x1640e3d3, 0x38abbd60, 0x2547adf0,
270
    0xba38209c, 0xf746ce76, 0x77afa1c5, 0x20756060,
271
    0x85cbfe4e, 0x8ae88dd8, 0x7aaaf9b0, 0x4cf9aa7e,
272
    0x1948c25c, 0x02fb8a8c, 0x01c36ae4, 0xd6ebe1f9,
273
    0x90d4f869, 0xa65cdea0, 0x3f09252d, 0xc208e69f,
274
    0xb74e6132, 0xce77e25b, 0x578fdfe3, 0x3ac372e6}
275
};
276
277
#endif
(-)john-1.6.orig/src/blowfish.c (+186 lines)
Line 0 Link Here
1
/* 
2
 * blowfish.c - part of blowfish.mod
3
 * handles: encryption and decryption of passwords
4
 */
5
/* 
6
 * The first half of this is very lightly edited from public domain
7
 * sourcecode.  For simplicity, this entire module will remain public
8
 * domain.
9
 */
10
/* 
11
 * This is ripped from eggdrop 1.3.28's source files (blowfish.mod)
12
 * Modified by Sun-Zero <sun-zero@freemail.hu>
13
 * 2002-04-16
14
*/
15
16
#include <stdlib.h>
17
18
#include "blowfish.h"
19
#include "bf_tab.h"		/* P-box P-array, S-box */
20
21
/* #define S(x,i) (bf_S[i][x.w.byte##i]) */
22
#define S0(x) (bf_S[0][x.w.byte0])
23
#define S1(x) (bf_S[1][x.w.byte1])
24
#define S2(x) (bf_S[2][x.w.byte2])
25
#define S3(x) (bf_S[3][x.w.byte3])
26
#define bf_F(x) (((S0(x) + S1(x)) ^ S2(x)) + S3(x))
27
#define ROUND(a,b,n) (a.word ^= bf_F(b) ^ bf_P[n])
28
29
#include <time.h>
30
31
/* keep a set of rotating P & S boxes */
32
static struct box_t {
33
  UWORD_32bits *P;
34
  UWORD_32bits **S;
35
  char key[81];
36
  char keybytes;
37
} box;
38
39
//static UWORD_32bits bf_P[bf_N+2];
40
//static UWORD_32bits bf_S[4][256];
41
static UWORD_32bits *bf_P;
42
static UWORD_32bits **bf_S;
43
44
45
void blowfish_first_init(void) {
46
      box.P = NULL;
47
      box.S = NULL;
48
      box.key[0] = 0;
49
}
50
51
static void blowfish_encipher(UWORD_32bits * xl, UWORD_32bits * xr)
52
{
53
  union aword Xl;
54
  union aword Xr;
55
56
  Xl.word = *xl;
57
  Xr.word = *xr;
58
59
  Xl.word ^= bf_P[0];
60
  ROUND(Xr, Xl, 1);
61
  ROUND(Xl, Xr, 2);
62
  ROUND(Xr, Xl, 3);
63
  ROUND(Xl, Xr, 4);
64
  ROUND(Xr, Xl, 5);
65
  ROUND(Xl, Xr, 6);
66
  ROUND(Xr, Xl, 7);
67
  ROUND(Xl, Xr, 8);
68
  ROUND(Xr, Xl, 9);
69
  ROUND(Xl, Xr, 10);
70
  ROUND(Xr, Xl, 11);
71
  ROUND(Xl, Xr, 12);
72
  ROUND(Xr, Xl, 13);
73
  ROUND(Xl, Xr, 14);
74
  ROUND(Xr, Xl, 15);
75
  ROUND(Xl, Xr, 16);
76
  Xr.word ^= bf_P[17];
77
78
  *xr = Xl.word;
79
  *xl = Xr.word;
80
}
81
82
static void blowfish_init(UBYTE_08bits * key, short keybytes)
83
{
84
  int i, j;
85
  UWORD_32bits data;
86
  UWORD_32bits datal;
87
  UWORD_32bits datar;
88
  union aword temp;
89
90
  /* is buffer already allocated for this? */
91
  if (box.P != NULL) {
92
      if ((box.keybytes == keybytes) &&
93
	  (!strncmp((char *) (box.key), (char *) key, keybytes))) {
94
	/* match! */
95
	bf_P = box.P;
96
	bf_S = box.S;
97
	return;
98
      }
99
        free(box.P);
100
        for (i = 0; i < 4; i++)
101
          free(box.S[i]);
102
        free(box.S);
103
  }
104
  /* initialize new buffer */
105
  /* uh... this is over 4k */
106
  box.P = (UWORD_32bits *) malloc((bf_N + 2) * sizeof(UWORD_32bits));
107
  box.S = (UWORD_32bits **) malloc(4 * sizeof(UWORD_32bits *));
108
  for (i = 0; i < 4; i++)
109
    box.S[i] = (UWORD_32bits *) malloc(256 * sizeof(UWORD_32bits));
110
  bf_P = box.P;
111
  bf_S = box.S;
112
  box.keybytes = keybytes;
113
  strncpy(box.key, key, keybytes);
114
  /* robey: reset blowfish boxes to initial state */
115
  /* (i guess normally it just keeps scrambling them, but here it's
116
   * important to get the same encrypted result each time) */
117
  for (i = 0; i < bf_N + 2; i++)
118
    bf_P[i] = initbf_P[i];
119
  for (i = 0; i < 4; i++)
120
    for (j = 0; j < 256; j++)
121
      bf_S[i][j] = initbf_S[i][j];
122
123
  j = 0;
124
  for (i = 0; i < bf_N + 2; ++i) {
125
    temp.word = 0;
126
    temp.w.byte0 = key[j];
127
    temp.w.byte1 = key[(j + 1) % keybytes];
128
    temp.w.byte2 = key[(j + 2) % keybytes];
129
    temp.w.byte3 = key[(j + 3) % keybytes];
130
    data = temp.word;
131
    bf_P[i] = bf_P[i] ^ data;
132
    j = (j + 4) % keybytes;
133
  }
134
  datal = 0x00000000;
135
  datar = 0x00000000;
136
  for (i = 0; i < bf_N + 2; i += 2) {
137
    blowfish_encipher(&datal, &datar);
138
    bf_P[i] = datal;
139
    bf_P[i + 1] = datar;
140
  }
141
  for (i = 0; i < 4; ++i) {
142
    for (j = 0; j < 256; j += 2) {
143
      blowfish_encipher(&datal, &datar);
144
      bf_S[i][j] = datal;
145
      bf_S[i][j + 1] = datar;
146
    }
147
  }
148
}
149
150
/* stuff below this line was written by robey for eggdrop use */
151
152
/* of course, if you change either of these, then your userfile will
153
 * no longer be able to be shared. :) */
154
#define SALT1  0xdeadd061
155
#define SALT2  0x23f6b095
156
157
/* convert 64-bit encrypted password to text for userfile */
158
static char *base64 = "./0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
159
160
static void blowfish_encrypt_pass(char *text, char *new)
161
{
162
  UWORD_32bits left, right;
163
  int n;
164
  char *p;
165
166
  blowfish_init(text, strlen(text));
167
  left = SALT1;
168
  right = SALT2;
169
  blowfish_encipher(&left, &right);
170
  p = new;
171
  *p++ = '+';			/* + means encrypted pass */
172
  n = 32;
173
  while (n > 0) {
174
    *p++ = base64[right & 0x3f];
175
    right = (right >> 6);
176
    n -= 6;
177
  }
178
  n = 32;
179
  while (n > 0) {
180
    *p++ = base64[left & 0x3f];
181
    left = (left >> 6);
182
    n -= 6;
183
  }
184
  *p = 0;
185
}
186
(-)john-1.6.orig/src/blowfish.h (+55 lines)
Line 0 Link Here
1
/* modified 19jul1996 by robey -- uses autoconf values now */
2
#ifndef _H_BLOWFISH
3
#define _H_BLOWFISH
4
5
#include "arch.h"
6
7
#define bf_N             16
8
#define noErr            0
9
#define DATAERROR        -1
10
11
#define UBYTE_08bits  unsigned char
12
#define UWORD_16bits  unsigned short
13
14
#define SIZEOF_INT 4
15
16
#if SIZEOF_INT==4
17
#define UWORD_32bits  unsigned int
18
#else
19
#if SIZEOF_LONG==4
20
#define UWORD_32bits  unsigned long
21
#endif
22
#endif
23
24
/* choose a byte order for your hardware */
25
26
#if !ARCH_LITTLE_ENDIAN
27
/* ABCD - big endian - motorola */
28
union aword {
29
  UWORD_32bits word;
30
  UBYTE_08bits byte[4];
31
  struct {
32
    unsigned int byte0:8;
33
    unsigned int byte1:8;
34
    unsigned int byte2:8;
35
    unsigned int byte3:8;
36
  } w;
37
};
38
#endif				/* !ARCH_LITTLE_ENDIAN */
39
40
#if ARCH_LITTLE_ENDIAN
41
/* DCBA - little endian - intel */
42
union aword {
43
  UWORD_32bits word;
44
  UBYTE_08bits byte[4];
45
  struct {
46
    unsigned int byte3:8;
47
    unsigned int byte2:8;
48
    unsigned int byte1:8;
49
    unsigned int byte0:8;
50
  } w;
51
};
52
53
#endif				/* ARCH_LITTLE_ENDIAN */
54
55
#endif
(-)john-1.6.orig/src/byteorder.h (+274 lines)
Line 0 Link Here
1
/* 
2
   Unix SMB/Netbios implementation.
3
   Version 1.9.
4
   SMB Byte handling
5
   Copyright (C) Andrew Tridgell 1992-1998
6
   
7
   This program is free software; you can redistribute it and/or modify
8
   it under the terms of the GNU General Public License as published by
9
   the Free Software Foundation; either version 2 of the License, or
10
   (at your option) any later version.
11
   
12
   This program is distributed in the hope that it will be useful,
13
   but WITHOUT ANY WARRANTY; without even the implied warranty of
14
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
   GNU General Public License for more details.
16
   
17
   You should have received a copy of the GNU General Public License
18
   along with this program; if not, write to the Free Software
19
   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20
*/
21
22
#ifndef _BYTEORDER_H
23
#define _BYTEORDER_H
24
25
/*
26
   This file implements macros for machine independent short and 
27
   int manipulation
28
29
Here is a description of this file that I emailed to the samba list once:
30
31
> I am confused about the way that byteorder.h works in Samba. I have
32
> looked at it, and I would have thought that you might make a distinction
33
> between LE and BE machines, but you only seem to distinguish between 386
34
> and all other architectures.
35
> 
36
> Can you give me a clue?
37
38
sure.
39
40
The distinction between 386 and other architectures is only there as
41
an optimisation. You can take it out completely and it will make no
42
difference. The routines (macros) in byteorder.h are totally byteorder
43
independent. The 386 optimsation just takes advantage of the fact that
44
the x86 processors don't care about alignment, so we don't have to
45
align ints on int boundaries etc. If there are other processors out
46
there that aren't alignment sensitive then you could also define
47
CAREFUL_ALIGNMENT=0 on those processors as well.
48
49
Ok, now to the macros themselves. I'll take a simple example, say we
50
want to extract a 2 byte integer from a SMB packet and put it into a
51
type called uint16 that is in the local machines byte order, and you
52
want to do it with only the assumption that uint16 is _at_least_ 16
53
bits long (this last condition is very important for architectures
54
that don't have any int types that are 2 bytes long)
55
56
You do this:
57
58
#define CVAL(buf,pos) (((unsigned char *)(buf))[pos])
59
#define PVAL(buf,pos) ((unsigned)CVAL(buf,pos))
60
#define SVAL(buf,pos) (PVAL(buf,pos)|PVAL(buf,(pos)+1)<<8)
61
62
then to extract a uint16 value at offset 25 in a buffer you do this:
63
64
char *buffer = foo_bar();
65
uint16 xx = SVAL(buffer,25);
66
67
We are using the byteoder independence of the ANSI C bitshifts to do
68
the work. A good optimising compiler should turn this into efficient
69
code, especially if it happens to have the right byteorder :-)
70
71
I know these macros can be made a bit tidier by removing some of the
72
casts, but you need to look at byteorder.h as a whole to see the
73
reasoning behind them. byteorder.h defines the following macros:
74
75
SVAL(buf,pos) - extract a 2 byte SMB value
76
IVAL(buf,pos) - extract a 4 byte SMB value
77
SVALS(buf,pos) signed version of SVAL()
78
IVALS(buf,pos) signed version of IVAL()
79
80
SSVAL(buf,pos,val) - put a 2 byte SMB value into a buffer
81
SIVAL(buf,pos,val) - put a 4 byte SMB value into a buffer
82
SSVALS(buf,pos,val) - signed version of SSVAL()
83
SIVALS(buf,pos,val) - signed version of SIVAL()
84
85
RSVAL(buf,pos) - like SVAL() but for NMB byte ordering
86
RSVALS(buf,pos) - like SVALS() but for NMB byte ordering
87
RIVAL(buf,pos) - like IVAL() but for NMB byte ordering
88
RIVALS(buf,pos) - like IVALS() but for NMB byte ordering
89
RSSVAL(buf,pos,val) - like SSVAL() but for NMB ordering
90
RSIVAL(buf,pos,val) - like SIVAL() but for NMB ordering
91
RSIVALS(buf,pos,val) - like SIVALS() but for NMB ordering
92
93
it also defines lots of intermediate macros, just ignore those :-)
94
95
*/
96
97
/* some switch macros that do both store and read to and from SMB buffers */
98
99
#define RW_PCVAL(read,inbuf,outbuf,len) \
100
	{ if (read) { PCVAL (inbuf,0,outbuf,len); } \
101
	else      { PSCVAL(inbuf,0,outbuf,len); } }
102
103
#define RW_PIVAL(read,big_endian,inbuf,outbuf,len) \
104
	{ if (read) { if (big_endian) { RPIVAL(inbuf,0,outbuf,len); } else { PIVAL(inbuf,0,outbuf,len); } } \
105
	else      { if (big_endian) { RPSIVAL(inbuf,0,outbuf,len); } else { PSIVAL(inbuf,0,outbuf,len); } } }
106
107
#define RW_PSVAL(read,big_endian,inbuf,outbuf,len) \
108
	{ if (read) { if (big_endian) { RPSVAL(inbuf,0,outbuf,len); } else { PSVAL(inbuf,0,outbuf,len); } } \
109
	else      { if (big_endian) { RPSSVAL(inbuf,0,outbuf,len); } else { PSSVAL(inbuf,0,outbuf,len); } } }
110
111
#define RW_CVAL(read, inbuf, outbuf, offset) \
112
	{ if (read) { (outbuf) = CVAL (inbuf,offset); } \
113
	else      { SCVAL(inbuf,offset,outbuf); } }
114
115
#define RW_IVAL(read, big_endian, inbuf, outbuf, offset) \
116
	{ if (read) { (outbuf) = ((big_endian) ? RIVAL(inbuf,offset) : IVAL (inbuf,offset)); } \
117
	else      { if (big_endian) { RSIVAL(inbuf,offset,outbuf); } else { SIVAL(inbuf,offset,outbuf); } } }
118
119
#define RW_SVAL(read, big_endian, inbuf, outbuf, offset) \
120
	{ if (read) { (outbuf) = ((big_endian) ? RSVAL(inbuf,offset) : SVAL (inbuf,offset)); } \
121
	else      { if (big_endian) { RSSVAL(inbuf,offset,outbuf); } else { SSVAL(inbuf,offset,outbuf); } } }
122
123
#undef CAREFUL_ALIGNMENT
124
125
/* we know that the 386 can handle misalignment and has the "right" 
126
   byteorder */
127
#ifdef __i386__
128
#define CAREFUL_ALIGNMENT 0
129
#endif
130
131
#ifndef CAREFUL_ALIGNMENT
132
#define CAREFUL_ALIGNMENT 1
133
#endif
134
135
#define CVAL(buf,pos) (((unsigned char *)(buf))[pos])
136
#define PVAL(buf,pos) ((unsigned)CVAL(buf,pos))
137
#define SCVAL(buf,pos,val) (CVAL(buf,pos) = (val))
138
139
140
#if CAREFUL_ALIGNMENT
141
142
#define SVAL(buf,pos) (PVAL(buf,pos)|PVAL(buf,(pos)+1)<<8)
143
#define IVAL(buf,pos) (SVAL(buf,pos)|SVAL(buf,(pos)+2)<<16)
144
#define SSVALX(buf,pos,val) (CVAL(buf,pos)=(val)&0xFF,CVAL(buf,pos+1)=(val)>>8)
145
#define SIVALX(buf,pos,val) (SSVALX(buf,pos,val&0xFFFF),SSVALX(buf,pos+2,val>>16))
146
#define SVALS(buf,pos) ((int16)SVAL(buf,pos))
147
#define IVALS(buf,pos) ((int32)IVAL(buf,pos))
148
#define SSVAL(buf,pos,val) SSVALX((buf),(pos),((uint16)(val)))
149
#define SIVAL(buf,pos,val) SIVALX((buf),(pos),((uint32)(val)))
150
#define SSVALS(buf,pos,val) SSVALX((buf),(pos),((int16)(val)))
151
#define SIVALS(buf,pos,val) SIVALX((buf),(pos),((int32)(val)))
152
153
#else /* CAREFUL_ALIGNMENT */
154
155
/* this handles things for architectures like the 386 that can handle
156
   alignment errors */
157
/*
158
   WARNING: This section is dependent on the length of int16 and int32
159
   being correct 
160
*/
161
162
/* get single value from an SMB buffer */
163
#define SVAL(buf,pos) (*(const uint16 *)((const char *)(buf) + (pos)))
164
#define IVAL(buf,pos) (*(const uint32 *)((const char *)(buf) + (pos)))
165
#define SVALS(buf,pos) (*(const int16 *)((const char *)(buf) + (pos)))
166
#define IVALS(buf,pos) (*(const int32 *)((const char *)(buf) + (pos)))
167
168
/* store single value in an SMB buffer */
169
#define SVALMOD(buf,pos) (*(uint16 *)((char *)(buf) + (pos)))
170
#define IVALMOD(buf,pos) (*(uint32 *)((char *)(buf) + (pos)))
171
#define SVALSMOD(buf,pos) (*(int16 *)((char *)(buf) + (pos)))
172
#define IVALSMOD(buf,pos) (*(int32 *)((char *)(buf) + (pos)))
173
174
#define SSVAL(buf,pos,val) SVALMOD(buf,pos)=((uint16)(val))
175
#define SIVAL(buf,pos,val) IVALMOD(buf,pos)=((uint32)(val))
176
#define SSVALS(buf,pos,val) SVALSMOD(buf,pos)=((int16)(val))
177
#define SIVALS(buf,pos,val) IVALSMOD(buf,pos)=((int32)(val))
178
179
#endif /* CAREFUL_ALIGNMENT */
180
181
/* macros for reading / writing arrays */
182
183
#define SMBMACRO(macro,buf,pos,val,len,size) \
184
{ uint32 l; for (l = 0; l < (uint32)(len); l++) (val)[l] = macro((buf), (pos) + (size)*l); }
185
186
#define SSMBMACRO(macro,buf,pos,val,len,size) \
187
{ uint32 l; for (l = 0; l < (uint32)(len); l++) macro((buf), (pos) + (size)*l, (val)[l]); }
188
189
/* reads multiple data from an SMB buffer */
190
#define PCVAL(buf,pos,val,len) SMBMACRO(CVAL,buf,pos,val,len,1)
191
#define PSVAL(buf,pos,val,len) SMBMACRO(SVAL,buf,pos,val,len,2)
192
#define PIVAL(buf,pos,val,len) SMBMACRO(IVAL,buf,pos,val,len,4)
193
#define PCVALS(buf,pos,val,len) SMBMACRO(CVALS,buf,pos,val,len,1)
194
#define PSVALS(buf,pos,val,len) SMBMACRO(SVALS,buf,pos,val,len,2)
195
#define PIVALS(buf,pos,val,len) SMBMACRO(IVALS,buf,pos,val,len,4)
196
197
/* stores multiple data in an SMB buffer */
198
#define PSCVAL(buf,pos,val,len) SSMBMACRO(SCVAL,buf,pos,val,len,1)
199
#define PSSVAL(buf,pos,val,len) SSMBMACRO(SSVAL,buf,pos,val,len,2)
200
#define PSIVAL(buf,pos,val,len) SSMBMACRO(SIVAL,buf,pos,val,len,4)
201
#define PSCVALS(buf,pos,val,len) SSMBMACRO(SCVALS,buf,pos,val,len,1)
202
#define PSSVALS(buf,pos,val,len) SSMBMACRO(SSVALS,buf,pos,val,len,2)
203
#define PSIVALS(buf,pos,val,len) SSMBMACRO(SIVALS,buf,pos,val,len,4)
204
205
206
/* now the reverse routines - these are used in nmb packets (mostly) */
207
#define SREV(x) ((((x)&0xFF)<<8) | (((x)>>8)&0xFF))
208
#define IREV(x) ((SREV(x)<<16) | (SREV((x)>>16)))
209
210
#define RSVAL(buf,pos) SREV(SVAL(buf,pos))
211
#define RSVALS(buf,pos) SREV(SVALS(buf,pos))
212
#define RIVAL(buf,pos) IREV(IVAL(buf,pos))
213
#define RIVALS(buf,pos) IREV(IVALS(buf,pos))
214
#define RSSVAL(buf,pos,val) SSVAL(buf,pos,SREV(val))
215
#define RSSVALS(buf,pos,val) SSVALS(buf,pos,SREV(val))
216
#define RSIVAL(buf,pos,val) SIVAL(buf,pos,IREV(val))
217
#define RSIVALS(buf,pos,val) SIVALS(buf,pos,IREV(val))
218
219
/* reads multiple data from an SMB buffer (big-endian) */
220
#define RPSVAL(buf,pos,val,len) SMBMACRO(RSVAL,buf,pos,val,len,2)
221
#define RPIVAL(buf,pos,val,len) SMBMACRO(RIVAL,buf,pos,val,len,4)
222
#define RPSVALS(buf,pos,val,len) SMBMACRO(RSVALS,buf,pos,val,len,2)
223
#define RPIVALS(buf,pos,val,len) SMBMACRO(RIVALS,buf,pos,val,len,4)
224
225
/* stores multiple data in an SMB buffer (big-endian) */
226
#define RPSSVAL(buf,pos,val,len) SSMBMACRO(RSSVAL,buf,pos,val,len,2)
227
#define RPSIVAL(buf,pos,val,len) SSMBMACRO(RSIVAL,buf,pos,val,len,4)
228
#define RPSSVALS(buf,pos,val,len) SSMBMACRO(RSSVALS,buf,pos,val,len,2)
229
#define RPSIVALS(buf,pos,val,len) SSMBMACRO(RSIVALS,buf,pos,val,len,4)
230
231
#define DBG_RW_PCVAL(charmode,string,depth,base,read,inbuf,outbuf,len) \
232
	{ RW_PCVAL(read,inbuf,outbuf,len) \
233
	DEBUG(5,("%s%04x %s: ", \
234
             tab_depth(depth), base,string)); \
235
    if (charmode) print_asc(5, (unsigned char*)(outbuf), (len)); else \
236
	{ uint32 idx; for (idx = 0; idx < len; idx++) { DEBUG(5,("%02x ", (outbuf)[idx])); } } \
237
	DEBUG(5,("\n")); } 
238
239
#define DBG_RW_PSVAL(charmode,string,depth,base,read,big_endian,inbuf,outbuf,len) \
240
	{ RW_PSVAL(read,big_endian,inbuf,outbuf,len) \
241
	DEBUG(5,("%s%04x %s: ", \
242
             tab_depth(depth), base,string)); \
243
    if (charmode) print_asc(5, (unsigned char*)(outbuf), 2*(len)); else \
244
	{ uint32 idx; for (idx = 0; idx < len; idx++) { DEBUG(5,("%04x ", (outbuf)[idx])); } } \
245
	DEBUG(5,("\n")); }
246
247
#define DBG_RW_PIVAL(charmode,string,depth,base,read,big_endian,inbuf,outbuf,len) \
248
	{ RW_PIVAL(read,big_endian,inbuf,outbuf,len) \
249
	DEBUG(5,("%s%04x %s: ", \
250
             tab_depth(depth), base,string)); \
251
    if (charmode) print_asc(5, (unsigned char*)(outbuf), 4*(len)); else \
252
	{ uint32 idx; for (idx = 0; idx < len; idx++) { DEBUG(5,("%08x ", (outbuf)[idx])); } } \
253
	DEBUG(5,("\n")); }
254
255
#define DBG_RW_CVAL(string,depth,base,read,inbuf,outbuf) \
256
	{ RW_CVAL(read,inbuf,outbuf,0) \
257
	DEBUG(5,("%s%04x %s: %02x\n", \
258
             tab_depth(depth), base, string, outbuf)); }
259
260
#define DBG_RW_SVAL(string,depth,base,read,big_endian,inbuf,outbuf) \
261
	{ RW_SVAL(read,big_endian,inbuf,outbuf,0) \
262
	DEBUG(5,("%s%04x %s: %04x\n", \
263
             tab_depth(depth), base, string, outbuf)); }
264
265
#define DBG_RW_IVAL(string,depth,base,read,big_endian,inbuf,outbuf) \
266
	{ RW_IVAL(read,big_endian,inbuf,outbuf,0) \
267
	DEBUG(5,("%s%04x %s: %08x\n", \
268
             tab_depth(depth), base, string, outbuf)); }
269
270
/* Alignment macros. */
271
#define ALIGN4(p,base) ((p) + ((4 - (PTR_DIFF((p), (base)) & 3)) & 3))
272
#define ALIGN2(p,base) ((p) + ((2 - (PTR_DIFF((p), (base)) & 1)) & 1))
273
274
#endif /* _BYTEORDER_H */
(-)john-1.6.orig/src/john.c (-1 / +11 lines)
Lines 37-46 Link Here
37
#endif
37
#endif
38
38
39
extern struct fmt_main fmt_DES, fmt_BSDI, fmt_MD5, fmt_BF;
39
extern struct fmt_main fmt_DES, fmt_BSDI, fmt_MD5, fmt_BF;
40
extern struct fmt_main fmt_AFS, fmt_LM;
40
extern struct fmt_main fmt_AFS, fmt_LM, fmt_NT;
41
extern struct fmt_main fmt_MYSQL, fmt_SKEY, fmt_KRB4, fmt_BFEgg;
41
42
42
extern int unshadow(int argc, char **argv);
43
extern int unshadow(int argc, char **argv);
43
extern int unafs(int argc, char **argv);
44
extern int unafs(int argc, char **argv);
45
extern int undrop(int argc, char **argv);
44
extern int unique(int argc, char **argv);
46
extern int unique(int argc, char **argv);
45
47
46
static struct db_main database;
48
static struct db_main database;
Lines 58-69 Link Here
58
{
60
{
59
	if (options.format) strlwr(options.format);
61
	if (options.format) strlwr(options.format);
60
62
63
	john_register_one(&fmt_BFEgg);
61
	john_register_one(&fmt_DES);
64
	john_register_one(&fmt_DES);
62
	john_register_one(&fmt_BSDI);
65
	john_register_one(&fmt_BSDI);
63
	john_register_one(&fmt_MD5);
66
	john_register_one(&fmt_MD5);
64
	john_register_one(&fmt_BF);
67
	john_register_one(&fmt_BF);
65
	john_register_one(&fmt_AFS);
68
	john_register_one(&fmt_AFS);
66
	john_register_one(&fmt_LM);
69
	john_register_one(&fmt_LM);
70
	john_register_one(&fmt_NT);
71
	john_register_one(&fmt_MYSQL);
72
	john_register_one(&fmt_SKEY);
73
	john_register_one(&fmt_KRB4);
67
74
68
	if (!fmt_list) {
75
	if (!fmt_list) {
69
		fprintf(stderr, "Unknown ciphertext format name requested\n");
76
		fprintf(stderr, "Unknown ciphertext format name requested\n");
Lines 276-281 Link Here
276
	if (!strcmp(name, "unique"))
283
	if (!strcmp(name, "unique"))
277
		return unique(argc, argv);
284
		return unique(argc, argv);
278
285
286
	if (!strcmp(name, "undrop"))
287
		return undrop(argc, argv);
288
279
	fprintf(stderr, "Sorry, I can't find myself\n");
289
	fprintf(stderr, "Sorry, I can't find myself\n");
280
	return 1;
290
	return 1;
281
}
291
}
(-)john-1.6.orig/src/loader.c (-6 / +24 lines)
Lines 18-23 Link Here
18
#include "signals.h"
18
#include "signals.h"
19
#include "formats.h"
19
#include "formats.h"
20
#include "loader.h"
20
#include "loader.h"
21
#include "options.h"
21
22
22
/*
23
/*
23
 * Flags for read_file().
24
 * Flags for read_file().
Lines 183-189 Link Here
183
static int ldr_split_line(char **login, char **ciphertext,
184
static int ldr_split_line(char **login, char **ciphertext,
184
	char **gecos, char **home,
185
	char **gecos, char **home,
185
	char *source, struct fmt_main **format,
186
	char *source, struct fmt_main **format,
186
	struct db_options *options, char *line)
187
	struct db_options *db_options, char *line)
187
{
188
{
188
	char *uid = NULL, *gid = NULL, *shell = NULL;
189
	char *uid = NULL, *gid = NULL, *shell = NULL;
189
	char *tmp;
190
	char *tmp;
Lines 206-215 Link Here
206
		if (!strncmp(*ciphertext, "NO PASSWORD", 11))
207
		if (!strncmp(*ciphertext, "NO PASSWORD", 11))
207
			*ciphertext = "";
208
			*ciphertext = "";
208
209
210
                /* NT loader hack starts here ! */
211
 
212
                if (options.format && (strncmp(options.format, "nt", 2)==0)) {
213
 
214
                        tmp = ldr_get_field(&line);
215
                        *ciphertext = tmp;
216
 
217
                        if (!strncmp(*ciphertext, "NO PASSWORD", 11))
218
                                *ciphertext = "";
219
                        else {
220
                                *ciphertext -= 4;
221
                                strncpy(*ciphertext,"$NT$",4);
222
                        }
223
                }
224
 
225
                /* NT loader hack ends here ! */
226
209
		if (source) sprintf(source, "%s:%s", uid, line);
227
		if (source) sprintf(source, "%s:%s", uid, line);
210
	}
228
	}
211
229
212
	if (options->flags & DB_WORDS || options->shells->head) {
230
	if (db_options->flags & DB_WORDS || db_options->shells->head) {
213
		gid = ldr_get_field(&line);
231
		gid = ldr_get_field(&line);
214
		do {
232
		do {
215
			*gecos = ldr_get_field(&line);
233
			*gecos = ldr_get_field(&line);
Lines 218-230 Link Here
218
		} while (!**gecos &&
236
		} while (!**gecos &&
219
			!strcmp(*home, "0") && !strcmp(shell, "0"));
237
			!strcmp(*home, "0") && !strcmp(shell, "0"));
220
	} else
238
	} else
221
	if (options->groups->head) {
239
	if (db_options->groups->head) {
222
		gid = ldr_get_field(&line);
240
		gid = ldr_get_field(&line);
223
	}
241
	}
224
242
225
	if (ldr_check_list(options->users, *login, uid)) return 0;
243
	if (ldr_check_list(db_options->users, *login, uid)) return 0;
226
	if (ldr_check_list(options->groups, gid, gid)) return 0;
244
	if (ldr_check_list(db_options->groups, gid, gid)) return 0;
227
	if (ldr_check_shells(options->shells, shell)) return 0;
245
	if (ldr_check_shells(db_options->shells, shell)) return 0;
228
246
229
	if (*format) return (*format)->methods.valid(*ciphertext);
247
	if (*format) return (*format)->methods.valid(*ciphertext);
230
248
(-)john-1.6.orig/src/md4.c (+187 lines)
Line 0 Link Here
1
/* 
2
   Unix SMB/Netbios implementation.
3
   Version 1.9.
4
   a implementation of MD4 designed for use in the SMB authentication protocol
5
   Copyright (C) Andrew Tridgell 1997-1998.
6
   
7
   This program is free software; you can redistribute it and/or modify
8
   it under the terms of the GNU General Public License as published by
9
   the Free Software Foundation; either version 2 of the License, or
10
   (at your option) any later version.
11
   
12
   This program is distributed in the hope that it will be useful,
13
   but WITHOUT ANY WARRANTY; without even the implied warranty of
14
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
   GNU General Public License for more details.
16
   
17
   You should have received a copy of the GNU General Public License
18
   along with this program; if not, write to the Free Software
19
   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20
*/
21
22
#include <sys/types.h>
23
24
25
#ifndef uchar
26
#define uchar unsigned char
27
#endif
28
29
#if !defined(uint16) && !defined(HAVE_UINT16_FROM_RPC_RPC_H)
30
#if (SIZEOF_SHORT == 4)
31
#define uint16 __ERROR___CANNOT_DETERMINE_TYPE_FOR_INT16;
32
#else /* SIZEOF_SHORT != 4 */
33
#define uint16 unsigned short
34
#endif /* SIZEOF_SHORT != 4 */
35
#endif
36
37
#ifndef uint32
38
#define uint32 unsigned int
39
#endif
40
41
/* NOTE: This code makes no attempt to be fast! 
42
43
   It assumes that a int is at least 32 bits long
44
*/
45
46
static uint32 A, B, C, D;
47
48
static uint32 F(uint32 X, uint32 Y, uint32 Z)
49
{
50
	return (X&Y) | ((~X)&Z);
51
}
52
53
static uint32 G(uint32 X, uint32 Y, uint32 Z)
54
{
55
	return (X&Y) | (X&Z) | (Y&Z); 
56
}
57
58
static uint32 H(uint32 X, uint32 Y, uint32 Z)
59
{
60
	return X^Y^Z;
61
}
62
63
static uint32 lshift(uint32 x, int s)
64
{
65
	x &= 0xFFFFFFFF;
66
	return ((x<<s)&0xFFFFFFFF) | (x>>(32-s));
67
}
68
69
#define ROUND1(a,b,c,d,k,s) a = lshift(a + F(b,c,d) + X[k], s)
70
#define ROUND2(a,b,c,d,k,s) a = lshift(a + G(b,c,d) + X[k] + (uint32)0x5A827999,s)
71
#define ROUND3(a,b,c,d,k,s) a = lshift(a + H(b,c,d) + X[k] + (uint32)0x6ED9EBA1,s)
72
73
/* this applies md4 to 64 byte chunks */
74
static void mdfour64(uint32 *M)
75
{
76
	int j;
77
	uint32 AA, BB, CC, DD;
78
	uint32 X[16];
79
80
	for (j=0;j<16;j++)
81
		X[j] = M[j];
82
83
	AA = A; BB = B; CC = C; DD = D;
84
85
        ROUND1(A,B,C,D,  0,  3);  ROUND1(D,A,B,C,  1,  7);  
86
	ROUND1(C,D,A,B,  2, 11);  ROUND1(B,C,D,A,  3, 19);
87
        ROUND1(A,B,C,D,  4,  3);  ROUND1(D,A,B,C,  5,  7);  
88
	ROUND1(C,D,A,B,  6, 11);  ROUND1(B,C,D,A,  7, 19);
89
        ROUND1(A,B,C,D,  8,  3);  ROUND1(D,A,B,C,  9,  7);  
90
	ROUND1(C,D,A,B, 10, 11);  ROUND1(B,C,D,A, 11, 19);
91
        ROUND1(A,B,C,D, 12,  3);  ROUND1(D,A,B,C, 13,  7);  
92
	ROUND1(C,D,A,B, 14, 11);  ROUND1(B,C,D,A, 15, 19);	
93
94
        ROUND2(A,B,C,D,  0,  3);  ROUND2(D,A,B,C,  4,  5);  
95
	ROUND2(C,D,A,B,  8,  9);  ROUND2(B,C,D,A, 12, 13);
96
        ROUND2(A,B,C,D,  1,  3);  ROUND2(D,A,B,C,  5,  5);  
97
	ROUND2(C,D,A,B,  9,  9);  ROUND2(B,C,D,A, 13, 13);
98
        ROUND2(A,B,C,D,  2,  3);  ROUND2(D,A,B,C,  6,  5);  
99
	ROUND2(C,D,A,B, 10,  9);  ROUND2(B,C,D,A, 14, 13);
100
        ROUND2(A,B,C,D,  3,  3);  ROUND2(D,A,B,C,  7,  5);  
101
	ROUND2(C,D,A,B, 11,  9);  ROUND2(B,C,D,A, 15, 13);
102
103
	ROUND3(A,B,C,D,  0,  3);  ROUND3(D,A,B,C,  8,  9);  
104
	ROUND3(C,D,A,B,  4, 11);  ROUND3(B,C,D,A, 12, 15);
105
        ROUND3(A,B,C,D,  2,  3);  ROUND3(D,A,B,C, 10,  9);  
106
	ROUND3(C,D,A,B,  6, 11);  ROUND3(B,C,D,A, 14, 15);
107
        ROUND3(A,B,C,D,  1,  3);  ROUND3(D,A,B,C,  9,  9);  
108
	ROUND3(C,D,A,B,  5, 11);  ROUND3(B,C,D,A, 13, 15);
109
        ROUND3(A,B,C,D,  3,  3);  ROUND3(D,A,B,C, 11,  9);  
110
	ROUND3(C,D,A,B,  7, 11);  ROUND3(B,C,D,A, 15, 15);
111
112
	A += AA; B += BB; C += CC; D += DD;
113
	
114
	A &= 0xFFFFFFFF; B &= 0xFFFFFFFF;
115
	C &= 0xFFFFFFFF; D &= 0xFFFFFFFF;
116
117
	for (j=0;j<16;j++)
118
		X[j] = 0;
119
}
120
121
static void copy64(uint32 *M, unsigned char *in)
122
{
123
	int i;
124
125
	for (i=0;i<16;i++)
126
		M[i] = (in[i*4+3]<<24) | (in[i*4+2]<<16) |
127
			(in[i*4+1]<<8) | (in[i*4+0]<<0);
128
}
129
130
static void copy4(unsigned char *out,uint32 x)
131
{
132
	out[0] = x&0xFF;
133
	out[1] = (x>>8)&0xFF;
134
	out[2] = (x>>16)&0xFF;
135
	out[3] = (x>>24)&0xFF;
136
}
137
138
/* produce a md4 message digest from data of length n bytes */
139
void mdfour(unsigned char *out, unsigned char *in, int n)
140
{
141
	unsigned char buf[128];
142
	uint32 M[16];
143
	uint32 b = n * 8;
144
	int i;
145
146
	A = 0x67452301;
147
	B = 0xefcdab89;
148
	C = 0x98badcfe;
149
	D = 0x10325476;
150
151
	while (n > 64) {
152
		copy64(M, in);
153
		mdfour64(M);
154
		in += 64;
155
		n -= 64;
156
	}
157
158
	for (i=0;i<128;i++)
159
		buf[i] = 0;
160
	memcpy(buf, in, n);
161
	buf[n] = 0x80;
162
	
163
	if (n <= 55) {
164
		copy4(buf+56, b);
165
		copy64(M, buf);
166
		mdfour64(M);
167
	} else {
168
		copy4(buf+120, b); 
169
		copy64(M, buf);
170
		mdfour64(M);
171
		copy64(M, buf+64);
172
		mdfour64(M);
173
	}
174
175
	for (i=0;i<128;i++)
176
		buf[i] = 0;
177
	copy64(M, buf);
178
179
	copy4(out, A);
180
	copy4(out+4, B);
181
	copy4(out+8, C);
182
	copy4(out+12, D);
183
184
	A = B = C = D = 0;
185
}
186
187
(-)john-1.6.orig/src/options.c (-2 / +2 lines)
Lines 58-64 Link Here
58
	{"salts", FLG_SALTS, FLG_SALTS, FLG_PASSWD, OPT_REQ_PARAM,
58
	{"salts", FLG_SALTS, FLG_SALTS, FLG_PASSWD, OPT_REQ_PARAM,
59
		"%d", &options.loader.min_pps},
59
		"%d", &options.loader.min_pps},
60
	{"format", FLG_FORMAT, FLG_FORMAT,
60
	{"format", FLG_FORMAT, FLG_FORMAT,
61
		FLG_CRACKING_SUP,
61
		0,
62
		FLG_MAKECHARS_CHK | FLG_STDOUT | OPT_REQ_PARAM,
62
		FLG_MAKECHARS_CHK | FLG_STDOUT | OPT_REQ_PARAM,
63
		OPT_FMT_STR_ALLOC, &options.format},
63
		OPT_FMT_STR_ALLOC, &options.format},
64
	{"savemem", FLG_SAVEMEM, FLG_SAVEMEM, 0, OPT_REQ_PARAM,
64
	{"savemem", FLG_SAVEMEM, FLG_SAVEMEM, 0, OPT_REQ_PARAM,
Lines 88-94 Link Here
88
"-shells:[-]SHELL[,..]     load users with this (these) shell(s) only\n" \
88
"-shells:[-]SHELL[,..]     load users with this (these) shell(s) only\n" \
89
"-salts:[-]COUNT           load salts with at least COUNT passwords only\n" \
89
"-salts:[-]COUNT           load salts with at least COUNT passwords only\n" \
90
"-format:NAME              force ciphertext format NAME " \
90
"-format:NAME              force ciphertext format NAME " \
91
	"(DES/BSDI/MD5/BF/AFS/LM)\n" \
91
	"(DES/BSDI/MD5/BF/AFS/LM/NT/MYSQL)\n" \
92
"-savemem:LEVEL            enable memory saving, at LEVEL 1..3\n"
92
"-savemem:LEVEL            enable memory saving, at LEVEL 1..3\n"
93
93
94
void opt_init(int argc, char **argv)
94
void opt_init(int argc, char **argv)
(-)john-1.6.orig/src/params.h (-2 / +2 lines)
Lines 53-61 Link Here
53
 * File names.
53
 * File names.
54
 */
54
 */
55
#define LOG_NAME			"~/john.pot"
55
#define LOG_NAME			"~/john.pot"
56
#define CFG_NAME			"~/john.ini"
56
#define CFG_NAME			"/etc/john.ini"
57
#define RECOVERY_NAME			"~/restore"
57
#define RECOVERY_NAME			"~/restore"
58
#define WORDLIST_NAME			"~/password.lst"
58
#define WORDLIST_NAME			"/usr/share/john/password.lst"
59
59
60
/*
60
/*
61
 * Configuration file section names.
61
 * Configuration file section names.
(-)john-1.6.orig/src/smbencrypt.c (+105 lines)
Line 0 Link Here
1
/* 
2
   Unix SMB/Netbios implementation.
3
   Version 1.9.
4
   SMB parameters and setup
5
   Copyright (C) Andrew Tridgell 1992-1998
6
   Modified by Jeremy Allison 1995.
7
   
8
   This program is free software; you can redistribute it and/or modify
9
   it under the terms of the GNU General Public License as published by
10
   the Free Software Foundation; either version 2 of the License, or
11
   (at your option) any later version.
12
   
13
   This program is distributed in the hope that it will be useful,
14
   but WITHOUT ANY WARRANTY; without even the implied warranty of
15
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
   GNU General Public License for more details.
17
   
18
   You should have received a copy of the GNU General Public License
19
   along with this program; if not, write to the Free Software
20
   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21
*/
22
23
24
#include <sys/types.h>
25
26
27
#ifndef uchar
28
#define uchar unsigned char
29
#endif
30
31
#if !defined(uint16) && !defined(HAVE_UINT16_FROM_RPC_RPC_H)
32
#if (SIZEOF_SHORT == 4)
33
#define uint16 __ERROR___CANNOT_DETERMINE_TYPE_FOR_INT16;
34
#else /* SIZEOF_SHORT != 4 */
35
#define uint16 unsigned short
36
#endif /* SIZEOF_SHORT != 4 */
37
#endif
38
39
#if !defined(int16) && !defined(HAVE_INT16_FROM_RPC_RPC_H)
40
#if (SIZEOF_SHORT == 4)
41
#define int16 __ERROR___CANNOT_DETERMINE_TYPE_FOR_INT16;
42
#else /* SIZEOF_SHORT != 4 */
43
#define int16 short
44
#endif /* SIZEOF_SHORT != 4 */
45
#endif
46
47
#include "byteorder.h"
48
49
extern void mdfour(unsigned char *out, unsigned char *in, int n);
50
51
52
/* Routines for Windows NT MD4 Hash functions. */
53
static int _my_wcslen(int16 *str)
54
{
55
	int len = 0;
56
	while(*str++ != 0)
57
		len++;
58
	return len;
59
}
60
61
/*
62
 * Convert a string into an NT UNICODE string.
63
 * Note that regardless of processor type 
64
 * this must be in intel (little-endian)
65
 * format.
66
 */
67
 
68
static int _my_mbstowcs(int16 *dst, uchar *src, int len)
69
{
70
	int i;
71
	int16 val;
72
 
73
	for(i = 0; i < len; i++) {
74
		val = *src;
75
		SSVAL(dst,0,val);
76
		dst++;
77
		src++;
78
		if(val == 0)
79
			break;
80
	}
81
	return i;
82
}
83
84
/* 
85
 * Creates the MD4 Hash of the users password in NT UNICODE.
86
 */
87
 
88
void E_md4hash(uchar *passwd, uchar *p16)
89
{
90
	int len;
91
	int16 wpwd[129];
92
	
93
	/* Password cannot be longer than 128 characters */
94
	len = strlen((char *)passwd);
95
	if(len > 128)
96
		len = 128;
97
	/* Password must be converted to NT unicode */
98
	_my_mbstowcs(wpwd, passwd, len);
99
	wpwd[len] = 0; /* Ensure string is null terminated */
100
	/* Calculate length in bytes */
101
	len = _my_wcslen(wpwd) * sizeof(int16);
102
103
	mdfour(p16, (unsigned char *)wpwd, len);
104
}
105
(-)john-1.6.orig/src/tgtsnarf.c (+279 lines)
Line 0 Link Here
1
/*
2
  tgtsnarf
3
4
  Collect AFS/Kerberos TGTs for later offline dictionary attack.
5
6
  Copyright (c) 1999 Dug Song <dugsong@monkey.org>
7
  All rights reserved, all wrongs reversed.
8
9
  Redistribution and use in source and binary forms, with or without
10
  modification, are permitted provided that the following conditions
11
  are met:
12
13
  1. Redistributions of source code must retain the above copyright
14
     notice, this list of conditions and the following disclaimer.
15
  2. Redistributions in binary form must reproduce the above copyright
16
     notice, this list of conditions and the following disclaimer in the
17
     documentation and/or other materials provided with the distribution.
18
  3. The name of author may not be used to endorse or promote products
19
     derived from this software without specific prior written permission.
20
21
  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
22
  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
23
  AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
24
  THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25
  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26
  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27
  OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28
  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29
  OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
30
  ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31
*/
32
33
#include <sys/types.h>
34
#include <sys/time.h>
35
#include <sys/socket.h>
36
#include <netinet/in.h>
37
#include <arpa/inet.h>
38
#include <netdb.h>
39
#include <stdio.h>
40
#include <stdlib.h>
41
#include <unistd.h>
42
#include <string.h>
43
#include <ctype.h>
44
45
#define VERSION		"1.2"
46
#define TGT_LENGTH	16
47
48
#ifndef MIN
49
#define MIN(a,b)	(((a)<(b))?(a):(b))
50
#endif
51
52
typedef struct ktext_st {
53
  u_int length;
54
  u_char dat[1250];
55
} KTEXT_ST;
56
57
int AFS = 0;
58
59
void
60
usage(void)
61
{
62
  fprintf(stderr, "Usage: tgtsnarf [-A] realm host [users...]\n");
63
  exit(1);
64
}
65
66
u_long
67
resolve_host(char *host)
68
{
69
  u_long addr;
70
  struct hostent *hp;
71
72
  if ((addr = inet_addr(host)) == -1) {
73
    if ((hp = gethostbyname(host)) == NULL)
74
      return (-1);
75
    memcpy((char *)&addr, hp->h_addr, sizeof(addr));
76
  }
77
  return (addr);
78
}
79
80
int
81
krb_put_int(u_long from, void *to, int size)
82
{
83
  int i;
84
  u_char *p = (u_char *)to;
85
  
86
  for (i = size - 1; i >= 0; i--) {
87
    p[i] = from & 0xff;
88
    from >>= 8;
89
  }
90
  return (size);
91
}
92
93
int
94
krb_put_string(char *from, void *to)
95
{
96
  strcpy((char *)to, from);
97
  return (strlen(from) + 1);
98
}
99
100
int
101
make_req(u_char *dst, char *user, char *realm)
102
{
103
  char *pname, *pinst;
104
  struct timeval tv;
105
  u_char *p;
106
107
  if ((pname = strdup(user)) == NULL)
108
    return (-1);
109
  
110
  if ((pinst = strchr(pname, '.')) != NULL)
111
    *pinst++ = '\0';
112
  else pinst = pname + strlen(pname);
113
114
  gettimeofday(&tv, NULL);
115
116
  p = dst;
117
  p += krb_put_int(4, p, 1);			/* protocol version */
118
  p += krb_put_int((1 << 1), p, 1);		/* msg type (KDC_REQUEST) */
119
  p += krb_put_string(pname, p);		/* principal name */
120
  p += krb_put_string(pinst, p);		/* principal instance */
121
  p += krb_put_string(realm, p);		/* realm */
122
  p += krb_put_int(tv.tv_sec, p, 4);		/* time */
123
  p += krb_put_int(120, p, 1);			/* lifetime (120) */
124
  p += krb_put_string("krbtgt", p);		/* service name (krbtgt)*/
125
  p += krb_put_string(realm, p);		/* service instance (realm) */
126
127
  free(pname);
128
  
129
  return (p - dst);
130
}
131
132
int
133
find_tkt(KTEXT_ST *ktext, u_char *dst, int size)
134
{
135
  u_char *p;
136
  int type, len;
137
  
138
  p = ktext->dat;
139
  p += 1;			/* version */
140
  type = *p++;
141
  type &= ~1;			/* msg type */
142
143
  if (type != (2 << 1))		/* KDC_REPLY */
144
    return (-1);
145
146
  p += strlen((char*)p) + 1;	/* name */
147
  p += strlen((char*)p) + 1;	/* instance */
148
  p += strlen((char*)p) + 1;	/* realm */
149
  p += 4;			/* time */
150
  p += 1;			/* # tickets */
151
  p += 4;			/* exp date */
152
  p += 1;			/* master kvno */
153
  p += 2;			/* length */
154
155
  len = MIN(ktext->length - (p - ktext->dat), size);
156
  memcpy(dst, p, len);
157
  
158
  return (len);
159
}
160
161
int
162
fetch_tgt(char *host, char *user, char *realm, u_char *dst, int size)
163
{
164
  struct sockaddr_in from, to;
165
  KTEXT_ST ktext;
166
  int sock, alen;
167
168
  /* Fill in dest addr. */
169
  memset(&to, 0, sizeof(to));
170
  if ((to.sin_addr.s_addr = resolve_host(host)) == -1) {
171
    fprintf(stderr, "bad host: %s\n", host);
172
    return (-1);
173
  }
174
  to.sin_family = AF_INET;
175
  to.sin_port = htons(750);
176
  
177
  /* Fill in our TGT request. */
178
  ktext.length = make_req(ktext.dat, user, realm);
179
180
  /* Send it to KDC. */
181
  if ((sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0) {
182
    perror("socket");
183
    return (-1);
184
  }
185
  alen = sizeof(to);
186
  if (sendto(sock, ktext.dat, ktext.length, 0, (struct sockaddr *)&to, alen)
187
      < 0) {
188
    perror("send");
189
    close(sock);
190
    return (-1);
191
  }
192
  /* Read reply. */
193
  if ((ktext.length = recvfrom(sock, ktext.dat, sizeof(ktext.dat), 0,
194
			       (struct sockaddr *)&from, &alen)) <= 0) {
195
    perror("recv");
196
    close(sock);
197
    return (-1);
198
  }
199
  close(sock);
200
201
  /* Extract TGT. */
202
  return (find_tkt(&ktext, dst, size));
203
}
204
205
void
206
print_tgt(char *host, char *user, char *realm)
207
{
208
  u_char tgt[TGT_LENGTH];
209
  int i, len;
210
211
  if ((len = fetch_tgt(host, user, realm, tgt, sizeof(tgt))) == -1) {
212
    fprintf(stderr, "==> couldn't get tgt for %s@%s\n", user, realm);
213
  }
214
  else {
215
    printf("%s:$%s$%s$", user, AFS ? "af" : "k4", realm);
216
    
217
    for (i = 0; i < len; i++)
218
      printf("%.2x", tgt[i]);
219
    
220
    printf("\n");
221
  }
222
}
223
224
char *
225
upcase(char *string)
226
{
227
  char *p;
228
229
  for (p = string; *p != '\0'; p++)
230
    *p = toupper(*p);
231
232
  return (string);
233
}
234
235
int
236
main(int argc, char *argv[])
237
{
238
  char c, *p, *host, *realm, user[128];
239
  int i;
240
241
  host = realm = NULL;
242
  
243
  while ((c = getopt(argc, argv, "h?AV")) != EOF) {
244
    switch (c) {
245
    case 'A':
246
      AFS = 1;
247
      break;
248
    case 'V':
249
      fprintf(stderr, "Version: %s\n", VERSION);
250
      usage();
251
      break;
252
    default:
253
      usage();
254
    }
255
  }
256
  argc -= optind;
257
  argv += optind;
258
259
  if (argc < 2)
260
    usage();
261
262
  realm = upcase(argv[0]);
263
  host = argv[1];
264
265
  if (argc == 2) {
266
    while (fgets(user, sizeof(user), stdin) != NULL) {
267
      if ((p = strrchr(user, '\n')) != NULL)
268
	*p = '\0';
269
      print_tgt(host, user, realm);
270
    }
271
  }
272
  else {
273
    for (i = 2; i < argc; i++)
274
      print_tgt(host, argv[i], realm);
275
  }
276
  exit(0);
277
}
278
279
/* 5000 */
(-)john-1.6.orig/src/undrop.c (+110 lines)
Line 0 Link Here
1
/*	
2
 * Eggdrop userfile converter
3
 * Copyright (c) 2002 by Sun-Zero <sun-zero@freemail.hu>
4
 * This is a free software distributable under terms of the GNU GPL. 
5
 * See the file COPYING for details. 
6
 *
7
 * 2002-04-06
8
*/
9
10
#include <stdio.h>
11
#include <string.h>
12
#include <unistd.h>
13
14
15
#define USERFILE_HEADER "#4v:"
16
#define USERNAME_LENGTH 11
17
#define PASSWORD_LENGTH 13
18
#define MAX_FLAGS_LENGTH 32
19
#define BUFSIZE 512
20
21
int readline( FILE *fd, char *rbuf ) {
22
	char c;
23
	int p = 0, rval;
24
25
	do
26
	{
27
		rval = fread(&c, 1, 1, fd);
28
		rbuf[p++] = c;
29
	}while( c != EOF && c != '\n' && p + 1 < BUFSIZE && rval == 1 &&
30
		!feof(fd) && !ferror(fd)
31
	);
32
33
	rbuf[p] = '\0';
34
	if( rval != 1 )
35
	{ 
36
		p--;
37
		rbuf[p] = '\0';
38
		return( rval );
39
	}
40
41
	return( p );
42
}
43
44
45
int undrop(int argc, char *argv[]) {
46
47
    FILE *userfile;
48
    char username[USERNAME_LENGTH];
49
    char password[PASSWORD_LENGTH];
50
    char flags[MAX_FLAGS_LENGTH];
51
    char t_username[512];
52
    char t_flags[512];
53
    char t_line[BUFSIZE];
54
    int t_lines;
55
56
    char temp_char;
57
    if (argc != 2) {
58
	userfile = stdin;
59
	printf("# userfile reading from stdin\n");
60
    } else {
61
        userfile = fopen(argv[1], "r");
62
        if (userfile == NULL) {
63
    	        fprintf(stderr, "opening userfile\n");
64
	        userfile = stdin;
65
        }
66
    }
67
    
68
    
69
    memset(&t_line, 0, sizeof(t_line));
70
    t_lines = readline(userfile, t_line);
71
    if (strncmp(t_line, USERFILE_HEADER, strlen(USERFILE_HEADER)) != 0) { 
72
	fprintf(stderr, "usefile format is wrong\n"); 
73
	return -1;
74
    } else {
75
	printf("# userfile format OK\n\n");
76
    }
77
    
78
    while (t_lines != 0) {
79
	memset(&t_username, 0, sizeof(t_username));
80
	memset(&t_flags, 0, sizeof(t_flags));
81
	memset(&t_line, 0, sizeof(t_line));
82
83
	t_lines = readline(userfile, t_line);
84
85
	temp_char = sscanf(t_line, "%10s - %24s\n", t_username, t_flags);
86
87
	if (temp_char == 2) {
88
	    if (strncmp(t_username, "! ", 2) != 0 &&
89
		strncmp(t_username, "--", 2) != 0 &&
90
		strncmp(t_username, "&&", 2) != 0 &&
91
		strncmp(t_username, "::", 2) != 0 &&
92
		strncmp(t_username, "$$", 2) != 0
93
	    ) {
94
		strncpy(username, t_username, USERNAME_LENGTH);
95
	        strncpy(flags, t_flags, MAX_FLAGS_LENGTH);
96
	    }
97
	}
98
	if (strncmp(t_line, "--PASS +", 8) == 0) {
99
	    sscanf(t_line, "--PASS %s", password);
100
	    printf("%s:%s:::%s:\n", username, password, flags);
101
102
	    memset(&username, 0, sizeof(username));
103
	    memset(&flags, 0, sizeof(flags));
104
	    memset(&password, 0, sizeof(password));
105
	}
106
	fflush(stdout);
107
    }
108
    fclose(userfile);
109
    return 0;
110
}

Return to bug 51442