Fierce::Parser - Parse fierce scan data with Perl
This document describes the latest version of Fierce::Parser
use Fierce::Parser; my $fp = new Fierce::Parser; # a Fierce::Parser Object my $parser = $fp->parse_file('test1.xml'); # a Fierce::Parser::Host Object my $host = $parser->get_node('google.com');
For a full listing of methods see the documentation corresponding to each object.
Fierce::Parser -- Core parser | +--Fierce::Parser::Session -- Fierce scan session information | +--Fierce::Parser::Domain -- General domain information | | | |--Fierce::Parser::Domain::NameServers -- Nameserver Information about the Domain | | | |--Fierce::Parser::Domain::ZoneTransfer -- Zone Transfer information | | | |--Fierce::Parser::Domain::Bruteforce -- Nodes found using Bruteforce | | | |--Fierce::Parser::Domain::ExtBruteforce -- Nodes found using Extension Bruteforce | | | |--Fierce::Parser::Domain::ReverseLookups -- Nodes found using Reverse Lookups | | | |--Fierce::Parser::Domain::WildCard -- Information about MX records found | | | |--Fierce::Parser::Domain::WhoisLookup -- Information about Whois lookups | | | |--Fierce::Parser::Domain::FindMX -- Information about MX records found | | | |--Fierce::Parser::Domain::Vhost -- Information about Virtual Hosts found
The main idea behind the core modules is, you will first parse the scan data then extract the information. Therefore, you should run parse_file then you can use any of the subroutines.
Parse a fierce XML file. The XML files are generated from using the following command:
fierce.pl -dns $DOMAIN -format xml -output domain.xml
Perform a fierce scan and parse the XML result.
use Fierce::Parser; my $fp = new Fierce::Parser; my @domains; push(@domains,"google.com"); my $parser = $fp->parse_scan("",@domains);
Obtain the fierce::Parser::Session object which contains the session scan information.
Obtain the Fierce::Parser::Host object which the host information.
Obtain an Array of Fierce::Parser::Node objects which contain domain information.
This object contains the scan session information of the Fierce scan.
Returns the options used to execute fierce.
Returns the start time of the scan in unixtime format.
Returns the start time of the scan in a readable string.
Returns the end time of the scan in unixtime format.
Returns the end time of the scan in a readable string.
Returns the elapsed time of the scan.
Returns the version of Fierce.
Returns the xml version.
This object contains the information for a domain.
Returns the domain name.
This object contains the information for a node. A Node is a simplistic object containing information about a device found during a Fierce scan. Many of the Fierce modules use a Node to represent the a device.
Returns the ip address of the node.
Returns the hostname of the node.
Return the type of the node.
This Object contains the information for a zone transfer request.
Returns the domain being tested.
Returns the name_server being tested.
Returns 1 or 0 if a zone transfer exists. 1=true and 0=false.
Returns the raw output of a axfr request.
Returns an ArrayRef containing Node Objects.
This object contains the Nameserver Information about the Domain.
Returns an Arrayref containing Node Objects.
my $name_servers = $domain->name_servers; foreach my $i ( @{ $name_servers->nodes } ) { print "\thostname:" . "\t" . $i->hostname . "\n"; print "\tip:" . "\t\t" . $i->ip . "\n"; }
This object contains the Zone Transfer information.
Returns an ArrayRef containing ZoneTransferResult objects.
my $name_servers = $domain->name_servers; my $zone_transfers = $domain->zone_transfers; foreach my $i ( @{ $name_servers->nodes } ) { print "\tIP:" . "\t\t" . $i->ip . "\n"; print "\tZone Transfer:" . "\t"; foreach ( @{ $zone_transfers->result } ) { if ($i->hostname eq $_->name_server ) { if ($_->bool == 1) { print "Enabled\n"; print "\n\tZone Trasfer Result:" . "\t"; print "\t\t" . $_->raw_output . "\n"; } else { print "Disabled\n"; } } } }
This object contains the Nodes found using Prefix Bruteforce.
Returns an ArrayRef containing Node objects.
my $bruteforce = $domain->bruteforce; foreach ( @{ $bruteforce->nodes } ) { print "\tHostname:" . "\t" . $_->hostname . "\n"; print "\tIP: " . "\t\t" . $_->ip . "\n"; }
This object contains the Nodes found using Extension Bruteforce.
my $ext_bruteforce = $domain->ext_bruteforce; foreach ( @{ $ext_bruteforce->nodes } ) { print "\thostname:" . "\t" . $_->hostname . "\n"; print "\tip: " . "\t\t" . $_->ip . "\n"; }
This object contains the Nodes found using Reverse Lookups.
my $reverse_lookups = $domain->reverse_lookups; foreach ( @{ $reverse_lookups->nodes } ) { print "\thostname:" . "\t" . $_->hostname . "\n"; print "\tip: " . "\t\t" . $_->ip . "\n"; }
This object contains the Information about MX records found.
This object contains the Information about Whois lookups.
my $whois_lookup = $domain->whois_lookup; print "Whois:\n"; foreach ( @{ $whois_lookup->result } ) { print "\tNetHandle:" . "\t" . $_->net_handle . "\n"; print "\tNetRange: " . "\t" . $_->net_range . "\n"; } print "\n";
This object contains Information about MX records found.
my $reverse_lookups = $domain->reverse_lookups; foreach ( @{ $findmx->result } ) { print "\tpreference:" . "\t" . $_->preference . "\n"; print "\texchange: " . "\t" . $_->exchange . "\n"; }
This object contains Information about Virtual Hosts found.
my $reverse_lookups = $domain->reverse_lookups; foreach ( @{ $vhost->nodes } ) { print "\thostname:" . "\t" . $_->hostname . "\n"; print "\tip: " . "\t\t" . $_->ip . "\n"; }
Here is an example of parsing an XML file using Fierce::Parser:
use Fierce::Parser; my $fp = new Fierce::Parser; if (defined($ARGV[0])){ my $file = $ARGV[0]; my $parser = $fp->parse_file($file); my @nodes = $parser->get_all_nodes(); foreach my $n (@nodes){ my $domain = $n; my $name_servers = $domain->name_servers; my $zone_transfers = $domain->zone_transfers; my $bruteforce = $domain->bruteforce; my $vhost = $domain->vhost; my $subdomain_bruteforce = $domain->subdomain_bruteforce; my $ext_bruteforce = $domain->ext_bruteforce; my $reverse_lookups = $domain->reverse_lookups; my $wildcard = $domain->wildcard; my $findmx = $domain->findmx; my $find_nearby = $domain->find_nearby; print "==== " . $n->domain . " ====\n"; if ( $name_servers ) { print "Nameservers:\n"; foreach my $i ( @{ $name_servers->nodes } ) { print "\tHostname:" . "\t" . $i->hostname . "\n"; print "\tIP:" . "\t\t" . $i->ip . "\n"; print "\tZone Transfer:" . "\t"; foreach ( @{ $zone_transfers->result } ) { if ($i->hostname eq $_->name_server ) { if ($_->bool == 1) { print "Enabled\n"; print "\n\tZone Trasfer Result:" . "\t"; print "\t\t" . $_->raw_output . "\n"; } else { print "Disabled\n"; } } } print "\n"; } if ( $findmx ) { print "MX:\n"; foreach ( @{ $findmx->result } ) { print "\tpreference:" . "\t" . $_->preference . "\n"; print "\texchange: " . "\t" . $_->exchange . "\n"; } print "\n"; } if ($bruteforce) { print "Prefix Bruteforce:\n"; foreach ( @{ $bruteforce->nodes } ) { print "\tHostname:" . "\t" . $_->hostname . "\n"; print "\tIP: " . "\t\t" . $_->ip . "\n"; } print "\n"; } if ($vhost) { print "Virtual Hosts:\n"; foreach ( @{ $vhost->nodes } ) { print "\thostname:" . "\t" . $_->hostname . "\n"; print "\tip: " . "\t\t" . $_->ip . "\n"; } print "\n"; } if ($ext_bruteforce){ print "Extension Bruteforce:\n"; foreach ( @{ $ext_bruteforce->nodes } ) { print "\thostname:" . "\t" . $_->hostname . "\n"; print "\tip: " . "\t\t" . $_->ip . "\n"; } print "\n"; } if ($reverse_lookups){ print "reverse lookup:\n"; foreach ( @{ $reverse_lookups->nodes } ) { print "\thostname:" . "\t" . $_->hostname . "\n"; print "\tip: " . "\t\t" . $_->ip . "\n"; } print "\n"; } if ($find_nearby){ print "Find Nearby:\n"; foreach ( @{ $find_nearby->ptrs } ) { print "\tPtrdname:" . "\t" . $_->ptrdname . "\n"; print "\tIP: " . "\t\t" . $_->ip . "\n"; } } } } else { print "Usage: $0 [fierce-xml]\n"; }
fierce, XML::LibXML and Object::InsideOut
Joshua D. Abraham, <jabra AT spl0it DOT org>
Copyright 2009 Joshua D. Abraham. All rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
To install Fierce::Parser, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Fierce::Parser
CPAN shell
perl -MCPAN -e shell install Fierce::Parser
For more information on module installation, please visit the detailed CPAN module installation guide.