Exemple #1
0
        public void PreExecution()
        {
            isrunning = true;

            running = false;
            stopped = false;

            if (enigmaPresentationFrame.EnigmaPresentation.checkReady())
            {
                enigmaPresentationFrame.EnigmaPresentation.stopclick(this, EventArgs.Empty);
            }
            EventsHelper.GuiLogMessage(OnGuiLogNotificationOccured, this, new GuiLogEventArgs("Preparing enigma for operation..", this, NotificationLevel.Info));

            if (settings.Model != 3 && settings.Model != 2)
            {
                EventsHelper.GuiLogMessage(OnGuiLogNotificationOccured, this, new GuiLogEventArgs("This simulator is work in progress. As of right now only Enigma I and Enigma Reichsbahn (Rocket) is supported!!", this, NotificationLevel.Warning));
                return;
            }

            // remember the current key-setting, in order to restore on stop
            savedKey = settings.Key;

            //configure the enigma
            core.setInternalConfig(settings.Rotor1, settings.Rotor2, settings.Rotor3, settings.Rotor4,
                                   settings.Reflector, settings.Ring1, settings.Ring2, settings.Ring3, settings.Ring4,
                                   settings.PlugBoard);
        }
Exemple #2
0
        public void Execute()
        {
            if (!string.IsNullOrEmpty(inputString))
            {
                if (settings.StickSize < 1)
                {
                    EventsHelper.GuiLogMessage(OnGuiLogNotificationOccured, this, new GuiLogEventArgs("Got an invalid stick size of " + settings.StickSize + "! Reverting to 1.", this, NotificationLevel.Warning));
                    settings.StickSize = 1;
                }
                
                //remove line breaks since they do not make any sense in the scytale
                inputString = inputString.Replace("\r", "").Replace("\n","");

                Progress(0,1);
                
                switch (settings.Action)
                {
                    case 0:
                        OutputString = Encrypt(inputString, settings.StickSize);
                        break;
                    case 1:
                        OutputString = Decrypt(inputString, settings.StickSize);
                        break;
                    default:
                        break;
                }

                Progress(1,1);
            }
        }
Exemple #3
0
        private void CreateRSAKey()
        {
            CspParameters parameters = new CspParameters();

            parameters.KeyContainerName    = "Container";
            this._rsaCryptoServiceProvider = new RSACryptoServiceProvider(parameters);
            EventsHelper.GuiLogMessage(OnGuiLogNotificationOccured, this, new GuiLogEventArgs("Key pair created", this, NotificationLevel.Info));
        }
Exemple #4
0
 private void GuiLogMessage(string message, NotificationLevel logLevel)
 {
     EventsHelper.GuiLogMessage(OnGuiLogNotificationOccured, this, new GuiLogEventArgs(message, this, logLevel));
     //if (OnGuiLogNotificationOccured != null)
     //{
     //  OnGuiLogNotificationOccured(this, new GuiLogEventArgs(message, this, logLevel));
     //}
 }
Exemple #5
0
 private string ExportPublicKey()
 {
     if (this._rsaCryptoServiceProvider != null)
     {
         EventsHelper.GuiLogMessage(OnGuiLogNotificationOccured, this, new GuiLogEventArgs("Public key exported", this, NotificationLevel.Info));
         return(this._rsaCryptoServiceProvider.ToXmlString(false));
     }
     return("");
 }
Exemple #6
0
 private bool Compiled()
 {
     if (this._serviceDescription == null)
     {
         EventsHelper.GuiLogMessage(OnGuiLogNotificationOccured, this, new GuiLogEventArgs("There is no Web Service Description available", this, NotificationLevel.Error));
         return(false);
     }
     return(true);
 }
