AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

MD5 + Salt (Shadow-File) aus Windows

Ein Thema von aayb · begonnen am 9. Jan 2008 · letzter Beitrag vom 17. Jan 2008
Antwort Antwort
gammatester

Registriert seit: 6. Dez 2005
999 Beiträge
 
#1

Re: MD5 + Salt (Shadow-File) aus Windows

  Alt 11. Jan 2008, 12:37
Zitat von aayb:
Hi Gammatester,

okay - ich hatte mir schon fast gedacht, das es so "einfach" nicht realisierbar ist.

Nur durch die Suche und den staendig auftretenden Antworten zum Thema Hash/Crypt a la "Aber vergiss nicht, spaeter
noch ein Salt zu verwenden" wurde ich wieder ein stueck optimistischer.

Muss mir dann wohl eine alternative Moeglichkeit suchen, den Hash inkl. Salt zu generieren (Oder mich noch tiefer einlesen).

Besten Dank fuer deine Muehe && Hilfe.

Gr.
Thomas
Hier ist ein Code, der zumindest Dein Beispielshadow erzeugt. Units gibts auf http://home.netsurf.de/wolfgang.ehrh...rchash_de.html
bzw. im zip

Ausgabe ist:

Test:"L8QJdkpAkAe6/ucGxAbBq."
Calc:"L8QJdkpAkAe6/ucGxAbBq."

Schönes Wochenende
Gammatester


Delphi-Quellcode:
program t_shad;

{$ifdef win32}
  {$apptype console}
{$endif}
uses
  mem_util, hash, md5;

{
Als Beispiel aus der /etc/shadow (Passwort ist 'password'):
$1$7fX5iR5l$L8QJdkpAkAe6/ucGxAbBq.
}




function to64(l: longint; n: integer): string;
const
  a64: array[0..63] of char = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
var
  s: string;
begin
  s := '';
  while n>0 do begin
    s := s+a64[l and $3f];
    l := l shr 6;
    dec(n);
  end;
  to64 := s;
end;


procedure md5crypt(const salt, pw: string; var shad: string);
const
  magic: array[0..2] of char = '$1$';
var
  ctx,ctx1: THashContext;
  final: TMD5Digest;
  i: integer;
  l: longint;
begin
  MD5Init(ctx);
  MD5Update(ctx, @pw[1], length(pw));
  MD5Update(ctx, @magic, 3);
  MD5Update(ctx, @salt[1], length(salt));

  MD5Init(ctx1);
  MD5Update(ctx1, @pw[1], length(pw));
  MD5Update(ctx1, @salt[1], length(salt));
  MD5Update(ctx1, @pw[1], length(pw));
  MD5Final(ctx1, final);
  i := length(pw);
  while i>0 do begin
    if i>16 then MD5Update(ctx, @final, 16)
    else MD5Update(ctx, @final, i);
    dec(i,16);
  end;
  fillchar(final,sizeof(final),0);
  i := length(pw);
  while i<>0 do begin
    if odd(i) then MD5Update(ctx, @final, 1)
    else MD5Update(ctx, @pw[1], 1);
    i := i shr 1;
  end;
  MD5Final(ctx, final);
  for i:=0 to 999 do begin
    MD5Init(ctx1);
    if (i and 1) <>0 then MD5Update(ctx1, @pw[1], length(pw))
    else MD5Update(ctx1, @final, 16);
    if i mod 3 <> 0 then MD5Update(ctx1, @salt[1], length(salt));
    if i mod 7 <> 0 then MD5Update(ctx1, @pw[1], length(pw));
    if (i and 1) <>0 then MD5Update(ctx1, @final, 16)
    else MD5Update(ctx1, @pw[1], length(pw));
    MD5Final(ctx1, final);
  end;
  shad := '';
  l := (longint(final[ 0]) shl 16) or (longint(final[ 6]) shl 8) or final[12]; shad := shad + to64(l,4);
  l := (longint(final[ 1]) shl 16) or (longint(final[ 7]) shl 8) or final[13]; shad := shad + to64(l,4);
  l := (longint(final[ 2]) shl 16) or (longint(final[ 8]) shl 8) or final[14]; shad := shad + to64(l,4);
  l := (longint(final[ 3]) shl 16) or (longint(final[ 9]) shl 8) or final[15]; shad := shad + to64(l,4);
  l := (longint(final[ 4]) shl 16) or (longint(final[10]) shl 8) or final[ 5]; shad := shad + to64(l,4);
  l := final[11]; shad := shad + to64(l,2);
end;

var
  shadow: string;
begin
  md5crypt('7fX5iR5l', 'password', shadow);
  writeln('Test:"L8QJdkpAkAe6/ucGxAbBq."');
  writeln('Calc:"',shadow,'"');
end.
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 18:08 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz