Newer
Older
DirtyScripts / ReportToolz / bp2json.php
  1. #!/usr/bin/php
  2. <?php
  3. //error_reporting(0);
  4.  
  5. /***
  6. * Main program - Don't edit below
  7. */
  8. echo " _ ______ _\n| | (_____ \ (_)\n| | _ ____ ____) ) _ ___ ___ ____\n| || \| _ \/_____/ | |/___)/ _ \| _ \ \n| |_) ) | | |______ | |___ | |_| | | | |\n|____/| ||_(_______)| (___/ \___/|_| |_|\n |_| (__/ \n\n";
  9.  
  10. foreach (glob("classes/*.php") as $filename)
  11. include $filename;
  12.  
  13. $definitions = new \Clapp\CommandLineArgumentDefinition(
  14. array(
  15. "help|h" => "Shows help message",
  16. "doc|d=s" => "/path/to/burp.xml to use",
  17. "no-save|n" => "Output only - Don't save JSON files",
  18. )
  19. );
  20.  
  21. $filter = new \Clapp\CommandArgumentFilter($definitions, $argv);
  22.  
  23. if ($filter->getParam('h') === true || $argc < 2) {
  24. echo "Convert burp \"report issues\" XML output file to JSON files for repgen.php\n\n";
  25. fwrite(STDERR, $definitions->getUsage());
  26. exit(0);
  27. }
  28.  
  29. // see if doc exists
  30. if ($filter->getParam("doc") == false)
  31. die("[-] no doc set\n");
  32.  
  33. echo "[!] doc: ".$filter->getParam("doc")."\n";
  34. if(!file_exists($filter->getParam("doc")))
  35. die("[-] no such file! \n");
  36.  
  37.  
  38. //$xmlfile = file_get_contents($filter->getParam("doc"));
  39. $burp= simplexml_load_file($filter->getParam("doc"));
  40.  
  41. $resultsFolder = substr($filter->getParam("doc"), 0, strrpos( $filter->getParam("doc"), '/') )."/";
  42. $vulnarray = array();
  43.  
  44. foreach($burp as $issue => $details){
  45. $issue = (string)$details->name;
  46. if(!in_array($issue, $vulnarray)){
  47. array_push($vulnarray, $issue);
  48. }
  49. }
  50.  
  51. echo "[=] ".count($vulnarray)." vulnerabilities identified\n";
  52.  
  53. foreach($vulnarray as $issue){
  54. $newfilename = preg_replace( '/[^a-z0-9]+/', '-', strtolower( $issue) );
  55. if($filter->getParam('no-save') === true){
  56. echo "[+] issue: ".$issue."\n";
  57. }else{
  58. echo "[+] creating file: ".$resultsFolder.$newfilename.".json\n";
  59. touch($resultsFolder.$newfilename.".json");
  60. }
  61. }
  62.  
  63. if($filter->getParam('no-save') !== true)
  64. echo "[!] These are empty JSON files, remember to floss!\n";
  65.  
  66.  
  67. ?>
Buy Me A Coffee