Exemple #7
0
        private void SetSearchStructure()
        {
            try
            {
                stringSearch = null;
                hashTable    = null;

                if (dictionaryInputString != null && inputString != null)
                {
                    if (settings.Search == ContainsSettings.SearchType.AhoCorasick)
                    {
                        // if DicDelimiter is set we have to split the input string
                        if (settings.DelimiterDictionary.Length == 1)
                        {
                            stringSearch = new StringSearch(dictionaryInputString.Split(settings.DelimiterDictionary[0]));
                        }
                        else
                        {
                            string[] arr = new string[1];
                            arr[0]       = dictionaryInputString;
                            stringSearch = new StringSearch(arr);
                        }
                    }
                    else if (settings.Search == ContainsSettings.SearchType.Hashtable)
                    {
                        hashTable = new Hashtable();
                        string[] theWords = null;
                        if (settings.DelimiterDictionary.Length == 1)
                        {
                            theWords = dictionaryInputString.Split(settings.DelimiterDictionary[0]);
                        }
                        else
                        {
                            theWords    = new string[1];
                            theWords[0] = dictionaryInputString;
                        }

                        foreach (string item in theWords)
                        {
                            string tmp = item;
                            //if( settings.IgnoreDiacritics ) tmp = RemoveDiacritics(item);
                            if (!hashTable.ContainsKey(tmp))
                            {
                                hashTable.Add(tmp, null);
                            }
                        }
                    }
                }
            }
            catch (Exception exception)
            {
                EventsHelper.GuiLogMessage(OnGuiLogNotificationOccured, this, new GuiLogEventArgs(exception.Message, this, NotificationLevel.Error));
                EventsHelper.GuiLogMessage(OnGuiLogNotificationOccured, this, new GuiLogEventArgs(exception.StackTrace, this, NotificationLevel.Error));
            }
        }
Exemple #8
0
 private void GuiLogMessage(string message, NotificationLevel logLevel, bool createLogOrChangeBackground)
 {
     if (createLogOrChangeBackground)
     {
         EventsHelper.GuiLogMessage(OnGuiLogNotificationOccured, this, new GuiLogEventArgs(message, this, logLevel));
     }
     else
     {
         lFSRPresentation.ChangeBackground(logLevel);
     }
 }
Exemple #9
0
 private void GuiLogMessage(string message, NotificationLevel logLevel)
 {
     EventsHelper.GuiLogMessage(OnGuiLogNotificationOccured, this, message, logLevel);
 }
Exemple #10
0
 public void createInfoMessage(string text)
 {
     EventsHelper.GuiLogMessage(OnGuiLogNotificationOccured, this, new GuiLogEventArgs(text, this, NotificationLevel.Info));
 }
Exemple #11
0
 private void ShowStatusBarMessage(string message, NotificationLevel logLevel)
 {
     EventsHelper.GuiLogMessage(OnGuiLogNotificationOccured, this, new GuiLogEventArgs(message, this, logLevel));
 }
Exemple #12
0
 /// <summary>
 /// Logs a message to the Cryptool console
 /// </summary>
 public void LogMessage(string msg, NotificationLevel level)
 {
     EventsHelper.GuiLogMessage(OnGuiLogNotificationOccured, this, new GuiLogEventArgs(msg, this, level));
 }
 protected void LogDebug(String msg) => EventsHelper.GuiLogMessage(this.OnGuiLogNotificationOccured, this, new GuiLogEventArgs(msg, this, NotificationLevel.Debug));
Exemple #14
0
 private void GuiMessage(string message, NotificationLevel level)
 {
     EventsHelper.GuiLogMessage(OnGuiLogNotificationOccured, this, new GuiLogEventArgs(message, this, level));
 }
