Mailing List Archive

1 2  View All
Re: Using a database as backend for Nessus (current state and volunteering for development) [ In reply to ]
On Wed, Jan 15, 2003 at 12:35:07PM +0100, Javier Fernandez-Sanguino wrote:
> Michael Boman wrote:
>
> >Let's stop _talking_ and get down to action, shall we? I have not yet
> >taken a look at the code itself, but this is a quick draft based on what
> >XML_NG can do, with what people (might) want to be able to do..:
> >
> >This is psudo code!!!
> >
> >
> >
> Ok. Before going in to the information that is introduced into each of
> the tables... why not talk about designing the overall schema? How about
> this one (adjointed, in raw form). Main idea is :
>
> 1- users run vulnerability sessions (it's important to keep track of who
> made what).

I agree on that.

> 2.- sessions run plugins against a set of hosts (information available
> should include: start time/end time, session configuration: specified
> plugins, parameters...)

So we need a session field in the host table then.. or maybe a session
glue table. We need

TABLE session (
scanid # the run of the scan. Refered by hosts.scan_id
# and data.scan_id among others
scan_start # When did nessus commence the scan
scan_end # When did it finish
username # Who requested it
host # Where did the user come from
)

and in the

TABLE reports (
scan_id, # Refer to hosts.scan_id/session.scanid
plugin_start, # When did we start this scan?
plugin_end, # When did this plugin end?
plugin_id, # Plugin number
plugin_version, # (is there such a thing? if not, something
# for NASL2?)
port_number, # What port is it we scanned?
port_protocol, # and what protocol is it using?
serverity, # Number refering to serverity.serverity_id
completed, # did the plugin actually finish or did nessusd
# kill it?

#ifndef If people want to store plugin output in several languages
lang # I don't know how relivant this is, but some
# ppl might want to store what lang the message
# is written in. Do we want to store several languages at once?
data # plugin output
#endif

)

#ifdef If people want to store plugin output in several languages
TABLE data (
scan_id # refer to hosts.scan_id
+ plugin_id # which plugin gave us the output
lang # language
data # plugin output
)
#endif


if we want to be really nasty we could have a plugin table looking
something like this:

TABLE plugins (
id # autoinc value used internally
plugin_id # The real plugin number
plugin_version # the real plugin version
)


The thing is that not only do I want to store a lot of data in the
database, I also want to queries to be executed fairly quickly. That
means that we should be careful how many tables we are using as the more
tables you need to search through the slower the query will be.

> 3.- vulnerabilities are associated to a given ExecutedPluginId (_not_ a
> plugin, see below) and might, or might not, discover information
> associated with it (which is kept in the plugin table, not separated).
> 4.- services are also detected by specific port-scan plugins (but might
> not be vulnerable in hosts in a given session).

Then it would be reported as the port is open but without any particular
vulnerability for it.

> The idea is that some administrators might want to keep track of how
> sessions have been executed: which plugins have been executed (the
> ExecutedPlugin entity has to hold also the version of the plugin), which
> hosts have been detected and which services are deemed vulnerable. This
> is why it's useful to separate plugin information (which BTW you can
> extract with 'nessus -qSp' or with the script I sent to the list), you
> don't need to duplicate plugin descriptions whenever a vulnerability is
> discovered. This also permits users to provide new translations for
> plugins by modifying the plugin table directly (or by introducing
> multiple language description cells)

That won't work as several plugins output dynamic vulnerability
description (usernames, banners etc).

> Also, a given plugin might detect more than one vulnerability and these
> might/might not include information notes (banners et al). Separating
> also service discovery from other vulnerability information is done
> because, IMHO, this is one of the most important (and homogeneus)
> information a given plugin (portscanners) will provide. It's also useful
> to do an inventory of open services in the network.
>
> Some other things you could do with this schema:
>
> - keep track of which plugins (and specific revisions/versions) were
> executed against a given host. This allows admins to automatically rerun
> them whenever new plugins are added or a plugin has been updated. Also,
> since plugins are continously being added to Nessus it might be
> appropiate to differentiate when a vulnerability has been discovered
> when it was not previously there (but tested) and when it was discovered
> because a new plugin was added (or modified) that detected it.

My scheme does that.

> - keep track of vulnerabilities associated with detected services.

Will port/protocol be enough, or do we want to mark it as a particular
software or operating system? I always wade through the reports and
confirm any dubts as I have had a lot of hosts that shows both IIS and
Apache vulnerabilities on the same system...

> - separate detected services (which might not be viewed as vulnerable
> since a plugin might not exploit them at the time of the run) from
> vulnerabilities. This allows for reports based on "seen services" in
> different sessions. Something on the lines of: 'which new services (open
> ports) have been detected on system X since the last run'.

Why not just mark it as a informal "vulnerability" with the "the port
was listening" kind of message?

> Note that reports are generated _based_ on the information in the
> database. As such, they do not really need to be stored in the database
> itself (IMHO)

Of course the report will only be based on the vulnerabilities found, but
shouldn't the actual message from the plugin tell you exactly _what_ it
found as well? If the data is there it's up to you to use it. Modify your
SELECT statement to include or exclude data you are (not) interested in.

