Use John to hack ubuntu 9.10 password

Source: Internet
Author: User
Tags crypt

Title: Using John to hack Ubuntu (Linux) 9.10 password--2011-11-23 15:00

Ubuntu 9.10 Account password encryption method instead of SHA512, the default John is not broken, fortunately, the official patch.

First extract the source code of john1.75, vi edit the makefile file, add the red font I marked below

Ldflags =-s-lcrypt
John_objs_minimal = \
DES_FMT.O DES_STD.O des_bs.o \
BSDI_FMT.O \
MD5_FMT.O MD5_STD.O \
BF_FMT.O BF_STD.O \
AFS_FMT.O \
LM_FMT.O \
BATCH.O bench.o charset.o common.o compiler.o config.o cracker.o \
CRC32.O EXTERNAL.O formats.o getopt.o idle.o inc.o john.o list.o \
LOADER.O logger.o math.o memory.o misc.o options.o params.o path.o \
RECOVERY.O rpp.o rules.o signals.o single.o status.o tty.o wordlist.o \
UNSHADOW.O \
UNAFS.O \
UNIQUE.O \
Crypt_fmt.o

Then create a new crypt_fmt.c file with the following code */* Public domain proof-of-concept code by Solar Designer */

#define _XOPEN_SOURCE/* for crypt (3) */
#include <string.h>
#include <unistd.h>

#include "arch.h"
#include "Params.h"
#include "Formats.h"

#define Format_label "Crypt"
#define FORMAT_NAME "Generic Crypt (3)"
#define ALGORITHM_NAME "?/" Arch_bits_str

#define Benchmark_comment ""
#define BENCHMARK_LENGTH 0

#define PLAINTEXT_LENGTH 72

#define BINARY_SIZE 128
#define Salt_size Binary_size

#define MIN_KEYS_PER_CRYPT 1
#define MAX_KEYS_PER_CRYPT 1

static struct fmt_tests tests[] = {
{"Ccnf8sbh3hdfq", "u*u*u*u*"},
{"CCX. K.mfy4ois "," U*u***u "},
{"Cc4rmpbg9amz.", "u*u***u*"},
{"Xxxzou6maqkqq", "*u*u*u*u"},
{"sdbsugebic58a", ""},
{NULL}
};

static char Saved_key[plaintext_length + 1];
static Char saved_salt[salt_size];
static char *crypt_out;

static int valid (char *ciphertext)
{
#if 1
int L = strlen (ciphertext);
return l >= && l < binary_size;
#else
/* Poor load time, but more effective at rejecting bad/unsupported hashes */
Char *r = Crypt ("", ciphertext);
int L = strlen (R);
Return
!STRNCMP (R, ciphertext, 2) &&
L = = strlen (ciphertext) &&
L >= && L < binary_size;
#endif
}

static void *binary (char *ciphertext)
{
static Char out[binary_size];
strncpy (out, ciphertext, sizeof); /* NUL padding is required */
return out;
}

static void *salt (char *ciphertext)
{
static Char out[salt_size];
int cut = sizeof (out);

#if 1
/* This piece was optional, but matching salts was not detected without it * *
Switch (strlen (ciphertext)) {
Case 13:
Case 24:
Cut = 2;
Break

Case 20:
if (ciphertext[0] = = ' _ ') cut = 9;
Break

Case 34:
if (!strncmp (ciphertext, "$1$", 3)) {
Char *p = STRCHR (ciphertext + 3, ' $ ');
if (p) cut = P-ciphertext;
}
Break

Case 59:
if (!strncmp (ciphertext, "$2$", 3)) cut = 28;
Break

Case 60:
if (!strncmp (ciphertext, "$2a$", 4)) cut = 29;
Break
}
#endif

/* NUL padding is required */
memset (out, 0, sizeof (out));
memcpy (out, ciphertext, cut);

return out;
}

static int binary_hash_0 (void *binary)
{
Return ((unsigned char *) binary) [n] & 0xF;
}

static int binary_hash_1 (void *binary)
{
Return ((unsigned char *) binary) [n] & 0xFF;
}

static int binary_hash_2 (void *binary)
{
Return
(((unsigned char *) binary) [& 0xFF] |
((int) (((unsigned char *) binary) [one] & 0xF) << 8);
}

static int get_hash_0 (int index)
{
return (unsigned char) crypt_out[12] & 0xF;
}

static int get_hash_1 (int index)
{
return (unsigned char) crypt_out[12] & 0xFF;
}

static int get_hash_2 (int index)
{
Return
((unsigned char) crypt_out[12] & 0xFF) |
((int) ((unsigned char) crypt_out[11] & 0xF) << 8);
}

static int salt_hash (void *salt)
{
int pos = strlen ((char *) salt)-2;

Return
(((unsigned char *) salt) [POS] & 0xFF) |
((int) (((unsigned char *) salt) [pos + 1] & 3) << 8);
}

static void Set_salt (void *salt)
{
strcpy (Saved_salt, salt);
}

static void Set_key (char *key, int index)
{
strcpy (Saved_key, key);
}

static char *get_key (int index)
{
return saved_key;
}

static void Crypt_all (int count)
{
Crypt_out = Crypt (Saved_key, Saved_salt);
}

static int Cmp_all (void *binary, int count)
{
Return!strcmp ((char *) binary, crypt_out);
}

static int cmp_exact (char *source, int index)
{
return 1;
}

struct Fmt_main Fmt_crypt = {
{
Format_label,
Format_name,
Algorithm_name,
Benchmark_comment,
Benchmark_length,
Plaintext_length,
Binary_size,
Salt_size,
Min_keys_per_crypt,
Max_keys_per_crypt,
Fmt_case | Fmt_8_bit,
Tests
}, {
Fmt_default_init,
Valid
Fmt_default_split,
Binary
Salt
{
Binary_hash_0,
Binary_hash_1,
Binary_hash_2
},
Salt_hash,
Set_salt,
Set_key,
Get_key,
Fmt_default_clear_keys,
Crypt_all,
{
Get_hash_0,
Get_hash_1,
Get_hash_2
},
Cmp_all,
Cmp_all,
Cmp_exact
}
};
Finally, modify the John.c file to add the red font I marked below
extern struct Fmt_main fmt_des, FMT_BSDI, Fmt_md5, FMT_BF;
extern struct Fmt_main fmt_afs, fmt_lm;
extern struct Fmt_main fmt_crypt;

John_register_one (&fmt_des);
John_register_one (&AMP;FMT_BSDI);
John_register_one (&AMP;FMT_MD5);
John_register_one (&AMP;FMT_BF);
John_register_one (&AMP;FMT_AFS);
John_register_one (&AMP;FMT_LM);
John_register_one (&fmt_crypt);

Now can compile, choose your platform and CPU type, can improve the speed of cracking, I use the linux,x86 architecture, so the choice is
Linux-x86-sse2 Linux, x86 with SSE2 (best if 32-bit)
If you're like me, enter the following red font
Make Linux-x86-sse2

Now, in practice, you can find the ability to crack


From China Yunan Net (www.yunsec.net) Original: http://www.yunsec.net/a/security/web/invasion/2010/0411/3284.html

Use John to hack ubuntu 9.10 password

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.