예제 #1
0
        public void TestExitEarlyFault2()
        {
            Variant foo = new Variant("foo");

            // FaultOnEarlyExit faults when StartOnCall is used and stop message is not sent

            Dictionary <string, Variant> args = new Dictionary <string, Variant>();

            args["Command"]          = new Variant("echo");
            args["Arguments"]        = new Variant("hello");
            args["StartOnCall"]      = foo;
            args["FaultOnEarlyExit"] = new Variant("true");

            CrashWrangler w = new CrashWrangler(null, "name", args);

            w.SessionStarting();
            w.IterationStarting(1, false);

            w.Message("Action.Call", foo);

            System.Threading.Thread.Sleep(1000);

            w.IterationFinished();

            Assert.AreEqual(true, w.DetectedFault());
            Fault f = w.GetMonitorData();

            Assert.NotNull(f);
            Assert.AreEqual("ProcessExitedEarly", f.folderName);


            w.SessionFinished();
            w.StopMonitor();
        }
예제 #2
0
        public void TestStartOnCall()
        {
            Variant foo = new Variant("foo");

            Dictionary <string, Variant> args = new Dictionary <string, Variant>();

            args["Command"]            = new Variant("nc");
            args["Arguments"]          = new Variant("-l 12345");
            args["StartOnCall"]        = foo;
            args["WaitForExitTimeout"] = new Variant("2000");
            args["NoCpuKill"]          = new Variant("true");

            CrashWrangler w = new CrashWrangler(null, "name", args);

            w.Message("Action.Call", foo);
            Thread.Sleep(1000);

            var before = DateTime.Now;

            w.IterationFinished();
            var after = DateTime.Now;

            var span = (after - before);

            Assert.AreEqual(false, w.DetectedFault());

            w.SessionFinished();
            w.StopMonitor();

            Assert.GreaterOrEqual(span.TotalSeconds, 1.8);
            Assert.LessOrEqual(span.TotalSeconds, 2.2);
        }
예제 #3
0
        public void TestGetData()
        {
            Dictionary <string, Variant> args = new Dictionary <string, Variant>();

            args["Command"] = new Variant("CrashingProgram");

            System.Environment.SetEnvironmentVariable("PEACH", "qwertyuiopasdfghjklzxcvbnmqwertyuio");

            CrashWrangler w = new CrashWrangler(null, "name", args);

            w.SessionStarting();
            w.IterationStarting(0, false);
            Thread.Sleep(1000);
            w.IterationFinished();
            Assert.AreEqual(true, w.DetectedFault());
            Fault fault = w.GetMonitorData();

            Assert.NotNull(fault);
            Assert.AreEqual(1, fault.collectedData.Count);
            Assert.True(fault.collectedData.ContainsKey("Log"));
            Assert.Greater(fault.collectedData["Log"].Length, 0);
            Assert.True(fault.description.StartsWith("Exploitable_Crash_0x"));
            w.SessionFinished();
            w.StopMonitor();
        }
예제 #4
0
        public void TestExitEarlyFault3()
        {
            Variant foo = new Variant("foo");

            // FaultOnEarlyExit doesn't fault when StartOnCall is used

            Dictionary <string, Variant> args = new Dictionary <string, Variant>();

            args["Command"]          = new Variant("nc");
            args["Arguments"]        = new Variant("-l 12345");
            args["StartOnCall"]      = foo;
            args["FaultOnEarlyExit"] = new Variant("true");

            CrashWrangler w = new CrashWrangler(null, "name", args);

            w.SessionStarting();
            w.IterationStarting(1, false);

            w.Message("Action.Call", foo);

            w.IterationFinished();

            Assert.AreEqual(false, w.DetectedFault());

            w.SessionFinished();
            w.StopMonitor();
        }
예제 #5
0
        public void TestExitEarlyFault1()
        {
            Variant foo = new Variant("foo");
            Variant bar = new Variant("bar");

            // FaultOnEarlyExit doesn't fault when stop message is sent

            Dictionary <string, Variant> args = new Dictionary <string, Variant>();

            args["Command"]           = new Variant("echo");
            args["Arguments"]         = new Variant("hello");
            args["StartOnCall"]       = foo;
            args["WaitForExitOnCall"] = bar;
            args["FaultOnEarlyExit"]  = new Variant("true");

            CrashWrangler w = new CrashWrangler(null, "name", args);

            w.SessionStarting();
            w.IterationStarting(1, false);

            w.Message("Action.Call", foo);
            w.Message("Action.Call", bar);

            w.IterationFinished();

            Assert.AreEqual(false, w.DetectedFault());

            w.SessionFinished();
            w.StopMonitor();
        }