Exemple #15
0
        public void Execute()
        {
            try
            {
                List <StringSearchResult> listReturn = new List <StringSearchResult>();
                string[]      arrSearch  = null;
                List <string> wordsFound = new List <string>();

                if (InputString != null && DictionaryInputString != null)
                {
                    if (settings.Search == ContainsSettings.SearchType.AhoCorasick && stringSearch != null)
                    {
                        listReturn.AddRange(stringSearch.FindAll(InputString));
                    }
                    else if (settings.Search == ContainsSettings.SearchType.Hashtable && hashTable != null)
                    {
                        if (settings.DelimiterInputString != null && settings.DelimiterInputString.Length == 1)
                        {
                            arrSearch = InputString.Split(settings.DelimiterInputString[0]);
                        }
                        if (arrSearch != null)
                        {
                            for (int i = 0; i < arrSearch.Length; i++)
                            {
                                string s = arrSearch[i];
                                if (settings.IgnoreDiacritics)
                                {
                                    s = RemoveDiacritics(s);
                                }

                                if (hashTable.ContainsKey(arrSearch[i]))
                                {
                                    if (settings.CountWordsOnlyOnce)
                                    {
                                        if (!wordsFound.Contains(arrSearch[i]))
                                        {
                                            wordsFound.Add(arrSearch[i]);
                                            listReturn.Add(new StringSearchResult(i, arrSearch[i]));
                                        }
                                    }
                                    else
                                    {
                                        listReturn.Add(new StringSearchResult(i, arrSearch[i]));
                                    }
                                }
                            }
                        }
                        else
                        {
                            if (hashTable.ContainsKey(InputString))
                            {
                                listReturn.Add(new StringSearchResult(0, InputString));
                            }
                        }
                    }


                    HitCount = listReturn.Count;
                    Result   = (HitCount >= settings.Hits);

                    double percentage = HitCount * 100.0 / settings.Hits;

                    // set target-hits bases on current setting
                    presentation.TargetHits = (settings.HitPercentFromInputString && arrSearch != null) ? (int)percentage : settings.Hits;
                    presentation.SetData(listReturn.ToArray());

                    //ProgressChanged(Math.Min(percentage, 100.0), 100);
                    ProgressChanged(100, 100);
                }
                else
                {
                    foreach (KeyValuePair <string, NotificationLevel> kvp in dicWarningsAndErros)
                    {
                        EventsHelper.GuiLogMessage(OnGuiLogNotificationOccured, this, new GuiLogEventArgs(kvp.Key, this, kvp.Value));
                    }
                    dicWarningsAndErros.Clear();
                    if (InputString == null)
                    {
                        EventsHelper.GuiLogMessage(OnGuiLogNotificationOccured, this, new GuiLogEventArgs(Properties.Resources.no_input_string, this, NotificationLevel.Error));
                    }
                    if (DictionaryInputString == null)
                    {
                        EventsHelper.GuiLogMessage(OnGuiLogNotificationOccured, this, new GuiLogEventArgs(Properties.Resources.no_dictionary, this, NotificationLevel.Error));
                    }
                }
            }
            catch (Exception exception)
            {
                EventsHelper.GuiLogMessage(OnGuiLogNotificationOccured, this, new GuiLogEventArgs(exception.Message, this, NotificationLevel.Error));
            }
        }
Exemple #16
0
 protected void GuiLogMessage(string message, NotificationLevel logLevel)
 {
     EventsHelper.GuiLogMessage(OnGuiLogNotificationOccured, this, new GuiLogEventArgs(message, this, logLevel));
 }
Exemple #17
0
 /// <summary>
 /// Handles log messages from the settings class
 /// </summary>
 private void Lorenz_LogMessage(string msg, NotificationLevel loglevel)
 {
     EventsHelper.GuiLogMessage(OnGuiLogNotificationOccured, this, new GuiLogEventArgs(msg, this, loglevel));
 }
Exemple #18
0
 // catches LogNotification from settings
 private void settings_OnGuiLogNotificationOccured(IPlugin sender, GuiLogEventArgs args)
 {
     EventsHelper.GuiLogMessage(OnGuiLogNotificationOccured, this, new GuiLogEventArgs(args.Message, this, args.NotificationLevel));
 }
Exemple #19
0
 private static void GuiLogMessage(string message, NotificationLevel logLevel)
 {
     EventsHelper.GuiLogMessage(OnGuiLogNotificationOccured, null, new GuiLogEventArgs(message, null, logLevel));
 }
