Tuesday, 14 December 2010

Sun Service Tags Nmap Discovery Script

Oracle/Sun has had a software agent available for a few years now that runs on numerous operating systems (Solaris 8,9,10, RHEL, OEL, SuSE, and Windows) which enables automatic discovery of assets including software and hardware. The agent is called Sun Service Tags and it provides a way to query a system over a LAN and find out about the hardware, OS, and some of the software installed on it (I say some because the software developer has to register their application at install time with Service Tags and not many outside of Oracle/Sun seem to).

I was inspired last week by a colleague who was looking at installing a Cisco Discovery Protocol (CDP) agent on his Solaris systems so he could easily get an inventory of his network via his routers and switches with the show cdp neighbor command. I pointed out to him that his Solaris systems very likely had Service Tags already installed on them and he could just query that.

To prove the point a set out to write an Nmap script that could scan a host or network and display all the Service Tags information it could find for each host. The nmap script can be downloaded here and needs to be installed in /usr/local/share/nmap/scripts (or where ever your nmap stores them).

You can see some sample usage output below:

# nmap -sU --script=servicetags -p 6481

Starting Nmap 5.35DC1 ( http://nmap.org ) at 2010-12-14 15:57 EST
Nmap scan report for host.example.com (
Host is up (0.00045s latency).
6481/udp open unknown
| servicetags:
| URN: urn:st:3bf76681-5e68-415b-f980-db3d77fda252
| System: SunOS
| Release: 5.10
| Hostname: host
| Architecture: sparc
| Platform: SUNW,SPARC-Enterprise-T5120::Generic_142900-13
| Manufacturer: Sun Microsystems, Inc.
| CPU Manufacturer: Sun Microsystems, Inc.
| Serial Number: ABC123456
| HostID: 12345678
| RAM: 16256
| CPUs: 1
| Cores: 4
| Virtual CPUs: 32
| CPU Name: UltraSPARC-T2
| CPU Clock Rate: 1165
| Service Tags
| Solaris 10 Operating System
| Product Name: Solaris 10 Operating System
| Instance URN: urn:st:90592a79-974d-ebcc-c17a-b87b8eee5f1f
| Product Version: 10
| Product URN: urn:uuid:5005588c-36f3-11d6-9cec-fc96f718e113
| Product Parent URN: urn:uuid:596ffcfa-63d5-11d7-9886-ac816a682f92
| Product Parent: Solaris Operating System
| Product Defined Instance ID:
| Timestamp: 2010-08-10 07:35:40 GMT
| Container: global
| Source: SUNWstosreg
| SUNW,SPARC-Enterprise-T5120 SPARC System
| Product Name: SUNW,SPARC-Enterprise-T5120 SPARC System
| Instance URN: urn:st:51c61acd-9f37-65af-a667-c9925a5b0ee9
| Product Version:
| Product URN: urn:st:hwreg:SUNW,SPARC-Enterprise-T5120:Sun Microsystems:sparc
| Product Parent URN: urn:st:hwreg:System:Sun Microsystems
| Product Parent: System
| Product Defined Instance ID:
| Timestamp: 2010-08-10 07:35:41 GMT
| Container: global
| Source: SUNWsthwreg
| Explorer
| Product Name: Explorer
| Instance URN: urn:st:2dc5ab61-9bb5-409b-e910-fa39840d0d85
| Product Version: 6.4
| Product URN: urn:uuid:9cb70a38-7d15-11de-9d26-080020a9ed93
| Product Parent URN:
| Product Parent:
| Product Defined Instance ID:
| Timestamp: 2010-08-10 07:35:42 GMT
| Container: global
|_ Source: Explorer

Nmap done: 1 IP address (1 host up) scanned in 1.43 seconds
As you can see it reveals quite a bit of information about the system including the hostname, OS version and kernel patch revision, serial number, host id, RAM, number of CPUs and core, etc etc. Very useful for system administrators and hackers alike!

This was my first foray into writing in the Lua scripting language so I have probably made some mistakes and would appreciate some feedback if you find any bugs or have any suggestions.

No comments: