Autor Beitrag
Trashkid2000
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 561
Erhaltene Danke: 137



BeitragVerfasst: Di 03.08.10 20:16 
Kommen wir zu dem Schluss, dass sowieso nichts sicher ist. Als Programmierer muss man immer daran denken, dass es eigentlich immer möglich ist, irgendwas zu knacken! Man muss halt nur genug Zeit reinstecken und die richtigen Techniken anwenden.

Bitte korrigiert mich, wenn ich falsch liege!

Und mit .NET und dem IL-Code wird das Ganze nicht besser, da war es schon schwieriger, "normale" PE- Programme zu cracken. Da musste man sich noch mit Assembler auskennen. Ich weiss, dass es auch für .NET Fuscatoren gibt. Aber ob das was nützt?

Ist halt immer ein Wettbewerb zwischen Programmierern und Crackern. Deshalb sollte, so finde ich, jeder Programmierer auch wissen, wie Cracker vorgehen, wenn sie sich an dem Programm vergehen. Erst dann kann man wissen, wie man das Programm (halbwegs) sicher bekommt. Mit dem Wissen, dass ja wie schon gesagt nichts sicher ist.

Aber man kann es Crackern schwerer machen. So dass Cracker vielleicht die Lust verlieren.

Ist vielleicht Off-Topic, aber wollte ich mal los werden.

MfG, Marko
uall@ogc
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 1826
Erhaltene Danke: 11

Win 2000 & VMware
Delphi 3 Prof, Delphi 7 Prof
BeitragVerfasst: Di 03.08.10 21:20 
Die ganzen Salfeld sind nicht wirklich gut. Ich hatte mit mal das "Exe Password" Programm vor 2 Jahren angeschaut. Die eigentliche geschützte Exe steckt nach dem verschlüssseln einfach hinter der Entschlüsselungs Exe. Mit nem Hexeditor kann man das rauskopieren. Nicht mal das Password war mit MD5 etc. verschlüsselt sondern durch irgend ne einfache XOR Methode...

Die damalige PW Generierung für ExePassword:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
function Encode(s: string): Integer;
var
  a: Integer;
  b: Integer;
  i: Integer;
begin
  s := s + #0;
  a := 0;
  for i := 2 to length(s) do begin
    b := Ord(s[i]) + a * $25;
    a := b;
  end;
  Result := a;
end;


Der Code um das zu umgehen (also Exe entpacken bzw. Key auslesen):

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:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189:
190:
191:
192:
193:
194:
195:
196:
197:
198:
199:
200:
201:
202:
203:
204:
205:
206:
207:
208:
209:
210:
211:
212:
213:
214:
215:
216:
217:
218:
219:
220:
221:
222:
223:
224:
225:
226:
227:
228:
229:
230:
231:
232:
233:
234:
235:
236:
237:
238:
239:
240:
241:
242:
program decodefly;
{$APPTYPE CONSOLE}
uses
  windows,
  tlHelp32,
  classes,
  sysutils,
  messages;
// the Password encode code

function Encode(s: string): Integer;
var
  a: Integer;
  b: Integer;
  i: Integer;
begin
  s := s + #0;
  a := 0;
  for i := 2 to length(s) do begin
    b := Ord(s[i]) + a * $25;
    a := b;
  end;
  Result := a;
end;
var
  r: string =
    'abcdefghijklmnopqrstuvwxyz' +
    'ABCDEFGHIJKLMNOPQRSTUVWXYZ' +
    '01234567890' +
    '!"§$%&/()=?' +
    'ÖÄÜöüä' +
    '+*~#-_.:,;<>@€';

