Unpasswording word files

Miscellaneous Forums/General Discussion/Unpasswording word files

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

All the trials I've seen prove they work but only on passwords of 2 characters or something equally useless.

Does the forgetful user remember how many characters there are as 5-6 is doable but more is just real bad. Here's my delphi code, you might be able to convert it to a language you use and for Word also ...

procedure TForm1.Button1Click(Sender: TObject);
const
 MaxLength = 8;
var
 xls, xlw: Variant;
 pass: String;
 Success: Boolean;
 n: Integer;
 msg: String;
 passlength: Integer;
 startchar: Char;
 test: Array [0..MaxLength-1] of Char;
 print: Boolean;
 chars: Array [0..255] of Char;
 charscount: Integer;
 finalchar: Integer;
 index: Array[0..255] of Integer;

 procedure ClearArray;
 var i: integer;
 begin
  For i := 0 to MaxLength-1 do
    test[i] := #0;
  For i := 0 to 255 do
    index[i] := 0;
 end;

begin
 Button1.enabled := false;
 {load MS Excel}
 xls := CreateOLEObject('Excel.Application');

 //read in chars to scan for
 CharsCount := Length(EditChars.Text);
 FinalChar := CharsCount-1;
 StrPCopy(chars, EditChars.text);

 Success := False;
 pass := '';
 passlength := 1;
 startchar := chars[0];
 n := 0; //char pos 1
 ClearArray; //all zeros
 test[n] := startchar;
 Print := True;

 While true do
 begin
   If Print then
   begin
     Try
       Pass := test;
        {open the xls-file}
       xlw := xls.WorkBooks.Open(FileName := 'c:\test.xls', Password := pass, ReadOnly := True);
       Success := True;
      Break
     Except
    End;
   end;

  print := true;

  If index[n] < finalchar then
  begin
    Inc(index[n]);
    test[n] := chars[index[n]];
    If n > 0 then n := 0;
  end
  else
  begin
    testing.caption := pass;
    testing.refresh;
    index[n] := 0;
    test[n] := startchar; //reset current
    inc(n);
    If n = MaxLength then break;
    //add a new digit on the end of the string?
    If n = passlength then
    begin
      inc(passlength);
      test[n] := startchar; //reset new
    end;
    print := False;
  end;

  Application.ProcessMessages();
  If FormClose then
   begin
    Close;
    exit;
   end;
 end;

 {save with other file name}
 If success then
 begin
   xlw.SaveAs(FileName := 'c:\test_cracked', Password := '');
   xls.Workbooks.Close;

   msg := 'Password was '+pass;
   application.messagebox(pchar(msg),'Done!', MB_OK);
 end
 else
   application.messagebox('Failed!','Failed!', MB_OK);

 xls.Application.Quit;
 {unload MS Excel}
 xlw := UnAssigned;
 xls := UnAssigned;
 Button1.enabled := true;


EditChars.text is a string typed by the user into an editbox that contains all the characters that you want to check for. Don't just check for all possible characters (upper, lower, symbols) or it'll take forever.