예제 #6
0
        public void TestExitEarlyFault()
        {
            Dictionary <string, Variant> args = new Dictionary <string, Variant>();

            args["Command"]          = new Variant("echo");
            args["Arguments"]        = new Variant("hello");
            args["FaultOnEarlyExit"] = new Variant("true");

            CrashWrangler w = new CrashWrangler(null, "name", args);

            w.IterationStarting(1, false);

            System.Threading.Thread.Sleep(1000);

            w.IterationFinished();

            Assert.AreEqual(true, w.DetectedFault());
            Fault f = w.GetMonitorData();

            Assert.NotNull(f);
            Assert.AreEqual("ProcessExitedEarly", f.folderName);

            w.SessionFinished();
            w.StopMonitor();
        }
예제 #7
0
        public void TestExitTime()
        {
            Dictionary <string, Variant> args = new Dictionary <string, Variant>();

            args["Command"]           = new Variant("nc");
            args["Arguments"]         = new Variant("-l 12345");
            args["RestartOnEachTest"] = new Variant("true");

            CrashWrangler w = new CrashWrangler(null, "name", args);

            w.SessionStarting();
            w.IterationStarting(1, false);

            var before = DateTime.Now;

            w.IterationFinished();
            var after = DateTime.Now;

            var span = (after - before);

            Assert.AreEqual(false, w.DetectedFault());

            w.SessionFinished();
            w.StopMonitor();

            Assert.GreaterOrEqual(span.TotalSeconds, 0.0);
            Assert.LessOrEqual(span.TotalSeconds, 0.1);
        }
예제 #8
0
        public void TestExitOnCallFault()
        {
            Variant foo = new Variant("foo");
            Variant bar = new Variant("bar");

            Dictionary <string, Variant> args = new Dictionary <string, Variant>();

            args["Command"]            = new Variant("nc");
            args["Arguments"]          = new Variant("-l 12345");
            args["StartOnCall"]        = foo;
            args["WaitForExitOnCall"]  = bar;
            args["WaitForExitTimeout"] = new Variant("2000");
            args["NoCpuKill"]          = new Variant("true");

            CrashWrangler w = new CrashWrangler(null, "name", args);

            w.Message("Action.Call", foo);
            w.Message("Action.Call", bar);

            w.IterationFinished();

            Assert.AreEqual(true, w.DetectedFault());
            Fault f = w.GetMonitorData();

            Assert.NotNull(f);
            Assert.AreEqual("ProcessFailedToExit", f.folderName);

            w.SessionFinished();
            w.StopMonitor();
        }
예제 #9
0
        public void TestExitOnCallNoFault()
        {
            Variant foo = new Variant("foo");
            Variant bar = new Variant("bar");

            Dictionary <string, Variant> args = new Dictionary <string, Variant>();

            args["Command"]           = new Variant("echo");
            args["Arguments"]         = new Variant("hello");
            args["StartOnCall"]       = foo;
            args["WaitForExitOnCall"] = bar;
            args["NoCpuKill"]         = new Variant("true");

            CrashWrangler w = new CrashWrangler(null, "name", args);

            w.Message("Action.Call", foo);
            w.Message("Action.Call", bar);

            w.IterationFinished();

            Assert.AreEqual(false, w.DetectedFault());

            w.SessionFinished();
            w.StopMonitor();
        }
예제 #10
0
        public void TestStopping()
        {
            Dictionary <string, Variant> args = new Dictionary <string, Variant>();

            args["Command"]   = new Variant("nc");
            args["Arguments"] = new Variant("-l 12345");

            CrashWrangler w = new CrashWrangler(null, "name", args);

            w.SessionStarting();
            w.IterationStarting(0, false);
            Thread.Sleep(1000);
            w.IterationFinished();
            Assert.AreEqual(false, w.DetectedFault());
            w.SessionFinished();
            w.StopMonitor();
        }
예제 #11
0
        public void TestExitEarlyFault4()
        {
            // FaultOnEarlyExit doesn't fault when restart every iteration is true

            Dictionary <string, Variant> args = new Dictionary <string, Variant>();

            args["Command"]           = new Variant("nc");
            args["Arguments"]         = new Variant("-l 12345");
            args["RestartOnEachTest"] = new Variant("true");
            args["FaultOnEarlyExit"]  = new Variant("true");

            CrashWrangler w = new CrashWrangler(null, "name", args);

            w.SessionStarting();
            w.IterationStarting(1, false);

            w.IterationFinished();

            Assert.AreEqual(false, w.DetectedFault());

            w.SessionFinished();
            w.StopMonitor();
        }