Autor Beitrag
Philipp_Reitter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 430



BeitragVerfasst: Sa 11.08.07 20:14 
Hi...

ich würde gerne so einen algo schreiben der Brute Force macht...
also ihr wisst schon alle moglichkeiten ausprobieren die man mit einen charset machen kann
es is a nix zum hacken oder cracken sondern was mathematisches was in unserer mathestunde aufgekommen ist..

ich hab schon ein bisschen probiert aber mit den dynamischen längen haut das bei mir nicht hin... ich mein ich kann 2 schleifen machen udn dann bekomm ich alle möglichen
von 00 bis 99 aber wenn ich dann sag mit 15 stellen will ich ned 15 schleifen einbauen... ^^

kann mir da jemand weiterhelfen?

mfg
PHilipp
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 11.08.07 21:40 
Bitte nutze die FoSuFu und füttere sie mit Kombination, Variation oder Permutation ;-)
Sollte dich deinem Ziel näher bringen :P

_________________
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.
klezmor
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 558


delphi 6 personal delphi 2005 personal
BeitragVerfasst: So 12.08.07 01:34 
Insgesamt gibt es ja (Anzahl der Buchstaben=x)^(Ziffernlänge=b) viele Kombinationen. Man muss also entweder b+1 forschleifen implementieren oder deren Grenzen auf über x erhöhen.
Stimmt das so, ne andere möglichkeit gibts ja eigentlich net oder?
Ach keine Ahnung :)

_________________
"Beware of bugs in the above code; I have only proved it correct, not tried it." Donald Knuth
Chryzler
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1097
Erhaltene Danke: 2



BeitragVerfasst: So 12.08.07 09:31 
Ohne jetzt lange überlegt zu haben, ich würde da irgendwie ne rekursive Funktion einbauen:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
function BruteForce(s: String; l: Integer): String;
var
  i: Integer;
  t: String;
begin
  for i := 97 to 122 do
  begin
    t := S + Chr(i);
    if Length(S) < l then
      t := BruteForce(t, l);
    ShowMessage(t);
  end;
end;

So in etwa sollte es gehen, habs aber nicht ausprobiert. Aufruf erfolgt dann so:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
var
  s: String;
begin
  s := '';
  BruteForce(s, 3); 
end;


Zuletzt bearbeitet von Chryzler am So 12.08.07 10:46, insgesamt 1-mal bearbeitet
Philipp_Reitter Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 430



BeitragVerfasst: So 12.08.07 10:43 
hey cool...
danke!
klezmor
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 558


delphi 6 personal delphi 2005 personal
BeitragVerfasst: So 12.08.07 13:18 
Ist das jetzt eigentlich speicherfressend, da ja immer neuer speicherplatz reserviert wird oder? Man könnte doch auch einfach ein eigenes Zahlensystem definieren mit der Basis 26 und dann ganz einfach nach oben zählen oder?

_________________
"Beware of bugs in the above code; I have only proved it correct, not tried it." Donald Knuth
Chryzler
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1097
Erhaltene Danke: 2



BeitragVerfasst: So 12.08.07 14:33 
user profile iconklezmor hat folgendes geschrieben:
Ist das jetzt eigentlich speicherfressend, da ja immer neuer speicherplatz reserviert wird oder? Man könnte doch auch einfach ein eigenes Zahlensystem definieren mit der Basis 26 und dann ganz einfach nach oben zählen oder?

Wüsste nicht was da Speicher fressen sollte. Ich denke so ist es auf jeden Fall einfacher und bestimmt schneller, als ein neues Zahlensystem zu erfinden. Denk ich mal. :gruebel:
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: So 12.08.07 14:36 
@Chryzler: Mal abgesehen davon, dass Du uninitialisierte Strings zurückgibst ...

_________________
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.
Chryzler
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1097
Erhaltene Danke: 2



BeitragVerfasst: So 12.08.07 15:01 
user profile iconBenBE hat folgendes geschrieben:
@Chryzler: Mal abgesehen davon, dass Du uninitialisierte Strings zurückgibst ...

Ich hab auch nie behauptet dass dieser Code auch nur annähernd funktioniert.. :motz:
ausblenden 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:
type
  TWorkProc = procedure(s: String);

implementation

procedure BruteForce(charset: array of Char; l: Integer; p: TWorkProc);
  procedure BruteForceRecursive(s: String);
  var
    i: Integer;
    t: String;
  begin
    for i := 0 to High(charset) do
    begin
      t := S + charset[i];
      if Length(S) < l - 1 then
        BruteForceRecursive(t)
      else
        p(t);
    end;
  end;
var
  s: String;
begin
  s := '';
  BruteForceRecursive(s);
end;