Best regards
Michael Boman

PS
Sorry for the late reply, have been busy
DS

--
Michael Boman
Security Architect, SecureCiRT (A SBU of Z-Vance Pte Ltd)
http://www.securecirt.com
RE: Using a database as backend for Nessus (current state and volunteering for development) [ In reply to ]
> -----Original Message-----
> From: Michael Boman [mailto:michael.boman@securecirt.com]
> Sent: Saturday, January 18, 2003 8:05 PM
> To: Javier Fernandez-Sanguino
> Cc: nessus-devel@list.nessus.org
> Subject: Re: Using a database as backend for Nessus (current state and
> volunteering for development)
>
>
> On Wed, Jan 15, 2003 at 12:35:07PM +0100, Javier Fernandez-Sanguino
> wrote:
> > Michael Boman wrote:
> >
> > >Let's stop _talking_ and get down to action, shall we? I have not yet
> > >taken a look at the code itself, but this is a quick draft based on
> what
> > >XML_NG can do, with what people (might) want to be able to do..:
> > >
> > >This is psudo code!!!
> > >
> > >
> > >
> > Ok. Before going in to the information that is introduced into each of
>
> > the tables... why not talk about designing the overall schema? How
> about
> > this one (adjointed, in raw form). Main idea is :
> >
> > 1- users run vulnerability sessions (it's important to keep track of
> who
> > made what).
>
> I agree on that
>
> > 2.- sessions run plugins against a set of hosts (information available
>
> > should include: start time/end time, session configuration: specified
> > plugins, parameters...)
>
> So we need a session field in the host table then.. or maybe a session
> glue table. We need
>
> TABLE session (
> scanid # the run of the scan. Refered by hosts.scan_id
> # and data.scan_id among others
> scan_start # When did nessus commence the scan
> scan_end # When did it finish
> username # Who requested it
> host # Where did the user come from
> )

I think we need to additionally have a Profile table that contains the
nessus configuration for that session, so that the next time we go to run a
scan, we can reuse the same configuration if we want.

> and in the
>
> TABLE reports (
> scan_id, # Refer to hosts.scan_id/session.scanid
> plugin_start, # When did we start this scan?
> plugin_end, # When did this plugin end?
> plugin_id, # Plugin number
> plugin_version, # (is there such a thing? if not, something
> # for NASL2?)
> port_number, # What port is it we scanned?
> port_protocol, # and what protocol is it using?
> serverity, # Number refering to serverity.serverity_id
> completed, # did the plugin actually finish or did nessusd
> # kill it?
>
> #ifndef If people want to store plugin output in several languages
> lang # I don't know how relivant this is, but some
> # ppl might want to store what lang the message
> # is written in. Do we want to store several
> languages at once?
> data # plugin output
> #endif
>
> )
>
> #ifdef If people want to store plugin output in several languages
> TABLE data (
> scan_id # refer to hosts.scan_id
> + plugin_id # which plugin gave us the output
> lang # language
> data # plugin output
> )
> #endif
>
>
> if we want to be really nasty we could have a plugin table looking
> something like this:
>
> TABLE plugins (
> id # autoinc value used internally
> plugin_id # The real plugin number
> plugin_version # the real plugin version
> )
>
>
> The thing is that not only do I want to store a lot of data in the
> database, I also want to queries to be executed fairly quickly. That
> means that we should be careful how many tables we are using as the more
> tables you need to search through the slower the query will be.

I very seriously doubt that the output of some nessus sessions is going to
even begin to tax a modern databse. I am more familiar with MySQL so I can't
speak for postgress, but I have never seen it take more than a few MS to
return a query, even with 10 tables involved. If at some point performace
becomes a problem, we can go to stored procedures.

> > 3.- vulnerabilities are associated to a given ExecutedPluginId (_not_
> a
> > plugin, see below) and might, or might not, discover information
> > associated with it (which is kept in the plugin table, not separated).
> > 4.- services are also detected by specific port-scan plugins (but
> might
> > not be vulnerable in hosts in a given session).
>
> Then it would be reported as the port is open but without any particular
> vulnerability for it.

From my perspective, We should track the following things:

1. Discovered Hosts
2. Discovered ports on those hosts
3. Services enumerated on those ports
4. NASLs launched against those services
5. Vulnerabilities found in the services.

If you think about it, the Plugin executed against a particular host doesn't
have anything to do with what vulnerabilities are existing on a particular
service on a particular host.

> > The idea is that some administrators might want to keep track of how
> > sessions have been executed: which plugins have been executed (the
> > ExecutedPlugin entity has to hold also the version of the plugin),
> which
> > hosts have been detected and which services are deemed vulnerable.
> This
> > is why it's useful to separate plugin information (which BTW you can
> > extract with 'nessus -qSp' or with the script I sent to the list), you
>
> > don't need to duplicate plugin descriptions whenever a vulnerability
> is
> > discovered. This also permits users to provide new translations for
> > plugins by modifying the plugin table directly (or by introducing
> > multiple language description cells)
>
> That won't work as several plugins output dynamic vulnerability
> description (usernames, banners etc).

