发布一个.net探针

类别:.NET开发 点击:0 评论:0 推荐:

未经说明,本blog.csdn.net/wind7788均为本人原创代码,凡是引用或者应用请注明出处,表示对作者的尊重.

以下代码主要使用了NameValueCollection来存储信息,用HtmlTable来显示信息.以方便扩展.你也可以用xml来存储要刺探的项目,这样更有利于扩充.

using System;
using System.Collections;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

namespace Addr.Admin
{
?///


?/// Bougie 的摘要说明。
?///

?public class Bougie : System.Web.UI.Page
?{
??protected HtmlTable ServerInfo,ComInfo,ClientInfo;
??protected System.Web.UI.WebControls.TextBox newCom;
??protected System.Web.UI.WebControls.Button OK1;
??protected System.Web.UI.WebControls.Label resultCom;
??protected System.Web.UI.WebControls.Label resultAdd;
??protected System.Web.UI.WebControls.TextBox newExec;
??protected System.Web.UI.WebControls.ValidationSummary Val2;
??protected System.Web.UI.WebControls.Button OK2;
??protected System.Web.UI.WebControls.RangeValidator Val1;
??protected System.Web.UI.WebControls.RequiredFieldValidator Val3;
??protected System.Web.UI.HtmlControls.HtmlTableCell CopyRight;
?
??private void Page_Load(object sender, System.EventArgs e)
??{
???// 在此处放置用户代码以初始化页面
???Response.Expires = 0;
???Response.CacheControl = "no-cache";

???NameValueCollection nvcServer=new NameValueCollection();
???NameValueCollection nvcCom=new NameValueCollection();
???NameValueCollection nvcClient=new NameValueCollection();

????DateTime StartTime=DateTime.Now;
????//服务器信息
????nvcServer.Add("服务器名称",Server.MachineName);
????nvcServer.Add("服务器IP地址",Request.ServerVariables["LOCAL_ADDR"]);
????nvcServer.Add("服务器域名",Request.ServerVariables["SERVER_NAME"]);
????nvcServer.Add(".NET框架版本",Environment.Version.ToString());
????nvcServer.Add("服务器操作系统",Environment.OSVersion.ToString());
????nvcServer.Add("IIS环境",Request.ServerVariables["SERVER_SOFTWARE"]);
????nvcServer.Add("服务器端口",Request.ServerVariables["SERVER_PORT"]);
????nvcServer.Add("脚本超时设置",Server.ScriptTimeout.ToString());
????nvcServer.Add("服务器现在时间",DateTime.Now.ToString());
????nvcServer.Add("虚拟目录绝对路径",Request.ServerVariables["APPL_PHYSICAL_PATH"]);
????nvcServer.Add("执行文件绝对路进",Request.ServerVariables["PATH_TRANSLATED"]);
????nvcServer.Add("HTTPS支持",Request.ServerVariables["HTTPS"]);
????nvcServer.Add("SESSION总数",Session.Keys.Count.ToString());
????nvcServer.Add("APPLICATION总数",Application.Keys.Count.ToString());
????//组件支持情况
????if (checkObject("JMail.SmtpMail"))
????{
?????nvcCom.Add("JMail邮件","√");
????}
????else
????{
?????nvcCom.Add("JMail邮件","×");
????}
?
????if (checkObject("Persits.MailSender"))
????{
?????nvcCom.Add("Persits邮件","√");
????}
????else
????{
?????nvcCom.Add("Persits邮件","×");
????}

????if (checkObject("Geocel.Mailer"))
????{
?????nvcCom.Add("Geocel邮件","√");
????}
????else
????{
?????nvcCom.Add("Geocel邮件","×");
????}
?
????if (checkObject("SmtpMail.SmtpMail.1"))
????{
?????nvcCom.Add("SmtpMail邮件","√");
????}
????else
????{
?????nvcCom.Add("SmtpMail邮件","×");
????}
?
????if (checkObject("Persits.Upload.1"))
????{
?????nvcCom.Add("Persits上传","√");
????}
????else
????{
?????nvcCom.Add("Persits上传","×");
????}

????if (checkObject("aspcn.Upload"))
????{
?????nvcCom.Add("Paspcn上传","√");
????}
????else
????{
?????nvcCom.Add("Paspcn上传","×");
????}

????if (checkObject("LyfUpload.UploadFile"))
????{
?????nvcCom.Add("LyfUpload上传","√");
????}
????else
????{
?????nvcCom.Add("LyfUpload上传","×");
????}
?
????if (checkObject("SoftArtisans.FileManager"))
????{
?????nvcCom.Add("SoftArtisans文件管理","√");
????}
????else
????{
?????? nvcCom.Add("SoftArtisans文件管理","×");
????}

????if (checkObject("w3.upload"))
????{
?????nvcCom.Add("w3上传","√");
????}
????else
????{
?????nvcCom.Add("w3上传","×");
????}
?
????if (checkObject("W3Image.Image"))
????{
?????nvcCom.Add("W3Image图像读写","√");
????}
????else
????{
?????nvcCom.Add("W3Image图像读写","×");
????}
????if(checkObject("ADODB.Connection"))
????{
?????nvcCom.Add("ADO数据连接","√");
????}
????else
????{
?????nvcCom.Add("ADO数据连接","×");
????}
????if(checkObject("ADODB.RecordSet"))
????{
?????nvcCom.Add("ADO数据集","√");
????}
????else
????{
?????nvcCom.Add("ADO数据集","×");
????}
????if (checkObject("Scripting.FileSystemObject"))
????{
?????nvcCom.Add("FSO","√");
????}
????else
????{
?????nvcCom.Add("FSO","×");
????}
????if (checkObject("CDONTS.NewMail"))
????{
?????nvcCom.Add("CDONTS邮件","√");
????}
????else
????{
?????nvcCom.Add("CDONTS邮件","×");
????}
????//客户端信息
????nvcClient.Add("客户端IP地址",Request.ServerVariables["REMOTE_ADDR"]);
????HttpBrowserCapabilities HBC=Request.Browser;
????nvcClient.Add("客户端操作系统",HBC.Platform.ToString());
????nvcClient.Add("浏览器",HBC.Browser.ToString());
????nvcClient.Add("浏览器版本",HBC.Version.ToString());
????nvcClient.Add("VBS",HBC.VBScript.ToString());
????nvcClient.Add("JS",HBC.JavaScript.ToString());
????nvcClient.Add("ActiveX",HBC.ActiveXControls.ToString());
????nvcClient.Add("JavaApplets",HBC.JavaApplets.ToString());
????nvcClient.Add("语言",Request.ServerVariables["HTTP_ACCEPT_LANGUAGE"]);
????nvcClient.Add("框架支持",HBC.Frames.ToString());
????nvcClient.Add("Cookie支持",HBC.Cookies.ToString());
????nvcClient.Add("DOM",HBC.MSDomVersion.ToString());
????//写出数据
????writeOut(nvcServer,ServerInfo);
????writeOut(nvcCom,ComInfo);
????writeOut(nvcClient,ClientInfo);

????DateTime EndTime=DateTime.Now;
???CopyRight.InnerHtml="本页执行时间:"+((EndTime-StartTime).TotalSeconds).ToString()+"秒  ";
???CopyRight.InnerHtml+="CopyRighy ©2004 - 2006 4renx.com  .netBougie version 1.0
千山一鸟作品[[email protected]]";
??}
??private void writeOut(NameValueCollection nvc,HtmlTable ht)
??{
???for(int i=0;i???{
????HtmlTableRow tr=new HtmlTableRow();
????for(int j=0;j<2;j++)
????{
?????HtmlTableCell td=new HtmlTableCell();
?????td.InnerHtml=nvc.GetKey(i).ToString();
?????td.Width="20%";
?????HtmlTableCell td1=new HtmlTableCell();
?????td1.InnerHtml=nvc[i].ToString();
?????td1.Width="30%";
?????tr.Controls.Add(td);
?????tr.Controls.Add(td1);
?????i++;
????}
????ht.Controls.Add(tr);
???}
??}
??private bool checkObject(string obj)
??{
???try
???{
????object meobj = Server.CreateObject(obj);
????return(true);
???}
???catch
???{
????return(false);
???}
??}

??#region Web Form Designer generated code
??override protected void OnInit(EventArgs e)
??{
???//
???// CODEGEN:该调用是 ASP.NET Web 窗体设计器所必需的。
???//
???InitializeComponent();
???base.OnInit(e);
??}
??
??///


??/// 设计器支持所需的方法 - 不要使用代码编辑器修改
??/// 此方法的内容。
??///

??private void InitializeComponent()
??{???
???this.OK1.Click += new System.EventHandler(this.OK1_Click);
???this.OK2.Click += new System.EventHandler(this.OK2_Click);
???this.Load += new System.EventHandler(this.Page_Load);

??}
??#endregion

??private void OK1_Click(object sender, System.EventArgs e)
??{
???if(checkObject(newCom.Text))
???{
????resultCom.Text="√";
???}
???else
???{
????resultCom.Text="×";
???}
??}

??private void OK2_Click(object sender, System.EventArgs e)
??{
???try
???{
????int sum=0;
????int newData=Convert.ToInt32(newExec.Text.Trim());
????DateTime startTime=DateTime.Now;
????for(int i=0;i????{
?????sum+=i;
????}
????DateTime endTime=DateTime.Now;
????resultAdd.Text=((endTime-startTime).TotalMilliseconds).ToString()+"毫秒";
???}
???catch
???{
????resultAdd.Text="执行错误!可能是参数无效!";
???}
??}

?}
}

<%@ Page language="c#" Codebehind="Bougie.aspx.cs" AutoEventWireup="false" Inherits="Addr.Admin.Bougie" %>


?
??Bougie
??
??
??
??http://schemas.microsoft.com/intellisense/ie5">
??
??
?
?
??


???
????
?????
????
???
服务器信息

???
???

???
????
?????
????
???
组件支持信息

???
???

???
????
?????
????
???
客户端信息

???
???

???
????
?????
????
????
?????
?????
?????
?????
????
????
?????
?????
?????
?????
????
???
组件支持查询及执行效率查询
自定义组件查询 
??????
 
??????
 
??????
加法循环测试
???????
???????
 
??????10000000
 
??????
 
??????

???
????
?????
????
???

???
??

?

?

本文地址:http://com.8s8s.com/it/it44029.htm