ITPub博客

首页 > IT基础架构 > 网络安全 > 获取网页中的密码和文本输入框的内容 (转)

获取网页中的密码和文本输入框的内容 (转)

原创 网络安全 作者:gugu99 时间:2007-08-17 10:33:03 0 删除 编辑
获取网页中的密码和文本输入框的内容 (转)[@more@]

介绍
网页中的密码输入框和一般不同,他没有句柄之类的,但是可以通过IE的IHTMLInputTextElement接口获取!

本文是教你如何得到网页中输入框的内容。如何你想获取网页中的密码,则只要把if (lstrcmpi(strtype, _T("TEXT")) == 0) 改成if

(lstrcmpi(strtype, _T("PASSword")) == 0) 就可以了,如果你要是再加个实时监视的话,就成了密码窃取程序了咯!
 
 主要思路:获取IE的IHTMLInputTextElement接口,这样就可以获取网页中的输入框(包括文本和密码输入框)的内容了。
 
 警告:本代码只用作学习和编程测试的使用,严禁用于商业或者非法用途,否则一切后果与本人无关!

 如果要转载,请与作者联系!
 Copyright (C) 2002. All Rights Reserved.
 



 VARIANT id, index;
  CComPtr spDispatch;
  CComQIPtr pDoc2;
  CComQIPtr pElement;
  CComPtr pElementCol;
  CComPtr pFormElement;
  CComPtr pInputElement;

//首先获取IwebBrowser2接口
CoInitialize(NULL); //必须要这句初始化
SHDocVw::IWebBrowser2Ptr spBrowser(spDisp);
if (m_spSHWinds == NULL)
{
 if (m_spSHWinds.CreateInstance(__uuidof(SHDocVw::shellwindows)) != S_OK)
 {
  MessageBox("Failed");
  CoUninitialize();
 
 }
}

if (m_spSHWinds)
  {
 int n = m_spSHWinds->GetCount();
 for (int i = 0; i < n; i++)
 {
  _variant_t v = (long)i;
  IDispatchPtr spDisp = m_spSHWinds->Item(v);

  SHDocVw::IWebBrowser2Ptr spBrowser(spDisp);  //生成一个IE窗口的智能指针
  if (spBrowser)
  {
//获取IHTMLDocument2接口
if (SUCCEEDED(spBrowser->get_Document( &spDispatch)))
  pDoc2 = spDispatch;
 if(pDoc2!=NULL)
 {
 // AfxMessageBox("已经获取IHTMLDocument2");
 if (SUCCEEDED(pDoc2->get_forms(&pElementCol)))
 {
 // AfxMessageBox("已经获取IHTMLElementCollection");
 long p=0;
 if(SUCCEEDED(pElementCol->get_length(&p)));
  if(p!=0)
  { 

 for(long i=0;i<=(p-1);i++)
 {

 V_VT(&id) = VT_I4;
 V_I4(&id) = i;
 V_VT(&index) = VT_I4;
 V_I4(&index) = 0;

 if(SUCCEEDED(pElementCol->item(id,index, &spDispatch)))
 

if(SUCCEEDED(spDispatch->QueryInterface(IID_IHTMLFormElement,(void**)&pFormElement)))
 {
 // AfxMessageBox("已经获取IHTMLFormElement");
 long q=0;
  if(SUCCEEDED(pFormElement->get_length(&q)));
 for(long j=0;j<=(q-1);j++)
 {
 V_VT(&id) = VT_I4;
 V_I4(&id) = j;
 V_VT(&index) = VT_I4;
 V_I4(&index) = 0;
  if(SUCCEEDED(pFormElement->item(id,index, &spDispatch)))

 

if(SUCCEEDED(spDispatch->QueryInterface(IID_IHTMLInputTextElement,(void**)&pInputElement)))
  {
 //AfxMessageBox("已经获取IHTMLInputTextElement");
  CComBSTR value;
  CComBSTR type;
  pInputElement->get_type(&type);//获取输入框类型(密码框还是文本框)
 
  CString strtype(type);
  strtype.MakeUpper();
 if (lstrcmpi(strtype, _T("TEXT")) == 0)
 {
 pInputElement->get_value(&value);//获取文本框的值
 CString strvalue(value);
 AfxMessageBox(strvalue);
  }
  }
 }
 }
 }
  }
 
}

  注意:具体细节请看原始代码!最好不要向作者要技术支持!谢谢阅

读! to:TanXin79@163.NET">TanXin79@163.net,文章的源代码:

ASP/ibr_UPLOAD/791.rar">http://www.vchelp.net/ASP/ibr_upload/791.rar


来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/10748419/viewspace-963546/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
  • 博文量
    3121
  • 访问量
    2644423