Autor Beitrag
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8535
Erhaltene Danke: 473

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Sa 16.12.06 11:45 
Das Geburtstagsrätsel. Die Auflösung

Toni muss 20 Kerzen auf den Kuchen packen.

Lösungsanleitung. Was man wissen muss, und was spätestens aus dem letzten Tip hervorgegangen sein sollte, ist, dass Passwörter recht häufig nur als MD5-Hash gespeichert werden.
Aus einem MD5-Hash kann man allerdings nicht das Passwort zurückrechnen. Hier hilft einzig und allein ein durchprobieren aller Möglichkeiten. D.h. Passwort aussuchen, MD5-Hash berechnen, vergleichen mit dem Hashwert aus dem Rätsel und bei Bedarf mit dem nächsten Passwort weitermachen.

Vom Prinzip her einfach, und es gibt nur ein paar Kleinigkeiten, die man umschiffen muss:
  • Man muss die Funktion finden, die aus einem MD5-Hash, der ja eigentlich erstmal ein Array of Byte ist, einen String in dieser Form baut. Bei der einen Unit, die ich hier im Forum gefunden habe, ist es MD5DigestToStr, bei der, die gestern noch in einem Topic besprochen wurde, ist es MD5Print.
  • Eine Unit gibt den String mit Großbuchstaben aus, die andere mit Kleinbuchstaben. vor einem Vergleich mit dem Rätselhash muss das ggf. angepasst werden.
  • Man muss das richtige Datumsformat erraten. Da es hier nicht soviele Möglichkeiten gibt, ist das nicht so fies. Das richtige Format ist "TT.MM.JJJJ". Bei kleinen Tagen/Monaten muss man also ggf. eine führende Null einführen. Das ist mit Format kein Problem, ansonsten schreibt man eine kleine Funktion IntTo2Str.

Ein Durchlauf mit dem richtigen Datumsformat liefert dann einen Treffer bei "24.01.1987". Der nächste Geburtstag ist also am 24.01.2007, und da Geburtstagskind wird dann 20.

Im Anhang ist ein kleines Lösungprogramm, was Hashwerte berechnen kann und einen Geburtstagshash in verschiedenen Formaten knacken kann. Auch auf langsameren Rechnern ist das eine Sache von wenigen Sekunden.
Einloggen, um Attachments anzusehen!
_________________
We are, we were and will not be.
GTA-Place
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
EE-Regisseur
Beiträge: 5248
Erhaltene Danke: 2

WIN XP, IE 7, FF 2.0
Delphi 7, Lazarus
BeitragVerfasst: Sa 16.12.06 11:51 
Simple Methode, wenn man das Format raus hat:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
var
  aDay, aMonth, aYear: Integer;
  Temp: String;
const
  Hash = '21D0E9077B6CF51BC68C2D79DB8D8078';
begin
  for aYear := 1930 to 1996 do
    for aMonth := 1 to 12 do
      for aDay := 1 to 31 do
      begin
        Temp := Format('%.2d.%.2d.%d', [aDay, aMonth, aYear]);

        if MD5Print(MD5String(Temp)) = AnsiLowerCase(Hash) then
          ShowMessage('Sie ist am ' + Temp + ' geboren');
      end;
end;

Die ist etwas sauberer als deine ;-) Man könnte natürlich hier auch noch die Checkbox-Möglichkeit einbauen.

_________________
"Wer Ego-Shooter Killerspiele nennt, muss konsequenterweise jeden Horrorstreifen als Killerfilm bezeichnen." (Zeit.de)
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Sa 16.12.06 12:08 
Hier gibt's noch die C#-Lösung :-)
Einloggen, um Attachments anzusehen!
_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
evilsoft.de
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 39

XP
Delphi 7
BeitragVerfasst: Sa 16.12.06 12:17 
Hier mal mein Lösungsweg!
ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
program WGtwo;

{$APPTYPE CONSOLE}

uses
  SysUtils,
  md5;

{
  :: Delphi-Forum.de Adventsgewinnspiel 2006 2. Woche
  :: Lösung von EvilSoft.de

  Die Zahlen und Buchstaben sind nichts anderes wie ein "Hash"!
  Da das Delphi-Forum auf dem phpBB-Board basiert,
  und eh' die meisten dieser Scripte die selbe
  Methode benutzen, kommt man leicht darauf das,
  es ein MD5 Hash ist!
  Ich habe es so gelöst, das ich jede Datum-Kombination (Standart-Format (xx.xx.19xx)),
  generiert habe, und es in Hash Form mit dem MD5-Hash aus dem Delphi-Forum
  verglichen habe!
}


