密码是怎么被察看的

cutelocust 2002-05-09 09:13:17
密码是怎么被察看的
首先声明,我写此篇文章时参考了前辈们编的源程序,在此我表示感谢。
打开搜索引擎,你能搜到诸如此类的软件,他们能察看你输入的密码。能将"*"所掩盖的真实的密码还原。
下面的一段程序就能做到这一点:
procedure Tform1.Timer1(Sender: TObject);
var
ClassName: PChar;
ptCursor: TPoint;
hWndOver: HWND;
Text: PChar;
begin
GetCursorPos(ptCursor);
hWndOver := WindowFromPoint(ptCursor);
GetMem(ClassName, 100);
GetMem(Text, 255);
try
GetClassName(hWndOver, ClassName, 100);
SendMessage(hWndOver, WM_GETTEXT, 255, LongInt(Text));
Canvas.FillRect(Rect(5, 20 , PreClassLength + 20, 40));
Canvas.FillRect(Rect(5, 40 , PreTextLength + 20, 60));
PreClassLength := Canvas.TextWidth(ClassName);
PreTextLength := Canvas.TextWidth(Text);
if PreClassLength > PreTextLength then
Width := Canvas.TextWidth(ClassName) + 20
else
Width := Canvas.TextWidth(Text) + 20;
Canvas.TextOut(5, 20, string(ClassName));
Canvas.TextOut(5, 35, string(Text));
finally
FreeMem(ClassName);
FreeMem(Text);
end;
end;
我给出这段程序,或许不用我说你就能明白,察看密码的原理:
在此,我还是班门弄斧一次,如有错误请指出.
1,函数的意义:
GetCursorPos(ptCursor):
英文解释:The GetCursorPos function retrieves the cursor's position, in screen coordinates.
中文解释:GetCursorPos函数能返回屏幕上光标的位置.
WindowFromPoint:
英文解释:The WindowFromPoint function retrieves the handle of the window that contains the specified point.
中文解释:WindowFromPoin函数能返回特定点的句柄.
GetClassName:好像不用我解释你就能明白她的含义.
sendmessage:
英文解释:The SendMessage function sends the specified message to a window or windows. The function calls the window procedure for the specified window and does not return until the window procedure has processed the message.
中文解释:sendmessage函数能发送一个特定消息给窗口,这个函数能为特定的窗口调用那个过程,直到那个窗口处理了这个消息才返回.
这些中文的解释是我翻译的,本人的英文学的不怎么样,如有错误之出请指正。
2.主要的函数意义我解释了,到此,我就是不说,大家也应该知道程序工作的原理.
程序首先通过GetClassName函数获得classname,然后通过sendmessage函数获得它的text,一般输入密码的控件
都为edit因此程序运行之后,你能在form上获得控件的名称,还有它的text,而她的text正是你想要获得内容,密码,尽管它被"*"所掩盖.
...全文
23 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
linzhisong 2002-06-09
  • 打赏
  • 举报
回复
收藏,看起来不错!

多谢了!
knock 2002-05-17
  • 打赏
  • 举报
回复
看了,感觉挺爽
lovedata 2002-05-10
  • 打赏
  • 举报
回复
windows系统的密码是很脆弱的,因为所有的密码输入的时候都显示为********
表面上看这很安全,因为一般人不懂*******是什么东西,但其实要看到*******
下的内容是很容易的事,工作原理如下:
windows是基于窗口的消息驱动型作业系统,每个窗口都有自已的属性,其中密码窗
口的属性是es_password,所以我们可以利用枚举子窗口enumchildwindows的方法
来找出系统中所有子窗口,再检查其属性getwindowlong,若是es_password则是个密码窗
然后用sendmessage()取得窗口标题,那就是******下的真正内容



=========下面是delphi程序=====================

program lookpass;

interface

uses
windows, messages, sysutils;
var
hcount:integer;

//这是一个窗口响应函数,注意:result:=true很重要,因为只有这样才能连续扫描所有子窗口
function lpenumfunc(hwnd:integer;uint:integer):boolean;stdcall;
var hw,hs,wlong:integer;
sbuf,sb2:array[0..256] of char;
sb1:string;
begin
//得到窗口的属性
wlong:=getwindowlong(hwnd,gwl_style);
//若属性为es_password则为密码窗
if (wlong and es_password)<>0 then
begin
inc(hcount);
//发送获取窗口标题的消息
sendmessage(hwnd,wm_gettext,40,integer(@sbuf));
//设置得到的密码
strpcopy(sbuf,format('[password %d] = %s',[hcount,sbuf]));
//显示密码
end;
//result为true时继续扫描下一个子窗口
result:=true;
end;


begin
lp:=0;hcount:=0;
//枚举子窗口,getdesktopwindow用来得到桌面的句柄
enumchildwindows(getdesktopwindow,@lpenumfunc,lp);
end.
//////////////////////////////////////////////////////////////////////////////
作者:倪建华
copyright (c) 2001-6-27 allright reserved.

XueGLSoft 2002-05-10
  • 打赏
  • 举报
回复
要说就说

不要卖关子
纯冰糖 2002-05-10
  • 打赏
  • 举报
回复
如果你需要我可以公开我的一段源程序给你,比你的方便多了,没有几行代码,原理很相似的!记住我的网名!
cutelocust 2002-05-10
  • 打赏
  • 举报
回复
he GetClassName function retrieves the name of the class to which the specified window belongs.
和码帮主 2002-05-10
  • 打赏
  • 举报
回复
帮你简洁一下:
procedure Tform1.Timer1();
var
ClassName: PChar;
ptCursor: TPoint;
hWndOver: HWND;
Text: PChar;
begin
GetCursorPos(ptCursor);
hWndOver := WindowFromPoint(ptCursor);
GetMem(ClassName, 100);
GetMem(Text, 255);
try
GetClassName(hWndOver, ClassName, 100);
SendMessage(hWndOver, WM_GETTEXT, 255, LongInt(Text));
ShowMessage(String(Text));
finally
FreeMem(ClassName);
FreeMem(Text);
end;
和码帮主 2002-05-10
  • 打赏
  • 举报
回复
帮你简洁一下:
procedure Tform1.Timer1();
var
ClassName: PChar;
ptCursor: TPoint;
hWndOver: HWND;
Text: PChar;
begin
GetCursorPos(ptCursor);
hWndOver := WindowFromPoint(ptCursor);
GetMem(ClassName, 100);
GetMem(Text, 255);
try
GetClassName(hWndOver, ClassName, 100);
SendMessage(hWndOver, WM_GETTEXT, 255, LongInt(Text));
ShowMessage(String(Text));
finally
FreeMem(ClassName);
FreeMem(Text);
end;
tygh2000 2002-05-10
  • 打赏
  • 举报
回复
清早起床,就学了一招,一个字,爽!
ihihonline 2002-05-10
  • 打赏
  • 举报
回复
我记的delphi的可以方便的查看;
先收藏了
lastshrill 2002-05-10
  • 打赏
  • 举报
回复
GetClassName(hWndOver, ClassName, 100);
有什么用?
cutelocust 2002-05-10
  • 打赏
  • 举报
回复
thanks

5,388

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