Skip to content

Commit

Permalink
First commit
Browse files Browse the repository at this point in the history
  • Loading branch information
b3b0 committed Apr 13, 2018
0 parents commit 50311ba
Show file tree
Hide file tree
Showing 11 changed files with 806 additions and 0 deletions.
98 changes: 98 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
# nventory

```
_
| |
_ ____ _____ _ __ | |_ ___ _ __ _ _
| '_ \ \ / / _ \ '_ \| __/ _ \| '__| | | |
| | | \ V / __/ | | | || (_) | | | |_| |
|_| |_|\_/ \___|_| |_|\__\___/|_| \__, |
__/ |
|___/
```

A light-weight NMAP wrapper based on https://github.com/argp/nmapdb.

### Setup:

1. cd to `$ nventory-master/installer`
2. `$ sudo python2 install.py`
3. You're done!

### Usage:

`$ nventory`

### What's next?

Everything else from this point is straight-forward. You can use list files (-iL) for inventorying multiple hosts.
Feel free to fork it / break it / bop it.

# nmapdb

nmapdb parses nmap's XML output files and inserts them into an SQLite database.

I coded this a while back (mid 2009) and have been using it since. Some
people I have shared nmapdb with have found it useful, so I am releasing it
publicly.

Example usage:

```$ sudo nmap -A -oX scanme.xml scanme.nmap.org

Starting Nmap ...

$ ls scanme.xml
scanme.xml
$ ./nmapdb.py -h
usage: ./nmapdb.py [options] <nmap output XML file(s)>
options:
(-h) --help this message
(-v) --verbose verbose output
(-c) --create specify input SQL file to create SQLite DB
(-d) --database specify output SQLite DB file
(-f) --frequency list most frequent open ports from specified DB
(-n) --nodb do not perform any DB operations (i.e. dry run)
(-V) --version output version number and exit
```

Use -c to create a database from the schema on the first run:
```$ ./nmapdb.py -c nmapdb.sql -d myscan.db scanme.xml
$ file myscan.db
myscan.db: SQLite 3.x database
$ sqlite3 myscan.db
SQLite version 3.7.7 ...
sqlite> select * from hosts;
74.207.244.221||scanme.nmap.org|ipv4|Linux 2.6.18|Linux|85|2.6.X|1316681984|up|
sqlite> select * from ports;
74.207.244.221|22|tcp|ssh|open|
74.207.244.221|80|tcp|http|open|
```

Subsequent scans can be entered into the same database:

```$ ./nmapdb.py -d myscan.db bar.xml foo.xml host1.xml host2.xml \
host3.xml host4.xml meh.xml (or simply *.xml)
$ sqlite3 myscan.db
SQLite version 3.7.7 ...
sqlite> select * from ports where ports.port='22';
aa.bb.244.221|22|tcp|ssh|open|
204.cc.ddd.250|22|tcp|ssh|open|
bbb.242.aa.180|22|tcp|ssh|open|
aa.bb.121.21|22|tcp|ssh|open|
sqlite> select * from ports where ports.port='23';
192.168.1.254|23|tcp|telnet|open|
sqlite> select * from hosts inner join ports on hosts.ip=ports.ip where hosts.ip='192.168.1.254' and ports.state='open';
192.168.1.254|00:00:C5:CF:86:30|modem|ipv4||||||up|Farallon Computing/netopia|192.168.1.254|23|tcp|telnet|open|
192.168.1.254|00:00:C5:CF:86:30|modem|ipv4||||||up|Farallon Computing/netopia|192.168.1.254|80|tcp|http|open|
sqlite> select * from hosts inner join ports on hosts.ip=ports.ip where hosts.os_name like '%bsd%' and ports.port=22;
aa.bb.91.25||foo.bar.org|ipv4|FreeBSD 7.0-STABLE|FreeBSD|95|7.X|1231841556|up||aa.bb.91.25|22|tcp|ssh|open|
```

Feel free to fork, submit patches, whatever.

Thanks to antonat and thomas for providing feedback.

argp, Mon Apr 30 14:49:21 EEST 2012


23 changes: 23 additions & 0 deletions installer/install.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#Copyright (C) 2018 Dustin Davis (b3b0)

#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 3 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, see <http://www.gnu.org/licenses/>.

import os
import sys

os.system("cp -R ../nventory /opt/")
os.system("cp -R nventory /usr/bin/")
os.system("chmod +x /usr/bin/nventory")

print("Installation: successful!")
17 changes: 17 additions & 0 deletions installer/nventory
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash
#Copyright (C) 2018 Dustin Davis (b3b0)

#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 3 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, see <http://www.gnu.org/licenses/>.

sudo python2 /opt/nventory/bin/nventory.py
29 changes: 29 additions & 0 deletions licenses/nmapdb - LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
nmapdb - Parse nmap's XML output files and insert them into an SQLite database

Copyright (c) 2012 Patroklos Argyroudis <argp at domain census-labs.com>
Copyright (c) 2012 Census, Inc.
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:

1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. The names of the authors and copyright holders may not be used to
endorse or promote products derived from this software without
specific prior written permission.

THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
17 changes: 17 additions & 0 deletions licenses/nventory - LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---nventory---
(https://github.com/b3b0/nventory)

Copyright (C) 2018 Dustin Davis (b3b0)

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 3 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, see <http://www.gnu.org/licenses/>.
Loading

0 comments on commit 50311ba

Please sign in to comment.