function CrackMD5(hash:String):String;
var
  tag, monat, jahr: Integer;
  stag, smonat, sjahr, temp: String;
begin
  Result := 'Nicht gefunden!';
  for jahr := 1927 to 1997 do
  begin
    sjahr := IntToStr(jahr);
    for monat := 1 to 12 do
    begin
      smonat := IntToStr(monat);
      if length(smonat) = 1 then
        smonat := '0'+smonat;
      for tag := 1 to 31 do
      begin
        stag := IntToStr(tag);
        if length(stag) = 1 then
          stag := '0'+stag;
        temp := stag+'.'+smonat+'.'+sjahr;
        if UpperCase(MD5Print(MD5String(temp))) = hash then
        begin
          Result := temp;
          exit;
        end;
      end;
    end;
  end;
end;

begin
  WriteLN('Geburtsdatum: '+CrackMD5('21D0E9077B6CF51BC68C2D79DB8D8078'));
  ReadLN;
end.


wobei es noch ein Format gibt was hier nicht diskutiert wurde (bzw 2).
1: zB das Datum 22.12.1986 (mein geburtstag) als passwort -> 221286 bzw 22121986 (also ohne Punkte)
coder62
Hält's aus hier
Beiträge: 29



BeitragVerfasst: Sa 16.12.06 12:30 
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
<?php
$find = '21d0e9077b6cf51bc68c2d79db8d8078';
for($i=1;$i<=31;$i++){
  for($i2=1;$i2<=12;$i2++){
    for($i3=1916;$i3<=2006;$i3++){
      $datum = date('d.m.Y',mktime(0, 0, 0, $i2, $i, $i3));
      $mdhash = md5($datum);
      if($find == $mdhash){
        echo $find.''.$mdhash.''.$datum;
        die;
      }
    }
  }
}
?>


wie immer in php gelöst
Jailbird
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 127

Windows XP Pro SP2
Delphi 7 Professional
BeitragVerfasst: Sa 16.12.06 12:45 
user profile iconcoder62 hat folgendes geschrieben:
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
<?php
$find = '21d0e9077b6cf51bc68c2d79db8d8078';
for($i=1;$i<=31;$i++){
  for($i2=1;$i2<=12;$i2++){
    for($i3=1916;$i3<=2006;$i3++){
      $datum = date('d.m.Y',mktime(0, 0, 0, $i2, $i, $i3));
      $mdhash = md5($datum);
      if($find == $mdhash){
        echo $find.''.$mdhash.''.$datum;
        die;
      }
    }
  }
}
?>


wie immer in php gelöst


Du hast damit aber ziemlich Glück gehabt. mktime funktioniert nämlich bezüglich dem 1.1.1970 in positiver Richtung. Wäre die junge Dame also älter als 37, dann hättest du nix gefunden. Dies als kleiner Nachtrag

_________________
Jailbird
F34r0fTh3D4rk
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 5284
Erhaltene Danke: 27

Win Vista (32), Win 7 (64)
Eclipse, SciTE, Lazarus
BeitragVerfasst: Sa 16.12.06 12:57 
mein sieht so aus:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
procedure TForm1.Button1Click(Sender: TObject);
  function inttostrN(a, count: integer): string;
  begin
    result := inttostr(a);
    while length(result) < count do
      result := '0' + result;
  end;
const
  hash = '21D0E9077B6CF51BC68C2D79DB8D8078';
var
  d, m, y: integer;
begin
  for y := 2000 downto 1900 do
    for m := 12 downto 1 do
      for d := 31 downto 1 do
        if uppercase(MD5Print(MD5String(inttostrN(d, 2) + '.' + inttostrN(m, 2) + '.' + inttostrN(y, 4)))) = hash then
        begin
          edit2.text := inttostrN(d, 2) + '.' + inttostrN(m, 2) + '.' + inttostrN(y, 4);
          exit;
        end;
end;


ich dachte zuerst auch an das format DDMMYYYY, aber dafür wäre der hash kürzer gewesen.

mfg
Heiko
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 3169
Erhaltene Danke: 11



BeitragVerfasst: Sa 16.12.06 13:01 
Meine PHP-Version:

ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
<?php
  $cmp = strtolower("21D0E9077B6CF51BC68C2D79DB8D8078");
  for ($y = 1920; $y<=1997; $y++){
    for ($m = 1; $m<=12; $m++){
      if ($m<10) $mstr =".0".$m.".".$y;
      else $mstr =".".$m.".".$y;
      for ($d = 1; $d<=31; $d++){
        if ($d<10) $str ="0".$d.$mstr;
        else $str =$d.$mstr;
        if (md5($str) == $cmp) {
          echo $str;
        }
      }
    }
  }
