Beispiel #1
0
        private void TryImportExport(TriggernometryExport tex)
        {
            string warning        = "";
            bool   includesLaunch = HasLaunchTriggers(tex);
            bool   includesScript = HasScriptTriggers(tex);
            bool   includesWmsg   = HasWmsgTriggers(tex);

            BuildTreeFromExport(tex, null, null, false);
            treeView1.ExpandAll();
            if (includesLaunch == true || includesScript == true || includesWmsg == true)
            {
                if (includesLaunch == true)
                {
                    if (includesScript == true)
                    {
                        if (includesWmsg == true)
                        {
                            warning = I18n.Translate("internal/ImportForm/dangerprocscriptwmsg", "Some of the imported triggers include triggers which launch arbitrary processes, execute arbitrary scripts, and send arbitrary window messages. These triggers can be dangerous and malicious triggers may even compromise your system and security. The items in question have been highlighted below.");
                        }
                        else
                        {
                            warning = I18n.Translate("internal/ImportForm/dangerprocscript", "Some of the imported triggers include triggers which launch arbitrary processes and execute arbitrary scripts. These triggers can be dangerous and malicious triggers may even compromise your system and security. The items in question have been highlighted below.");
                        }
                    }
                    else
                    {
                        if (includesWmsg == true)
                        {
                            warning = I18n.Translate("internal/ImportForm/dangerprocwmsg", "Some of the imported triggers include triggers which launch arbitrary processes and send arbitrary window messages. These triggers can be dangerous and malicious triggers may even compromise your system and security. The items in question have been highlighted below.");
                        }
                        else
                        {
                            warning = I18n.Translate("internal/ImportForm/dangerproc", "Some of the imported triggers include triggers which launch arbitrary processes. These triggers can be dangerous and malicious triggers may even compromise your system and security. The items in question have been highlighted below.");
                        }
                    }
                }
                else if (includesScript == true)
                {
                    if (includesWmsg == true)
                    {
                        warning = I18n.Translate("internal/ImportForm/dangerscriptwmsg", "Some of the imported triggers include triggers which execute arbitrary scripts and send arbitrary window messages. These triggers can be dangerous and malicious triggers may even compromise your system and security. The items in question have been highlighted below.");
                    }
                    else
                    {
                        warning = I18n.Translate("internal/ImportForm/dangerscript", "Some of the imported triggers include triggers which execute arbitrary scripts. These triggers can be dangerous and malicious triggers may even compromise your system and security. The items in question have been highlighted below.");
                    }
                }
                else if (includesWmsg == true)
                {
                    warning = I18n.Translate("internal/ImportForm/dangerwmsg", "Some of the imported triggers include triggers which send arbitrary window messages. These triggers can be dangerous and malicious triggers may even compromise your system and security. The items in question have been highlighted below.");
                }
            }
            if (warning.Length > 0)
            {
                lblWarning.Text    = warning;
                lblWarning.Visible = true;
            }
        }
