All about security

scripts.girl

导航

通过445端口判断远程windows操作系统的OS版本的NASL脚本

Posted on 2005-05-14 03:10  isno's world  阅读(414)  评论(0)    收藏  举报
if(description)
{
 script
_id(1000000);
 script
_version ("$Revision: 1.0 $");
 name["english"] = "detect os";
 
 script
_name(english:name["english"]);
 
 desc["english"] = "
This script connects to the remote host
using a null session, and detect os type

_content>Risk factor : Medium";
 
 script_description(english:desc["english"]);
 
 summary["english"] = "determinite remote windows host os type";
  script_summary(english:summary["english"]);
 
 script_category(ACT_GATHER_INFO);
 
 script_copyright(english:"This script is Copyright (C) 2005 zhouzhen");
 family["english"] = "Windows";
 script_family(english:family["english"]);
 
 script_dependencies("netbios_name_get.nasl", "smb_login.nasl");
 script_require_keys("SMB/transport", "SMB/name", "SMB/login", "SMB/password");
 script_require_ports(139, 445);
 exit(0);
}

_content>include("smb_nt.inc");

_content>if ( get_kb_item("SMB/samba") ) exit(0);

_content>name = kb_smb_name();
if(!name)
name = "*SMBSERVER";

_content>_smb_port = kb_smb_transport();
if(!_smb_port)
_smb_port = 139;

_content>if(!get_port_state(_smb_port))return(FALSE);

_content>login = kb_smb_login();
pass  = kb_smb_password();

_content>


domain = kb_smb_domain();

if(!login)login = "";
if(!pass) pass = "";
 
soc = open_sock_tcp(_smb_port);
if(!soc)return(FALSE);

#
# Request the session
#
r = smb_session_request(soc:soc,  remote:name);
if(!r) { close(soc); return(FALSE); }

#
# Negociate the protocol
#
prot = smb_neg_prot(soc:soc);
if(!prot){ close(soc); return(FALSE); }


#
# Set up our session
#
r = smb_session_setup(soc:soc, login:login, password:pass, domain:domain, prot:prot);
if(!r){ close(soc); return(FALSE); }

osType = "";

for (i=0; i<37; i++)
osType = osType + raw_string(ord(r[45+i]));

display(osType);