private static void Main(string[] args) { var si = new SecureInstance(@"..\..\..\Evil\bin\Debug", "Evil", "Evil.MyCode", typeof (ITest)); si.CallMethode<object>("MyMethode", null); si.Close(); Console.WriteLine("[C#-Security] You're done."); Console.ReadKey(); }
private static void Main(string[] args) { if (args.Length > 6) { _path = args[1]; _assemblyName = args[2]; _typeName = args[3]; _iface = Type.GetType(args[4]); _maxMethodeTime = Int64.Parse(args[5]); _maxMemoryUsage = Int64.Parse(args[6]); /* Console.WriteLine("path = " + path); Console.WriteLine("assemblyName = " + assemblyName); Console.WriteLine("typeName = " + typeName); Console.WriteLine("iface = " + iface); Console.WriteLine("maxMethodeTime = " + maxMethodeTime); Console.WriteLine("maxMemoryUsage = " + maxMemoryUsage); */ using (var pipeStream = new NamedPipeClientStream(".", args[0], PipeDirection.InOut)) { try { pipeStream.Connect(); var t = new Thread(WatchDog); t.Start(); Console.WriteLine("[SecureInstanceRunner] Pipe connection established"); _outStream = new StreamWriter(pipeStream); _inStream = new StreamReader(pipeStream); _outStream.AutoFlush = true; string msg = "READY"; try { _secureInstance = new SecureInstance(_path, _assemblyName, _typeName, _iface, _maxMethodeTime); } catch (SecurityException) { msg = "FAIL"; } CheckThreads(); _outStream.WriteLine(msg); Console.WriteLine("[SecureInstanceRunner] Constructor called. Waiting for methode calls."); string temp; string command = ""; while ((temp = _inStream.ReadLine()) != null) { if (temp == "QUIT") { break; } if (temp == "SYNC") { ProcessCommand(command); command = ""; Console.WriteLine("[SecureInstanceRunner] Methode called. Waiting for methode calls."); } else { command = command + temp + "\n"; } } } catch (OutOfMemoryException) { _outStream.WriteLine("FAIL"); } _watchdogAlive = false; Console.WriteLine("[SecureInstanceRunner] Bye!"); } Process.GetCurrentProcess().Kill(); Environment.Exit(-1); } }