[<prev] [next>] [day] [month] [year] [list]
Date: Mon, 2 Aug 2010 02:21:49 +0400
From: Solar Designer <solar@...nwall.com>
To: john-users@...ts.openwall.com
Subject: KnownForce to try dates and times
Hi,
Attached is a variation of KnownForce configured to try likely date and
time strings. Note that this is configurable for lengths 4, 5, 7, and 8
(it is set to 8 by default).
Also note that only a portion of init() is different from the KnownForce
sample in john.conf supplied with JtR; generate() and restore() have
remained exactly the same. I am pointing this out as it might help you
learn how to customize KnownForce for your needs.
This did not help in the contest (which only used dates with month names
in them, not numeric dates), yet it is more successful on real-world
passwords (and that's what we should really care about, right?) and it
is a good example of modifying KnownForce.
Enjoy.
Alexander
# A variation of KnownForce configured to try likely date and time strings.
[List.External:DateTime]
int last; // Last character position, zero-based
int lastofs; // Last character position offset into charset[]
int lastid; // Current character index in the last position
int id[0x7f]; // Current character indices for other positions
int charset[0x7f00]; // Character sets, 0x100 elements for each position
void init()
{
int length;
int pos, ofs, i, c;
length = 8; // Must be one of: 4, 5, 7, 8
/* This defines the character sets for different character positions */
pos = 0;
while (pos < length - 6) {
ofs = pos++ << 8;
i = 0;
c = '0';
while (c <= '9')
charset[ofs + i++] = c++;
charset[ofs + i] = 0;
}
if (pos) {
ofs = pos++ << 8;
charset[ofs] = '/';
charset[ofs + 1] = '.';
charset[ofs + 2] = ':';
charset[ofs + 3] = 0;
}
while (pos < length - 3) {
ofs = pos++ << 8;
i = 0;
c = '0';
while (c <= '9')
charset[ofs + i++] = c++;
charset[ofs + i] = 0;
}
ofs = pos++ << 8;
charset[ofs] = '/';
charset[ofs + 1] = '.';
charset[ofs + 2] = ':';
charset[ofs + 3] = 0;
while (pos < length) {
ofs = pos++ << 8;
i = 0;
c = '0';
while (c <= '9')
charset[ofs + i++] = c++;
charset[ofs + i] = 0;
}
last = length - 1;
pos = -1;
while (++pos <= last)
word[pos] = charset[id[pos] = pos << 8];
lastid = (lastofs = last << 8) - 1;
word[pos] = 0;
}
void generate()
{
int pos;
/* Handle the typical case specially */
if (word[last] = charset[++lastid]) return;
word[pos = last] = charset[lastid = lastofs];
while (pos--) { // Have a preceding position?
if (word[pos] = charset[++id[pos]]) return;
word[pos] = charset[id[pos] = pos << 8];
}
word = 0; // We're done
}
void restore()
{
int i, c;
/* Calculate the current length and infer the character indices */
last = 0;
while (c = word[last]) {
i = lastofs = last << 8;
while (charset[i] != c && charset[i]) i++;
if (!charset[i]) i = lastofs; // Not found
id[last++] = i;
}
lastid = id[--last];
}
Powered by blists - more mailing lists
Powered by Openwall GNU/*/Linux -
Powered by OpenVZ