# OpenVAS Vulnerability Test # $Id$ # Description: Gather installed packages/rpms/etc for local security checks # # Authors: # Thomas Reinke # Tim Brown # # Copyright: # Copyright (c) 2008 E-Soft Inc. http://www.securityspace.com # Copyright (c) 2008 Tim Brown # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License Version 2 # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA # if(description) { script_id(50282); script_version("1.1.1"); name["english"] = "Determine OS and list of installed packages via SSH login"; script_name(english:name["english"]); desc["english"] = " This script will, if given a userid/password or key to the remote system, login to that system, determine the OS it is running, and for supported systems, extract the list of installed packages/rpms. Risk factor : None"; script_description(english:desc["english"]); summary["english"] = "Determine OS and list of installed packages via SSH login"; script_summary(english:summary["english"]); script_category(ACT_GATHER_INFO); script_copyright(english:"Copyright (c) 2008 E-Soft Inc. http://www.securityspace.com & Tim Brown"); family["english"] = "Misc."; script_family(english:family["english"]); script_dependencies("find_service.nes", "ssh_authorization.nasl"); exit(0); } # # The script code starts here # cmdline = 0; include("ssh_func.inc"); port = get_kb_item("Services/ssh"); if(!port) { port = 22; } sock = ssh_login_or_reuse_connection(); if(!sock) { exit(0); } # First command: Grab uname -a of the remote system uname = ssh_cmd(socket:sock, cmd:"uname -a"); set_kb_item(name: "ssh/login/uname", value:uname); # GNU/Linux platforms: # Ok...let's first check if this is a RedHat/Fedora Core/Mandrake release rls = ssh_cmd(socket:sock, cmd:"cat /etc/redhat-release"); if("Red Hat Linux release 7.3" >< rls) { set_kb_item(name: "ssh/login/release", value: "RH7.3"); buf = ssh_cmd(socket:sock, cmd:"/bin/rpm -qa --qf '%{NAME}~%{VERSION}~%{RELEASE};\n'"); set_kb_item(name: "ssh/login/rpms", value: ";" + buf); security_note(port:port, data:string("We are able to login and detect that you are running ", rls)); exit(0); } if("Red Hat Linux release 8.0 (Psyche)" >< rls) { set_kb_item(name: "ssh/login/release", value: "RH8.0"); buf = ssh_cmd(socket:sock, cmd:"/bin/rpm -qa --qf '%{NAME}~%{VERSION}~%{RELEASE};\n'"); set_kb_item(name: "ssh/login/rpms", value: ";" + buf); security_note(port:port, data:string("We are able to login and detect that you are running ", rls)); exit(0); } if("Red Hat Linux release 9 (Shrike)" >< rls) { set_kb_item(name: "ssh/login/release", value: "RH9"); buf = ssh_cmd(socket:sock, cmd:"/bin/rpm -qa --qf '%{NAME}~%{VERSION}~%{RELEASE};\n'"); set_kb_item(name: "ssh/login/rpms", value: ";" + buf); security_note(port:port, data:string("We are able to login and detect that you are running ", rls)); exit(0); } if("Fedora Core release 1 (Yarrow)" >< rls) { set_kb_item(name: "ssh/login/release", value: "FC1"); buf = ssh_cmd(socket:sock, cmd:"/bin/rpm -qa --qf '%{NAME}~%{VERSION}~%{RELEASE};\n'"); set_kb_item(name: "ssh/login/rpms", value: ";" + buf); security_note(port:port, data:string("We are able to login and detect that you are running ", rls)); exit(0); } if("Fedora Core release 2 (Tettnang)" >< rls) { set_kb_item(name: "ssh/login/release", value: "FC2"); buf = ssh_cmd(socket:sock, cmd:"/bin/rpm -qa --qf '%{NAME}~%{VERSION}~%{RELEASE};\n'"); set_kb_item(name: "ssh/login/rpms", value: ";" + buf); security_note(port:port, data:string("We are able to login and detect that you are running ", rls)); exit(0); } if("Fedora Core release 3 (Heidelberg)" >< rls) { set_kb_item(name: "ssh/login/release", value: "FC3"); buf = ssh_cmd(socket:sock, cmd:"/bin/rpm -qa --qf '%{NAME}~%{VERSION}~%{RELEASE};\n'"); set_kb_item(name: "ssh/login/rpms", value: ";" + buf); security_note(port:port, data:string("We are able to login and detect that you are running ", rls)); exit(0); } if("Fedora Core release 4 (Stentz)" >< rls) { set_kb_item(name: "ssh/login/release", value: "FC4"); buf = ssh_cmd(socket:sock, cmd:"/bin/rpm -qa --qf '%{NAME}~%{VERSION}~%{RELEASE};\n'"); set_kb_item(name: "ssh/login/rpms", value: ";" + buf); security_note(port:port, data:string("We are able to login and detect that you are running ", rls)); exit(0); } if("Fedora Core release 5 (Bordeaux)" >< rls) { set_kb_item(name: "ssh/login/release", value: "FC5"); buf = ssh_cmd(socket:sock, cmd:"/bin/rpm -qa --qf '%{NAME}~%{VERSION}~%{RELEASE};\n'"); set_kb_item(name: "ssh/login/rpms", value: ";" + buf); security_note(port:port, data:string("We are able to login and detect that you are running ", rls)); exit(0); } if("Fedora Core release 6 (Zod)" >< rls) { set_kb_item(name: "ssh/login/release", value: "FC6"); buf = ssh_cmd(socket:sock, cmd:"/bin/rpm -qa --qf '%{NAME}~%{VERSION}~%{RELEASE};\n'"); set_kb_item(name: "ssh/login/rpms", value: ";" + buf); security_note(port:port, data:string("We are able to login and detect that you are running ", rls)); exit(0); } if("Fedora release 7 (Moonshine)" >< rls) { set_kb_item(name: "ssh/login/release", value: "FC7"); buf = ssh_cmd(socket:sock, cmd:"/bin/rpm -qa --qf '%{NAME}~%{VERSION}~%{RELEASE};\n'"); set_kb_item(name: "ssh/login/rpms", value: ";" + buf); security_note(port:port, data:string("We are able to login and detect that you are running ", rls)); exit(0); } if("Fedora release 8 (Werewolf)" >< rls) { set_kb_item(name: "ssh/login/release", value: "FC8"); buf = ssh_cmd(socket:sock, cmd:"/bin/rpm -qa --qf '%{NAME}~%{VERSION}~%{RELEASE};\n'"); set_kb_item(name: "ssh/login/rpms", value: ";" + buf); security_note(port:port, data:string("We are able to login and detect that you are running ", rls)); exit(0); } if("Fedora release 9 (Sulphur)" >< rls) { set_kb_item(name: "ssh/login/release", value: "FC9"); buf = ssh_cmd(socket:sock, cmd:"/bin/rpm -qa --qf '%{NAME}~%{VERSION}~%{RELEASE};\n'"); set_kb_item(name: "ssh/login/rpms", value: ";" + buf); security_note(port:port, data:string("We are able to login and detect that you are running ", rls)); exit(0); } # Red Hat Enterprise Linux ES release 2.1 (Panama) # Red Hat Enterprise Linux AS release 3 (Taroon Update 1) # Red Hat Enterprise Linux AS release 3 (Taroon Update 2) # Red Hat Enterprise Linux AS release 3 (Taroon Update 3) # Red Hat Enterprise Linux Desktop release 3.90 if(egrep(pattern:"Red Hat Enterprise.*release 2\.1", string:rls)) { set_kb_item(name: "ssh/login/release", value: "RHENT_2.1"); buf = ssh_cmd(socket:sock, cmd:"/bin/rpm -qa --qf '%{NAME}~%{VERSION}~%{RELEASE}~%{SIGGPG:pgpsig};\n'"); set_kb_item(name: "ssh/login/rpms", value: ";" + buf); security_note(port:port, data:string("We are able to login and detect that you are running ", rls)); exit(0); } if(egrep(pattern:"Red Hat Enterprise.*release 3 ", string:rls)) { set_kb_item(name: "ssh/login/release", value: "RHENT_3"); buf = ssh_cmd(socket:sock, cmd:"/bin/rpm -qa --qf '%{NAME}~%{VERSION}~%{RELEASE}~%{SIGGPG:pgpsig};\n'"); set_kb_item(name: "ssh/login/rpms", value: ";" + buf); security_note(port:port, data:string("We are able to login and detect that you are running ", rls)); exit(0); } if(egrep(pattern:"Red Hat Enterprise.*release 4 ", string:rls)) { set_kb_item(name: "ssh/login/release", value: "RHENT_4"); buf = ssh_cmd(socket:sock, cmd:"/bin/rpm -qa --qf '%{NAME}~%{VERSION}~%{RELEASE}~%{SIGGPG:pgpsig};\n'"); set_kb_item(name: "ssh/login/rpms", value: ";" + buf); security_note(port:port, data:string("We are able to login and detect that you are running ", rls)); exit(0); } if(egrep(pattern:"Red Hat Enterprise.*release 5 ", string:rls)) { set_kb_item(name: "ssh/login/release", value: "RHENT_5"); buf = ssh_cmd(socket:sock, cmd:"/bin/rpm -qa --qf '%{NAME}~%{VERSION}~%{RELEASE}~%{SIGGPG:pgpsig};\n'"); set_kb_item(name: "ssh/login/rpms", value: ";" + buf); security_note(port:port, data:string("We are able to login and detect that you are running ", rls)); exit(0); } if("Mandriva Linux release 2008.1" >< rls) { set_kb_item(name: "ssh/login/release", value: "MNDK_2008.1"); buf = ssh_cmd(socket:sock, cmd:"/bin/rpm -qa --qf '%{NAME}~%{VERSION}~%{RELEASE};\n'"); set_kb_item(name: "ssh/login/rpms", value: ";" + buf); security_note(port:port, data:string("We are able to login and detect that you are running ", rls)); exit(0); } if("Mandriva Linux release 2008.0" >< rls) { set_kb_item(name: "ssh/login/release", value: "MNDK_2008.0"); buf = ssh_cmd(socket:sock, cmd:"/bin/rpm -qa --qf '%{NAME}~%{VERSION}~%{RELEASE};\n'"); set_kb_item(name: "ssh/login/rpms", value: ";" + buf); security_note(port:port, data:string("We are able to login and detect that you are running ", rls)); exit(0); } if("Mandriva Linux release 2007.1" >< rls) { set_kb_item(name: "ssh/login/release", value: "MNDK_2007.1"); buf = ssh_cmd(socket:sock, cmd:"/bin/rpm -qa --qf '%{NAME}~%{VERSION}~%{RELEASE};\n'"); set_kb_item(name: "ssh/login/rpms", value: ";" + buf); security_note(port:port, data:string("We are able to login and detect that you are running ", rls)); exit(0); } if("Mandriva Linux release 2007.0" >< rls) { set_kb_item(name: "ssh/login/release", value: "MNDK_2007.0"); buf = ssh_cmd(socket:sock, cmd:"/bin/rpm -qa --qf '%{NAME}~%{VERSION}~%{RELEASE};\n'"); set_kb_item(name: "ssh/login/rpms", value: ";" + buf); security_note(port:port, data:string("We are able to login and detect that you are running ", rls)); exit(0); } if("Mandriva Linux release 2006.0" >< rls) { set_kb_item(name: "ssh/login/release", value: "MNDK_2006.0"); buf = ssh_cmd(socket:sock, cmd:"/bin/rpm -qa --qf '%{NAME}~%{VERSION}~%{RELEASE};\n'"); set_kb_item(name: "ssh/login/rpms", value: ";" + buf); security_note(port:port, data:string("We are able to login and detect that you are running ", rls)); exit(0); } if("Mandrakelinux release 10.2" >< rls) { set_kb_item(name: "ssh/login/release", value: "MNDK_10.2"); buf = ssh_cmd(socket:sock, cmd:"/bin/rpm -qa --qf '%{NAME}~%{VERSION}~%{RELEASE};\n'"); set_kb_item(name: "ssh/login/rpms", value: ";" + buf); security_note(port:port, data:string("We are able to login and detect that you are running ", rls)); exit(0); } if("Mandrakelinux release 10.1" >< rls) { set_kb_item(name: "ssh/login/release", value: "MNDK_10.1"); buf = ssh_cmd(socket:sock, cmd:"/bin/rpm -qa --qf '%{NAME}~%{VERSION}~%{RELEASE};\n'"); set_kb_item(name: "ssh/login/rpms", value: ";" + buf); security_note(port:port, data:string("We are able to login and detect that you are running ", rls)); exit(0); } if("Mandrake Linux release 10.0" >< rls) { set_kb_item(name: "ssh/login/release", value: "MNDK_10.0"); buf = ssh_cmd(socket:sock, cmd:"/bin/rpm -qa --qf '%{NAME}~%{VERSION}~%{RELEASE};\n'"); set_kb_item(name: "ssh/login/rpms", value: ";" + buf); security_note(port:port, data:string("We are able to login and detect that you are running ", rls)); exit(0); } if("Mandrake Linux release 9.2" >< rls) { set_kb_item(name: "ssh/login/release", value: "MNDK_9.2"); buf = ssh_cmd(socket:sock, cmd:"/bin/rpm -qa --qf '%{NAME}~%{VERSION}~%{RELEASE};\n'"); set_kb_item(name: "ssh/login/rpms", value: ";" + buf); security_note(port:port, data:string("We are able to login and detect that you are running ", rls)); exit(0); } if("Mandrake Linux release 9.1" >< rls) { set_kb_item(name: "ssh/login/release", value: "MNDK_9.1"); buf = ssh_cmd(socket:sock, cmd:"/bin/rpm -qa --qf '%{NAME}~%{VERSION}~%{RELEASE};\n'"); set_kb_item(name: "ssh/login/rpms", value: ";" + buf); security_note(port:port, data:string("We are able to login and detect that you are running ", rls)); exit(0); } if("Mandrake Linux release 8.1" >< rls) { set_kb_item(name: "ssh/login/release", value: "MNDK_8.1"); buf = ssh_cmd(socket:sock, cmd:"/bin/rpm -qa --qf '%{NAME}~%{VERSION}~%{RELEASE};\n'"); set_kb_item(name: "ssh/login/rpms", value: ";" + buf); security_note(port:port, data:string("We are able to login and detect that you are running ", rls)); exit(0); } if("Mandrake Linux release 8.0" >< rls) { set_kb_item(name: "ssh/login/release", value: "MNDK_8.0"); buf = ssh_cmd(socket:sock, cmd:"/bin/rpm -qa --qf '%{NAME}~%{VERSION}~%{RELEASE};\n'"); set_kb_item(name: "ssh/login/rpms", value: ";" + buf); security_note(port:port, data:string("We are able to login and detect that you are running ", rls)); exit(0); } if("Mandrake Linux release 7.2" >< rls) { set_kb_item(name: "ssh/login/release", value: "MNDK_7.2"); buf = ssh_cmd(socket:sock, cmd:"/bin/rpm -qa --qf '%{NAME}~%{VERSION}~%{RELEASE};\n'"); set_kb_item(name: "ssh/login/rpms", value: ";" + buf); security_note(port:port, data:string("We are able to login and detect that you are running ", rls)); exit(0); } # Ok...also using /etc/redhat-release is CentOS...let's try them now # We'll stay with major release # checking unless we find out we need to do # otherwise. #CentOS release 4.0 (Final) #CentOS release 4.1 (Final) #CentOS release 3.4 (final) if("CentOS release 4" >< rls) { set_kb_item(name: "ssh/login/release", value: "CENTOS4"); buf = ssh_cmd(socket:sock, cmd:"/bin/rpm -qa --qf '%{NAME}~%{VERSION}~%{RELEASE};\n'"); set_kb_item(name: "ssh/login/rpms", value: ";" + buf); security_note(port:port, data:string("We are able to login and detect that you are running CentOS release 4")); exit(0); } if("CentOS release 3" >< rls) { set_kb_item(name: "ssh/login/release", value: "CENTOS3"); buf = ssh_cmd(socket:sock, cmd:"/bin/rpm -qa --qf '%{NAME}~%{VERSION}~%{RELEASE};\n'"); set_kb_item(name: "ssh/login/rpms", value: ";" + buf); security_note(port:port, data:string("We are able to login and detect that you are running CentOS release 3")); exit(0); } # Hmmm...is it Ubuntu? rls = ssh_cmd(socket:sock, cmd:"cat /etc/lsb-release"); if("DISTRIB_ID=Ubuntu">< rls) { set_kb_item(name: "ssh/login/release", value: "CL9"); buf = ssh_cmd(socket:sock, cmd:"/bin/rpm -qa --qf '%{NAME}~%{VERSION}~%{RELEASE};\n'"); set_kb_item(name: "ssh/login/rpms", value:buf); security_note(port:port, data:string("We are able to login and detect that you are running Conectiva Linux 9")); exit(0); } if("Conectiva Linux 10" >< rls) { set_kb_item(name: "ssh/login/release", value: "CL10"); buf = ssh_cmd(socket:sock, cmd:"/bin/rpm -qa --qf '%{NAME}~%{VERSION}~%{RELEASE};\n'"); set_kb_item(name: "ssh/login/rpms", value:buf); security_note(port:port, data:string("We are able to login and detect that you are running Conectiva Linux 10")); exit(0); } # How about Turbolinux? # Turbolinux signatures: # release 6.0 WorkStation (Shiga) -- Unsupported # TurboLinux release 6.1 Server (Naha) -- Unsupported # Turbolinux Server 6.5 (Jupiter) -- Unsupported # Turbolinux Server 7.0 (Esprit) # Turbolinux Workstation 7.0 (Monza) # Turbolinux Server 8.0 (Viper) # Turbolinux Workstation 8.0 (SilverStone) # Turbolinux Server 10.0 (Celica) # Turbolinux Desktop 10.0 (Suzuka) # -- Need: #- Turbolinux Appliance Server 1.0 Hosting Edition #- Turbolinux Appliance Server 1.0 Workgroup Edition #- Turbolinux Home #- Turbolinux 10 F... rls = ssh_cmd(socket:sock, cmd:"cat /etc/turbolinux-release"); if("Turbolinux Server 7.0" >< rls) { set_kb_item(name: "ssh/login/release", value: "TLS7"); buf = ssh_cmd(socket:sock, cmd:"/bin/rpm -qa --qf '%{NAME}~%{VERSION}~%{RELEASE};\n'"); set_kb_item(name: "ssh/login/rpms", value:buf); security_note(port:port, data:string("We are able to login and detect that you are running ", rls)); exit(0); } if("Turbolinux Workstation 7.0" >< rls) { set_kb_item(name: "ssh/login/release", value: "TLWS7"); buf = ssh_cmd(socket:sock, cmd:"/bin/rpm -qa --qf '%{NAME}~%{VERSION}~%{RELEASE};\n'"); set_kb_item(name: "ssh/login/rpms", value:buf); security_note(port:port, data:string("We are able to login and detect that you are running ", rls)); exit(0); } if("Turbolinux Server 8.0" >< rls) { set_kb_item(name: "ssh/login/release", value: "TLS8"); buf = ssh_cmd(socket:sock, cmd:"/bin/rpm -qa --qf '%{NAME}~%{VERSION}~%{RELEASE};\n'"); set_kb_item(name: "ssh/login/rpms", value:buf); security_note(port:port, data:string("We are able to login and detect that you are running ", rls)); exit(0); } if("Turbolinux Workstation 8.0" >< rls) { set_kb_item(name: "ssh/login/release", value: "TLWS8"); buf = ssh_cmd(socket:sock, cmd:"/bin/rpm -qa --qf '%{NAME}~%{VERSION}~%{RELEASE};\n'"); set_kb_item(name: "ssh/login/rpms", value:buf); security_note(port:port, data:string("We are able to login and detect that you are running ", rls)); exit(0); } if("Turbolinux Desktop 10.0" >< rls) { set_kb_item(name: "ssh/login/release", value: "TLDT10"); buf = ssh_cmd(socket:sock, cmd:"/bin/rpm -qa --qf '%{NAME}~%{VERSION}~%{RELEASE};\n'"); set_kb_item(name: "ssh/login/rpms", value:buf); security_note(port:port, data:string("We are able to login and detect that you are running ", rls)); exit(0); } if("Turbolinux Server 10.0" >< rls) { set_kb_item(name: "ssh/login/release", value: "TLS10"); buf = ssh_cmd(socket:sock, cmd:"/bin/rpm -qa --qf '%{NAME}~%{VERSION}~%{RELEASE};\n'"); set_kb_item(name: "ssh/login/rpms", value:buf); security_note(port:port, data:string("We are able to login and detect that you are running ", rls)); exit(0); } if("Turbolinux">< rls) { security_note(port:port, data:string("We have detected you are running a version of Turbolinux currently not supported by SecuritySpace. Please report the following banner to SecuritySpace: ", rls)); exit(0); } # Hmmm...is it Debian? rls = ssh_cmd(socket:sock, cmd:"cat /etc/debian_version"); if("2.2">< "sparc") { security_note(port:port, data:string("We are able to login and detect that you are running Solaris ", osversion, " Arch: SPARC")); } else { security_note(port:port, data:string("We are able to login and detect that you are running Solaris ", osversion, " Arch: x86")); } exit(0); } #{ "NetBSD", "????????????????", }, #{ "OpenBSD", "????????????????", }, #{ "WhiteBox", "????????????????", }, #{ "Linspire", "????????????????", }, #{ "Desktop BSD","????????????????", }, #{ "PC-BSD", "????????????????", }, #{ "FreeSBIE", "????????????????", }, #{ "JDS", "/etc/sun-release", }, #{ "Yellow Dog", "/etc/yellowdog-release", }, security_note(port: 0, data: strcat('System identifier unknown: "', uname, '"\nTherefore no local security checks applied (missing list of installed packages) though ssh login provided and works')); exit(0);