示例#1
0
        static void Main(string[] args)
        {
            #if __MonoCS__
            using (IR2Pipe pipe = new R2Pipe("/bin/ls"))
            #else
            using (IR2Pipe pipe = new R2Pipe(@"C:\Windows\notepad.exe", @"C:\radare2\radare2.exe"))
            #endif
            {
                Console.WriteLine("Hello r2! " + pipe.RunCommand("?V"));

                Task<string> async = pipe.RunCommandAsync("?V");

                // To use non-blocking async stuff in console applications, you need an async context. Google helps you.

                // calling Result will block ulitmately.
                Console.WriteLine("Hello async r2!" + async.Result);

                // We can also issue multiple command sequentially, using a QueuedR2Pipe.
                // Note however that if we supply the pipe to use we must not call dispose on the pipe.

                QueuedR2Pipe qr2 = new QueuedR2Pipe(pipe);

                qr2.Enqueue(new R2Command("x", (string result) => { Console.WriteLine("Result of x:\n {0}", result); }));
                qr2.Enqueue(new R2Command("pi 10", (string result) => { Console.WriteLine("Result of pi 10:\n {0}", result); }));

                // note that this can also be done asynchronously via qr2.ExecuteCommandsAsync();
                qr2.ExecuteCommands();
            }
        }
示例#2
0
        static void Main(string[] args)
        {
#if __MonoCS__
            using (IR2Pipe pipe = new R2Pipe("/bin/ls"))
#else
            using (IR2Pipe pipe = new R2Pipe(@"C:\Windows\notepad.exe", @"C:\radare2\radare2.exe"))
#endif
            {
                Console.WriteLine("Hello r2! " + pipe.RunCommand("?V"));

                Task <string> async = pipe.RunCommandAsync("?V");

                // To use non-blocking async stuff in console applications, you need an async context. Google helps you.

                // calling Result will block ulitmately.
                Console.WriteLine("Hello async r2!" + async.Result);

                // We can also issue multiple command sequentially, using a QueuedR2Pipe.
                // Note however that if we supply the pipe to use we must not call dispose on the pipe.

                QueuedR2Pipe qr2 = new QueuedR2Pipe(pipe);

                qr2.Enqueue(new R2Command("x", (string result) => { Console.WriteLine("Result of x:\n {0}", result); }));
                qr2.Enqueue(new R2Command("pi 10", (string result) => { Console.WriteLine("Result of pi 10:\n {0}", result); }));

                // note that this can also be done asynchronously via qr2.ExecuteCommandsAsync();
                qr2.ExecuteCommands();
            }
        }
示例#3
0
        public string ExtractText(string filePath, string extension)
        {
            string r2Path = null;

            if (FilesUtils.ExistsOnPath("radare2.exe"))
            {
                r2Path = FilesUtils.GetFullPath("radare2.exe");
            }
            else if (FilesUtils.ExistsOnPath("radare2"))
            {
                r2Path = FilesUtils.GetFullPath("radare2");
            }
            else
            {
                PrintR2NotFound();
                return(null);                // No radare
            }

            PrintR2Warning();

            Console.Error.WriteLine($"Using radare from {r2Path}");

            var sb = new StringBuilder();

            using (IR2Pipe pipe = new R2Pipe(filePath, r2Path))
            {
                var queue = new QueuedR2Pipe(pipe);
                queue.Enqueue(new R2Command("?V", (string result) =>
                                            Console.Error.WriteLine($"Using radare version: {result}")));
                queue.Enqueue(new R2Command("e bin.rawstr=1", (no_use) => { /* Do nothing */ }));
                queue.Enqueue(new R2Command("izj", (string jsonResult) =>
                {
                    List <R2ZString> strings = JsonConvert.DeserializeObject <List <R2ZString> >(jsonResult);

                    foreach (var s in strings)
                    {
                        sb.AppendLine(Base64Decode(s.String));
                    }
                }));
                queue.ExecuteCommands();
            }

            return(sb.ToString());
        }
示例#4
0
        static void Main(string[] args)
        {
            using(IR2Pipe pipe = new HttpR2Pipe("http://cloud.rada.re/cmd/"))
            {
                Console.WriteLine(pipe.RunCommand("p8 32"));

                // you can use the queue here too:
                QueuedR2Pipe qr2 = new QueuedR2Pipe(pipe);

                qr2.Enqueue(new R2Command("?V", (string result) => { 
                    Console.WriteLine("Version: {0}", result); 
                }));

                qr2.Enqueue(new R2Command("pdf @ entry0", (string result) =>
                {
                    Console.WriteLine("Entrypoint: \n{0}", result);
                }));

                qr2.ExecuteCommands();
            }
        }
示例#5
0
        static void Main(string[] args)
        {
            using (IR2Pipe pipe = new HttpR2Pipe("http://cloud.rada.re/cmd/"))
            {
                Console.WriteLine(pipe.RunCommand("p8 32"));

                // you can use the queue here too:
                QueuedR2Pipe qr2 = new QueuedR2Pipe(pipe);

                qr2.Enqueue(new R2Command("?V", (string result) => {
                    Console.WriteLine("Version: {0}", result);
                }));

                qr2.Enqueue(new R2Command("pdf @ entry0", (string result) =>
                {
                    Console.WriteLine("Entrypoint: \n{0}", result);
                }));

                qr2.ExecuteCommands();
            }
        }