function GetPossible(a: int64; var b: int64): Boolean;
begin
  Result := False;
  while ((a mod $25) <> 0and (a < $25000000000do
    inc(a, $100000000);
  if (a < $25000000000then
    Result := True;
  b := (a div $25);
end;

function decodebrute(a: int64; var s: string; tiefe: integer; maxdepth: integer): Boolean;
var
  i: integer;
  b: int64;
begin
  if (a = 0then begin
    s := '';
    Result := True;
    Exit;
  end;
  if (a > $25and (a <= $FFand (Pos(Char(a), r) > 0then begin
    s := Char(a);
    Result := True;
    Exit;
  end;
  if (tiefe > maxdepth) then begin
    Result := False;
    Exit;
  end;
  i := 1;
  Result := False;
  while (i <= length(r)) and (not Result) do begin
    b := a - ord(r[i]);
    if (b > 0and (b mod $25 = 0then
      if decodebrute(b div $25, s, tiefe + 1, maxdepth) then begin
        s := s + char(r[i]);
        Result := True;
      end;
    inc(i);
  end;
end;

function decode(a: integer): string;
var
  s: string;
  b: int64;
begin
  if GetPossible(a, b) then
    if decodebrute(b, s, 06then
      Result := '?' + s;
end;

function GetEdit: HWND;
var
  wnd: HWND;
begin
  Result := 0;
  wnd := FindWindow('TForm1'nil);
  wnd := FindWindowEx(wnd, 0'TPanel'nil);
  wnd := FindWindowEx(wnd, 0'TPageControl'nil);
  wnd := FindWindowEx(wnd, 0'TTabSheet'nil);
  wnd := FindWindowEx(wnd, 0'TEdit'nil);
  if wnd <> 0 then
    Result := wnd;
end;

function GetExecutableFromPID(dwProcessID: DWord): stringstdcall;
var
  FSnapshotHandle: THandle;
  FModuleEntry32: TModuleEntry32;
begin
  Result := '';
  if (dwProcessID <> 0then begin
    FSnapshotHandle := CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, dwProcessID);
    if (fSnapshotHandle <> 0then begin
      FModuleEntry32.dwSize := Sizeof(FModuleEntry32);
      Module32First(FSnapshotHandle, FModuleEntry32);
      Result := FModuleEntry32.szExePath;
      CloseHandle(FSnapshotHandle);
    end;
  end;
end;

function ExtractEncodedPassword(ExeName: string): integer;
var
  fm: TFileStream;
  f: string;
  i: integer;
  begx, endx: integer;
begin
  Result := 0;
  fm := TFileStream.Create(ExeName, fmOpenRead);
  SetLength(f, fm.Size);
  fm.Read(f[1], fm.size);
  fm.free;
  begx := 0;
  endx := 0;
  for i := 1 to length(f) do begin
    if Copy(f, i, length('!#0005H3X¶')) = '!#0005H3X¶' then
      begx := i + 10;
    if Copy(f, i, length('EO!#0005H3XSO')) = 'EO!#0005H3XSO' then
      endx := i;
  end;
  if (begx <> 0and (endx <> 0and (endx > begx) then
    Result := StrToIntDef(Copy(f, begx, endx - begx), 0)
end;

function TrySetEditText(): Boolean;
var
  pid: DWord;
  Name: string;
  pwencoded: integer;
  Edit: Dword;
  pwdecoded: string;
begin
  Result := False;
  Edit := GetEdit;
  if (edit <> 0then begin
    if GetWindowThreadProcessID(Edit, pid) <> 0 then begin
      Name := GetExecutableFromPID(pid);
      if (Name <> ''then begin
        pwencoded := ExtractEncodedPassword(Name);
        if (pwencoded <> 0then begin
          pwdecoded := decode(pwencoded);
          if (pwdecoded <> ''then begin
            SendMessage(Edit, WM_SETTEXT, 0, integer(PChar(pwdecoded)));
            Result := True;
          end;
        end;
      end;
    end;
  end;
end;

function unpack(fl: string): Boolean;
var
  fm: TFileStream;
  InFile: string;
  i: integer;
begin
  Result := False;
  fm := TFileStream.Create(fl, fmOpenRead);
  setLength(InFile, fm.size);
  fm.Read(inFile[1], fm.Size);
  fm.free;
  for i := 1 to Length(inFile) do begin
    if (Copy(Infile, i, 3) = 'AAA'and (Copy(Infile, i + 123) = 'MZP'then begin
      fm := TFileStream.Create((fl + ' extract.exe'), fmCreate);
      fm.Write(InFile[i + 12], Length(InFile) - i - 11);
      fm.free;
      Result := True;
    end;
  end;
end;

function ShowPw(fl: string): string;
var
  pwencoded: integer;
begin
  Result := '';
  pwencoded := ExtractEncodedPassword(fl);
  if (pwencoded <> 0then
    Result := decode(pwencoded);
end;

procedure main;
var
  pw: string;
begin
  Writeln('-----------------------------');
  Writeln(' Salfeld.de Exe Depassword ');
  Writeln(' 2007 by uall ');
  Writeln('-----------------------------');
  Writeln('');
  Writeln('(1) -up "ExeName": unpacks the original executable');
  Writeln('(2) -pw "ExeName": extracts a password for the executable');
  Writeln('(3) no param: searches for started program and inserts password');
  Writeln('');
  if (paramcount < 2then begin
    write('method (3) used: ');
    if TrySetEditText then
      writeln('successful')
    else
      writeln('failed');
  end else begin
    if (paramstr(1) = '-up'then begin
      write('method (1) used: ');
      if Fileexists(paramstr(2)) and unpack(paramstr(2)) then
        writeln('successful')
      else
        writeln('failed');
    end else if (paramstr(1) = '-pw'then begin
      write('method (2) used: ');
      if FileExists(paramstr(2)) then begin
        pw := showpw(paramstr(2));
        if (pw <> ''then
          writeln('successful pw: ' + pw)
        else
          writeln('failed');
      end else
        writeln('failed');
    end else
      writeln('unknown parameter used');
  end;
  ReadLn;
end;
begin
  Main;
end.


Edit: Funktioniert immer noch, habs mal auf Sprachversionen angepasst. Nett auch, dass noch nicht mal TForm1 umbenannt wurde ;)

_________________
wer andern eine grube gräbt hat ein grubengrabgerät
- oder einfach zu viel zeit

Für diesen Beitrag haben gedankt: jexner
Boldar
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Beiträge: 1555
Erhaltene Danke: 70

Win7 Enterprise 64bit, Win XP SP2
Turbo Delphi
BeitragVerfasst: Di 03.08.10 21:40 
user profile iconTrashkid2000 hat folgendes geschrieben Zum zitierten Posting springen:

Aber man kann es Crackern schwerer machen. So dass Cracker vielleicht die Lust verlieren.


Ein echter Cracker macht dann erst recht weiter, das ist erst die Motivation.

Ist vielleicht Off-Topic, aber wollte ich mal los werden.