Пример #1
0
        public ProxyUDPSocketService(IPEndPoint src, IPEndPoint dest, string output, string format, bool modify)
            : base(src)
        {
            this.src    = src;
            this.dest   = dest;
            this.modify = modify;

            try
            {
                if (format.Equals("asciibin"))
                {
                    writer = new HexLogWriter();
                    writer.Open(output, "w");
                }
                else if (format.Equals("json"))
                {
                    writer = new JSONLogWriter();
                    writer.Open(output, "w");
                }
            }
            catch (System.IO.IOException ioe)
            {
                Console.WriteLine("Error opening output {0} for writing (logging disabled): {1}", output, ioe.Message);
            }
        }
Пример #2
0
        public int ProcessData()
        {
            int ret = SetDecryptor(decrypto.dll);

            if (ret != 0)
            {
                return(ret);
            }
            if (decrypto.format.Equals("json"))
            {
                var    output      = new IntPtr();
                var    output_size = 0;
                string sender      = "";
                reader = new JSONLogWriter();
                reader.Open(decrypto.input, "r");
                Transmissions trans = reader.ReadTransmission();
                foreach (LogEvent e in trans.LogEventList)
                {
                    try
                    {
                        if (e.sender == CLIENT)
                        {
                            sender = "client";
                        }
                        else
                        {
                            sender = "server";
                        }
                        Console.WriteLine("sender: {0} packet: {1} length: {2}", sender, e.count, e.data.Length);
                        Decrypt.Decrypt(e.sender, e.data, e.data.Length, e.count, ref output, ref output_size);
                        byte[] decrypted = new byte[output_size];
                        Marshal.Copy(output, decrypted, 0, output_size);
                        Console.WriteLine("\nAfter decrypt: {0}", Encoding.ASCII.GetString(decrypted));
                        Console.WriteLine("--------------------------------------");
                        if (writer != null)
                        {
                            writer.LogTransmission(decrypted, sender, e.count);
                        }
                    }
                    finally
                    {
                        if (output != IntPtr.Zero)
                        {
                            Marshal.FreeCoTaskMem(output);
                        }
                    }
                }
            }

            return(0);
        }
Пример #3
0
 public DecryptFileProcessor(DecryptOptions decrypto)
 {
     this.decrypto = decrypto;
     if (!this.decrypto.output.Equals(""))
     {
         if (this.decrypto.outputformat.Equals("json"))
         {
             writer = new JSONLogWriter();
         }
         else if (this.decrypto.outputformat.Equals("asciibin"))
         {
             writer = new HexLogWriter();
         }
         else
         {
             Console.WriteLine("Error only asciibin and json supported!");
             return;
         }
         writer.Open(this.decrypto.output, "w");
     }
 }