Beispiel #2
0
 internal void BuildTreeFromExport(TriggernometryExport tex, TreeNode parentnode, Folder parentfolder, bool isRemote)
 {
     if (parentfolder == null)
     {
         TreeNode tn = new TreeNode();
         treeView1.Nodes.Add(tn);
         if (tex.ExportedFolder != null)
         {
             tn.ImageIndex         = 0;
             tn.SelectedImageIndex = 0;
             tn.Text    = tex.ExportedFolder.Name;
             tn.Checked = tex.ExportedFolder.Enabled;
             tn.Tag     = tex.ExportedFolder;
             BuildTreeFromExport(tex, tn, tex.ExportedFolder, isRemote);
             return;
         }
         else
         {
             tn.ImageIndex         = 2;
             tn.SelectedImageIndex = 2;
             tn.Text    = tex.ExportedTrigger.Name;
             tn.Checked = tex.ExportedTrigger.Enabled;
             tn.Tag     = tex.ExportedTrigger;
             return;
         }
     }
     foreach (Folder f in parentfolder.Folders)
     {
         TreeNode tn = new TreeNode();
         tn.Text               = f.Name;
         tn.Checked            = f.Enabled;
         tn.Tag                = f;
         tn.ImageIndex         = 0;
         tn.SelectedImageIndex = 0;
         parentnode.Nodes.Add(tn);
         f.Parent = parentfolder;
         BuildTreeFromExport(tex, tn, f, isRemote);
     }
     foreach (Trigger t in parentfolder.Triggers)
     {
         TreeNode tn = new TreeNode();
         tn.Text               = t.Name;
         tn.Checked            = t.Enabled;
         tn.Tag                = t;
         tn.ImageIndex         = 2;
         tn.SelectedImageIndex = 2;
         if ((IsLaunchTrigger(t) == true || IsScriptTrigger(t) == true || IsWmsgTrigger(t) == true) && isRemote == false)
         {
             tn.BackColor = Color.Yellow;
         }
         parentnode.Nodes.Add(tn);
         t.Parent = parentfolder;
     }
 }
Beispiel #3
0
 private bool HasLaunchTriggers(TriggernometryExport tex)
 {
     return(tex.ExportedFolder != null ? HasLaunchTriggers(tex.ExportedFolder) : IsLaunchTrigger(tex.ExportedTrigger));
 }
Beispiel #4
0
 private void TryImportText()
 {
     try
     {
         TriggernometryExport tex = TriggernometryExport.Unserialize(importData);
         if (tex != null)
         {
             TryImportExport(tex);
             return;
         }
     }
     catch (Exception)
     {
     }
     try
     {
         TriggernometryExport tex = TriggernometryExport.Unserialize(WebUtility.HtmlDecode(importData));
         if (tex != null)
         {
             TryImportExport(tex);
             return;
         }
     }
     catch (Exception)
     {
     }
     try
     {
         string nex = "<ActWrapper>" + importData + "</ActWrapper>";
         TryImportActWrapper(nex);
         return;
     }
     catch (Exception)
     {
     }
     try
     {
         string nex = "&lt;ActWrapper&gt;" + importData + "&lt;/ActWrapper&gt;";
         TryImportActWrapper(WebUtility.HtmlDecode(nex));
         return;
     }
     catch (Exception)
     {
     }
     try
     {
         Configuration cfg = null;
         XmlSerializer xs  = new XmlSerializer(typeof(Configuration));
         using (MemoryStream ms = new MemoryStream(UTF8Encoding.UTF8.GetBytes(importData)))
         {
             cfg = (Configuration)xs.Deserialize(ms);
             TriggernometryExport tex = new TriggernometryExport();
             tex.ExportedFolder      = cfg.Root;
             tex.ExportedFolder.Name = I18n.Translate("internal/ImportForm/importedconfigfile", "Imported configuration file ({0})", DateTime.Now);
             tex.ExportedTrigger     = null;
             TryImportExport(tex);
             return;
         }
     }
     catch (Exception)
     {
     }
     try
     {
         Configuration cfg = null;
         XmlSerializer xs  = new XmlSerializer(typeof(Configuration));
         using (MemoryStream ms = new MemoryStream(UTF8Encoding.UTF8.GetBytes(WebUtility.HtmlDecode(importData))))
         {
             cfg = (Configuration)xs.Deserialize(ms);
             TriggernometryExport tex = new TriggernometryExport();
             tex.ExportedFolder      = cfg.Root;
             tex.ExportedFolder.Name = I18n.Translate("internal/ImportForm/importedconfigfile", "Imported configuration file ({0})", DateTime.Now);
             tex.ExportedTrigger     = null;
             TryImportExport(tex);
             return;
         }
     }
     catch (Exception)
     {
     }
     throw new Exception(I18n.Translate("internal/ImportForm/importcantrecognize", "Can't recognize the provided data as any valid, importable format. You may be trying to import newer triggers to an older version of Triggernometry. Make sure you are using the latest version."));
 }