Exemple #20
0
        private void CheckSoap()
        {
            bool signatureValid = true;

            this.Compiled();
            if (this._inputDocument == null)
            {
                return;
            }
            if (this._inputDocument.GetElementsByTagName("ds:Signature") != null)
            {
                this._validator = new SignatureValidator(this);
            }
            signatureValid = this._validator.Valid;
            object invokedObject = new object();

            object[] parameters = null;
            string   response;

            if (this._serviceDescription == null)
            {
                EventsHelper.GuiLogMessage(OnGuiLogNotificationOccured, this, new GuiLogEventArgs("There is no Web Service Description available", this, NotificationLevel.Error));
            }
            else
            {
                if (!signatureValid)
                {
                    EventsHelper.GuiLogMessage(OnGuiLogNotificationOccured, this, new GuiLogEventArgs("Signature validation failed", this, NotificationLevel.Error));
                    goto Abort;
                }

                Types types = this._serviceDescription.Types;
                PortTypeCollection   portTypes         = this._serviceDescription.PortTypes;
                MessageCollection    messages          = this._serviceDescription.Messages;
                PortType             porttype          = portTypes[0];
                Operation            operation         = porttype.Operations[0];
                OperationOutput      output            = operation.Messages[0].Operation.Messages.Output;
                OperationInput       input             = operation.Messages[0].Operation.Messages.Input;
                Message              messageOutput     = messages[output.Message.Name];
                Message              messageInput      = messages[input.Message.Name];
                MessagePart          messageOutputPart = messageOutput.Parts[0];
                MessagePart          messageInputPart  = messageInput.Parts[0];
                XmlSchema            xmlSchema         = types.Schemas[0];
                XmlSchemaElement     outputSchema      = (XmlSchemaElement)xmlSchema.Elements[messageOutputPart.Element];
                XmlSchemaElement     inputSchema       = (XmlSchemaElement)xmlSchema.Elements[messageInputPart.Element];
                XmlSchemaComplexType complexTypeOutput = (XmlSchemaComplexType)outputSchema.SchemaType;
                XmlSchemaSequence    sequenzTypeOutput = (XmlSchemaSequence)complexTypeOutput.Particle;
                XmlSchemaComplexType complexTypeInput  = (XmlSchemaComplexType)inputSchema.SchemaType;
                XmlSchemaSequence    sequenzTypeInput  = (XmlSchemaSequence)complexTypeInput.Particle;
                Hashtable            paramTypesTable   = new Hashtable();
                StringWriter         xmlStringWriter   = new StringWriter();
                xmlSchema.Write(xmlStringWriter);
                this._set = new DataSet();
                StringReader  sreader   = new StringReader(xmlStringWriter.ToString());
                XmlTextReader xmlreader = new XmlTextReader(sreader);
                this._set.ReadXmlSchema(xmlreader);
                if (sequenzTypeInput != null)
                {
                    foreach (XmlSchemaElement inputParam in sequenzTypeInput.Items)
                    {
                        XmlQualifiedName schemaName = inputParam.SchemaTypeName;
                        paramTypesTable.Add(inputParam.QualifiedName.Name, schemaName.Name);
                    }

                    XmlNamespaceManager manager = new XmlNamespaceManager(this._modifiedInputDocument.NameTable);
                    XmlElement          body    = (XmlElement)this._inputDocument.GetElementsByTagName("s:Body")[0];
                    manager.AddNamespace("s", body.NamespaceURI);
                    manager.AddNamespace("tns", "http://tempuri.org/");
                    XmlNode    node         = this._modifiedInputDocument.SelectSingleNode("s:Envelope/s:Body/" + "tns:" + this._set.Tables[0].TableName, manager);
                    XmlElement ele          = (XmlElement)node;
                    int        paramCounter = new Int32();
                    try
                    {
                        paramCounter = ele.ChildNodes.Count;
                    }

                    catch
                    {
                        EventsHelper.GuiLogMessage(OnGuiLogNotificationOccured, this, new GuiLogEventArgs("Some params are missing", this, NotificationLevel.Error));
                    }
                    if (paramCounter != 0)
                    {
                        parameters = new Object[paramCounter];

                        for (int i = 0; i < paramCounter; i++)
                        {
                            string param     = ele.ChildNodes[i].InnerText;
                            Object paramType = paramTypesTable[ele.ChildNodes[i].LocalName];
                            if (paramType.ToString().Equals("int"))
                            {
                                if (!ele.ChildNodes[i].InnerText.Equals(""))
                                {
                                    try
                                    {
                                        parameters[i] = Convert.ToInt32((Object)ele.ChildNodes[i].InnerText);
                                    }
                                    catch (Exception e)
                                    {
                                        EventsHelper.GuiLogMessage(OnGuiLogNotificationOccured, this, new GuiLogEventArgs(e.Message, this, NotificationLevel.Error));
                                        goto Abort;
                                    }
                                }
                                else
                                {
                                    if (ele.ChildNodes[i].Name != null)
                                    {
                                        EventsHelper.GuiLogMessage(OnGuiLogNotificationOccured, this, new GuiLogEventArgs("Parameter " + ele.ChildNodes[i].Name + " is missing", this, NotificationLevel.Error));
                                    }
                                    goto Abort;
                                }
                            }
                            if (paramType.ToString().Equals("string"))
                            {
                                if (!ele.ChildNodes[i].InnerText.Equals(""))
                                {
                                    try
                                    {
                                        parameters[i] = Convert.ToString((Object)ele.ChildNodes[i].InnerText);
                                    }
                                    catch (Exception e)
                                    {
                                        EventsHelper.GuiLogMessage(OnGuiLogNotificationOccured, this, new GuiLogEventArgs(e.Message, this, NotificationLevel.Error));
                                        goto Abort;
                                    }
                                }
                                else
                                {
                                    if (ele.ChildNodes[i].Name != null)
                                    {
                                        EventsHelper.GuiLogMessage(OnGuiLogNotificationOccured, this, new GuiLogEventArgs("Parameter " + ele.ChildNodes[i].Name + " is missing", this, NotificationLevel.Error));
                                    }
                                    goto Abort;
                                }
                            }
                            if (paramType.ToString().Equals("double"))
                            {
                                if (!ele.ChildNodes[i].InnerText.Equals(""))
                                {
                                    try
                                    {
                                        parameters[i] = Convert.ToDouble((Object)ele.ChildNodes[i].InnerText);
                                    }
                                    catch (Exception e)
                                    {
                                        EventsHelper.GuiLogMessage(OnGuiLogNotificationOccured, this, new GuiLogEventArgs(e.Message, this, NotificationLevel.Error));
                                        goto Abort;
                                    }
                                }
                                else
                                {
                                    if (ele.ChildNodes[i].Name != null)
                                    {
                                        EventsHelper.GuiLogMessage(OnGuiLogNotificationOccured, this, new GuiLogEventArgs("Parameter " + ele.ChildNodes[i].Name + " is missing", this, NotificationLevel.Error));
                                    }
                                    goto Abort;
                                }
                            }
                        }
                        for (int i = 0; i < parameters.Length; i++)
                        {
                            if (parameters[i] == null)
                            {
                                goto Abort;
                            }
                        }
                        try
                        {
                            Type   typ        = this._service.GetType().GetMethod(operation.Name).ReturnType;
                            string returnType = typ.ToString();
                            if (!returnType.Equals("System.Void"))
                            {
                                invokedObject = this._service.GetType().GetMethod(operation.Name).Invoke(this._service, parameters).ToString();
                            }
                            else
                            {
                                this._service.GetType().GetMethod(operation.Name).Invoke(this._service, parameters).ToString();
                            }
                        }
                        catch (Exception e)
                        {
                            EventsHelper.GuiLogMessage(OnGuiLogNotificationOccured, this, new GuiLogEventArgs(e.Message, this, NotificationLevel.Error));
                            goto Abort;
                        }
                    }
                    else
                    {
                        if (sequenzTypeOutput != null)
                        {
                            try
                            {
                                invokedObject = this._service.GetType().GetMethod(operation.Name).Invoke(this._service, null).ToString();
                            }
                            catch (Exception e)
                            {
                                EventsHelper.GuiLogMessage(OnGuiLogNotificationOccured, this, new GuiLogEventArgs(e.Message, this, NotificationLevel.Error));
                                goto Abort;
                            }
                        }
                        else
                        {
                            this._service.GetType().GetMethod(operation.Name).Invoke(this._service, parameters);
                        }
                    }
                    response = invokedObject.ToString();
                    this.CreateResponse(response);
                }
            }
            Abort :;
        }
Exemple #21
0
 private void GuiLogMessage(string p, NotificationLevel notificationLevel)
 {
     EventsHelper.GuiLogMessage(OnGuiLogNotificationOccured, this, new GuiLogEventArgs(p, this, notificationLevel));
 }
Exemple #22
0
 public void ShowWarning(string message)
 {
     EventsHelper.GuiLogMessage(OnGuiLogNotificationOccured, this, new GuiLogEventArgs(message, this, NotificationLevel.Warning));
 }