Changeset 227
- Timestamp:
- 10/30/09 03:45:46 (4 years ago)
- File:
-
- 1 edited
-
fierce2/branch/fierce (modified) (31 diffs)
Legend:
- Unmodified
- Added
- Removed
-
fierce2/branch/fierce
r225 r227 64 64 } 65 65 } 66 # handle output calls 67 sub header_output { 68 my ($str) = @_; 69 $str = validate($str); 70 if ( $format eq 'txt' and $options{output} ) { 71 print FILE $str; 72 } 73 print $str; 74 } 75 66 76 67 77 # handle output calls … … 403 413 } 404 414 } 415 my $include_path_txt = $include_path; 416 $include_path_txt =~ s/$format/txt/; 417 # some useful options (see below for full list) 418 my $config_txt = { 419 INCLUDE_PATH => "$include_path_txt", # or list ref 420 INTERPOLATE => 1, # expand "$var" in plain text 421 POST_CHOMP => 1, # cleanup whitespace 422 EVAL_PERL => 1, # evaluate Perl code blocks 423 }; 424 # create Template object 425 my $tt_txt = Template->new($config_txt); 405 426 406 427 # some useful options (see below for full list) … … 411 432 EVAL_PERL => 1, # evaluate Perl code blocks 412 433 }; 413 414 434 # create Template object 415 435 my $tt = Template->new($config); … … 425 445 ); 426 446 427 sub t emplate_output{447 sub tt_output_setup { 428 448 my ( $obj, $result, $template ) = @_; 429 449 … … 438 458 elasp => $obj->elasp, 439 459 }; 440 460 461 ## nmap output style 441 462 # reference to output text string 442 463 $tt->process( "$template", $vars, \$obj_output ) 443 464 || die $tt->error(), "\n"; 444 output($obj_output); 465 466 return $obj_output; 467 } 468 469 sub tt_output_setup_txt { 470 my ( $obj, $result, $template ) = @_; 471 472 my $obj_output; 473 474 my $vars = { 475 result => $result, 476 start => $obj->start, 477 startstr => $obj->startstr, 478 end => $obj->end, 479 endstr => $obj->endstr, 480 elasp => $obj->elasp, 481 }; 482 483 ## nmap output style 484 # reference to output text string 485 $tt_txt->process( "$template", $vars, \$obj_output ) 486 || die $tt_txt->error(), "\n"; 487 488 489 $obj_output = validate($obj_output); 490 return $obj_output; 491 } 492 493 494 sub template_output { 495 my ( $output,$output_txt ) = @_; 496 $output = validate($output); 497 $output_txt = validate($output_txt); 498 499 output($output); 500 if ( defined($filename) ) { 501 print $output_txt; 502 } 445 503 } 446 504 … … 491 549 my $iprange_obj = IPrange->new( iprange => \@ipranges ); 492 550 493 print "Finding Nearby IPs ... \n" 494 if ( $verbose > 0 or $format eq 'txt' ); 551 header_output("Finding Nearby IPs ... \n"); 495 552 my $find_nearby = tFindNearby->new( 496 553 search => $search, … … 502 559 503 560 my $find_nearby_result = $find_nearby->result(); 504 template_output( $find_nearby, $find_nearby_result, 'find_nearby.tt' ); 561 562 template_output( 563 tt_output_setup( $find_nearby, 564 $find_nearby_result, 565 'find_nearby.tt' ), 566 tt_output_setup_txt( $find_nearby, 567 $find_nearby_result, 568 'find_nearby.tt' ), 569 570 ) ; 505 571 exit; 506 572 } … … 533 599 \$start_domainscan_output ) 534 600 || die $tt->error(), "\n"; 535 output($start_domainscan_output); 601 my $start_domainscan_output_txt; 602 # reference to output text string 603 $tt_txt->process( 'start_domainscan.tt', $start_domainscan_vars, 604 \$start_domainscan_output_txt ) 605 || die $tt_txt->error(), "\n"; 606 607 template_output($start_domainscan_output,$start_domainscan_output_txt); 536 608 537 609 my ( $zt, $ns, $prefix_bf, $subdomain_bf, $reverse_lookup, $find_mx ); … … 545 617 my ($find_nearby_result); 546 618 547 print "Nameservers for $dns\n" 548 if ( $verbose > 0 or $format eq 'txt' ); 619 header_output("Nameservers for $dns\n"); 549 620 $ns = NameServers->new(); 550 621 $ns = $ns->execute( $domain, $base ); 551 622 552 623 my $ns_result = $ns->result(); 553 template_output( $ns, $ns_result, 'ns.tt' ); 624 template_output( 625 tt_output_setup( $ns, $ns_result, 'ns.tt' ), 626 tt_output_setup_txt( $ns, $ns_result, 'ns.tt' ), 627 ); 554 628 555 629 if ( grep( !/arin/, $no ) ) { … … 566 640 $arin_query =~ s/\..*//g; 567 641 } 568 print "ARIN lookup $arin_query\n" 569 if ( $verbose > 0 or $format eq 'txt' ); 642 header_output("ARIN lookup $arin_query\n"); 570 643 my $arin = ARIN->new( query => $arin_query ); 571 644 $arin = $arin->execute($domain); … … 587 660 $tt->process( "arin.tt", $arin_vars, \$arin_output ) 588 661 || die $tt->error(), "\n"; 589 output($arin_output); 590 662 my $arin_output_txt; 663 664 # reference to output text string 665 $tt_txt->process( "arin.tt", $arin_vars, \$arin_output_txt ) 666 || die $tt_txt->error(), "\n"; 667 template_output($arin_output,$arin_output_txt); 591 668 } 592 669 … … 597 674 598 675 if ( grep( !/zt/, $no ) ) { 599 print "Trying Zone Transfer ... \n" 600 if ( $verbose > 0 or $format eq 'txt' ); 676 header_output("Trying Zone Transfer ... \n"); 601 677 $zt = ZoneTransfer->new(); 602 678 $zt = $zt->execute( $domain, $base, $base->new_dns_resolver ); 603 679 604 680 $zt_result = $zt->result(); 605 template_output( $zt, $zt_result, 'zt.tt' ); 681 template_output( 682 tt_output_setup( $zt, $zt_result, 'zt.tt'), 683 tt_output_setup_txt( $zt, $zt_result, 'zt.tt'), 684 ); 606 685 } 607 686 unless ( $options{ztstop} and $zt->check == 1 ) { … … 612 691 if ( grep( !/wildc/, $no ) ) { 613 692 614 print "Testing for Wildcards ... \n" 615 if ( $verbose > 0 or $format eq 'txt' ); 693 header_output("Testing for Wildcards ... \n"); 616 694 617 695 $wildcard = CheckWildCard->new(); … … 619 697 620 698 $wildcard_result = $wildcard->result(); 621 template_output( $wildcard, $wildcard_result, 'wildcard.tt' ); 699 template_output( 700 tt_output_setup( $wildcard, $wildcard_result, 'wildcard.tt' ), 701 tt_output_setup_txt( $wildcard, $wildcard_result, 'wildcard.tt' ), 702 ); 622 703 } 623 704 unless ($options{wildcstop} … … 631 712 if ( grep( !/prebf/, $no ) ) { 632 713 633 print "Trying Prefix Bruteforce ... \n" 634 if ( $verbose > 0 or $format eq 'txt' ); 714 header_output("Trying Prefix Bruteforce ... \n"); 635 715 636 716 $prefix_bf = tBruteForceDNS->new( … … 641 721 642 722 $prefix_bf_result = $prefix_bf->result(); 643 template_output( $prefix_bf, $prefix_bf_result, 644 'prefix_bf.tt' ); 723 template_output( 724 tt_output_setup( $prefix_bf, $prefix_bf_result, 725 'prefix_bf.tt' ), 726 tt_output_setup_txt( $prefix_bf, $prefix_bf_result, 727 'prefix_bf.tt' ), 728 ); 645 729 } 646 730 ##################################### … … 649 733 # 650 734 if ( grep( !/subbf/, $no ) ) { 651 print "Trying Subdomain Bruteforce ... \n" 652 if ( $verbose > 0 or $format eq 'txt' ); 735 header_output("Trying Subdomain Bruteforce ... \n"); 653 736 654 737 my @subdomain_prefix_list = ( 'www', 'mail' ); … … 662 745 663 746 $subdomain_bf_result = $subdomain_bf->result(); 664 template_output( $subdomain_bf, $subdomain_bf_result, 665 'subdomain_bf.tt' ); 747 template_output( 748 tt_output_setup( $subdomain_bf, $subdomain_bf_result, 749 'subdomain_bf.tt' ), 750 tt_output_setup_txt( $subdomain_bf, $subdomain_bf_result, 751 'subdomain_bf.tt' ), 752 753 ); 666 754 } 667 755 } … … 672 760 if ( grep( !/extbf/, $no ) ) { 673 761 674 print "Trying Extension Bruteforce ... \n" 675 if ( $verbose > 0 or $format eq 'txt' ); 762 header_output("Trying Extension Bruteforce ... \n"); 676 763 677 764 $ext_bf = tExtensionBruteForceDNS->new( … … 679 766 $ext_bf = $ext_bf->execute($domain); 680 767 $ext_bf_result = $ext_bf->result(); 681 template_output( $ext_bf, $ext_bf_result, 'ext_bf.tt' ); 768 template_output( 769 tt_output_setup( $ext_bf, $ext_bf_result, 'ext_bf.tt' ), 770 tt_output_setup_txt( $ext_bf, $ext_bf_result, 'ext_bf.tt' ), 771 ); 682 772 } 683 773 ###################################### … … 687 777 if ( grep( !/vhost/, $no ) ) { 688 778 689 print "Testing for Virtual Hosts ... \n" 690 if ( $verbose > 0 or $format eq 'txt' ); 779 header_output("Testing for Virtual Hosts ... \n"); 691 780 692 781 my $vhost = tVhost->new(); … … 694 783 695 784 $vhost_result = $vhost->result(); 696 template_output( $vhost, $vhost_result, 'vhost.tt' ); 785 template_output( 786 tt_output_setup( $vhost, $vhost_result, 'vhost.tt' ), 787 tt_output_setup_txt( $vhost, $vhost_result, 'vhost.tt' ), 788 ); 697 789 } 698 790 ################################################ … … 702 794 if ( grep( !/findmx/, $no ) ) { 703 795 704 print "Looking for MX records ... \n" 705 if ( $verbose > 0 or $format eq 'txt' ); 796 header_output("Looking for MX records ... \n"); 706 797 $find_mx = tFindMX->new(); 707 798 $find_mx 708 799 = $find_mx->execute( $domain, $base->new_dns_resolver ); 709 800 $find_mx_result = $find_mx->result(); 710 template_output( $find_mx, $find_mx_result, 'find_mx.tt' ); 801 template_output( 802 tt_output_setup( $find_mx, $find_mx_result, 'find_mx.tt' ), 803 tt_output_setup_txt( $find_mx, $find_mx_result, 'find_mx.tt' ), 804 ); 711 805 } 712 806 ##################################################### … … 716 810 if ( grep( !/whois/, $no ) ) { 717 811 718 print "Performing Whois Lookups ... \n" 719 if ( $verbose > 0 or $format eq 'txt' ); 812 header_output("Performing Whois Lookups ... \n"); 720 813 721 814 $whois = WhoisLookup->new(); … … 723 816 724 817 $whois_result = $whois->result(); 725 template_output( $whois, $whois_result, 'whois.tt' ); 818 template_output( 819 tt_output_setup( $whois, $whois_result, 'whois.tt' ), 820 tt_output_setup_txt( $whois, $whois_result, 'whois.tt' ), 821 ); 726 822 } 727 823 … … 735 831 $prefix_cnames = $prefix_bf->cnames; 736 832 } 737 print "Performing Reverse Lookups ... \n" 738 if ( $verbose > 0 or $format eq 'txt' ); 833 header_output("Performing Reverse Lookups ... \n"); 739 834 $reverse_lookup = tReverseLookup->new( 740 835 max_lookups => $max_lookups, … … 744 839 745 840 $reverse_lookup_result = $reverse_lookup->result(); 746 template_output( $reverse_lookup, $reverse_lookup_result, 747 'reverse_lookup.tt' ); 841 template_output( 842 tt_output_setup( $reverse_lookup, $reverse_lookup_result,'reverse_lookup.tt' ), 843 tt_output_setup_txt( $reverse_lookup, $reverse_lookup_result,'reverse_lookup.tt' ), 844 ); 748 845 } 749 846 ######################################################### … … 771 868 my $iprange_obj = IPrange->new( iprange => \@ipranges ); 772 869 773 print "Finding Nearby IPs ... \n" 774 if ( $verbose > 0 or $format eq 'txt' ); 870 header_output("Finding Nearby IPs ... \n"); 775 871 $find_nearby = tFindNearby->new( 776 872 search => $search, … … 783 879 784 880 $find_nearby_result = $find_nearby->result(); 785 template_output( $find_nearby, $find_nearby_result, 786 'find_nearby.tt' ); 881 template_output( 882 tt_output_setup( $find_nearby, $find_nearby_result, 883 'find_nearby.tt' ), 884 tt_output_setup_txt( $find_nearby, $find_nearby_result, 885 'find_nearby.tt' ), 886 ); 787 887 } 788 888 } … … 806 906 || die $tt->error(), 807 907 "\n"; 808 output($end_domainscan_output); 908 909 my $end_domainscan_output_txt; 910 # reference to output text string 911 $tt_txt->process( 'end_domainscan.tt', $end_domainscan_vars, 912 \$end_domainscan_output_txt ) 913 || die $tt_txt->error(), 914 "\n"; 915 916 template_output($end_domainscan_output,$end_domainscan_output_txt); 809 917 } 810 918 … … 825 933 \$end_fiercescan_output ) 826 934 || die $tt->error(), "\n"; 827 output($end_fiercescan_output); 935 936 my $end_fiercescan_output_txt; 937 # reference to output text string 938 $tt_txt->process( 'end_fiercescan.tt', $end_fiercescan_vars, 939 \$end_fiercescan_output_txt ) 940 || die $tt_txt->error(), 941 "\n"; 942 943 template_output($end_fiercescan_output); 828 944 } 829 945 else {
Note: See TracChangeset
for help on using the changeset viewer.