private void cmbCmdline_KeyPress(object sender, KeyPressEventArgs e) { if (e.KeyChar == '\r') { cmbCmdline.Items.Remove(""); cmbCmdline.Items.Add(cmbCmdline.Text); r2pw.run(cmbCmdline.Text, "output", true); // append cmbCmdline.Items.Add(""); cmbCmdline.Text = ""; } }
private void btnConvert_Click(object sender, EventArgs e) { string input; txtOutput.Text = ""; foreach (string cmd in txtCommands.Text.Split('\n')) { if (cmd.Length > 0) { input = r2pw.run(cmd).TrimEnd('\r').TrimEnd('\n'); if (input.Length > 0) { txtOutput.Text += input + Environment.NewLine; } } } if (txtOutput.TextLength > 0) { txtOutput.Focus(); txtOutput.SelectionStart = txtOutput.TextLength - 1; txtOutput.SelectionLength = 0; } }
private void DoLoadFile() { if (!File.Exists(fileName)) { MessageBox.Show(string.Format("Wops!\n{0}\nfile not found...", fileName), "LoadFile", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } r2pw.open(fileName); r2pw.run("pd 100", "dissasembly"); r2pw.run("izq", "strings"); r2pw.run("aaa;aflj", "functions_listview", false, new List <string> { "name", "offset" }); r2pw.run("iij", "imports_listview", false, new List <string> { "name", "plt" }); r2pw.run("px 2000", "hexview"); }
public string convert(string cmds, string console_text, dynamic json_obj, ref MatchCollection mc) // calls htmlize or htmljsonize { string html_body = "", html_header = ""; string css_filename = ""; string themeName = "classic"; string js_filename = r2pw.rconfig.load <string>( "gui.scripts.js_def", "r2html.js"); string jquery_base = r2pw.rconfig.load <string>( "gui.datapath"); if (r2pw.rconfig.dataPath == null) { r2pw.rconfig.dataPath = r2pw.find_dataPath( string.Format( @"{0}\media", System.IO.Path.GetDirectoryName(Application.ExecutablePath) ) ); jquery_base = r2pw.rconfig.load <string>( "gui.datapath"); } if (jquery_base != null) { jquery_base = "file:///" + jquery_base + @"\..\scripts\"; } else { jquery_base = "https://code.jquery.com/"; } themeName = r2pw.rconfig.load <string>("gui.theme_name", themeName); js_filename = r2pw.rconfig.load <string>("gui.datapath") + @"\..\scripts\" + js_filename; css_filename = string.Format( @"{0}\{1}", r2pw.rconfig.load <string>("gui.datapath"), r2pw.rconfig.load <string>("gui.hexview.css", "r2pipe.css") ); html_header = "<!DOCTYPE html>\n"; html_header += "<meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge,chrome=1\">\n"; html_header += "<meta charset=\"UTF-8\">\n"; html_header += "<html>\r\n"; html_header += "<head>\r\n"; html_header += "<link href='" + css_filename + "' rel='stylesheet'>\r\n"; //html_header += "<link rel = \"stylesheet\" href = \"https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css\" >\r\n"; html_header += "<script src=\"" + jquery_base + "jquery-1.11.3.js\"></script>\r\n"; html_header += "<script>var r2output = null; addresses = null; pd_previews = null; </script>\r\n"; html_header += "<script>var address_hexlength = '" + r2pw.address_hexlength + "'; </script>\r\n"; html_header += "</head>\r\n"; html_header += "<body>\r\n"; html_header += "<div id=my_dialog class=msg></div>\r\n"; // dump html or json js if (json_obj == null) { mc = null; html_body = htmlize(console_text, ref mc); html_body = "<div id=#r2code>" + html_body + "</div>\r\n"; } else { html_body = htmljsonize(cmds, json_obj); } // add list with matched addresses and pd previews if (mc != null) { addresses.Clear(); List <string> pd_previews = new List <string>(); Cursor.Current = Cursors.WaitCursor; // add funcions (fcn) to previews Regex address_regex = new Regex((@"\b((fcn|str)\.([\:\w]+))"), RegexOptions.IgnoreCase); // same regex that used up mc = address_regex.Matches(console_text); foreach (Match m in mc) { string address = m.Groups[0].Value; // get the address if (!address.StartsWith("str.") && !address.StartsWith("fcn.")) // fix the fnc.0000000 address { address = "0x" + address; } if (!addresses.Contains(address)) { addresses.Add(address); } } addresses = new HashSet <string>(addresses).ToList(); foreach (string address in addresses) { if (cmds != null && (cmds.StartsWith("pd") || cmds.StartsWith("agf")) && r2pw.fileName.StartsWith("-") == false) { string preview = ""; // get some previevs string print_cmd = "psz"; if (!address.StartsWith("str.")) { print_cmd = "pdf"; } preview = r2pw.run(print_cmd + " @ " + address); if (preview != null) { preview = preview.TrimEnd('\n'); //preview = encodeutf8(preview); preview = htmlize(preview, ref mc); preview = preview.Replace("'", "'"); preview = preview.Replace("\r", "\\r"); preview = preview.Replace("\n", "\\n"); pd_previews.Add("'" + address + "':'" + preview + "'"); } } } // add the rest of address foreach (Match m in mc) { string address = m.Groups[2].Value; addresses.Add(m.Groups[2].Value); } Cursor.Current = Cursors.Default; html_body += "<script>\r\n"; html_body += "addresses = ['" + string.Join("', '", addresses) + "'];\r\n"; html_body += "pd_previews = {" + string.Join(", ", pd_previews) + "};\r\n"; html_body += "</script>\r\n"; } html_body += "<script src='" + js_filename + "'></script>\r\n"; if (!File.Exists(js_filename)) { html_body += string.Format("<div class=msg></div>", js_filename); } html_body += "</body>\r\n"; html_body += "</html>\r\n"; return(html_header + html_body); }
private void DoLoadFile() { if (!File.Exists(fileName)) { r2pw.Show(string.Format("Wops!\n{0}\nfile not found...", fileName), "LoadFile"); return; } r2pw.open(fileName); r2pw.run("aaa;aflj", "functions_listview", false, new List <string> { "name", "offset" }); r2pw.run("pd 100", "dissasembly"); r2pw.run("izj", "strings_listview", false, new List <string> { "vaddr", "section", "type", "string" }); r2pw.run("iij", "imports_listview", false, new List <string> { "name", "plt" }); r2pw.run("iSj", "sections_listview", false, new List <string> { "name", "size", "flags", "paddr", "vaddr" }); r2pw.run("px 2000", "hexview"); r2pw.run("?", "r2help"); }