Perform Nmap Scan using non default interface
General Options:
-v --version Display version
-h --help Display this information
Send Comments to Joshua D. Abraham ( jabra\@ccs.neu.edu )\n";
exit;
}
sub print_version {
print "$PROG version $VERSION by $AUTH\n";
exit;
}
##############################################################################
GetOptions(
\%options,
'scan|s=s', 'nmap|n=s', 'inter=s',
'help|h' => sub { help(); },
'version|v' => sub { print_version(); },
)
or exit 1;
if ( $options{'nmap'} ) {
if ( -X $options{'nmap'} ) {
$nmapPath = $options{'nmap'};
}
else {
print $options{'nmap'} . " isn't executable using $nmapPath\n";
}
}
if ( $options{'scan'} ) {
my $ipRange;
if ( $options{'scan'}
=~ /(\d{1,3})\.(\d{1,3}|\*)\.(\d{1,3}|\*)\.(0\/\d{1,2}|\d{1,3}|\*|'*')/
)
{
$ipRange = $options{'scan'};
$type = 'scan';
}
else {
print "scan is $options{'scan'}";
}
push( @ipRange, $ipRange );
}
if ( $options{'inter'} ) {
$interface = "-e " . $options{'interface'} . " ";
$args = $args . $interface;
}
# make sure something is passed
help() if ( $type ne 'scan' );
scan();
pbnj-2.04/AUTHORS 0000600 0001750 0001750 00000000071 10523541634 012351 0 ustar jabra jabra Author of PBNJ
Joshua D. Abraham - jabra@ccs.neu.edu
pbnj-2.04/README 0000600 0001750 0001750 00000013001 10526514535 012161 0 ustar jabra jabra PBNJ Version 2.04
by Joshua D. Abraham ( http://pbnj.sf.net )
********************************************************************
COPYRIGHT
Copyright(C) 2005 - 2006 Joshua D. Abraham ( jabra@ccs.neu.edu )
This program is free software you can redistribute it and /or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at
your option) any later version.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
USA.
********************************************************************
PBNJ - a suite of tools to monitor changes on a network.
OVERVIEW
PBNJ is a network suite to monitor changes that occur on a network
over time. It does this by checking for changes on the target
machine(s), which includes the details about the services running on
them as well as the service state. PBNJ parses the data from a scan
and stores it in a database. PBNJ uses Nmap to perform scans.
It should be noted that when performing a scan using PBNJ will be
detected by an IDS, which will alert the Network Admin that a scan
is being performed.
WHAT IS NEW IN VERSION 2.0
The PBNJ 2.0 is completely different from PBNJ 1.0. The most drastic
change is that PBNJ 2.0 stores the information from a scan in
database. It also has queries that can extract the information that is
most useful to the user. When the user wants to extract information,
PBNJ extracts the information into a Perl data structure, so there
can be multiple output methods such as tab, csv and html. PBNJ 2.0
can also accept input from Nmap in XML format. This allows PBNJ to
be more flexbile than version 1.0.
PROGRAMS
PBNJ include 2 main programs, ScanPBNJ and OutputPBNJ. It also
includes a program called Genlist.
ScanPBNJ - a program for running Nmap scans and storing the results in
a PBNJ 2.0 database.
OutputPBNJ - a program to query a PBNJ 2.0 database.
Genlist - ping scanner
FILES
PBNJ's data files are stored in ScanPBNJ and OutputPBNJ. When
either of these programs is run the configuration files will be
generated for the user if they don't already exists and placed in
the $HOME/.pbnj-2.0 directory. Again, if there is a configuration
file in the current directory it is used instead of the version in
the configuration directory.
$HOME/.pbnj-2.0/config.yaml - holds settings for connecting to the
database which store the information from PBNJ scans.
$HOME/.pbnj-2.0/query.yaml - lists all queries that can be used to
retrieve information from the database. Also, includes the name
and description for each query. This is only generated when you
executed OutputPBNJ.
For Windows, the pbnj-2.0 config directory is in the APPDATA
directory, which contains both config.yaml and query.yaml.
Depending on your environment, the APPDATA directory may be
a different location from other environments. Therefore, when the
configs are executed for the first time they will display the path
where the configs were generated.
FEATURE REQUESTS
Any feature requests should be reported to the online
feature-request-tracking system available on the web at :
http://sourceforge.net/tracker/?func=add&group_id=149390&atid=774489
Before requesting a feature, please check to see if the features has
already been requested.
BUG REPORTS
Any bugs found should be reported to the online bug-tracking system
available on the web at :
http://sourceforge.net/tracker/?func=add&group_id=149390&atid=774488.
Before reporting bugs, please check to see if the bug has already been
reported.
When reporting PBNJ bugs, it is important to include a reliable
way to reproduce the bug, version number of PBNJ and
Nmap, OS name and version, and any relevant hardware specs. And
of course, patches to rectify the bug are even better.
SUPPORTED DATABASES
The following databases are supported:
* SQLite [default]
* MySQL
* Postgres
* CSV
To use any of the alternative database simply change the
config.yaml to the configuration that you want.
DATABASE SCHEMA
The following is the SQLite database schema:
CREATE TABLE machines (
mid INTEGER PRIMARY KEY AUTOINCREMENT,
ip TEXT,
host TEXT,
localh INTEGER,
os TEXT,
machine_created TEXT,
created_on TEXT);
CREATE TABLE services (
mid INTEGER,
service TEXT,
state TEXT,
port INTEGER,
protocol TEXT,
version TEXT,
banner TEXT,
machine_updated TEXT,
updated_on TEXT);
MAN PAGES
Man pages are available for each program. Also, there are versions
in html in the docs directory.
Let me know what you think.
Joshua D. Abraham (jabra@ccs.neu.edu)
pbnj-2.04/docs/ 0000700 0001750 0001750 00000000000 10523541605 012227 5 ustar jabra jabra pbnj-2.04/docs/outputpbnj-man.html 0000700 0001750 0001750 00000035227 10526513742 016120 0 ustar jabra jabra Content-type: text/html
Man page of OUTPUTPBNJ.MAN.1
OUTPUTPBNJ.MAN.1
Section: User Contributed Perl Documentation (1)
Updated: 2006-11-06
Index
Return to Main Contents
NAME
OutputPBNJ - a program to query a PBNJ 2.0 database.
SYNOPSIS
outputpbnj [Query Options] [Database Options] [General Options]
DESCRIPTION
OutputPBNJ uses a query yaml config file to execute queries against
the PBNJ 2.0 database. OutputPBNJ returns the result in various
output types (csv, tab and html).
Apart of PBNJ 2.0 suite of tools to monitor changes on a network.
OPTIONS
Usage: outputpbnj [Query Options] [Config Options] [General Options]
Query Options:
-q --query <name> Perform sql query
-t --type <type> Output Type [csv,tab,html]
-f --file <file> Store the result in file otherwise stdout
--both Print results and store them in a file
--dir <dir> Store the result in this directory [def .]
-l --lookup <name> Lookup description based on name
--list List of names and descriptions
-n --name Lookup all the names
-d --desc Lookup all the descriptions
-s --sql Lookup all the sql queries
Config Options:
--qconfig <file> Config of sql queries [def query.yaml]
--dbconfig <file> Config for accessing database [def config.yaml]
--dbdir <dir> Directory for Config file [def .]
--data <file> SQLite Database override [def data.dbl]
General Options:
--test <level> Test Level
--debug <level> Verbose information
-v --version Display version
-h --help Display this information
Send Comments to Joshua D. Abraham ( jabra@ccs.neu.edu )
THINGS TO NOTE
* OutputPBNJ requires root privileges to query a database that is
owned by root. Thus, if you are scanning with ScanPBNJ you will need
to run OutputPBNJ with root privileges to access the database.
* If there are configs in the current directory, they are used
instead of those in the user's config directory.
Query Options
-q --query <name> Perform sql query
This option is where the actual query is specified. Therefore, once
you know the query you wish to use simply pass it as an argument to
this option.
-t --type <type> Output Type [csv,tab,html]
This options is used to specify which output format you wish to use.
For example, if you would like to have output that you can show
someone else the CSV format is useful because you can simply pull the
file into OpenOffice Calc or Excel as it is a comma delimited file.
-f --file <file>
This option is used to specifiy output to a file rather than standard
output. This is useful if you want to grow the results of queries as
the result will be added onto the end of the file.
--both
This option is used when you want both output to standard output, as
well as to a file. This will save the result to a file if you are
having the result sent to the screen or piped to your email which you
may or may not disregard.
--dir <dir> Store the result in this directory [default .]
This option is used with the writing to a file. This option will
store the file in a alternative directory than the current directory.
-l --lookup <name>
This options is used to lookup the description of a specific query.
This will return the description of the query.
--list List of names and descriptions
This option is used to return a list of all the queries with the
names and descriptions. This is very useful when you are starting to
use OutputPBNJ or using a new query config.
-n --name
This option is used to print the all the query names.
-d --desc
This option is used to print the all the query descriptions. This is
useful to find out all the queries do.
-s --sql
This option is used to print the all the queries. This is useful for
developing new queries based on other queries.
Config Options
--qconfig <file>
Config of sql queries [default query.yaml]
This option is used to specify an alternative query.yaml file.
--dbconfig <file>
Config for accessing results database [default config.yaml]
This option is used to specify an alternative config.yaml file.
--dbdir <dir>
Directory for Config file [default .]
This option is used to specify an alternative directory for the
config.yaml file.
GENERAL OPTIONS
--test <level>
Increases the Test level, causing OutputPBNJ to print testing
information about the Query. Using the Test level is mostly only
using for testing. This will also print the debugging information so
it can get rather lengthy. The greater the Test level the more output
will be given.
This option is also used for reporting bugs. All bug reports should
be submitted using --test 1 and an additional report may be needed
depending on the issue
--debug <level>
Increases the Debug level, causing OutputPBNJ to print more
information about the query in progress. The higher the debug leve
the more output the user will receive.
-v --version
Prints the OutputPBNJ version number and exits.
-h --help Display this information
Prints a help screen with the command flags.
Running OutputPBNJ without any arguments does the same thing.
FILES
PBNJ's data files are stored in ScanPBNJ and OutputPBNJ. When either
of these programs is run the configuration files will be generated
for the user if they do not already exists and placed in the
$HOME/.pbnj-2.0 directory. Again, if there is a configuration file in
the current directory it is used instead of the version in the
configuration directory.
$HOME/.pbnj-2.0/config.yaml - holds settings for connecting to the
database which store the information from PBNJ scans.
$HOME/.pbnj-2.0/query.yaml - lists all queries that can be used to
retrieve information from the database. Also, includes the name and
description for each query. This is only generated when you executed
OutputPBNJ.
For Windows, the pbnj-2.0 config directory is in the APPDATA
directory, which contains both config.yaml and query.yaml. Depending
on your environment, the APPDATA directory may be a different location
from other environments. Therefore, when the configs are executed for
the first time they will display the path where the configs were
generated.
QUERY
The query.yaml file contains the list of various names, descriptions
and sql queries that can be executed by OutputPBNJ.
Here is one example:
- name: vulnssh
desc: list all of the services that have old ssh running
sql: |-
select S.updated_on,M.ip,S.service,S.port,S.version from services
as S, machines as M where service='ssh' and state='up' and
version!='4.1p1'
This examples shows how the name, description and sql are layed out in
the yaml format. Therefore, we know the name of the query is vulnssh
and it's purpose is to list SSH servers which are not running
a version 4.1p1. It is very easy to create another script that would
check for the latest version of a given service and therefore the
user would be able to verify that that particular service needed to
be updated on the machine that was scanned.
FEATURE REQUESTS
Any feature requests should be reported to the online
feature-request-tracking system available on the web at:
http://sourceforge.net/tracker/?func=add&group_id=149390&atid=774489
Before requesting a feature, please check to see if the features has
already been requested.
BUG REPORTS
Any bugs found should be reported to the online bug-tracking system
available on the web at :
http://sourceforge.net/tracker/?func=add&group_id=149390&atid=774488.
Before reporting bugs, please check to see if the bug has already been
reported.
When reporting PBNJ bugs, it is important to include a reliable way
to reproduce the bug, version number of PBNJ and Nmap, OS
name and version, and any relevant hardware specs. And of course,
patches to rectify the bug are even better.
SUPPORTED DATABASES
The following databases are supported:
* SQLite [default]
* MySQL
* Postgres
* CSV
DATABASE SCHEMA
The following is the SQLite version of the database schema:
CREATE TABLE machines (
mid INTEGER PRIMARY KEY AUTOINCREMENT,
ip TEXT,
host TEXT,
localh INTEGER,
os TEXT,
machine_created TEXT,
created_on TEXT);
CREATE TABLE services (
mid INTEGER,
service TEXT,
state TEXT,
port INTEGER,
protocol TEXT,
version TEXT,
banner TEXT,
machine_updated TEXT,
updated_on TEXT);
SEE ALSO
scanpbnj(1), genlist(1), nmap(1)
AUTHORS
Joshua D. Abraham ( jabra@ccs.neu.edu )
LEGAL NOTICES
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details at
http://www.gnu.org/copyleft/gpl.html, or in the COPYING file included
with PBNJ.
It should also be noted that PBNJ has occasionally been known to crash
poorly written applications, TCP/IP stacks, and even operating systems.
While this is extremely rare, it is important to keep in mind. PBNJ
should never be run against mission critical systems unless you are
prepared to suffer downtime. We acknowledge here that PBNJ may crash
your systems or networks and we disclaim all liability for any damage
or problems PBNJ could cause.
Index
- NAME
-
- SYNOPSIS
-
- DESCRIPTION
-
- OPTIONS
-
- THINGS TO NOTE
-
- Query Options
-
- -q --query <name> Perform sql query
-
- -t --type <type> Output Type [csv,tab,html]
-
- -f --file <file>
-
- --both
-
- --dir <dir> Store the result in this directory [default .]
-
- -l --lookup <name>
-
- --list List of names and descriptions
-
- -n --name
-
- -d --desc
-
- -s --sql
-
- Config Options
-
- --qconfig <file>
-
- --dbconfig <file>
-
- --dbdir <dir>
-
- GENERAL OPTIONS
-
- --test <level>
-
- --debug <level>
-
- -v --version
-
- -h --help Display this information
-
- FILES
-
- QUERY
-
- FEATURE REQUESTS
-
- BUG REPORTS
-
- SUPPORTED DATABASES
-
- DATABASE SCHEMA
-
- SEE ALSO
-
- AUTHORS
-
- LEGAL NOTICES
-
This document was created by
man2html,
using the manual pages.
Time: 04:30:26 GMT, November 15, 2006
pbnj-2.04/docs/scanpbnj-man.html 0000700 0001750 0001750 00000053221 10526514016 015471 0 ustar jabra jabra Content-type: text/html
Man page of SCANPBNJ.MAN.1
SCANPBNJ.MAN.1
Section: User Contributed Perl Documentation (1)
Updated: 2006-11-14
Index
Return to Main Contents
NAME
ScanPBNJ - a program for running Nmap scans and storing the results in
a PBNJ 2.0 database.
SYNOPSIS
scanpbnj [Options] {target specification}
DESCRIPTION
ScanPBNJ performs an Nmap scan and then stores the results in
a database. The ScanPBNJ stores information about the machine that has
been scanned. ScanPBNJ stores the IP Address, Operating System,
Hostname and a localhost bit. The localhost bit, is simply a single
bit which is 1 when the target machine is localhost, otherwise it is
0. It also stores two timestamps for the machine table. The first is
a human readable version and the second is the unix time. Both of
these timestamp correspond to the first time that the machine was
scanned.
ScanPBNJ stores information about the services that are found to be
running on the target machine. ScanPBNJ stores typical information
about the service, by storing the port and protocol. Also, ScanPBNJ
stores version, product and service state information about each
service. The service state can either be up or down. Two timestamps
are also inserted for each instance of every service. The first is a
human readable version and the second is the unix time. Both of
these timestamp correspond to the time that the service was scanned.
This tool can give an admin a clear network layout with of
all the machines with all the services they are running.
Apart of PBNJ 2.0 suite of tools to monitor changes on a network.
OPTIONS
Usage: scanpbnj [Options] {target specification}
Target Specification:
Can be a IP Address, hostname, network etc.
Ex: microsoft.com, 10.0.0.0/24, 192.168.1.1, 10.0.0.0-100
-i --iplist <iplist> Scan using a list of IPs from a file
-x --xml <xml-file> Parse scan/info from Nmap XML file
Scan Options:
-a --args <args> Execute Nmap with args (needs quotes)
-e --extraargs <args> Add args to the default args (needs quotes)
--inter <interface> Perform scan with non default interface
-m --moreports <ports> Add ports to scan ex: 8080 or 3306,5900-5910
-n --nmap <path> Path to Nmap executable
-p --pingscan Ping Target then scan the alive host(s)
--udp Add UDP to the scan arguments
--rpc Add RPC to the scan arguments
-r --range <range> Ports for scan [def 1-1025]
--diffbanner Parse changes of the banner
Config Options:
-d --dbconfig <config> Config for results database [def config.yaml]
--configdir <dir> Directory for the database config file
--data <file> SQLite Database override [def data.dbl]
--dir <dir> Directory for SQLite or CSV files [def .]
General Options:
--nocolors Don't Print Colors
--test <level> Testing information
--debug <level> Debug information
-v --version Display version
-h --help Display this information
Send Comments to Joshua D. Abraham ( jabra@ccs.neu.edu )
THINGS TO NOTE
* ScanPBNJ requires root privileges to perform a scan.
* If you do not pass a specific ports range, 1-1025 is used.
* If there are configs in the current directory, they are used
instead of those in the user's config directory.
* ScanPBNJ does not modify previous database entries. It simply
inserts new information when a change is found.
* One thing that should be done when performing scans is to make
sure to use the same ports or you will get false positives.
EXAMPLE SINGLE SCAN
1) Scan a class B network on ports 1-9000
sudo ./scanpbnj -r 1-9000 10.0.0.0/16
2) Scan an IP Address on ports 1-9000
sudo ./scanpbnj -r 1-9000 10.0.0.100
EXAMPLE AUTOMATED SCANS
The following examples can be added to /etc/crontab
1) Scan a Class C network every 2 hours
30 */2 * * * root scanpbnj 10.0.0.\*
2) Scan a Class C network everyday at 2:30
30 2 * * * root scanpbnj 10.0.0.\*
TARGET SPECIFICATION
The target specified is a typical method of probing the network.
Therefore, any of the following can be used:
(e.g. 10.0.0.1, 10.0.0.1-254, 10.0.0.0/24 or 10.0.0.\* ).
The first example is simply an IP address. The second example is
the scanning of a range. The third is a range in CIDR notation.
The fourth example is the IP with the star which specifies to scan
255 hosts. This is the same format that Nmap uses with the only
exception being the \* on the last octet. This is needed because it
needs to not interpret the star when it is being executed.
Another option, is to use a hostname or domain name. ScanPBNJ will
then resolve the name to the correct IP address. If you pass a
debug flag with level 1 or greater, ScanPBNJ will display what IP
address, the hostname resolved too.
-i <iplist> Scan using a list of IPs from a file
The iplist option is useful when you have a specific list of IPs to
scan. This will perform a full scan of the IPs that are specified.
This option is similar to using -sL with Nmap. The results of
the scan are inserted into the database.
-x <xml-file> Parse scan/info from Nmap XML file
This option is useful when you can't perform the scan yourself or
you don't want ScanPBNJ to perform the scan. Another situation where
this is useful, is if you have an XML file that was done in the past
and you want to extract information from it, possibly to compare
with what is currently being run on the target. ScanPBNJ parses the
Nmap XML file and extracts the information about the host(s) and
service(s) then inserts the results into the database.
SCAN OPTIONS
-a --args <args>
** NOTE ** This option needs quotes around the passed arguments
This option will bypass the default arguments that are used in
scanning with Nmap. This can be used to do a particular type of scan
that is not possible by simply adding extra arguments. For example,
if you want to only scan UDP ports and still do version
identification and OS detection, you would do so using the following
notation:
sudo scapbnj -a "-A -O -sU" localhost
-e --extraargs <args>
** NOTE ** This option needs quotes around the passed arguments
This option will add additional arguments onto the default scan
arguments. This is most useful in doing scans where time optimization
is needed. Therefore, these arguments will be added and then used in
the scan.
--inter <intface>
This option sets an alternative interface for performing the scan.
This is useful when you have multiple interfaces on a machine
with restrictions on which devices can access certain IP or IP ranges.
-m --moreports <ports>
This options adds additional ports to the range of ports to scan.
Individual port numbers are OK, as are ranges separated by a
hyphen (e.g. 1-1023,5800,5900,8080).
For example:
sudo scanpbnj -m 7000-7500,8080 localhost
This scan would scan the default range as well 7000-7500 and 8080.
-n --nmap <alternative-nmap-path>
Use an alternative Nmap rather than Nmap located in the your path.
This is useful if you have multiple version of Nmap installed on
a system or if you are testing a new version of Nmap. Remember that if
you are using a newly compiled version of Nmap that you need to
export NMAPDIR to the location that Nmap was compiled in. Thus, if
you have compiled Nmap in your homedir, use the following notation:
export NMAPDIR=$HOME/nmap-VERSION/
sudo scanpbnj -n $HOME/nmap-VERISON/ localhost
-p Ping Target then scan the host(s) that are alive
The ping scan is a useful method of only scanning the host that are
responding to ICMP echo requests. This scan basically takes the host
that respond to ICMP echo requests and then performs a scan only on
those hosts. Therefore, no time is wasted in scanning hosts that do
not respond. The results of the scan are then inserted into the
database.
--udp Add UDP to the scan arguments
Perform a UDP scan, in addition to the default scan.
sudo scanpbnj --udp localhost
If you want to only perform a UDP scan you need to set the specific
arguments for the scan.
sudo scanpbnj -a "-vv -O -P0 1-1025 -sVU" localhost
--rpc Add RPC to the scan arguments
Perform a RPC scan in addition to the default scan.
sudo scanpbnj --udp localhost
If you want to only perform a RPC scan you need to set the specific
arguments for the scan.
sudo scanpbnj -a "-vv -O -P0 1-1025 -sVR" localhost
-r --range <ports>
Ports for scan [default 1-1025]
This option specifies which ports you want to scan and overrides the
default. Individual port numbers are OK, as are ranges separated by a
hyphen (e.g. 1-1023,5800,5900,8080 ).
Thus, a scan like this is ok.
sudo scanpbnj -r 22,25,80,100-200 localhost
Also, if you have leave off the number after the hyphen it will scan
all from the start port to 65535.
For example:
sudo scanpbnj -r 22,25- localhost
--diffbanner
Parse changes of the banner
This options enables ScanPBNJ to do comparisons on the banner. The
reason this is not on by default is that it could show changes in
services that are not are important to the user. However, this option
is useful to a security professional who is looking for any changes
that occur so that they can be verified.
DATABASE OPTIONS
-d --dbconfig <file>
Config for results database [default config.yaml]
This option is used to specify an alternative config.yaml file.
--configdir <dir>
Directory for Config file [default . ]
This option is used to specify an alternative directory for the
config.yaml file.
--data <file>
SQLite Database override [default data.dbl ]
This option is used when you want to change the name of the SQLite
database file that is generated.
--dir <dir>
Directory for SQLite or CSV files [default . ]
This option is used when you want the database to be generated in a
different directory.
GENERAL OPTIONS
--nocolors
The default results from ScanPBNJ print the useful changes with colors
This options will simply not print the colors.
--test <level>
Increases the Test level, causing ScanPBNJ to print testing information
about the scan in progress. Using the Test level is mostly only using
for testing. This will also print the debugging information so it can
get rather lengthy. The greater the Test level the more output will be
given.
This option is also used for reporting bugs. All bug reports should
be submitted using --test 1 and an additional report may be needed
depending on the issue.
--debug <level>
Increases the Debug level, causing ScanPBNJ to print more information
about the scan in progress. Nmap scanning arguments are shown as well
as the ip address if you are scanning a domain name. This option is
used to give the user more information about what the scanner is doing.
The higher the debug level the more output the user will receive.
-v --version
Prints the ScanPBNJ version number and exits.
-h --help
Prints a short help screen with the command flags. Running ScanPBNJ
without any arguments does the same thing.
DEFAULT SCAN
Here are the default arguments that are used during a default scan:
-vv -O -P0 -sSV -p 1-1025
FILES
PBNJ's data files are stored in ScanPBNJ and OutputPBNJ. When either
of these programs is run the configuration files will be generated
for the user if they don't already exists and placed in the
$HOME/.pbnj-2.0 directory. Again, if there is a configuration file
in the current directory it is used instead of the version in the
configuration directory.
$HOME/.pbnj-2.0/config.yaml - holds settings for connecting to
the database which store the information from PBNJ scans.
$HOME/.pbnj-2.0/query.yaml - lists all queries that can be used to
retrieve information from the database. Also, includes the name and
description for each query. This is only generated when you executed
OutputPBNJ.
For Windows, the pbnj-2.0 config directory is in the APPDATA
directory, which contains both config.yaml and query.yaml. Depending
on your environment, the APPDATA directory may be a different location
from other environments. Therefore, when the configs are executed for
the first time they will display the path where the configs were
generated.
FEATURE REQUESTS
Any feature requests should be reported to the online
feature-request-tracking system available on the web at :
http://sourceforge.net/tracker/?func=add&group_id=149390&atid=774489
Before requesting a feature, please check to see if the features has
already been requested.
BUG REPORTS
Any bugs found should be reported to the online bug-tracking system
available on the web at :
http://sourceforge.net/tracker/?func=add&group_id=149390&atid=774488.
Before reporting a bug, please check to see if the bug has already been
reported.
When reporting PBNJ bugs, it is important to include a reliable way to
reproduce the bug, version number of PBNJ and Nmap, OS
name and version, and any relevant hardware specs. And of course,
patches to rectify the bug are even better.
SUPPORTED DATABASES
The following databases are supported:
* SQLite [default]
* MySQL
* Postgres
* CSV
DATABASE SCHEMA
The following is the SQLite version of the database schema:
CREATE TABLE machines (
mid INTEGER PRIMARY KEY AUTOINCREMENT,
ip TEXT,
host TEXT,
localh INTEGER,
os TEXT,
machine_created TEXT,
created_on TEXT);
CREATE TABLE services (
mid INTEGER,
service TEXT,
state TEXT,
port INTEGER,
protocol TEXT,
version TEXT,
banner TEXT,
machine_updated TEXT,
updated_on TEXT);
SEE ALSO
outputpbnj(1), genlist(1), nmap(1)
AUTHORS
Joshua D. Abraham ( jabra@ccs.neu.edu )
LEGAL NOTICES
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details at
http://www.gnu.org/copyleft/gpl.html, or in the COPYING file included
with PBNJ.
It should also be noted that PBNJ has occasionally been known to
crash poorly written applications, TCP/IP stacks, and even operating
systems. While this is extremely rare, it is important to keep in
mind. PBNJ should never be run against mission critical systems
unless you are prepared to suffer downtime. We acknowledge here that
PBNJ may crash your systems or networks and we disclaim all liability
for any damage or problems PBNJ could cause.
Index
- NAME
-
- SYNOPSIS
-
- DESCRIPTION
-
- OPTIONS
-
- THINGS TO NOTE
-
- EXAMPLE SINGLE SCAN
-
- EXAMPLE AUTOMATED SCANS
-
- TARGET SPECIFICATION
-
- -i <iplist> Scan using a list of IPs from a file
-
- -x <xml-file> Parse scan/info from Nmap XML file
-
- SCAN OPTIONS
-
- -a --args <args>
-
- -e --extraargs <args>
-
- --inter <intface>
-
- -m --moreports <ports>
-
- -n --nmap <alternative-nmap-path>
-
- -p Ping Target then scan the host(s) that are alive
-
- --udp Add UDP to the scan arguments
-
- --rpc Add RPC to the scan arguments
-
- -r --range <ports>
-
- --diffbanner
-
- DATABASE OPTIONS
-
- -d --dbconfig <file>
-
- --configdir <dir>
-
- --data <file>
-
- --dir <dir>
-
- GENERAL OPTIONS
-
- --nocolors
-
- --test <level>
-
- --debug <level>
-
- -v --version
-
- -h --help
-
- DEFAULT SCAN
-
- FILES
-
- FEATURE REQUESTS
-
- BUG REPORTS
-
- SUPPORTED DATABASES
-
- DATABASE SCHEMA
-
- SEE ALSO
-
- AUTHORS
-
- LEGAL NOTICES
-
This document was created by
man2html,
using the manual pages.
Time: 04:31:10 GMT, November 15, 2006
pbnj-2.04/docs/genlist-man.html 0000700 0001750 0001750 00000016531 10526514042 015342 0 ustar jabra jabra Content-type: text/html
Man page of GENLIST.MAN.1
GENLIST.MAN.1
Section: User Contributed Perl Documentation (1)
Updated: 2006-11-06
Index
Return to Main Contents
NAME
Genlist - ping scanner
SYNOPSIS
genlist [Input Type] [Scan Options] [General Options]
DESCRIPTION
Genlist is a program that returns a list of hosts that responding
to ping probes. Thus, this list can be used to perform an scan of
these machines using PBNJ or Nmap.
Apart of PBNJ 2.0 suite of tools to monitor changes on a network.
OPTIONS
Usage: genlist [Input Type] [General Options]
Input Type:
-s --scan <target> Ping Target Range ex: 10.0.0.\*
Scan Options:
-n --nmap <path> Path to Nmap executable
--inter <interface> Perform scan using non default interface
General Options:
-v --version Display version
-h --help Display this information
Send Comments to Joshua D. Abraham ( jabra@ccs.neu.edu )
EXAMPLE OF GENLIST USED WITH PBNJ
$ ./genlist -s 10.0.0.\* > iplist
$ sudo ./scanpbnj -i iplist
EXAMPLE OF GENLIST USED WITH NMAP
$ ./genlist -s 10.0.0.\* > iplist
$ sudo ./nmap -iL iplist
INPUT TYPE
-s <target> Ping Target Range ex: 10.0.0.*
The ping scan is a useful method of only scanning the host that are
responding to ICMP echo requests. This scan basically takes the host
that respond to ping and prints them. This is useful in combining
the result with a PBNJ or Nmap scan because no time is wasted in
scanning hosts that do not respond.
SCAN OPTIONS
--interface <intface>
This option sets an alternative interface for performing the scan.
This is useful when you have multiple interfaces on a machine
with restrictions on which devices can access certain IP ranges.
-n --nmap <path>
Use an alternative Nmap rather than Nmap located in the your path.
This is useful if you have multiple version of Nmap installed on
a system or if you are testing a new version of Nmap. Remember that if
you are using a newly compiled version of Nmap that you need to
export NMAPDIR to the location that Nmap was compiled in. Thus, if
you have compiled Nmap in your homedir, use the following notation to
run it with Genlist:
$ export NMAPDIR=$HOME/nmap-VERSION/
$ sudo genlist -s 10.0.0.\* --nmap $HOME/nmap-VERISON/
General Options:
-v --version
Prints the Genlist version number and exits.
-h --help Display this information
Prints a short help screen with the most common command flags.
Running Genlist without any arguments does the same thing.
FEATURE REQUESTS
Any feature requests should be reported to the online
feature-request-tracking system available on the web at :
http://sourceforge.net/tracker/?func=add&group_id=149390&atid=774489
Before requesting a feature, please check to see if the features has
already been requested.
BUG REPORTS
Any bugs found should be reported to the online bug-tracking system
available on the web at :
http://sourceforge.net/tracker/?func=add&group_id=149390&atid=774488.
Before reporting bugs, please check to see if the bug has already been
reported.
When reporting PBNJ bugs, it is important to include a reliable way to
reproduce the bug, version number of PBNJ and Nmap, OS
name and version, and any relevant hardware specs. And of course,
patches to rectify the bug are even better.
SEE ALSO
scanpbnj(1) outputpbnj(1), nmap(1)
AUTHORS
Joshua D. Abraham ( jabra@ccs.neu.edu )
LEGAL NOTICES
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details at
http://www.gnu.org/copyleft/gpl.html, or in the COPYING file included
with PBNJ.
It should also be noted that PBNJ has occasionally been known to crash
poorly written applications, TCP/IP stacks, and even operating systems.
While this is extremely rare, it is important to keep in mind. PBNJ
should never be run against mission critical systems unless you are
prepared to suffer downtime. We acknowledge here that PBNJ may crash
your systems or networks and we disclaim all liability for any damage
or problems PBNJ could cause.
Index
- NAME
-
- SYNOPSIS
-
- DESCRIPTION
-
- OPTIONS
-
- EXAMPLE OF GENLIST USED WITH PBNJ
-
- EXAMPLE OF GENLIST USED WITH NMAP
-
- INPUT TYPE
-
- -s <target> Ping Target Range ex: 10.0.0.*
-
- SCAN OPTIONS
-
- --interface <intface>
-
- -n --nmap <path>
-
- General Options:
-
- -v --version
-
- -h --help Display this information
-
- FEATURE REQUESTS
-
- BUG REPORTS
-
- SEE ALSO
-
- AUTHORS
-
- LEGAL NOTICES
-
This document was created by
man2html,
using the manual pages.
Time: 04:31:30 GMT, November 15, 2006
pbnj-2.04/outputpbnj 0000700 0001750 0001750 00000102626 10526513046 013447 0 ustar jabra jabra #!/usr/bin/perl
#
# Copyright (C) 2005-2006 Joshua D. Abraham ( jabra@ccs.neu.edu )
#
# This program is released under the terms of the GNU General Public License
# (GPL), which is distributed with this software in the file "COPYING".
# The GPL specifies the terms under which users may copy and use this software.
#
# PBNJ 2.0
# (P)orts (B)anners N' (J)unk
#
# Author: Joshua D. Abraham
# Date: March 15, 2006
# Updated: November 15, 2006
# Version: 2.04
#
#
# OutputPBNJ - a program to query a PBNJ 2.0 database.
#
use strict;
use warnings;
use Shell;
use YAML;
use DBI;
use Getopt::Long;
use Text::CSV_XS;
use FileHandle;
use File::HomeDir;
use vars qw( $PROG );
( $PROG = $0 ) =~ s/^.*[\/\\]//; # Truncate calling path from the prog name
my $AUTH = 'Joshua D. Abraham'; # author
my $VERSION = '2.04'; # version
my $type = 'tab'; # default output format
my $output = 'stdout'; # default output
my $bothOutput = 0; # use both output methods
my $query = 'query.yaml'; # yaml configureation file
my $data; # store the contents of yaml config
my $result; # result of sql query
my %options; # getopts hash
my $header = 0; # print column headers
my $dbh; # database connection
my $dbconfig = 'config.yaml'; # database config
my $database; # database file
my $db; # db backend
my $hostname; # db host ip
my $port; # db port
my $user; # db username
my $passwd; # db password
my $dbdir = "."; # output database directory
my $dir = "."; # output database directory
my $datadb; # db
$options{test} = 0; # testing flag
$options{debug} = 0; # debug flag
my $configdir;
#chown() that reports errors
sub safe_chown {
my $uid = shift;
my $gid = shift;
my $file = shift;
if ( chown( $uid, $gid, $file ) != 1 ) {
error( 'Unable to change the owner of the file ' . $file . '.'
. "\n\n" );
}
}
if ( $^O eq 'MSWin32' || $^O =~ /cygwin/ ) {
require Win32;
import Win32;
Win32->import(qw(CSIDL_APPDATA));
my $dir = Win32::GetFolderPath( CSIDL_APPDATA() );
$configdir = $dir . "\\" . "pbnj-2.0";
if ( -e $configdir and -d $configdir ) {
#print "$configdir exists\n";
}
else {
mkdir $configdir;
print "mkdir $configdir\n";
}
# check if config exists in the current directory
if ( !-e $dbconfig ) {
$dbconfig = "$configdir\\$dbconfig";
}
my ( $read_config, $read_query );
# check if the config exists in ~/.pbnj-2.0/config.yaml
if ( !-e $dbconfig ) {
$read_config = 0;
}
else {
# print "config exists\n";
$read_config = 2;
}
if ( !-e $query ) {
$query = "$configdir\\$query";
}
if ( !-e $query ) {
$read_query = 0;
}
else {
# print "query exists\n";
$read_query = 2;
}
my @array;
while () {
push( @array, $_ );
}
#print "query is $read_query and config is $read_config\n";
if ( $read_query != 2 or $read_config != 2 ) {
if ( $read_config == 0 ) {
open( CONFIG, ">$dbconfig" );
foreach (@array) {
last if (/Query.yaml/);
if ( defined($_) ) {
print CONFIG $_;
}
}
close(CONFIG);
print "$dbconfig generated\n";
}
if ( $read_query == 0 ) {
open( QUERY, ">$query" );
my $config = 2;
foreach (@array) {
$config = 0 if (/Query.yaml/);
if ( defined($_) and $config == 0 ) {
print QUERY $_;
}
}
close(QUERY);
print "$query generated\n";
}
}
}
else {
$configdir = File::HomeDir->my_home;
my $tmpuser = $configdir;
$tmpuser =~ s/home//;
$tmpuser =~ s/\///g;
my $uid = getpwnam($tmpuser);
my $gid = id("-g $tmpuser");
if ( !defined($gid) ) {
error("gid not defined\n");
}
if ( !defined($uid) ) {
error("uid not defined\n");
}
$configdir .= "/.pbnj-2.0";
if ( -e $configdir and -d $configdir ) {
#print "$configdir exists\n";
}
else {
umask 077;
mkdir $configdir;
print "mkdir $configdir\n";
safe_chown( $uid, $gid, $configdir );
}
# check if config exists in the current directory
if ( !-e $dbconfig ) {
$dbconfig = "$configdir/$dbconfig";
}
my ( $read_config, $read_query );
# check if the config exists in ~/.pbnj-2.0/config.yaml
if ( !-e $dbconfig ) {
$read_config = 0;
}
else {
# print "config exists\n";
$read_config = 2;
}
if ( !-e $query ) {
$query = "$configdir/$query";
}
if ( !-e $query ) {
$read_query = 0;
}
else {
# print "query exists\n";
$read_query = 2;
}
my @array;
while () {
push( @array, $_ );
}
#print "query is $read_query and config is $read_config\n";
if ( $read_query != 2 or $read_config != 2 ) {
if ( $read_config == 0 ) {
umask 077;
open( CONFIG, ">$dbconfig" );
foreach (@array) {
last if (/Query.yaml/);
if ( defined($_) ) {
print CONFIG $_;
}
}
close(CONFIG);
safe_chown( $uid, $gid, $dbconfig );
print "$dbconfig generated\n";
}
if ( $read_query == 0 ) {
umask 077;
open( QUERY, ">$query" );
my $config = 2;
foreach (@array) {
$config = 0 if (/Query.yaml/);
if ( defined($_) and $config == 0 ) {
print QUERY $_;
}
}
close(QUERY);
safe_chown( $uid, $gid, $query );
print "$query generated\n";
}
}
}
##############################################################################
#
# help ->
# display help information
# side effect: exits program
#
##############################################################################
sub help {
print "Usage: $PROG [Query Options] [Config Options] [General Options]
Query Options:
-q --query Perform sql query
-t --type Output Type [csv,tab,html]
-f --file Store the result in file otherwise stdout
--both Print results and store them in a file
--dir Store the result in this directory [def .]
-l --lookup Lookup descrition based on name
--list List of names and descriptions
-n --name Lookup all the names
-d --desc Lookup all the descriptions
-s --sql Lookup all the sql queries
Config Options:
--qconfig Config of sql queries [def query.yaml]
--dbconfig Config for accessing database [def config.yaml]
--configdir Directory for the database config file
--data SQLite Database override [def data.dbl]
General Options:
--test Testing information
--debug Debug information
-v --version Display version
-h --help Display this information
Send Comments to Joshua D. Abraham ( jabra\@ccs.neu.edu )\n";
exit;
}
##############################################################################
#
# print_version ->
# displays version
# side effect: exits program
#
##############################################################################
sub print_version {
print "$PROG version $VERSION by $AUTH\n";
exit;
}
##############################################################################
#
# printName: array ->
# print the names of the queries
# side effect: exits program
#
# data yaml config contents
#
##############################################################################
sub printName {
my $data = shift || die "printName data not defined";
print "Name of the Queries\n";
print "* * * * * * * * * * * * * * * * * * * * * * * * * * * \n";
foreach (@$data) {
my $tmp = $_;
foreach my $key ( keys %$tmp ) {
if ( $key eq 'name' ) {
print "- " . $$tmp{$key} . "\n";
}
}
}
exit;
}
##############################################################################
#
# printDesc
# print the descriptions of the queries
# side effect: exits program
#
# data yaml config contents
#
##############################################################################
sub printDesc {
my $data = shift || die "printDesc: data not defined";
print "Description of the Queries\n";
print "* * * * * * * * * * * * * * * * * * * * * * * * * * * \n";
foreach (@$data) {
my $tmp = $_;
foreach my $key ( keys %$tmp ) {
if ( $key eq 'desc' ) {
print "- " . $$tmp{$key} . "\n";
}
}
}
exit;
}
##############################################################################
#
# printList
# print the list of the queries name followed by description
# side effect: exits program
#
# data yaml config contents
#
##############################################################################
sub printList {
my $data = shift || die "printList: data not defined";
print "List of Name - Description of the Queries\n";
print "* * * * * * * * * * * * * * * * * * * * * * * * * * * \n";
my %line;
my $i = 0;
foreach (@$data) {
my $tmp = $_;
foreach my $key ( keys %$tmp ) {
next if ( !defined( $$tmp{$key} ) );
$line{ $i++ }{name} = $$tmp{$key} if ( $key eq "name" );
$line{$i}{desc} = $$tmp{$key} if ( $key eq "desc" );
}
}
$i--;
foreach ( 0 .. $i ) {
next
if ( !defined( $line{$_}{name} or !defined( $line{$_}{desc} ) ) );
print $line{$_}{name} . " - " . $line{$_}{desc} . "\n";
}
exit;
}
##############################################################################
#
# printSql
# print the Sql of the queries
# side effect: exits program
#
# data yaml config contents
#
##############################################################################
sub printSql {
my $data = shift || die "printSql: data not defined";
print "Sql of the Queries\n";
print "* * * * * * * * * * * * * * * * * * * * * * * * * * * \n";
foreach (@$data) {
my $tmp = $_;
foreach my $key ( keys %$tmp ) {
if ( $key eq 'sql' ) {
print "- " . $$tmp{$key} . "\n";
}
}
}
exit;
}
##############################################################################
#
# lookupDescByName: anon hash
# lookup description of the query based on the name
# side effect: exits program
#
# data yaml config contents
# name name of the query to lookup
#
##############################################################################
sub lookupDescByName {
my ($href) = @_;
die "lookupByName: data not defined" unless defined $href->{data};
die "lookupByName: name not defined" unless defined $href->{name};
my $data = $href->{data};
my $name = $href->{name};
foreach (@$data) {
my $tmp = $_;
foreach my $key ( keys %$tmp ) {
if ( $key eq 'name' and $$tmp{$key} eq $name ) {
print "Description for $name\n";
print "$$tmp{desc}\n";
exit;
}
}
}
print "Didn't find any descrition with the name $name\n";
exit 1;
}
##############################################################################
# lookupByDesc : anon hash ->
# lookup description of query based on the decription
# side effect: exits program
#
# data yaml config contents
# desc descrition of the query to lookup
#
##############################################################################
sub lookupNameByDesc {
my ($href) = @_;
die "lookupByDesc: data not defined" unless defined $href->{data};
die "lookupByDesc: desc not defined" unless defined $href->{desc};
my $data = $href->{data};
my $desc = $href->{desc};
foreach (@$data) {
my $tmp = $_;
foreach my $key ( keys %$tmp ) {
if ( $key eq 'desc' and $$tmp{$key} eq $desc ) {
print "Name is $$tmp{name}\n";
exit;
}
}
}
print "didn't find any descrition with the name $desc\n";
exit 1;
}
##############################################################################
#
# lookupSql: anon hash -> scalar
# lookup sql based on the name
#
# data data from the yaml config file
# name name of the query to lookup
#
##############################################################################
sub lookupSql {
my ($href) = @_;
die "lookupSqlByName: data not defined" unless defined $href->{data};
die "lookupSqlByName: name not defined" unless defined $href->{name};
my $data = $href->{data};
my $name = $href->{name};
foreach (@$data) {
my $tmp = $_;
foreach my $key ( keys %$tmp ) {
if ( $key eq 'name' and $$tmp{$key} eq $name ) {
my $sql = $$tmp{sql};
return $sql;
}
}
}
}
##############################################################################
#
# realName: anon hash -> scalar
# determines if the name exists
#
# data data from the yaml config file
# name name of the query to lookup
#
##############################################################################
sub realName {
my ($href) = @_;
die "realName: data not defined" unless defined $href->{data};
die "realName: name not defined" unless defined $href->{data};
my $data = $href->{data};
my $name = $href->{name};
foreach (@$data) {
my $tmp = $_;
foreach my $key ( keys %$tmp ) {
if ( $key eq 'name' and $$tmp{$key} eq $name ) {
return 1;
}
}
}
return 0;
}
##############################################################################
#
# runSql: anon hash -> array ref
# execute sql and return arrayref to the result
#
# data data for output
# name name of sql query
# db sqlite3 database file
#
# ############################################################################
sub runSql {
my ($href) = @_;
die "runSql: data not defined" unless defined $href->{data};
die "runSql: name not defined" unless defined $href->{name};
die "runSql: db not defined" unless defined $href->{db};
my $data = $href->{data};
my $name = $href->{name};
my $dbh = $href->{db};
my ( $exist, $sql );
$exist = realName( { data => $data, name => $name } );
if ( $exist eq 1 ) {
$sql = lookupSql( { data => $data, name => $name } );
print "sql is $sql\n"
if ( $options{debug} eq 1 or $options{test} eq 1 );
}
else {
print "Query $name does not exist the Query Config File\n";
exit 1;
}
my $sth = $dbh->prepare($sql);
if (defined($sth)){
my $tmp = $sth->execute;
return $sth;
}
else {
print "Broken SQL Query\n";
exit 1;
}
exit;
}
# html output
sub htmlOutput {
my $output = shift;
foreach (@$output) {
foreach (@$_) {
print "$_ ";
}
print "\n";
}
print "\n";
}
# tab output
sub tabOutput {
my $output = shift;
foreach (@$output) {
foreach (@$_) {
print "$_\t";
}
print "\n";
}
print "\n";
}
# csv output
sub csvOutput {
my $output = shift;
foreach (@$output) {
foreach (@$_) {
print "$_,";
}
print "\n";
}
print "\n";
}
##############################################################################
#
# delimOutput: anon hash ->
# output the results of a sql query using a delminatator
# side effect:
#
# results the data for output
# fileName contains the filename of the output or stdout
# delim Delminator for the file (csv, tab, space)
#
# ##############################################################################
sub delimOutput {
my ($href) = @_;
my ( $fh, @fields, $elements );
die "output: results not defined" unless defined $href->{results};
die "output: fileName not defined" unless defined $href->{fileName};
die "output: delim not defined" unless defined $href->{delim};
my $sth = $href->{results};
my $fileName = $href->{fileName};
my $delim = $href->{delim};
my $csv = Text::CSV_XS->new( { binary => 1 } );
my $row = $sth->fetchall_arrayref;
if ( $fileName ne 'stdout' ) {
$fh = new FileHandle(">>$fileName");
die "'$fileName': $!" unless defined $fh;
}
my $num_fields = $sth->{NUM_OF_FIELDS};
if (scalar(@$row) eq 0){
print "No Results from Query\n";
exit;
}
print "num of fields is $num_fields\n" if ( $options{test} eq 1 );
if ( ( $type eq 'csv' or $type eq 'html' ) and ( $header eq 1 ) ) {
for ( 0 .. $num_fields ) {
print "before column extraction\n" if ( $options{test} eq 1 );
my $column = $sth->{NAME_lc}->[$_];
print "after column extraction\n" if ( $options{test} eq 1 );
if ( defined($column) ) {
print "column is $column\n"
if ( $options{debug} eq 1 or $options{debug} eq 1 );
print $fh "$column" if ( $fileName ne 'stdout' );
print $fh "$delim"
if ( $fileName ne 'stdout'
&& $_ < $num_fields - 1 );
print "$column"
if ( $fileName eq 'stdout' or $bothOutput eq 1 );
print "$delim"
if ( ( $fileName eq 'stdout' or $bothOutput eq 1 )
&& $_ < ( $num_fields - 1 ) );
}
else {
print "column not defined" if ( $options{test} eq 1 );
}
}
print "\n" if ( $fileName eq 'stdout' );
print $fh "\n" if ( $fileName ne 'stdout' );
}
my $rownum = 0;
foreach (@$row) {
my $result;
foreach my $line (@$_) {
if ( defined $result ) {
$result = join( ',', $result, $line );
}
else {
$result = join( ',', $line );
}
}
if ( $csv->parse($result) ) {
@fields = $csv->fields();
$elements = @fields;
}
if ( $type eq "tab" and $rownum eq 0 and $header eq 1 ) {
for ( my $x = 0; $x < $elements; $x++ ) {
print "before column extraction\n" if ( $options{test} eq 1 );
my $col = $sth->{NAME_lc}->[$x];
print "after column extraction\n" if ( $options{test} eq 1 );
if ( defined($col) ) {
print "column is $col\n" if ( $options{test} eq 1 );
my $len = "%" . length( $fields[$x] );
my $tmp;
if ( $fields[$x] =~ /\w/ ) {
$tmp = 's';
}
elsif ( $fields[$x] =~ /\d/ ) {
$tmp = 'd';
}
else {
print "field is $fields[$x]"
if ( $options{test} eq 1 );
}
printf "$len$tmp", $col
if ( $type eq 'tab'
and ( $fileName eq 'stdout' or $bothOutput eq 1 ) );
printf "\t"
if ( $type eq 'tab'
and ( $fileName eq 'stdout' or $bothOutput eq 1 ) );
printf $fh "$len$tmp", $col
if ( $type eq 'tab' && $fileName ne 'stdout' );
printf $fh "\t"
if ( $type eq 'tab' && $fileName ne 'stdout' );
}
}
$rownum++;
}
for ( my $x = 0; $x < $elements; $x++ ) {
my $len;
my $tmp;
#print "x is $x \t\n";
#print "element is $elements \t\n";
$len = "%" . length( $fields[$x] );
if ( $fields[$x] =~ /\w/ ) {
$tmp = 's';
}
elsif ( $fields[$x] =~ /\d/ ) {
$tmp = 'd';
}
else {
$tmp = 's';
}
printf $fh "$fields[$x]" if ( $fileName ne 'stdout' );
printf $fh "$delim"
if ( $fileName ne 'stdout' && $x < $elements - 1 );
printf "$len$tmp", $fields[$x]
if ( $fileName eq 'stdout' or $bothOutput eq 1 );
printf "$delim"
if ( ( $fileName eq 'stdout' or $bothOutput eq 1 )
&& $x < $elements - 1 );
}
printf "\n" if ( $fileName eq 'stdout' or $bothOutput eq 1 );
printf $fh "\n" if ( $fileName ne 'stdout' );
}
print "\n" if ( $fileName eq 'stdout' or $bothOutput eq 1 );
print "\n" if ( $fileName ne 'stdout' );
printf $fh "\n" if ( $fileName ne 'stdout' );
}
#############################################################################
#
# GetOpts
#
#############################################################################
if ( @ARGV == 0 ) {
help;
exit;
}
GetOptions(
\%options,
'type|t=s', 'file|f=s', 'lookup|l=s', 'both|b',
'query|q=s', 'names|n', 'desc|d', 'sql|s', 'list',
'dbconfig=s', 'configdir=s', 'dir=s', 'data=s', 'qconfig=s',
'test|=s', 'debug|=s',
'help|h' => sub { help(); },
'version|v' => sub { print_version(); },
'both' => sub { $bothOutput = 1 },
)
or exit 1;
if ( $options{'configdir'} ) {
$configdir = $options{'configdir'};
}
if ( $options{'dir'} ) {
$dir = $options{'dir'};
}
if ( $options{'dbconfig'} ) {
my $tmpconfig;
if ( $^O eq 'MSWin32' || $^O =~ /cygwin/ ) {
$tmpconfig = $configdir . '\\' . $options{'dbconfig'};
}
else {
$tmpconfig = $configdir . "/" . $options{'dbconfig'};
}
if ( -e $tmpconfig && -r $tmpconfig ) {
$dbconfig = $tmpconfig;
}
}
if ( $options{'qconfig'} ) {
my $tmpconfig;
if ( $^O eq 'MSWin32' || $^O =~ /cygwin/ ) {
$tmpconfig = $configdir . '\\' . $options{'qconfig'};
}
else {
$tmpconfig = $configdir . "/" . $options{'qconfig'};
}
if ( -e $tmpconfig && -r $tmpconfig ) {
$query = $tmpconfig;
}
}
if ( -e $query && -r $query ) {
$data = YAML::LoadFile($query);
}
else {
print "configuration file $query not readable\n";
exit 1;
}
chdir($dir) or die "Couldn't change to directory $dir\n";
if ( $options{'query'} ) {
if ( $options{data} ) {
$db = "SQLite";
$database = $options{data};
}
else {
if ( -e $dbconfig && -r $dbconfig ) {
$datadb = YAML::LoadFile($dbconfig);
foreach my $tmp ( keys %$datadb ) {
$passwd = $$datadb{$tmp} if ( $tmp eq 'passwd' );
$user = $$datadb{$tmp} if ( $tmp eq 'user' );
$db = $$datadb{$tmp} if ( $tmp eq 'db' );
$database = $$datadb{$tmp} if ( $tmp eq 'database' );
$hostname = $$datadb{$tmp} if ( $tmp eq 'host' );
$port = $$datadb{$tmp} if ( $tmp eq 'port' );
}
}
else {
print "Configuration file $dbconfig not readable\n";
exit 1;
}
}
# connection to database
if ( $db eq 'SQLite' ) {
if ( !-e $database ) {
print "SQLite database $database doesn't exist\n";
exit 1;
}
if ( !-r $database ) {
print "SQLite database $database can't be read\n";
print "Might need root privileges to access it\n";
exit 1;
}
$dbh = DBI->connect(
"dbi:$db:$database",
$user, $passwd,
{ PrintError => 0,
RaiseError => 0,
AutoCommit => 1
}
)
|| die "Cannot connect: $DBI::errstr";
}
elsif ( $db eq 'mysql' ) {
my $dsn = "DBI:$db:database=$database;host=$hostname;port=$port";
$dbh = DBI->connect(
$dsn, $user, $passwd,
{ PrintError => 0,
RaiseError => 0,
AutoCommit => 1
}
)
|| die "Cannot connect: $DBI::errstr";
}
elsif ( $db eq 'Pg' ) {
my $dsn = "DBI:$db:database=$database;host=$hostname;port=$port";
$dbh = DBI->connect(
$dsn, $user, $passwd,
{ PrintError => 0,
RaiseError => 0,
AutoCommit => 1,
PrintWarn => 0
}
)
|| die "Cannot connect: $DBI::errstr";
#$dbh = DBI->connect("dbi:$db:dbname=$dbname", "", "", {AutoCommit => 0});
}
elsif ( $db eq 'CSV' ) {
print "output queries not supported for CSV format\n";
exit;
}
else {
print "$db isn't supported\n";
}
}
if ( $options{'list'} ) {
printList($data);
}
if ( $options{'names'} ) {
printName($data);
}
if ( $options{'desc'} ) {
printDesc($data);
}
if ( $options{'sql'} ) {
printSql($data);
}
if ( $options{'type'} ) {
if ( $options{'type'} eq 'tab' ) {
$type = 'tab';
}
elsif ( $options{'type'} eq 'html' ) {
$type = 'html';
}
elsif ( $options{'type'} eq 'csv' ) {
$type = 'csv';
}
else {
print $options{'type'};
die "type not supported\n";
}
}
if ( $options{'file'} ) {
chdir($dir) or die "Couldn't change to $dir directory\n";
if ( -e $options{'file'} ) {
if ( -w $options{'file'} ) {
$output = $options{'file'};
}
}
elsif ( !-w $options{'file'} ) {
$output = $options{'file'};
}
else {
print "file not writable\n";
exit 1;
}
}
if ( $options{'lookup'} ) {
lookupDescByName( { data => $data, name => $options{'lookup'} } );
exit;
}
if ( $options{'query'} ) {
$result
= runSql( { data => $data, name => $options{'query'}, db => $dbh } );
}
&help if ( not defined $result );
#############################################################################
#
# Main
#
#############################################################################
if ( $type eq 'html' ) {
#htmlOutput( $result, $output );
delimOutput( { results => $result, fileName => $output, delim => " " } );
}
elsif ( $type eq 'tab' ) {
delimOutput( { results => $result, fileName => $output, delim => "\t" } );
}
elsif ( $type eq 'csv' ) {
delimOutput( { results => $result, fileName => $output, delim => "," } );
}
else {
print "output not defined\n";
}
$dbh->disconnect;
__DATA__
# Config.yaml
#
# Copyright (C) 2005-2006 Joshua D. Abraham ( jabra@ccs.neu.edu )
#
# This config file is released under the terms of the GNU General
# Public License (GPL), which is distributed with this software in the
# file "COPYING". The GPL specifies the terms under which users
# may copy and use this software.
#
# PBNJ 2.0
# (P)orts (B)anners N' (J)unk
#
# Author: Joshua D. Abraham
# Date: March 15, 2006
# Updated: November 15, 2006
# Version: 2.04
#
# Configuration file for PBNJ 2.0
# YAML:1.0
#
# Config for connecting to a DBI database
# SQLite, mysql etc
db: SQLite
# for SQLite the name of the file. For mysql the name of the database
database: data.dbl
# Username for the database. For SQLite no username is needed.
user: ""
# Password for the database. For SQLite no password is needed.
passwd: ""
# Password for the database. For SQLite no host is needed.
host: ""
# Port for the database. For SQLite no port is needed.
port: ""
# Query.yaml
#
#
# Copyright (C) 2005-2006 Joshua D. Abraham ( jabra@ccs.neu.edu )
#
# This config file is released under the terms of the GNU General
# Public License (GPL), which is distributed with this software in the
# file "COPYING". The GPL specifies the terms under which users
# may copy and use this software.
#
#
# PBNJ 2.0
# (P)orts (B)anners N' (J)unk
#
# Author: Joshua D. Abraham
# Date: March 15, 2006
# Updated: November 15, 2006
# Version: 2.04
#
# Configuration file for PBNJ 2.0
#
# Contains all the names, descriptions and queries for PBNJ 2.0
#
# If you would like to submit a new query, please submit it to the link
# below. The summary should start with QUERY: description
#
# http://sourceforge.net/tracker/?func=add&group_id=149390&atid=774490
#
#
--- #YAML:1.0
- name: possiblevuln
desc: list all of the services that possibly, should not be running
sql: select * from services where service!='ssh' and state='up'
# example of verion checking
#- name: vulnssh
# desc: all of the services that have old ssh running
# sql: |-
# select S.updated_on,M.ip,S.service,S.port,S.version from services as S,
# machines as M where service='ssh' and state='up' and version!='4.1p1'
- name: sshmachines
desc: all the machines that have run ssh
sql: |-
select S.updated_on,M.host,S.service,S.state,S.version from
services as S, machines as M where port='22' and M.mid = S.mid
- name: allservices
desc: all services that have ever been up
sql: select * from services where state='up'
- name: services
desc: basic dump of the services table
sql: select updated_on,service,version,banner,state from services
- name: unknown_version_up
desc: services that have run a unknown version
sql: |-
select updated_on,service,banner from services where
version='unknown version' and state='up'
- name: unknown_banner_up
desc: services that have run a unknown banner
sql: |-
select updated_on,service,version from services where
banner='unknown banner' and state='up'
- name: machines
desc: basic dump of the machines table
sql: select created_on,ip,host,localh,os from machines
- name: sdump
desc: dump of the services table
sql: select * from services
- name: mdump
desc: dump of the machines table
sql: select * from machines
- name: servicesup
desc: services running on machines with a given ip or range
sql: |-
select M.host, S.service,S.version,S.banner from
services as S,machines as M where state='up' and M.mid = S.mid
- name: unknownversion
desc: all instances of services running with an unknown version
sql: select * from services where version='unknown version'
- name: unknownbanner
desc: all instances of services running with an unknown banner
sql: select * from services where banner='unknown banner'
- name: machine_audit
desc: machine audit query
sql: select ip,host,os from machines
- name: service_audit
desc: serice audit query
sql: |-
select s.port,s.protocol,s.service,s.banner,s.version from services s join
machines m join (select mid,service,max(machine_updated)'muo' from
services group by mid,service)r where s.mid=r.mid and
s.service=r.service and s.state='up'
AND s.machine_updated=r.muo and m.mid=s.mid ORDER BY s.port;
- name: latestinfo_audit
desc: latest host and services info
sql: |-
select S.port,S.protocol,S.service,S.state,S.banner,S.version from
services as S where updated_on = (select updated_on from
services ORDER BY updated_on DESC limit 1) ORDER BY s.port;
- name: latestinfo
desc: latest host and services info (by hostname)
sql: |-
select S.updated_on,M.host, S.service,S.state,S.version,S.protocol from
services as S,machines as M where updated_on = (select updated_on from
services ORDER BY updated_on DESC limit 1) and M.mid = S.mid
- name: latestchange
desc: latest host and services info (by ip)
sql: |-
select S.updated_on,M.ip, S.service,S.state,S.version,S.protocol from
services as S,machines as M where updated_on = (select updated_on from
services ORDER BY updated_on DESC limit 1) and M.mid = S.mid
- name: servicestate
desc: |-
most recent state for all services whether they have or have not changed
sql: |-
select s.updated_on,m.host,r.service,state from services s join
machines m join (select mid,service,max(machine_updated)'muo' from
services group by mid,service)r where s.mid=r.mid and
s.service=r.service and s.machine_updated=r.muo and m.mid=s.mid;
- name: uptimeratio
desc: |-
ratio for each service for each machine of the uptime of all the
services in the database. This is based on our scans. Therefore,
if you can scan once a day or once every hour the ratio is more or
less accurate depending.
sql: |-
select a.mid,a.service,upCount,scanCount,1.0*upCount/scanCount'ratio' from
(select mid,service,state,count(*)'upCount' from services where state='up'
group by mid,service,state) a join (select mid,service,count(*)'scanCount'
from services group by mid,service) b where a.mid=b.mid and
a.service=b.service ;
- name: monthlyreport
desc: |-
report of services ip addresses and versions that are currntly running
sql: |-
select M.ip, S.port,S.service,S.version,S.banner from services as
S,machines as M where updated_on = (select updated_on from services ORDER
BY updated_on DESC limit 1) and M.mid = S.mid
pbnj-2.04/quickinstall.sh 0000700 0001750 0001750 00000010024 10523541634 014340 0 ustar jabra jabra #!/bin/sh
#
# Copyright (C) 2005-2006 Joshua D. Abraham (jabra@ccs.neu.edu)
#
# This program is released under the terms of the GNU General Public License
# (GPL), which is distributed with this software in the the file "COPYING".
# The GPL specifies the terms under which users may copy and use this software.
#
# pbnj
# (P)orts (B)anners N' (J)unk
#
# Author: Joshua D. Abraham
# Date: March 15, 2005
# Updated: July 19, 2006
# Version: 2.0
#
# This program is a simple install script for for PBNJ 2.0
#
install(){
echo "Building Makefile [ perl Makefile.PL ] ..."
perl Makefile.PL
if test $? -ne 0 ; then
echo "Makefile error"
error
else
echo "ok"
fi
echo "Preparing PBNJ for Install [ make ] ..."
make
if test $? -ne 0 ; then
echo "make didn't pass"
error
else
echo "ok"
fi
echo "Testing PBNJ for Install [ make test ] ..."
make test
if test $? -ne 0 ; then
echo "All the tests didn't pass"
error
else
echo "ok"
fi
echo "Installing PBNJ [ sudo make install ] ..."
sudo make install
if test $? -ne 0 ; then
echo "Install Failed"
error
else
echo "ok"
echo "PBNJ installed"
echo "Run man pbnj for details";
fi
echo "Cleaning up dir [ make realclean ]..."
make realclean
if test $? -ne 0 ; then
echo "Cleanup Failed"
error
else
echo "ok"
echo "Installation is now Complete"
fi
}
ubuntuInstall() {
if test `uname -s` == "Linux" -a -e /etc/lsb-release; then
source /etc/lsb-release
if test "$DISTRIB_ID" == "Ubuntu" ; then
echo "Installing the modules needed for PBNJ 2.0"
sudo apt-get install libdbi-perl \
libdbd-sqlite3-perl libyaml-perl libxml-twig-perl \
libfile-which-perl libtext-csv-perl
if test $? -ne 0 ; then
echo "Couldn't find one of the module packages in apt"
nonUbuntuInstall
fi
echo "Here are the modules that are not provided by APT:"
echo " - Nmap::Parser"
echo " - File::HomeDir"
echo "Do you have all the modules installed? [y/n]"
read MOD
if test "$MOD" == "y" -o "$MOD" == "yes" ; then
install
else
echo "Use the directions in the INSTALL file."
fi
else
nonUbuntuInstall
fi
elif test `uname -s` == "FreeBSD"; then
echo "Here are the modules required for PBNJ"
echo " - YAML /usr/ports/databases/p5-DBI/ "
echo " - DBI /usr/ports/textproc/p5-YAML/ "
echo " - DBD::SQLite /usr/ports/databases/p5-DBD-SQLite"
echo " - XML::Twig /usr/ports/textproc/p5-XML-Twig/"
echo " - Text-CSV_XS /usr/ports/textproc/p5-Text-CSV_XS "
echo " - Nmap::Parser /usr/ports/security/p5-Nmap-Parser"
echo " - File::Which /usr/ports/sysutils/p5-File-Which"
echo " - File::HomeDir /usr/port/devel/p5-File-HomeDir"
echo " "
echo "Do you have all the modules installed? [y/n]"
read MOD
if test "$MOD" == "y" -o "$MOD" == "yes" ; then
install
else
echo "Use the directions in the INSTALL file."
fi
fi
}
nonUbuntuInstall(){
echo "Here are the modules required for PBNJ"
echo " - YAML"
echo " - DBI"
echo " - DBD::SQLite"
echo " - XML::Twig"
echo " - Nmap::Parser"
echo " - File::Which"
echo " - File::HomeDir"
echo "Do you have all the modules installed? [y/n]"
read MOD
if test "$MOD" == "y" -o "$MOD" == "yes" ; then
install
elif test "$MOD" == "n" -o "$MOD" == "no" ; then
echo "Use the directions in the INSTALL file."
fi
}
# start with Ubuntu Install
echo "Install script for PBNJ 2.0"
ubuntuInstall
pbnj-2.04/INSTALL 0000600 0001750 0001750 00000003461 10523541634 012340 0 ustar jabra jabra ####################################
PBNJ 2.0 UNIX Install Directions
####################################
Quick Install - simply run from this directory
To Install PBNJ Properly ( make sure you have the needed deps)
perl Makefile.PL
make
make test
** Then as root **
make install
You will need to install the following modules for PBNJ 2.0 to work
YAML
DBI
DBD::SQLite
XML::Twig
Nmap::Parser
File::Which
Text::CSV_XS
File::HomeDir
Also, you will need Nmap (any version will do)
If you are running Ubuntu, I suggest you use the packages whenever
possible.
NOTE * you will need to add the universe repo
Also, Nmap::Parser and File::HomeDir are not packaged yet.
sudo apt-get install \
libyaml-perl \
libdbi-perl \
libdbd-sqlite3-perl \
libxml-twig-perl \
libtext-csv-perl \
libfile-which-perl
If you are running FreeBSD here are the packages:
pkg_add -r p5-DBI ( /usr/ports/databases/p5-DBI/ )
pkg_add -r p5-YAML ( /usr/ports/textproc/p5-YAML/ )
pkg_add -r p5-DBD-SQLite ( /usr/ports/databases/p5-DBD-SQLite )
pkg_add -r p5-XML-Twig ( /usr/ports/textproc/p5-XML-Twig/ )
pkg_add -r p5-Text-CSV_XS ( /usr/ports/textproc/p5-Text-CSV_XS )
pkg_add -r p5-File-Which ( /usr/ports/sysutils/p5-File-Which )
pkg_add -r p5-Nmap-Parser ( /usr/ports/security/p5-Nmap-Parser )
pkg_add -r p5-File-HomeDir ( /usr/port/devel/p5-File-HomeDir )
To install a module using CPAN
$ sudo cpan
# make sure you have the latest version of CPAN installed
cpan> install CPAN
cpan> install Bundle::CPAN
# then when you see the cpan> prompt type install and the name of
# the module
cpan> install Nmap::Parser
cpan> install File::HomeDir
pbnj-2.04/NOTES-ON-NMAP-VERSION 0000600 0001750 0001750 00000001324 10523541634 014304 0 ustar jabra jabra The version of Nmap you have installed will affect the
performance of PBNJ 2.0. If you are running a version older than
Nmap-4.20ALPHA3, then Nmap won't be able to properly identify the OS
when no services are running. Thus, if you scan a machine that is
running services, then scan it when all the services are off,
PBNJ 2.0 will consider the operating system to different as the OS
for the 2nd scan is unknown. This is because there is nothing for
Nmap to connect to, so Nmap is not able to return a proper
fingerprint. Therefore, this would cause the machine from scan 1 to
show all services as still running and the machine from the 2nd scan
to be inserted as a new machine with no running services.
pbnj-2.04/genlist.man.1 0000600 0001750 0001750 00000011427 10523741754 013616 0 ustar jabra jabra #!/usr/bin/perl
#
# pod2man genlist.man.1 | gzip -c > genlist.1p.gz && gunzip genlist.1p.gz
#
# Copyright (C) 2005-2006 Joshua D. Abraham (jabra@ccs.neu.edu)
#
# This manpage is released under the terms of the GNU General Public
# License (GPL), which is distributed with this software in the file
# "COPYING". The GPL specifies the terms under which users may copy
# and use this software.
#
=pod
=begin man
=head1 NAME
Genlist - ping scanner
=head1 SYNOPSIS
genlist [Input Type] [Scan Options] [General Options]
=cut
=begin man
=head1 DESCRIPTION
Genlist is a program that returns a list of hosts that responding
to ping probes. Thus, this list can be used to perform an scan of
these machines using PBNJ or Nmap.
Apart of PBNJ 2.0 suite of tools to monitor changes on a network.
=head1 OPTIONS
Usage: genlist [Input Type] [General Options]
Input Type:
-s --scan Ping Target Range ex: 10.0.0.\*
Scan Options:
-n --nmap Path to Nmap executable
--inter Perform scan using non default interface
General Options:
-v --version Display version
-h --help Display this information
Send Comments to Joshua D. Abraham ( jabra@ccs.neu.edu )
=end man
=cut
__END__
=begin man
=head1 EXAMPLE OF GENLIST USED WITH PBNJ
$ ./genlist -s 10.0.0.\* > iplist
$ sudo ./scanpbnj -i iplist
=head1 EXAMPLE OF GENLIST USED WITH NMAP
$ ./genlist -s 10.0.0.\* > iplist
$ sudo ./nmap -iL iplist
=head1 INPUT TYPE
=head2 -s Ping Target Range ex: 10.0.0.*
The ping scan is a useful method of only scanning the host that are
responding to ICMP echo requests. This scan basically takes the host
that respond to ping and prints them. This is useful in combining
the result with a PBNJ or Nmap scan because no time is wasted in
scanning hosts that do not respond.
=head1 SCAN OPTIONS
=head2 --interface
This option sets an alternative interface for performing the scan.
This is useful when you have multiple interfaces on a machine
with restrictions on which devices can access certain IP ranges.
=head2 -n --nmap
Use an alternative Nmap rather than Nmap located in the your path.
This is useful if you have multiple version of Nmap installed on
a system or if you are testing a new version of Nmap. Remember that if
you are using a newly compiled version of Nmap that you need to
export NMAPDIR to the location that Nmap was compiled in. Thus, if
you have compiled Nmap in your homedir, use the following notation to
run it with Genlist:
$ export NMAPDIR=$HOME/nmap-VERSION/
$ sudo genlist -s 10.0.0.\* --nmap $HOME/nmap-VERISON/
=head1 General Options:
=head2 -v --version
Prints the Genlist version number and exits.
=head2 -h --help Display this information
Prints a short help screen with the most common command flags.
Running Genlist without any arguments does the same thing.
=head1 FEATURE REQUESTS
Any feature requests should be reported to the online
feature-request-tracking system available on the web at :
http://sourceforge.net/tracker/?func=add&group_id=149390&atid=774489
Before requesting a feature, please check to see if the features has
already been requested.
=head1 BUG REPORTS
Any bugs found should be reported to the online bug-tracking system
available on the web at :
http://sourceforge.net/tracker/?func=add&group_id=149390&atid=774488.
Before reporting bugs, please check to see if the bug has already been
reported.
When reporting PBNJ bugs, it is important to include a reliable way to
reproduce the bug, version number of PBNJ and Nmap, OS
name and version, and any relevant hardware specs. And of course,
patches to rectify the bug are even better.
=head1 SEE ALSO
scanpbnj(1) outputpbnj(1), nmap(1)
=head1 AUTHORS
Joshua D. Abraham ( jabra@ccs.neu.edu )
=head1 LEGAL NOTICES
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details at
http://www.gnu.org/copyleft/gpl.html, or in the COPYING file included
with PBNJ.
It should also be noted that PBNJ has occasionally been known to crash
poorly written applications, TCP/IP stacks, and even operating systems.
While this is extremely rare, it is important to keep in mind. PBNJ
should never be run against mission critical systems unless you are
prepared to suffer downtime. We acknowledge here that PBNJ may crash
your systems or networks and we disclaim all liability for any damage
or problems PBNJ could cause.
=end man
pbnj-2.04/scanpbnj.man.1 0000600 0001750 0001750 00000037232 10526513551 013744 0 ustar jabra jabra #!/usr/bin/perl
#
# pod2man scanpbnj.man.1 | gzip -c > scanpbnj.1p.gz && gunzip scanpbnj.1p.gz
#
# Copyright (C) 2005-2006 Joshua D. Abraham (jabra@ccs.neu.edu)
#
# This manpage is released under the terms of the GNU General Public
# License (GPL), which is distributed with this software in the file
# "COPYING". The GPL specifies the terms under which users may copy
# and use this software.
#
=pod
=begin man
=head1 NAME
ScanPBNJ - a program for running Nmap scans and storing the results in
a PBNJ 2.0 database.
=head1 SYNOPSIS
scanpbnj [Options] {target specification}
=cut
=begin man
=head1 DESCRIPTION
ScanPBNJ performs an Nmap scan and then stores the results in
a database. The ScanPBNJ stores information about the machine that has
been scanned. ScanPBNJ stores the IP Address, Operating System,
Hostname and a localhost bit. The localhost bit, is simply a single
bit which is 1 when the target machine is localhost, otherwise it is
0. It also stores two timestamps for the machine table. The first is
a human readable version and the second is the unix time. Both of
these timestamp correspond to the first time that the machine was
scanned.
ScanPBNJ stores information about the services that are found to be
running on the target machine. ScanPBNJ stores typical information
about the service, by storing the port and protocol. Also, ScanPBNJ
stores version, product and service state information about each
service. The service state can either be up or down. Two timestamps
are also inserted for each instance of every service. The first is a
human readable version and the second is the unix time. Both of
these timestamp correspond to the time that the service was scanned.
This tool can give an admin a clear network layout with of
all the machines with all the services they are running.
Apart of PBNJ 2.0 suite of tools to monitor changes on a network.
=head1 OPTIONS
Usage: scanpbnj [Options] {target specification}
Target Specification:
Can be a IP Address, hostname, network etc.
Ex: microsoft.com, 10.0.0.0/24, 192.168.1.1, 10.0.0.0-100
-i --iplist Scan using a list of IPs from a file
-x --xml Parse scan/info from Nmap XML file
Scan Options:
-a --args Execute Nmap with args (needs quotes)
-e --extraargs Add args to the default args (needs quotes)
--inter Perform scan with non default interface
-m --moreports Add ports to scan ex: 8080 or 3306,5900-5910
-n --nmap Path to Nmap executable
-p --pingscan Ping Target then scan the alive host(s)
--udp Add UDP to the scan arguments
--rpc Add RPC to the scan arguments
-r --range Ports for scan [def 1-1025]
--diffbanner Parse changes of the banner
Config Options:
-d --dbconfig Config for results database [def config.yaml]
--configdir Directory for the database config file
--data SQLite Database override [def data.dbl]
--dir Directory for SQLite or CSV files [def .]
General Options:
--nocolors Don't Print Colors
--test Testing information
--debug Debug information
-v --version Display version
-h --help Display this information
Send Comments to Joshua D. Abraham ( jabra@ccs.neu.edu )
=end man
=cut
__END__
=begin man
=head1 THINGS TO NOTE
* ScanPBNJ requires root privileges to perform a scan.
* If you do not pass a specific ports range, 1-1025 is used.
* If there are configs in the current directory, they are used
instead of those in the user's config directory.
* ScanPBNJ does not modify previous database entries. It simply
inserts new information when a change is found.
* One thing that should be done when performing scans is to make
sure to use the same ports or you will get false positives.
=head1 EXAMPLE SINGLE SCAN
1) Scan a class B network on ports 1-9000
sudo ./scanpbnj -r 1-9000 10.0.0.0/16
2) Scan an IP Address on ports 1-9000
sudo ./scanpbnj -r 1-9000 10.0.0.100
=head1 EXAMPLE AUTOMATED SCANS
The following examples can be added to /etc/crontab
1) Scan a Class C network every 2 hours
30 */2 * * * root scanpbnj 10.0.0.\*
2) Scan a Class C network everyday at 2:30
30 2 * * * root scanpbnj 10.0.0.\*
=head1 TARGET SPECIFICATION
The target specified is a typical method of probing the network.
Therefore, any of the following can be used:
(e.g. 10.0.0.1, 10.0.0.1-254, 10.0.0.0/24 or 10.0.0.\* ).
The first example is simply an IP address. The second example is
the scanning of a range. The third is a range in CIDR notation.
The fourth example is the IP with the star which specifies to scan
255 hosts. This is the same format that Nmap uses with the only
exception being the \* on the last octet. This is needed because it
needs to not interpret the star when it is being executed.
Another option, is to use a hostname or domain name. ScanPBNJ will
then resolve the name to the correct IP address. If you pass a
debug flag with level 1 or greater, ScanPBNJ will display what IP
address, the hostname resolved too.
=head2 -i Scan using a list of IPs from a file
The iplist option is useful when you have a specific list of IPs to
scan. This will perform a full scan of the IPs that are specified.
This option is similar to using -sL with Nmap. The results of
the scan are inserted into the database.
=head2 -x Parse scan/info from Nmap XML file
This option is useful when you can't perform the scan yourself or
you don't want ScanPBNJ to perform the scan. Another situation where
this is useful, is if you have an XML file that was done in the past
and you want to extract information from it, possibly to compare
with what is currently being run on the target. ScanPBNJ parses the
Nmap XML file and extracts the information about the host(s) and
service(s) then inserts the results into the database.
=head1 SCAN OPTIONS
=head2 -a --args
** NOTE ** This option needs quotes around the passed arguments
This option will bypass the default arguments that are used in
scanning with Nmap. This can be used to do a particular type of scan
that is not possible by simply adding extra arguments. For example,
if you want to only scan UDP ports and still do version
identification and OS detection, you would do so using the following
notation:
sudo scapbnj -a "-A -O -sU" localhost
=head2 -e --extraargs
** NOTE ** This option needs quotes around the passed arguments
This option will add additional arguments onto the default scan
arguments. This is most useful in doing scans where time optimization
is needed. Therefore, these arguments will be added and then used in
the scan.
=head2 --inter
This option sets an alternative interface for performing the scan.
This is useful when you have multiple interfaces on a machine
with restrictions on which devices can access certain IP or IP ranges.
=head2 -m --moreports
This options adds additional ports to the range of ports to scan.
Individual port numbers are OK, as are ranges separated by a
hyphen (e.g. 1-1023,5800,5900,8080).
For example:
sudo scanpbnj -m 7000-7500,8080 localhost
This scan would scan the default range as well 7000-7500 and 8080.
=head2 -n --nmap
Use an alternative Nmap rather than Nmap located in the your path.
This is useful if you have multiple version of Nmap installed on
a system or if you are testing a new version of Nmap. Remember that if
you are using a newly compiled version of Nmap that you need to
export NMAPDIR to the location that Nmap was compiled in. Thus, if
you have compiled Nmap in your homedir, use the following notation:
export NMAPDIR=$HOME/nmap-VERSION/
sudo scanpbnj -n $HOME/nmap-VERISON/ localhost
=head2 -p Ping Target then scan the host(s) that are alive
The ping scan is a useful method of only scanning the host that are
responding to ICMP echo requests. This scan basically takes the host
that respond to ICMP echo requests and then performs a scan only on
those hosts. Therefore, no time is wasted in scanning hosts that do
not respond. The results of the scan are then inserted into the
database.
=head2 --udp Add UDP to the scan arguments
Perform a UDP scan, in addition to the default scan.
sudo scanpbnj --udp localhost
If you want to only perform a UDP scan you need to set the specific
arguments for the scan.
sudo scanpbnj -a "-vv -O -P0 1-1025 -sVU" localhost
=head2 --rpc Add RPC to the scan arguments
Perform a RPC scan in addition to the default scan.
sudo scanpbnj --udp localhost
If you want to only perform a RPC scan you need to set the specific
arguments for the scan.
sudo scanpbnj -a "-vv -O -P0 1-1025 -sVR" localhost
=head2 -r --range
Ports for scan [default 1-1025]
This option specifies which ports you want to scan and overrides the
default. Individual port numbers are OK, as are ranges separated by a
hyphen (e.g. 1-1023,5800,5900,8080 ).
Thus, a scan like this is ok.
sudo scanpbnj -r 22,25,80,100-200 localhost
Also, if you have leave off the number after the hyphen it will scan
all from the start port to 65535.
For example:
sudo scanpbnj -r 22,25- localhost
=head2 --diffbanner
Parse changes of the banner
This options enables ScanPBNJ to do comparisons on the banner. The
reason this is not on by default is that it could show changes in
services that are not are important to the user. However, this option
is useful to a security professional who is looking for any changes
that occur so that they can be verified.
=head1 DATABASE OPTIONS
=head2 -d --dbconfig
Config for results database [default config.yaml]
This option is used to specify an alternative config.yaml file.
=head2 --configdir
Directory for Config file [default . ]
This option is used to specify an alternative directory for the
config.yaml file.
=head2 --data
SQLite Database override [default data.dbl ]
This option is used when you want to change the name of the SQLite
database file that is generated.
=head2 --dir
Directory for SQLite or CSV files [default . ]
This option is used when you want the database to be generated in a
different directory.
=head1 GENERAL OPTIONS
=head2 --nocolors
The default results from ScanPBNJ print the useful changes with colors
This options will simply not print the colors.
=head2 --test
Increases the Test level, causing ScanPBNJ to print testing information
about the scan in progress. Using the Test level is mostly only using
for testing. This will also print the debugging information so it can
get rather lengthy. The greater the Test level the more output will be
given.
This option is also used for reporting bugs. All bug reports should
be submitted using --test 1 and an additional report may be needed
depending on the issue.
=head2 --debug
Increases the Debug level, causing ScanPBNJ to print more information
about the scan in progress. Nmap scanning arguments are shown as well
as the ip address if you are scanning a domain name. This option is
used to give the user more information about what the scanner is doing.
The higher the debug level the more output the user will receive.
=head2 -v --version
Prints the ScanPBNJ version number and exits.
=head2 -h --help
Prints a short help screen with the command flags. Running ScanPBNJ
without any arguments does the same thing.
=head1 DEFAULT SCAN
Here are the default arguments that are used during a default scan:
-vv -O -P0 -sSV -p 1-1025
=head1 FILES
PBNJ's data files are stored in ScanPBNJ and OutputPBNJ. When either
of these programs is run the configuration files will be generated
for the user if they don't already exists and placed in the
$HOME/.pbnj-2.0 directory. Again, if there is a configuration file
in the current directory it is used instead of the version in the
configuration directory.
$HOME/.pbnj-2.0/config.yaml - holds settings for connecting to
the database which store the information from PBNJ scans.
$HOME/.pbnj-2.0/query.yaml - lists all queries that can be used to
retrieve information from the database. Also, includes the name and
description for each query. This is only generated when you executed
OutputPBNJ.
For Windows, the pbnj-2.0 config directory is in the APPDATA
directory, which contains both config.yaml and query.yaml. Depending
on your environment, the APPDATA directory may be a different location
from other environments. Therefore, when the configs are executed for
the first time they will display the path where the configs were
generated.
=head1 FEATURE REQUESTS
Any feature requests should be reported to the online
feature-request-tracking system available on the web at :
http://sourceforge.net/tracker/?func=add&group_id=149390&atid=774489
Before requesting a feature, please check to see if the features has
already been requested.
=head1 BUG REPORTS
Any bugs found should be reported to the online bug-tracking system
available on the web at :
http://sourceforge.net/tracker/?func=add&group_id=149390&atid=774488.
Before reporting a bug, please check to see if the bug has already been
reported.
When reporting PBNJ bugs, it is important to include a reliable way to
reproduce the bug, version number of PBNJ and Nmap, OS
name and version, and any relevant hardware specs. And of course,
patches to rectify the bug are even better.
=head1 SUPPORTED DATABASES
The following databases are supported:
* SQLite [default]
* MySQL
* Postgres
* CSV
=head1 DATABASE SCHEMA
The following is the SQLite version of the database schema:
CREATE TABLE machines (
mid INTEGER PRIMARY KEY AUTOINCREMENT,
ip TEXT,
host TEXT,
localh INTEGER,
os TEXT,
machine_created TEXT,
created_on TEXT);
CREATE TABLE services (
mid INTEGER,
service TEXT,
state TEXT,
port INTEGER,
protocol TEXT,
version TEXT,
banner TEXT,
machine_updated TEXT,
updated_on TEXT);
=head1 SEE ALSO
outputpbnj(1), genlist(1), nmap(1)
=head1 AUTHORS
Joshua D. Abraham ( jabra@ccs.neu.edu )
=head1 LEGAL NOTICES
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details at
http://www.gnu.org/copyleft/gpl.html, or in the COPYING file included
with PBNJ.
It should also be noted that PBNJ has occasionally been known to
crash poorly written applications, TCP/IP stacks, and even operating
systems. While this is extremely rare, it is important to keep in
mind. PBNJ should never be run against mission critical systems
unless you are prepared to suffer downtime. We acknowledge here that
PBNJ may crash your systems or networks and we disclaim all liability
for any damage or problems PBNJ could cause.
=end man
pbnj-2.04/INSTALL-WIN32.txt 0000600 0001750 0001750 00000002114 10523541634 013750 0 ustar jabra jabra ####################################
PBNJ 2.0 Windows Install Directions
####################################
Download the nmap installer for windows which
can be found on Nmap's download page.
http://www.insecure.org/nmap/download.html
------------------------------------------
Download ActiveState Perl
http://www.activestate.com/Products/Download/Download.plex?id=ActivePerl
Then to install the module you should use
ActiveState's ppm (Programmer's Package Manager).
Start Menu -> run -> cmd
c:>ppm
ppm>install YAML
ppm>install DBI
ppm>install DBD-SQLite
ppm>install XML-Twig
ppm>install Nmap-Parser
ppm>install Text-CSV_XS
ppm>install File-Which
ppm>install File-HomeDir
------------------------------------------
Download nmake
ftp://ftp.microsoft.com/softlib/mslfiles/nmake15.exe
Then use the standard Perl Make Install Directions.
C:\pbnj-2.0>nmake15.exe
C:\pbnj-2.0>perl Makefile.PL
C:\pbnj-2.0>nmake install
Then you should be able to run the programs.
There is documentation about each tools in the
docs directory.
pbnj-2.04/MANIFEST 0000600 0001750 0001750 00000000754 10525442316 012441 0 ustar jabra jabra README
INSTALL
MANIFEST
Makefile.PL
scanpbnj
outputpbnj
ChangeLog
scanpbnj.man.1
outputpbnj.man.1
genlist.man.1
quickinstall.sh
INSTALL-WIN32.txt
EXAMPLES
AUTHORS
BUGS
NOTES-ON-NMAP-VERSION
genlist
query.yaml
config.yaml
docs/scanpbnj-man.html
docs/outputpbnj-man.html
docs/genlist-man.html
databases/pg.yaml
databases/mysql.yaml
databases/csv.yaml
databases/sqlite3.yaml
t/01modules.t
t/02callback.t
t/02parser.t
t/03parser.t
t/test1.xml
t/nmap_results.xml
pbnj-2.04/EXAMPLES 0000600 0001750 0001750 00000001655 10523541634 012453 0 ustar jabra jabra SINGLE SCAN
Scan Localhost
sudo ./scanpbnj 127.0.0.1
Mail latest changes in csv format to user bill
sudo ./outputpbnj -q latestinfo -t csv |mail -s "PBNJ Latest Info" bill
AUTOMATED SCANS WITH CRONJOBS
Copy the following into your /etc/crontab
# scan of 10 net every 2 hours and email the latest changes to root
16 */2 * * * root /root/bin/scan
# monthly report of class c and email to root
59 1 1 * * root /root/bin/monthly-report
Scan Every 2 Hours:
/root/bin/scan contains the following:
#!/bin/sh
scanpbnj 192.168.10.\*
outputpbnj -q latestinfo -t csv | mail -s "PBNJ LatestInfo `date`" root
Monthly Report:
/root/bin/monthly-report contains the following:
#!/bin/sh
MONTHYEAR=`date +%B-%Y`
cd /root/
mkdir report-$MONTHYEAR
cd report-$MONTHYEAR
scanpbnj 192.168.10.\*
outputpbnj -q monthlyreport -t csv | mail -s "PBNJ Month Report `date
+%B+%r`" root
pbnj-2.04/databases/ 0000700 0001750 0001750 00000000000 10523541575 013234 5 ustar jabra jabra pbnj-2.04/databases/csv.yaml 0000600 0001750 0001750 00000000717 10523541575 014722 0 ustar jabra jabra # YAML:1.0
# Config for connecting to a DBI database
# SQLite, mysql etc
db: CSV
# for SQLite the name of the file. For mysql the name of the database
database: data.csv
# Username for the database. For SQLite no username is needed.
user: ""
# Password for the database. For SQLite no password is needed.
passwd: ""
# Password for the database. For SQLite no host is needed.
host: ""
# Port for the database. For SQLite no port is needed.
port: ""
pbnj-2.04/databases/mysql.yaml 0000600 0001750 0001750 00000000736 10523541575 015275 0 ustar jabra jabra # YAML:1.0
# Config for connecting to a DBI database
# SQLite, mysql etc
db: mysql
# for SQLite the name of the file. For mysql the name of the database
database: pbnjdb
# Username for the database. For SQLite no username is needed.
user: pbnjuser
# Password for the database. For SQLite no password is needed.
passwd: ""
# Password for the database. For SQLite no host is needed.
host: localhost
# Port for the database. For SQLite no port is needed.
port: 3306
pbnj-2.04/databases/pg.yaml 0000600 0001750 0001750 00000000736 10523541575 014536 0 ustar jabra jabra # YAML:1.0
# Config for connecting to a DBI database
# SQLite, mysql etc
db: Pg
# for SQLite the name of the file. For mysql the name of the database
database: pbnjdb
# Username for the database. For SQLite no username is needed.
user: pbnjuser
# Password for the database. For SQLite no password is needed.
passwd: "tmp"
# Password for the database. For SQLite no host is needed.
host: localhost
# Port for the database. For SQLite no port is needed.
port: 5432
pbnj-2.04/databases/sqlite3.yaml 0000600 0001750 0001750 00000000722 10523541575 015507 0 ustar jabra jabra # YAML:1.0
# Config for connecting to a DBI database
# SQLite, mysql etc
db: SQLite
# for SQLite the name of the file. For mysql the name of the database
database: data.dbl
# Username for the database. For SQLite no username is needed.
user: ""
# Password for the database. For SQLite no password is needed.
passwd: ""
# Password for the database. For SQLite no host is needed.
host: ""
# Port for the database. For SQLite no port is needed.
port: ""