Cover | Table of Contents | Colophon
nessusd, is
responsible for performing the actual vulnerability tests. The Nessus
server listens for incoming connections from Nessus clients that end
users use to configure and launch specific scans. Nessus clients must
authenticate to the server before they are allowed to launch scans.
This architecture makes it easy to administer the Nessus
installations.nessusd, is
responsible for performing the actual vulnerability tests. The Nessus
server listens for incoming connections from Nessus clients that end
users use to configure and launch specific scans. Nessus clients must
authenticate to the server before they are allowed to launch scans.
This architecture makes it easy to administer the Nessus
installations.[notroot]$ lynx -source http://install.nessus.org | sh
http://install.nessus.org/ and runs it using
the sh interpreter. If you want to see the
contents of the file that is executed, simply point your web browser
to http://install.nessus.org/.http://nessus.org/download/. First, install
nessus-libraries:[notroot]$ tar zxvf nessus-libraries-x.y.z.tar.gz [notroot]$ cd nessus-libraries [notroot]$ ./configure [notroot] make [root]# make install
libnasl:[notroot]$ tar zxvf libnasl-x.y.z.tar.gz [notroot]$ cd libnasl [notroot]$ ./configure [notroot]$ make [root]# make install [root]# ldconfig
nessus-core:[notroot]$ tar zxvf nessus-core.x.y.z.tar.gz [notroot]$ cd nessus-core [notroot]$ ./configure [notroot]$ make [root]# make install
nessus-core on a server that
does not have the GTK libraries and you don't need
the Nessus GUI client, run ./configure with the
--disable-gtk option.[root]# nessusd &
nessus-adduser
executable. Note that Nessus is responsible for authenticating and
authoring its users, so a Nessus user has no connection with a Unix
or Linux user account. Next, run the
nessus
executable from the host on
which you installed Nessus or on a remote host that will connect to
the Nessus server.
nasl, to run and test NASL scripts via the command
line. Invoke it with the -v flag to see what
version is installed on your system:[notroot]$ nasl -v
nasl 2.0.10
Copyright (C) 1999 - 2003 Renaud Deraison <deraison@cvs.nessus.org>
Copyright (C) 2002 - 2003 Michel Arboi <arboi@noos.fr>
See the license for details
nasl. For example, the
finger.nasl
script checks to see if
fingerd is enabled on a remote host. Finger is a
service that listens on port 79 by default, and you can use it to
query information about
users. To run this script
against a host with the IP address of 192.168.1.1 using the NASL
interpreter, execute the following: [notroot]$ nasl -t 192.168.1.1 finger.nasl
** WARNING : packet forgery will not work
** as NASL is not running as root
The 'finger' service provides useful information to attackers, since it allows
them to gain usernames, check if a machine is being used, and so on...
Here is the output we obtained for 'root' :
Login: root Name: System Administrator
Directory: /var/root Shell: /bin/sh
On since Wed 5 May 08:51 (CDT) on ttyp2 from 127.0.0.1:0.0
No Mail.
No Plan.
Solution : comment out the 'finger' line in /etc/inetd.conf
Risk factor : Low
[6533] plug_set_key:send(0)['1 finger/active=1;
'](0 out of 19): Socket operation on non-socket
finger server
running on host 192.168.1.1 to find out information about the
root user.display("Hello World\n");
nasl interpreter,
and you will see the text Hello World displayed.h=0x1b;
display ("The value of h is ",h,"\n");
[notroot]$ nasl hex.nasl
The value of h is 27
x and y are equivalent in the
following example:x=014; #octal y=12; #decimal
abcdefg, Hello
World, and Boeing
747 are all examples of strings. Consider the
following NASL script:mystring="Hello. I am a string!\n"; display(mystring);
\n at the end of
mystring is an escape character and is equivalent
to a newline character. Table 1-1 lists common
escape characters applicable to NASL.+
cat, dog, mouse' - ',
dog' results in the string 'cat, mouse'.*
/
%
10%3 computes to 1.**
if...else statement to execute a block of
statements depending on a condition. For example, suppose we want the
value of variable port_open to be
1 if the value of the variable
success is positive. Otherwise, we want the value
of port_open to be -1. Our
if...else statement would be as follows:if (success>0)
{
port_open=1;
}
else
{
port_open=-1;
}
if
and else blocks, the braces {
and } are optional, so our statement would have
also worked if we had not enclosed our assignment statements within
the braces.
if...else
statements. For example, suppose we want to assign the value
-2 to port_open if
success equals -10, or the
value 0 to port_open if
success is less than 1.
Otherwise, we want to assign the value 1 to
port_open. In this case, our
if..else statement would be as follows:if (success==-10)
{
port_open=-2;
}
else if (success<1)
{
port_open=0;
}
else
{
port_open=1;
}
for
loop expects three statements separated by
semicolons as arguments. The first statement is executed first, and
only once. It is most frequently used to assign a value to a
variable, which is usually used by the loop to perform iteration. The
second statement is a condition that should return
true for the loop to continue looping. The third
statement is invoked by the for loop after every
iteration, and is used to increment or decrement the iteration
variable. For example, the following for loop
prints all the values of the array myports:for(i=0; i < max_index(myports); i++)
{
display(myports[i],"\n");
}
max_index()
returns the number of elements in an
array, and we use it in our
for loop to ensure that the value of
i is within range.foreach
statement to loop for every
array element. This is useful in cases when you need to iterate
through an array. For example, the following loop iterates through
myports[] and prints the values contained in it:foreach i (myports)
{
display (i, "\n");
}
until is evaluated
after the loop is executed. This means a
repeat...until
loop always executes at least once.
For example, the following displays the string
Looping!:i=0;
repeat
{
display ("Looping!\n");
} until (i == 0);
while
loop expects one conditional statement and
loops as long as the condition is true. For example, consider the
following while loop, which prints integers 1 to
10:port as input. The function returns
1 if port is even,
0 if it is odd:function is_even (port)
{
return (!(port%2));
}
is_even( ) performs the modulo
operation to obtain the remainder when port is
divided by 2. If the modulo operation returns 0,
the value of port must be even. If the modulo
operation returns 1, the value of
port must be odd. The
!
operator is used to invert the
evaluation, and this causes the function to return
1 when the modulo operation evaluates to
0, and 0 when the modulo
operation evaluates to 1.is_even(port:22). Here is
an example of how you can invoke is_even( ):for(i=1;i<=5;i++)
{
display (i," is ");
if(is_even(port:i))
display ("even!");
else
display ("odd!");
display ("\n");
}
1 is odd! 2 is even! 3 is odd! 4 is even! 5 is odd!
include()
function call. For example:include("http_func.inc");
include("http_keepalive.inc");
TRUE should always evaluate to a nonzero value,
while FALSE should always evaluate to
0.TRUE
evaluates to 1. The
variable FALSE evaluates to 0.i
==
NULL) with
NULL, first it will be compared with
0. If a string variable is tested (example:
str == NULL) with NULL, it will
be compared with the
empty
string "".script_category(). For example, a plug-in whose main purpose is to test a
denial-of-service vulnerability should invoke
script_category( ) as
follows:
script_category(ACT_DENIAL);
script_category(
)
function with any of the following
categories as the parameter:ACT_ATTACK
ACT_DENIAL
chomp()
function takes in a string as a
parameter and strips away any
carriage returns,
line feeds, tabs, or whitespace at the end of the string. For
example:mystring='abcd \t\r\n';
display ('BEGIN',chomp(mystring),'END\n');
BEGINabcdEND on one line.crap( )
function is used to fill a
buffer with repeated
occurrences of a specified string. The function takes in two
parameters, length and data.
The length parameter specifies the length of the
string to be returned, while the data parameter
specifies the string that should be used to fill the buffer. For
example, crap(length:10,data:'a') returns
aaaaaaaaaa. If data is not
specified, a default value of X is used.strcat( ) function. This function also converts
given variables to strings when performing concatenation. The
following example causes the value of mystring to
be set to abcdefgh123:string1="abcd"; string2="efgh"; number1=123; mystring=strcat(string1,string2,number1);
ftp_anonymous.nasl
plug-in connects to an FTP server to
check if anonymous access is allowed:#
# This script was written by Renaud Deraison <deraison@cvs.nessus.org>
#
#
# See the Nessus Scripts License for details
#
if(description)
{
script_id(10079);
script_version ("$Revision: 1.2 $");
script_cve_id("CAN-1999-0497");
script_name(english:"Anonymous FTP enabled");
script_description(english:"
This FTP service allows anonymous logins. If you do not want to share data
with anyone you do not know, then you should deactivate the anonymous account,
since it can only cause troubles.
Risk factor : Low");
script_summary(english:"Checks if the remote ftp server accepts anonymous logins");
script_category(ACT_GATHER_INFO);
script_family(english:"FTP");
script_copyright(english:"This script is Copyright (C) 1999 Renaud Deraison");
script_dependencie("find_service.nes", "logins.nasl", "smtp_settings.nasl");
script_require_ports("Services/ftp", 21);
exit(0);
}
#
# The script code starts here :
#
include("ftp_func.inc");
port = get_kb_item("Services/ftp");
if(!port)port = 21;
state = get_port_state(port);
if(!state)exit(0);
soc = open_sock_tcp(port);
if(soc)
{
domain = get_kb_item("Settings/third_party_domain");
r = ftp_log_in(socket:soc, user:"anonymous", pass:string("nessus@", domain));
if(r)
{
port2 = ftp_get_pasv_port(socket:soc);
if(port2)
{
soc2 = open_sock_tcp(port2, transport:get_port_transport(port));
if (soc2)
{
send(socket:soc, data:'LIST /\r\n');
listing = ftp_recv_listing(socket:soc2);
close(soc2);
}
}
data = "
This FTP service allows anonymous logins. If you do not want to share data
with anyone you do not know, then you should deactivate the anonymous account,
since it may only cause troubles.
";
if(strlen(listing))
{
data += "The content of the remote FTP root is :
" + listing;
}
data += "
Risk factor : Low";
security_warning(port:port, data:data);
set_kb_item(name:"ftp/anonymous", value:TRUE);
user_password = get_kb_item("ftp/password");
if(!user_password)
{
set_kb_item(name:"ftp/login", value:"anonymous");
set_kb_item(name:"ftp/password", value:string("nessus@", domain));
}
}
close(soc);
}http://ettercap.sourceforge.net/download.php.
Grab the latest tarball and compile Ettercap:[notroot]$ tar zxvf ettercap-NG-x.y.z.tar.gz [notroot]$ cd ettercap-NG-x.y.z [notroot]$ ./configure [notroot]$ make [root]# make install
ettercap -h to discover the plethora of
options and features Ettercap provides. See the
ettercap manpage for more details on available
options and features.http://ettercap.sourceforge.net/download.php.
Grab the latest tarball and compile Ettercap:[notroot]$ tar zxvf ettercap-NG-x.y.z.tar.gz [notroot]$ cd ettercap-NG-x.y.z [notroot]$ ./configure [notroot]$ make [root]# make install
ettercap -h to discover the plethora of
options and features Ettercap provides. See the
ettercap manpage for more details on available
options and features.http://ettercap.sourceforge.net/forum/.[root]# ettercap --text --quiet
ettercap NG-0.7.0 copyright 2001-2004 ALoR & NaGA
Listening on en0... (Ethernet)
eth0 -> 00:0B:25:30:11:B 192.168.1.1 255.255.255.0
Privileges dropped to UID 65534 GID 65534...
0 plugins
39 protocol dissectors
53 ports monitored
6312 mac vendor fingerprint
1633 tcp OS fingerprint
2183 known services
Starting Unified sniffing...
Text only Interface activated...
Hit 'h' for inline help
FTP : 10.0.0.1:21 -> USER: john PASS: try4ndgu355m3!!
try4ndgu355m3!! of user
john logged on to an FTP server running on host
10.0.0.1.220:220 Welcome to ftp.example.com
220
response code,
which signifies that the FTP server is ready to serve further
requests.find_tcp_conn, a plug-in that detects the
initiation of a new TCP connection on the network.SYN
flag set to the remote host. If the
remote host is listening on a particular port, it responds with a TCP
packet with the SYN and
ACK
flags set. The source host then sends
a TCP packet with the ACK bit set to formally
establish the TCP connection. This sequence is known as the
three-way TCP
handshake
. Therefore, to detect new TCP connections
with other hosts, our plug-in has to analyze the network traffic for
TCP packets that have the SYN flag set. The
find_tcp_conn plug-in described in the following
paragraphs analyzes TCP packets for the SYN flag,
and if one is found, it alerts the Ettercap user that a host on the
network is attempting to establish a new TCP connection with another
host.find_tcp_conn plug-in alerts the Ettercap user
whenever a TCP packet with the SYN flag set is
captured. Therefore, the plug-in alerts the Ettercap user even if the
server host does not respond to the connection attempt. This plug-in
can be useful for noticing when a SYN port-scan is being performed on a
network.find_tcp_conn plug-in will not detect new TCP
connections when the host running Ettercap is on a network switch
because network switches attempt to segregate network traffic.
Therefore, the find_tcp_conn plug-in will detect
SYN packets from other hosts only when the host running Ettercap is
on a network hub, or when Ettercap is instructed to perform ARP
poisoning.http://www.thc.org/) for
testing networked services for weak
username and
password combinations. This technique, commonly known as
brute-force testing, is valuable for
ensuring that network services and systems are not vulnerable to
password-guessing attacks due to weak username and password
combinations.http://www.thc.org/thc-hydra/. The module
described in this section is included in Hydra Version 4.2.http://www.thc.org/) for
testing networked services for weak
username and
password combinations. This technique, commonly known as
brute-force testing, is valuable for
ensuring that network services and systems are not vulnerable to
password-guessing attacks due to weak username and password
combinations.http://www.thc.org/thc-hydra/. The module
described in this section is included in Hydra Version 4.2.|
telnet
|
ftp
|
http
|
|
https
|
>nmap -sV 127.0.0.1 Starting nmap 3.50 ( http://www.insecure.org/nmap/ ) at 2003-07-05 17:12 EDT Interesting ports on localhost (127.0.0.1): (The 1658 ports scanned but not shown below are in state: closed) PORT STATE SERVICE VERSION 22/tcp open ssh OpenSSH 3.8.1p1 (protocol 2.0) Nmap run completed -- 1 IP address (1 host up) scanned in 1.104 seconds
http://www.cirt.net. Download the latest
tar.gz file of the Nikto source code. After
uncompressing it, execute perl nikto.pl from the
command line to see the program's options. This
chapter was written using Nikto 1.32 as a reference, but future
versions should be very similar, as the core is stable.http://www.activestate.com/. If
you're running Nikto on a Unix-like system, you can
get
OpenSSL from http://www.openssl.org/ and the
Net::SSLeay module from http://www.cpan.org/. At its foundation Nikto
uses
RFP's LibWhisker, which
comes bundled with the tar.gz file; optionally
you can place Nikto in the Perl library search path.http://www.cirt.net. Download the latest
tar.gz file of the Nikto source code. After
uncompressing it, execute perl nikto.pl from the
command line to see the program's options. This
chapter was written using Nikto 1.32 as a reference, but future
versions should be very similar, as the core is stable.http://www.activestate.com/. If
you're running Nikto on a Unix-like system, you can
get
OpenSSL from http://www.openssl.org/ and the
Net::SSLeay module from http://www.cpan.org/. At its foundation Nikto
uses
RFP's LibWhisker, which
comes bundled with the tar.gz file; optionally
you can place Nikto in the Perl library search path.-debug, -update,
-dbcheck, and -verbose are
available by using the first letter as a short-form option. Execute
the program with no arguments, and a description of all available
options along with module-loading warning messages will be displayed.
You'll see the warning messages if support modules
such as SSL are not installed correctly.Cgidirs
all or none.
all forces the core plug-in to run checks against
every CGI directory specified in config.txt.
none runs all CGI checks against the webroot
(/).cookies
evasion+
$perl ./nikto.pl -h www.example.com -e 3489
findonlyfind . -name "*.pl" -o -name "*.pm" -o -name "*.plugin" | xargs ctags --language-force=perl
load_configs( )
parses the configuration file
config.txt and initializes
%CONFIG. Then the find_plugins( )
routine searches expected directories for the
plug-in file, and sets appropriate values in
%FILES. The nikto_core
plug-in and LibWhisker are included with
the require keyword, which makes all routines from
LW.pm and nikto_core.plugin
available to the rest of nikto.pl as well as to
its plug-ins. The general_config()
routine parses the command-line options and
sets %CLI appropriately. Next,
LibWhisker's http_init_request( )
initializes LibWhisker's
%request with default values.