用IE的自动化接口让程序命令IE反复的执行投票操作

基本原理就是利用IE的自动化接口让程序命令IE反复的执行投票操作。
实现:
vc6下新建对话框工程,添加4个编辑框,分别对应投票地址m_strAction(如http://www.aivtp.com/)
 每次投票数目m_lNumber = 20;
 每次投票时间间隔m_dwJG = 1500;
 投票时间m_lTime = 0;//<1时无限投票
添加开始/暂停投票按钮m_ok

包含头文件并引入_Module
#include <atlbase.h>
#include <atlcom.h>
#include <mshtml.h>
CComModule _Module;

//m_ok的响应函数
void CXiShuaShuaDlg::OnStart()
{
 bStart=!bStart;
 if(!bStart)
 {
  this->KillTimer(0);
  m_ok.SetWindowText("开始投票");
  return;
 }
 this->UpdateData();
 bAlert=false;
 m_ok.SetWindowText("暂停投票");
 SetTimer(0,m_dwJG,NULL);
 if(m_lTime>0) SetTimer(1,m_lTime*1000,NULL);
}
//
void CXiShuaShuaDlg::OnTimer(UINT nIDEvent)
{
 if(nIDEvent==1)
 {
  OnStart();
  KillTimer(1);
  return;
 }
 IHTMLWindow2* pHTMLWin;
 IHTMLDocument2* pHTMLDocument;
 CComPtr< IShellWindows > spShellWin;
 if ( FAILED ( spShellWin.CoCreateInstance( CLSID_ShellWindows ) ) )
 {
  if(!bAlert)
  {
   bAlert=true;
   MessageBox("获取 IShellWindows 接口错误");
  }
  return;
 }
 long nCount = 0;// 取得浏览器实例个数(Explorer 和 IExplorer)
 spShellWin->get_Count( &nCount );
 if( 0 == nCount )
 {
  if(!bAlert)
  {
   bAlert=true;
   MessageBox("没有在运行着的浏览器");
  }
  return;
 }
 CString strScript("var s,sm;");
 CString tmp;
 tmp.Format("s='f'+i;sm='fm'+i;if(typeof(document.all[s])=='undefined') document.body.insertAdjacentHTML('beforeEnd',/"<form id=/"+s+/" action='%s' target=/"+sm+/" method=post></form>/");",m_strAction);
 tmp+="if(typeof(document.all[sm])=='undefined') document.body.insertAdjacentHTML('beforeEnd',/"<iframe name=/"+sm+/"></iframe/");";
 strScript.Format("for(var i=0;i<%d;i++){%seval('f'+i+'.submit()');}",m_lNumber,tmp);
 VARIANT v;
 for(long i=0; i<nCount; i++)
 {
  CComPtr< IDispatch > spDispIE;
  if(FAILED(spShellWin->Item(CComVariant(i),&spDispIE))) continue;
  CComQIPtr< IWebBrowser2 > spBrowser = spDispIE;
  if(!spBrowser) continue;
  CComPtr < IDispatch > spDispDoc;
  if(FAILED(spBrowser->get_Document(&spDispDoc))) continue;
  CComQIPtr< IHTMLDocument2 > spDocument2 = spDispDoc;
  if(!spDocument2) continue;
  pHTMLDocument=spDocument2;
  if(FAILED(pHTMLDocument->get_parentWindow(&pHTMLWin))) continue;
  pHTMLWin->execScript(CComBSTR(strScript),CComBSTR("javascript"),&v);
 }
 CDialog::OnTimer(nIDEvent);
}
有的服务器端是通过Request.Forms['xx']或者其他方法获取数据的,此时要构造合适m_strAction句和strScript句
如此,一个简单的刷票工具就完成了

防止刷票?
1、客户端cookie,保存投票状态。这种方法最垃圾,但居然有人用。
2、服务器端记录IP地址。这种方法对局域网用户实在是非常不爽,,,
3、来源判断。防盗链的那种技术,判断提交数据的窗口地址是否为特定页面
4、要求注册为用户。这个就不说了,,
5、稍微进行点数据分析,判断是否刷票。
刷票具有的特征:
1、时间上连续不断
2、IP地址连续
3、某IP或时间段投票数目过多
对于1和2,高级的刷票程序会产生随机时间和随机IP地址进行伪装。
3虽然可以伪装,但这样一来刷票程序就失去其预料的效果(随机IP在10分钟内投1票?)。如果是不贪心的刷票程序,就只有利用专用数据工具或人工判断了

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值