Get Dialup Password [winXP]

Please discuss general Delphi programming topics here.

Get Dialup Password [winXP]

Postby Mehdi » October 20th, 2004, 7:35 pm

Hi :)
what i can get Dialup password from windows XP :)

tanX
Mehdi
Member
Member
 
Posts: 4
Joined: October 20th, 2004, 7:21 pm

Postby Stefan » October 20th, 2004, 8:54 pm

Hi,

Try the EnumCachedPasswords() routine in MPR.dll.
It is undocumented but that should retreive all of the cached passwords in Windows. Do a google search for it, I posted something about that a couple of years back on usenet, so that should still be there...

Cheers,
Stefan
User avatar
Stefan
Moderator
Moderator
 
Posts: 128
Joined: September 27th, 2004, 9:40 am
Location: Tilburg, The Netherlands

Postby Mehdi » October 20th, 2004, 9:09 pm

Hi,
tanX Stefan :)
i'm searching EnumCachedPasswords() from google but not found your response about this from usenet.
could you send this for me :-/

(: tanX :)
Mehdi
Member
Member
 
Posts: 4
Joined: October 20th, 2004, 7:21 pm

Postby Stefan » October 20th, 2004, 9:35 pm

Hmm, I can't seem to find it anymore either.

tada:

Code: Select all
unit Unit1;

interface

uses
  Windows, SysUtils, Classes, Forms, ShellAPI, Controls, StdCtrls, Dialogs;

type
  TForm1 = class(TForm)
    Button1: TButton;
    SaveDialog1: TSaveDialog;
    ListBox: TListBox;
    procedure Label1Click(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    hMPR: THandle;
  end;

var
  Form1: TForm1;

const
  Count: Integer = 0;

function WNetEnumCachedPasswords(lp: lpStr; w: Word; b: Byte; PC: PChar; dw:
DWord): Word; stdcall;

implementation

{$R *.DFM}
function WNetEnumCachedPasswords(lp: lpStr; w: Word; b: Byte; PC: PChar; dw:
DWord): Word; external mpr name 'WNetEnumCachedPasswords';

type
 PWinPassword = ^TWinPassword;
 TWinPassword = record
   EntrySize: Word;
   ResourceSize: Word;
   PasswordSize: Word;
   EntryIndex: Byte;
   EntryType: Byte;
   PasswordC: Char;
  end;

var
  WinPassword: TWinPassword;

function AddPassword(WinPassword: PWinPassword; dw: DWord): LongBool;
stdcall;
var
  Password: String;
  PC: Array[0..$FF] of Char;
begin
  inc(Count);

  Move(WinPassword.PasswordC, PC, WinPassword.ResourceSize);
  PC[WinPassword.ResourceSize] := #0;
  CharToOem(PC, PC);
  Password := StrPas(PC);

  Move(WinPassword.PasswordC, PC, WinPassword.PasswordSize +
WinPassword.ResourceSize);
  Move(PC[WinPassword.ResourceSize], PC, WinPassword.PasswordSize);
  PC[WinPassword.PasswordSize] := #0;
  CharToOem(PC, PC);
  Password := Password + ': ' + StrPas(PC);

  Form1.ListBox.Items.Add(Password);
  Result := True;
end;

procedure TForm1.FormShow(Sender: TObject);
begin
  if WNetEnumCachedPasswords(nil, 0, $FF, @AddPassword, 0) <> 0 then
   begin
    Application.Terminate;
   end
  else
   if Count = 0 then
    ListBox.Items.Add('No password found');
end;
User avatar
Stefan
Moderator
Moderator
 
Posts: 128
Joined: September 27th, 2004, 9:40 am
Location: Tilburg, The Netherlands

tanX Stefan

Postby Mehdi » October 21st, 2004, 10:21 am

txnX Stefan :)
Mehdi
Member
Member
 
Posts: 4
Joined: October 20th, 2004, 7:21 pm

Postby Mehdi » October 24th, 2004, 12:28 pm

Hi
Stefan you code not work into winXp true :?:
this code run only in win98 :)
Mehdi
Member
Member
 
Posts: 4
Joined: October 20th, 2004, 7:21 pm

Postby Stefan » October 26th, 2004, 7:44 am

Could be that it is pre-NT code only... I'm not sure, I never really did anything with it except play around on my Win95 (it was I believe) desktop :)
User avatar
Stefan
Moderator
Moderator
 
Posts: 128
Joined: September 27th, 2004, 9:40 am
Location: Tilburg, The Netherlands


Return to Delphi Programming

Who is online

Users browsing this forum: No registered users and 0 guests

cron