예제 #1
0
        private void StartSimulating()
        {
            this.intercepting = false;
            var commands = new Dictionary <Regex, string>();

            foreach (var requestResponse in this.requestResponseDictionary)
            {
                var request  = requestResponse.Key;
                var response = requestResponse.Value;
                commands[new Regex(request)] = response;
            }

            var cryptoHandler = new ActiveCryptoHandler();

            cryptoHandler.WorkingKeyDefined += this.OnWorkingKeyDefined;
            var virtualDevice   = new SerialDevice(this.UxComboVirtualCom.Text);
            var simulatedDevice = new RegexSimulatedDevice(cryptoHandler, commands);

            simulatedDevice.RegexApplied   += this.OnRegexApplied;
            simulatedDevice.CorruptCommand += this.OnCorruptCommand;
            simulatedDevice.AbortRequested += this.OnAbort;

            this.interceptor           = new Interceptor(virtualDevice, simulatedDevice);
            this.interceptor.Request  += this.OnRequest;
            this.interceptor.Response += this.OnResponse;
        }
예제 #2
0
        static void ProcessSimulator(ArgReader argReader, string primarySerialPort)
        {
            var regexPatterns = RecoverRegexPatterns(argReader);
            var cryptoHandler = new ActiveCryptoHandler();

            cryptoHandler.WorkingKeyDefined += OnWorkingKeyDefined;
            var virtualDevice   = new SerialDevice(primarySerialPort);
            var simulatedDevice = new RegexSimulatedDevice(cryptoHandler, regexPatterns);

            simulatedDevice.RegexApplied   += OnRegexApplied;
            simulatedDevice.CorruptCommand += OnCorruptCommand;
            simulatedDevice.AbortRequested += OnAbort;

            var interceptor = new Interceptor(virtualDevice, simulatedDevice);

            interceptor.Request  += OnRequest;
            interceptor.Response += OnResponse;

            AppendLog("Started");
            Thread.Sleep(Timeout.Infinite);
        }