Which is why we need to do a few things:

1. Standardize vulnerability messages so that they can be used in a database
environment.
2. Make it so that output from the plugin is stored in reference to the
vulnerability/service/port/host where it was found.

Think about this too, what about vulnerabilities that might be checked for
by different plugins. An example might be two plugins that tested for ASN.1
decode errors, there may be one plugin that tests Cisco devices, and one
that tests Nortel devices, and another one that test Foundry, Extreme,
Cisco, Netscreen, etc.. Wouldn't it be best to be able to have a query that
returns all the products vulnerable to the ASN.1 vulnerability.

What about default passwords, do we REALLY need 50 different texts that say:
this device has a default password, please consult the manual and change it?

> > Also, a given plugin might detect more than one vulnerability and
> these
> > might/might not include information notes (banners et al). Separating
> > also service discovery from other vulnerability information is done
> > because, IMHO, this is one of the most important (and homogeneus)
> > information a given plugin (portscanners) will provide. It's also
> useful
> > to do an inventory of open services in the network.
> >
> > Some other things you could do with this schema:
> >
> > - keep track of which plugins (and specific revisions/versions) were
> > executed against a given host. This allows admins to automatically
> rerun
> > them whenever new plugins are added or a plugin has been updated.
> Also,
> > since plugins are continously being added to Nessus it might be
> > appropiate to differentiate when a vulnerability has been discovered
> > when it was not previously there (but tested) and when it was
> discovered
> > because a new plugin was added (or modified) that detected it.
>
> My scheme does that.
>
> > - keep track of vulnerabilities associated with detected services.
>
> Will port/protocol be enough, or do we want to mark it as a particular
> software or operating system? I always wade through the reports and
> confirm any dubts as I have had a lot of hosts that shows both IIS and
> Apache vulnerabilities on the same system...

We can't always be sure about that. What if we detect Netbios and an apache
vuln? This could be a Windows box running appache or a linux box running
samba. What would be helpfull, would be if we could trust the Nmap output so
that we could use it as a tie-breaker.. This is certainly something WE ALL
WANT. I'm just not entirely sure how we can do this in a reliable manner.

> > - separate detected services (which might not be viewed as vulnerable
> > since a plugin might not exploit them at the time of the run) from
> > vulnerabilities. This allows for reports based on "seen services" in
> > different sessions. Something on the lines of: 'which new services
> (open
> > ports) have been detected on system X since the last run'.
>
> Why not just mark it as a informal "vulnerability" with the "the port
> was listening" kind of message?

We shouldn't have to mark anything as a vulnerability, we should just
compare the list of detected ports/services for a particular host.

> > Note that reports are generated _based_ on the information in the
> > database. As such, they do not really need to be stored in the
> database
> > itself (IMHO)
>
> Of course the report will only be based on the vulnerabilities found,
> but
> shouldn't the actual message from the plugin tell you exactly _what_ it
> found as well? If the data is there it's up to you to use it. Modify
> your
> SELECT statement to include or exclude data you are (not) interested in.

I think there is some confusion here. Obviously, every stick of information
gleaned from each host, nasl etc... needs to be collected and stuffed in the
database, however we probably don't want to store the final report in the
database as all of that information is already stored in the database and is
accessable through queries.

> Best regards
> Michael Boman
>
> PS
> Sorry for the late reply, have been busy
> DS
>
> --
> Michael Boman
> Security Architect, SecureCiRT (A SBU of Z-Vance Pte Ltd)
> http://www.securecirt.com
>

I went ahead and attached my schema here as I'm not sure I have gotten to
annoy everyone with it since there were listserve problems.

The philosophy arround my schema is that there are
Users,
Rules for users,
Sessions,
Profiles of nessus configurations associated with those sessions
There are Hosts (IP, Mac addresses)
There is a knowledge base associated with each host
There are Ports and Services that are associated with a given host
That Host's service may have one or more Plugins executed against it
That Host's service may have one or more Vulnerabilities associated with it.

I don't have any way of addressing the international angle in this. I would
think we would want to have a table of messages. Each row would have an ID
and a language ID associated with it in a combined key, That way any given
message has the same ID as a message of the same meaning in another
language, however it would be uniquely addressable with the language ID.
That way, the message equivalent to "hi" might be as follows:


mysql> select * from Language;
+----+-------------------+
| id | name |
+----+-------------------+
| 1 | English |
| 2 | Chineese - Pinyin |
| 3 | Frehch |
+----+-------------------+

mysql> select * from Message;
+----+------------+----------+
| id | Languageid | message |
+----+------------+----------+
| 1 | 1 | Hello |
| 1 | 2 | Ni how |
| 1 | 3 | Bon Jour |
+----+------------+----------+

mysql> select Language.name,Message.message from Language,Message where
Message.id = '1' and Language.name = 'English' and Message.Languageid =
Language.id;
+---------+---------+
| name | message |
+---------+---------+
| English | Hello |
+---------+---------+

I have never done internationalization, this is just a guess at how to do
it. Any message in another table could just be a reference to the message in
the message table..

1 2  View All