nikto源码分析

本文介绍了开源网站扫描器Nikto的入口文件nikto.pl的主要功能和代码结构。包括加载模块、配置文件处理、目录设置、插件加载以及目标扫描等核心流程。通过这个分析,读者可以了解到Nikto的工作原理。
摘要由CSDN通过智能技术生成
Nikto是一款开源的网站扫描器,软件的编写语言为perl。本文主要对入口 文件nikto.pl进行简单解析。

nikto的目录结构:
nikto     
|      
+-----+ databases/  #规则库目录
|           
+-----+ plugins/  #插件目录
|      
+----- nikto.pl  #入口文件

------------------------------------------------nikto.pl-------------------------------------------------

#!/usr/bin/perl

#加载所需模块,没什么可说的
use strict;
use Getopt::Long;
use Time::Local;
Getopt::Long::Configure('no_ignore_case');          # 处理配置时启用大小写敏感

# 定义全局变量, 没什么可说的
use vars qw/$TEMPLATES %CLI %VARIABLES %TESTS/;
use vars qw/%NIKTO %CONFIGFILE %COUNTERS %db_extensions/;
use vars qw/@RESULTS @PLUGINS @DBFILE @REPORTS %CONTENTSEARCH/;

$COUNTERS{'scan_start'}  = time();          # 取得时间
$VARIABLES{'DIV'}        = "-" x 75;     # 设置分割符号
$VARIABLES{'name'}       = "Nikto";          # 设置名字
$VARIABLES{'version'}    = "2.1.5";          # 设置版本号
$VARIABLES{'configfile'} = "/etc/nikto.conf";    # 定义配置文件路径

# 自定义中断处理函数,按了ctrl+c就会执行该函数
$SIG{'INT'} = \&safe_quit;

config_init();          # 配置文件初始化
setup_dirs();          # 设置目录路径
require "$CONFIGFILE{'PLUGINDIR'}/nikto_core.plugin";          # 加载plugins/目录下的nikto_core.plugin
nprint("T:" . localtime($COUNTERS{'scan_start'}) . ": Starting", "d");          # d表示debug模式,输出该模式下的信息,(不输出到正常结果文件)
require "$CONFIGFILE{'PLUGINDIR'}/LW2.pm";          # 加载plugins/目录下的LW2.pm
require "$CONFIGFILE{'PLUGINDIR'}/JSON-PP.pm";          # 加载plugins/目录下的JSON-PP.pm
$VARIABLES{'GMTOFFSET'} = gmt_offset();          # 设置相对于格林威治时间的偏移量


LW2::init_ssl_engine($CONFIGFILE{'LW_SSL_ENGINE'});          # 配置SSL相关

my ($a, $b) = split(/\./, $LW2::VERSION);          #  分割版本号,以便判断版本是否合适,版本号在LW2.PM里面有定义
die("- You must use LW2 2.4 or later\n") if ($a != 2 || $b < 4);          # 如果LW2版本低于2.4,则报错

general_config();          # 进行配置,对命令行参数进行基本的验证
load_databases();          # 加载系统默认规则库
load_databases('u');          # 加载自定义规则库
nprint("- $VARIABLES{'name'} v$VARIABLES{'version'}");          # 输出指定模式下的信息
nprint($VARIABLES{'DIV'});          # 单参数情况,跟print效果一样

# 目标为空,报错
if ($CLI{'host'} eq "") {
    nprint("+ ERROR: No host specified");
    usage();
}

$COUNTERS{'total_targets'} = $COUNTERS{'hosts_completed'} = 0;          #初始化扫描完成的目标个数为0
load_plugins();          #加载插件

# 传递获取到的参数,目标地址,端口,ssl选项,目标路径
my @MARKS = set_targets($CLI{'host'}, $CLI{'ports'}, $CLI{'ssl'}, $CLI{'root'});
# 指定了证书,则使用证书
if (defined($CLI{'key'}) || defined($CLI{'cert'})) {
    $CLI{'key'}  = $CLI{'cert'
  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Nikto是一款Web安全扫描工具,可以扫描指定主机的web类型,主机名,特定目录,cookie,特定CGI漏洞,XSS漏洞,SQL注入漏洞等,非常强大滴说。。。 root@91ri.org:~# cd /pentest/web/nikto/ root@91ri.org:/pentest/web/nikto# ls docs nikto.conf nikto.pl plugins templates root@91ri.org:/pentest/web/nikto# ./nikto.pl -h Option host requires an argument -config+ Use this config file -Cgidirs+ scan these CGI dirs: ‘none’, ‘all’, or values like “/cgi/ /cgi-a/” -dbcheck check database and other key files for syntax errors -Display+ Turn on/off display outputs -evasion+ ids evasion technique -Format+ save file (-o) format -host+ target host -Help Extended help information -id+ Host authentication to use, format is id:pass or id:pass:realm -list-plugins List all available plugins -mutate+ Guess additional file names -mutate-options+ Provide extra information for mutations -output+ Write output to this file -nocache Disables the URI cache -nossl Disables using SSL -no404 Disables 404 checks -port+ Port to use (default 80) -Plugins+ List of plugins to run (default: ALL) -root+ Prepend root value to all requests, format is /directory -ssl Force ssl mode on port -Single Single request mode -timeout+ Timeout (default 2 seconds) -Tuning+ Scan tuning -update Update databases and plugins from CIRT.net -vhost+ Virtual host (for Host header) -Version Print plugin and database versions + requires a value Note: This is the short help output. Use -H for full help. 升级插件 root@91ri.org:/pentest/web/nikto# ./nikto.pl -update -h 指定扫描的目标 –p 端口 root@91ri.org:/pentest/web/nikto# ./nikto.pl -h www.91ri.org -p 80 -C 指定CGI目录 –all表示猜解CGI目录 root@91ri.org:/pentest/web/nikto# ./nikto.pl -h www.91ri.org -C all -T选项包含很多小选项 –T 9表示扫描SQL注入漏洞 root@91ri.org:/pentest/web/nikto# ./nikto.pl -h www.91ri.org -T 9 -D指定输出显示 2显示cookies root@91ri.org:/pentest/web/nikto# ./nikto.pl -h www.91ri.org -D 2 -T选项包含的小选项解释: 0 检查文件上传页面 1 检查web日志 2 检查错误配置或默认文件 3检查信息泄露问题 4 检查XSS/Script/HTML问题 5 从根目录检查是否存在可访问的文件 6 检查拒绝服务问题 7 从任意文件检索是否存在可访问文件 8 检查是否存在系统命令执行漏洞 9 检查SQL注入漏洞 a 检查认证绕过问题 b 识别安装的软件版本 c 检查源代码泄露问题 x 反向链接选项
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值