public static log4net.ILog InitLogging(string logfilename, bool verbose)
        {
            ConsoleLogging = verbose;
            logfilename    = System.Environment.ExpandEnvironmentVariables(logfilename);
            if (verbose)
            {
                Console.WriteLine("Initializing logfile: {0}", logfilename);
            }
            log4net.Appender.ForwardingAppender  appender = new log4net.Appender.ForwardingAppender();
            log4net.Appender.RollingFileAppender rfa      = new log4net.Appender.RollingFileAppender
            {
                AppendToFile       = true,
                LockingModel       = new log4net.Appender.RollingFileAppender.MinimalLock(),
                Layout             = new log4net.Layout.PatternLayout("%date\t%message%newline"),
                File               = logfilename,
                MaxSizeRollBackups = 10,
                MaxFileSize        = 10 * 1024 * 1024,
                RollingStyle       = log4net.Appender.RollingFileAppender.RollingMode.Size,
                DatePattern        = "yyyyMMdd"
            };
            rfa.ActivateOptions();
            appender.AddAppender(rfa);
            if (verbose)
            {
                appender.AddAppender(
                    new log4net.Appender.ConsoleAppender
                {
                    Layout = new log4net.Layout.PatternLayout("%message%newline")
                }
                    );
            }

            log4net.Config.BasicConfigurator.Configure(appender);
            return(log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType));
        }
Exemple #2
0
        //        private static void TestApamaLinux()
        //        {
        //            IDictionary<string, string> config = new Dictionary<string, string>();
        //            config.Add("gdb_exec", "/opt/gdb-7.2/bin/gdb");
        //            config.Add("gdb_log", "stream:stderr");
        //            
        //            //config.Add("target", "extended-remote :1234");
        //            
        //            config.Add("target", "run_local");
        //            
        //            //config.Add("target", "attach_local");
        //            //config.Add("target-options", "14577");
        //            
        //            //config.Add("file", "/home/andi/Documents/Uni/master-thesis/src/test_sources/gdb_reverse_debugging_test/gdb_reverse_debugging_test");
        //            config.Add("file", "/home/andi/hacklet/prog0-x64");
        //            
        //            using(ITargetConnector connector =
        //                GenericClassIdentifierFactory.CreateFromClassIdentifierOrType<ITargetConnector>("general/gdb"))
        //            {
        //                ISymbolTable symbolTable = (ISymbolTable)connector;
        //                
        //                connector.Setup(config);
        //                connector.Connect();
        //                
        //                ISymbolTableMethod main = symbolTable.FindMethod("main");
        //                IBreakpoint snapshotBreakpoint = connector.SetSoftwareBreakpoint(main, 0, "break_snapshot");
        //                IBreakpoint restoreBreakpoint = connector.SetSoftwareBreakpoint (0x4007b5, 0, "break_restore");
        //                
        ////				IFuzzDescription barVar1_Description = new SingleValueFuzzDescription(bar.Parameters[0], 
        ////					new RandomByteGenerator( 4, 4, RandomByteGenerator.ByteType.All));		
        ////				IFuzzDescription barVar1_readableChar = new PointerValueFuzzDescription(bar.Parameters[0],
        ////					new RandomByteGenerator(5, 1000, RandomByteGenerator.ByteType.PrintableASCIINullTerminated));
        //                
        //                connector.DebugContinue ();
        ////				Registers r = ((Fuzzer.TargetConnectors.GDB.GDBConnector)connector).GetRegisters();
        ////				using(FileStream fSink = new FileStream("/home/andi/x86-64.registers", FileMode.CreateNew, FileAccess.Write))
        ////				{
        ////					StreamHelper.WriteTypedStreamSerializable(r, fSink);
        ////				}
        //             	ISymbolTableVariable argv = main.Parameters[1];
        //                ISymbolTableVariable dereferencedArgv = argv.Dereference();
        //                
        //                DataGeneratorLogger datagenLogger = new DataGeneratorLogger("/home/andi/log");
        ////				IFuzzDescription fuzzArgv = new PointerValueFuzzDescription(
        ////					dereferencedArgv, new RandomByteGenerator(
        ////				                          100, 10000, RandomByteGenerator.ByteType.PrintableASCIINullTerminated));
        ////				IStackFrameInfo stackFrameInfo = connector.GetStackFrameInfo();
        //                
        ////				
        ////				FuzzController fuzzController = new FuzzController(
        ////					connector,
        ////					snapshotBreakpoint,
        ////					restoreBreakpoint,
        ////					new LoggerCollection(
        ////						new GDBLogger((GDBConnector)connector, "/home/andi/log"),
        ////						new StackFrameLogger(connector, "/home/andi/log"),
        ////						datagenLogger
        ////					),
        ////					fuzzArgv);
        ////					
        ////				fuzzController.Fuzz();
        //            }
        //            
        //
        //            
        //            Console.ReadLine();
        //            
        //        }
        /// <summary>
        /// Initializes the logger
        /// </summary>
        private static void SetupLogging()
        {
            log4net.Appender.FileAppender fileAppender = new log4net.Appender.FileAppender();
            fileAppender.Name = "FileAppender";
            //fileAppender.Writer = new StreamWriter("/home/andi/fuzzer.log");
            fileAppender.ImmediateFlush = true;
            fileAppender.Layout = new log4net.Layout.PatternLayout("[%date{dd.MM.yyyy HH:mm:ss,fff}]-%-5level-[%c]: %message%newline");
            fileAppender.File = "/home/andi/fuzzer.log";
            fileAppender.ActivateOptions();

            log4net.Appender.ConsoleAppender appender = new log4net.Appender.ConsoleAppender();
            appender.Name = "ConsoleAppender";
            appender.Layout = new log4net.Layout.PatternLayout("[%date{dd.MM.yyyy HH:mm:ss,fff}]-%-5level-[%c]: %message%newline");

            log4net.Appender.ForwardingAppender forwarder = new log4net.Appender.ForwardingAppender();
            forwarder.AddAppender(fileAppender);
            forwarder.AddAppender(appender);

            log4net.Config.BasicConfigurator.Configure(forwarder);

            //_logger = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
        }