要成为一个出色的程序猿,还是很讲究猿粪的!
分类: LINUX
2013-09-26 17:44:16
一、脚本script.nasl
#
# here is description
#
if(description)
{
script_id(99999);
#script_cve_id("CAN-2002-0839", "CAN-2002-0840", "CAN-2002-0843");
script_version("$Revision: 1.0 $");
name = "Scan tcp port[0-1000] state";
script_name(name);
desc = "
This is my first nessus plugin.It scans tcp port from 0 to 1000
on target host. ";
script_description(desc);
summary = "tcp port scanner";
script_summary(summary);
script_category(ACT_GATHER_INFO);
script_copyright("This script is Copyright (C) XXX");
family = "General";
script_family(family);
exit(0);
}
#
# here is attack
#
include("/var/lib/openvas/plugins/revisions-lib.inc");
include("/var/lib/openvas/plugins/misc_func.inc");
display(string("Scanning tcp port[0-1000] state!\n"));
for(port=0;port<1000;port++)
{
state = get_port_state(port);
if(!state)
{
display("Port close.\n");
continue;
}
soc = open_sock_tcp(port, timeout:1);
if(!soc)
continue;
display('port=', port, ', ', 'state=', state, ', ', 'soc=', soc, '\n');
}
security_note(port);
exit(0);
利用openvas调试nasl脚本
二、不使用证书与签名:
1、编写nasl脚本,保存为script.nasl。
2、# openvas-nasl -X script.nasl。
三、使用证书与签名(强烈建议):
# vim /etc/openvas/openvassd.conf
nasl_no_signature_check = no
1、生成密钥:
# gpg --homedir=/etc/openvas/gnupg --gen-key
或直接使用官网的OpenVAS_TI.asc key文件:
# wget
双击OpenVAS_TI.asc文件将密钥注册到系统中
2、设置信任
# gpg --homedir=/etc/openvas/gnupg --list-keys
/etc/openvas/gnupg//pubring.gpg
-------------------------------
pub 2048R/CA9633422013-09-24
uid telnet (no)
sub 2048R/EFBBA6A92013-09-24
找到public key id: CA963342
# gpg --homedir=/etc/openvas/gnupg --lsign-key CA963342
3、生成签名文件signature
# gpg --homedir=/etc/openvas/gnupg/ --detach-sign -a -o script.nasl.asc script.nasl
4、添加证书
# gpg --homedir=/etc/openvas/gnupg --import script.nasl.asc
5、验证签名
# openvas-nasl -p script.nasl
6、执行脚本
# openvas-nasl -t 192.168.2.105 script.nasl
四、将自己写的plugin加入插件库
1、将自己写的插件复制到openvas插件库目录:
/var/lib/openvas/plugins
2、加载插件
# openvassd
3、重建插件库
# openvasmd –rebuild
参考文献:
http://lists.wald.intevation.org/pipermail/openvas-discuss/2007-September/000406.html