?>
GTA-Place
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
EE-Regisseur
Beiträge: 5248
Erhaltene Danke: 2

WIN XP, IE 7, FF 2.0
Delphi 7, Lazarus
BeitragVerfasst: Sa 16.12.06 13:14 
user profile iconF34r0fTh3D4rk hat folgendes geschrieben:
ich dachte zuerst auch an das format DDMMYYYY, aber dafür wäre der hash kürzer gewesen.

mfg

Ein Hash ist immer gleich lang ;-).

_________________
"Wer Ego-Shooter Killerspiele nennt, muss konsequenterweise jeden Horrorstreifen als Killerfilm bezeichnen." (Zeit.de)
Marco D.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: Sa 16.12.06 13:20 
Bei mir hat das ganze so geklappt:
ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
var
  Form1: TForm1;
  datum, hash: string;
  day, month, year: integer;

implementation

{$R *.dfm}

function MakeHash: string;
begin
   result := md5print(md5string(datum));
end;

//generiert das Datum aus day, month und year
function GenerateDate: string;
begin
  result := '';

  //Tag
  if (Day > 9then
    result := result + inttostr(Day)
  else
    result := result + '0' + inttostr(Day);

  //Punkt zwischen Tag und Monat
  result := result + '.';



  //Monat
  if (Month > 9then
    result := result + inttostr(Month)
  else
    result := result + '0' + inttostr(Month);

  //Punkt zwischen Monat und Jahr

  result := result + '.';

  //Jahr
  result := result + inttostr(Year);
end;

//erhöht day, month und year
procedure NextDay;
begin
  if (Day < 31then
  begin
    inc(Day);
  end
  else begin
    day := 1;
    if (Month < 12then
    begin
      inc(Month);
    end
    else begin
      Month := 1;
      inc(Year);
    end;
  end;
end;


function IsCorrectDate: boolean;
begin
  if (UpperCase(Hash) = '21D0E9077B6CF51BC68C2D79DB8D8078'then
    result := true
  else
    result := false;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
Day := 1;
Month := 1;
Year := 1920;
Hash := '';
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  repeat
    NextDay;
    Datum := GenerateDate;
    Memo1.Lines.Add('Datum: '+Datum);
    Hash := MakeHash;
    Memo1.Lines.Add('Hash: '+Hash);
    Memo1.Lines.Add('');
  until IsCorrectDate;

end;

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
F34r0fTh3D4rk
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 5284
Erhaltene Danke: 27

Win Vista (32), Win 7 (64)
Eclipse, SciTE, Lazarus
BeitragVerfasst: Sa 16.12.06 13:22 
user profile iconGTA-Place hat folgendes geschrieben:
user profile iconF34r0fTh3D4rk hat folgendes geschrieben:
ich dachte zuerst auch an das format DDMMYYYY, aber dafür wäre der hash kürzer gewesen.

mfg

Ein Hash ist immer gleich lang ;-).


jeder md5 hash ist 32 zeichen lang ?
Marco D.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: Sa 16.12.06 13:30 
user profile iconF34r0fTh3D4rk hat folgendes geschrieben:

jeder md5 hash ist 32 zeichen lang ?

Ja, ist er.
Aber wie geht das denn, wenn das denn?
Wikipedia:
Zitat:

MD5 (Message Digest Algorithm 5) ist eine weitverbreitete kryptographische Hash-Funktion, die einen 128-Bit-Hashwert erzeugt.

IMHO hat ein Zeichen 8 Bit. Dann wären es aber nur 16 Zeichen. :gruebel:

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
Christian S.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 20451
Erhaltene Danke: 2264

Win 10
C# (VS 2019)
BeitragVerfasst: Sa 16.12.06 13:33 
Was ihr oben seht, ist ja nur die Stringdarstellung in Hex-Zahlen.

21-D0-E9-07-7B-6C-F5-1B-C6-8C-2D-79-DB-8D-80-78

Das sind die 16 Byte bzw. 128 Bit.

_________________
Zwei Worte werden Dir im Leben viele Türen öffnen - "ziehen" und "drücken".
jakobwenzel
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1889
Erhaltene Danke: 1

XP home, ubuntu
BDS 2006 Prof
BeitragVerfasst: Sa 16.12.06 13:33 
Die Hash-Werte werden als Hex-Zahlen angezeigt. Und da entspricht 1 Zeichen 4 Bit.

Und 128 / 4 ist 32 :shock: :wink:

_________________
I thought what I'd do was, I'd pretend I was one of those deaf-mutes.
GTA-Place
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
EE-Regisseur
Beiträge: 5248
Erhaltene Danke: 2

WIN XP, IE 7, FF 2.0
Delphi 7, Lazarus
BeitragVerfasst: Sa 16.12.06 13:35 
@Marco D.: Schöner kurzer Source :mrgreen:.

_________________
"Wer Ego-Shooter Killerspiele nennt, muss konsequenterweise jeden Horrorstreifen als Killerfilm bezeichnen." (Zeit.de)
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Sa 16.12.06 13:57 
Jup. So sind Hashes definiert.

Einzig bei CRC32 werden manchmal die führenden 0en weggelassen, weshalb eine Datei auf den Hash 0 haben kann. bei MD5 wird dies aber nicht gemacht, da MD5 typischerweise nicht als Zahl sondern als Bytefeld interpretiert wird.

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
Marco D.
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 2750

Windows Vista
Delphi 7, Delphi 2005 PE, PHP 4 + 5 (Notepad++), Java (Eclipse), XML, XML Schema, ABAP, ABAP OO
BeitragVerfasst: Sa 16.12.06 14:02 
user profile iconGTA-Place hat folgendes geschrieben:
@Marco D.: Schöner kurzer Source :mrgreen:.

Hinterher ist man immer schlauer. :zwinker:

_________________
Pascal keeps your hand tied. C gives you enough rope to hang yourself. C++ gives you enough rope to shoot yourself in the foot
delfiphan
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2684
Erhaltene Danke: 32



BeitragVerfasst: Sa 16.12.06 14:09 
user profile iconBenBE hat folgendes geschrieben:
Jup. So sind Hashes definiert.

Einzig bei CRC32 werden manchmal die führenden 0en weggelassen, weshalb eine Datei auf den Hash 0 haben kann. bei MD5 wird dies aber nicht gemacht, da MD5 typischerweise nicht als Zahl sondern als Bytefeld interpretiert wird.

Ist es nicht eher so, dass man bei einer Datei denjenigen Wert hinzufügt, sodass der CRC 0 wird? So lässt sich leichter ermitteln, ob eine Datei okay ist. Es wäre komplizierter, den CRC-Check bis und ohne CRC-Wert zu rechnen und danach den berechneten Wert mit dem CRC-Wert in der Datei zu vergleichen.
CRC der gesamten Datei berechnen und schauen, ob die 0 ist, ist einfacher.
Dragonclaw
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 196

Windows Vista
Delphi 7 Prof.
BeitragVerfasst: Sa 16.12.06 14:27 
Hallo!
Dies mal hab ich das irgendwie nicht gepackt. Ich wusste zwar auf den ersten Blick, dass das nen Hash ist und auch sehr wahrscheinlich MD5. Dann hab ich direkt nen Programm geschrieben. Nämlich das hier:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
procedure TForm1.Button1Click(Sender: TObject);
var jahr, monat, tag, i  : Integer;
begin
for jahr := 1930 to 1996 do
 for monat := 1 to 12 do
  for tag := 1 to 31 do
 if AnsiLowerCase(MD5Print(MD5String(inttostr(tag)+'.0'+inttostr(monat)+'.'+inttostr(jahr))))
    = '21d0e9077b6cf51bc68c2d79db8d8078' then
  Label1.Caption := inttostr(tag)+'.0'+inttostr(monat)+'.'+inttostr(jahr)
   else Label1.Caption := 'NOPE!';
end;


Kann mir bitte einer Sagen warum das nicht funktioniert????
GTA-Place
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
EE-Regisseur
Beiträge: 5248
Erhaltene Danke: 2

WIN XP, IE 7, FF 2.0
Delphi 7, Lazarus
BeitragVerfasst: Sa 16.12.06 14:29 
Aus mehreren Gründen:
1. Du setzt immer eine 0 vor den Monat -> 01, 02, ... 010, 011, 012
2. Du setzt nie eine 0 vor den Tag -> 1, 2, 3, ... 29, 30, 31
3. Du brichst die Schleife nicht ab, bei einem Ergebnis (du würdest die Lösung gar nicht sehen).

_________________
"Wer Ego-Shooter Killerspiele nennt, muss konsequenterweise jeden Horrorstreifen als Killerfilm bezeichnen." (Zeit.de)