Habs mal noch ein bisschen verbessert/verschlechtert, je nachdem wie man's sieht. :?
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: So 12.08.07 15:10 
user profile iconChryzler hat folgendes geschrieben:
user profile iconBenBE hat folgendes geschrieben:
@Chryzler: Mal abgesehen davon, dass Du uninitialisierte Strings zurückgibst ...

Ich hab auch nie behauptet dass dieser Code auch nur annähernd funktioniert.. :motz:

[...]

Habs mal noch ein bisschen verbessert/verschlechtert, je nachdem wie man's sieht. :?


Schreib in Zeile 12 mal anstatt 0 ein Low(Charset) hin, da ich sonst deine Routine so hier aufrufe:

ausblenden Delphi-Quelltext
1:
2:
3:
const CharsetData : array[97..122of char = 'abcdefghijklmnopqrstuvwxyz';

BruteForce(CharsetData, 3, @p);

und mich dann über den Range Check Error in Zeile 14 beschwere ;-)

Zum Hintergrund: Open Array Parameter (die Du hier verwendest) nehmen jegliche Arrays an (auch statische). Und statische Arrays können jegliche Basis-Indizes haben (auch 97 und sonst was) ;-)

_________________
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.
Chryzler
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1097
Erhaltene Danke: 2



BeitragVerfasst: So 12.08.07 15:29 
Wollt ich machen, habs aber dann gelassen, da ich dachte, dynamische Arrays fangen immer bei 0 an (stand glaub in der Delphi-Hilfe), und array of Char ist ja ein dynamisches Array.

Edit:
user profile iconBenBE hat folgendes geschrieben:
Open Array Parameter (die Du hier verwendest) nehmen jegliche Arrays an (auch statische).
Aso. :P
klezmor
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 558


delphi 6 personal delphi 2005 personal
BeitragVerfasst: So 12.08.07 19:57 
Kanns denn nicht bei langen wörtern zu nem stackoverflow kommen?

_________________
"Beware of bugs in the above code; I have only proved it correct, not tried it." Donald Knuth
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: So 12.08.07 20:06 
Dazu müsstest Du Wörter um die 1-2KB (ggf. auch länger) nehmen ... Der Berechnungsaufwand dafür wäre aber enorm ;-)

Theoretisch aber: JA, kann es ;-)

_________________
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.
Chryzler
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 1097
Erhaltene Danke: 2



BeitragVerfasst: So 12.08.07 20:09 
user profile iconklezmor hat folgendes geschrieben:
Kanns denn nicht bei langen wörtern zu nem stackoverflow kommen?

Natürlich. :) Bei Wörtern länger als 21400 Zeichen kann es zu Problemen kommen (an der Stelle wars bei mir). D.h. man kann damit problemlos eine ~ 171 KBit Verschlüsselung bruteforcen. :)

EDIT: Und wieder zu spät..
cuejo
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 142

Win XP
Delphi 7 Personal und 2005 PE
BeitragVerfasst: So 12.08.07 21:46 
Hi user profile iconPhilipp_Reitter. Mich würd mal brennend interessieren um welches mathematische Problem es sich dabei handelt. :roll: :wink:

_________________
Computer sind dumm, aber fleißig. Deshalb arbeite ich so gerne damit.
Philipp_Reitter Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 430



BeitragVerfasst: Do 23.08.07 10:36 
also...
normale mathestunde
dann is einer aud die frage gekommen wie viele möglichkeiten man mit 4 stellen (im 10er system machen kann)... blöde frage 9999 natürlich!
dann hat da lehere noch gefrat wie es dann mim ABC is... natürlich keiner gewusst (auch ned wie mans ausrechnet)
dann hat mein nachtbar gesagt schreib dooch'n programm dann da leherer: "Gut Philipp schreib ein proigramm nächste stunde sind wir eh im EDV raum..."
jo so is passiert... nix hochmathematisches aber gut um die mathe stunde zu verkürtzen ^^

Mfg
Philipp
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8548
Erhaltene Danke: 477

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Do 23.08.07 10:52 
user profile iconPhilipp_Reitter hat folgendes geschrieben:
dann is einer aud die frage gekommen wie viele möglichkeiten man mit 4 stellen (im 10er system machen kann)... blöde frage 9999 natürlich!
Typischer Fall von blöde Frage - blöde Antwort. Die richtige Antwort wäre 10.000.

Wenn es nur um die Anzahl geht: x^n. Dabei ist x die Anzahl der Zeichen, n die Anzahl der Stellen.

_________________
We are, we were and will not be.
Philipp_Reitter Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 430



BeitragVerfasst: Do 23.08.07 11:57 
stimmt 0000 ist ja auch ne kombo...

naja bei uns hat eine mal im musik gefragt was saich musik eigentlich bringt
darauf hin aht die lehrerin irgenwelche tabletten geschlukt weil die volle ausgerasted ist ^^