{"id":109,"date":"2008-02-01T21:19:26","date_gmt":"2008-02-01T21:19:26","guid":{"rendered":"http:\/\/pentestmonkey.net\/?p=109"},"modified":"2011-08-31T16:24:24","modified_gmt":"2011-08-31T16:24:24","slug":"unix-privesc-check","status":"publish","type":"post","link":"https:\/\/pentestmonkey.net\/tools\/audit\/unix-privesc-check","title":{"rendered":"unix-privesc-check"},"content":{"rendered":"

Unix-privesc-checker is a script that runs on Unix systems (tested on Solaris 9, HPUX 11, Various Linuxes, FreeBSD 6.2).\u00a0 It tries to find misconfigurations that could allow local unprivilged users to escalate privileges to other users or to access local apps (e.g. databases).<\/p>\n

It is written as a single shell script so it can be easily uploaded and run (as opposed to un-tarred, compiled and installed).\u00a0 It can run either as a normal user or as root (obviously it does a better job when running as root because it can read more files).<\/p>\n

 <\/p>\n

<\/p>\n

Download<\/h2>\n

unix-privesc-check v1.4 can be downloaded here<\/a>.\u00a0 (Version 1.1 is here<\/a> if you still need it).<\/p>\n

Update: The google code SVN<\/a> is more up to date.<\/p>\n

Usage<\/h2>\n

The download is gzip’d, so gunzip it.\u00a0 Upload it to the server you’re auditing \/ pentesting then just run it:<\/p>\n

$ .\/unix-privesc-check > output.txt<\/pre>\n

The output’s a bit messy (it’s hard to be neat with shell scripts), so you’re probably best to save the output and search it for the word ‘WARNING’.\u00a0 If you don’t see the word ‘WARNING’ then the script didn’t find anything.\u00a0 Example:<\/p>\n

$ .\/unix-privesc-check<\/pre>\n
Starting unix-privesc-check v1.0 ( http:\/\/pentestmonkey.net\/tools\/unix-privesc-check )\r\n\r\nThis script checks file permissions and other settings that could allow\r\nlocal users to escalate privileges.\r\n\r\nUse of this script is only permitted on systems which you have been granted\r\nlegal permission to perform a security assessment of.\u00a0 Apart from this\r\ncondition the GPL v2 applies.\r\n\r\nSearch the output below for the word 'WARNING'.\u00a0 If you don't see it then\r\nthis script didn't find any problems.\r\n\r\nAssuming the OS is: linux\r\n\r\n############################################\r\nChecking if external authentication is allowed in \/etc\/passwd\r\n############################################\r\nNo +:... line found in \/etc\/passwd\r\n\r\n############################################\r\nChecking nsswitch.conf for addition authentication methods\r\n############################################\r\nNeither LDAP nor NIS are used for authentication<\/pre>\n
... lots more output ...<\/pre>\n

What’s the Intended usage of user-privesc-checker?<\/h2>\n

It’s intended to be run by security auditors and pentetration testers against systems they have been engaged to assess, and also by system admnisitrators who want to check for “obvious” misconfigurations.\u00a0 It can even be run as a cron job so you can check regularly for misconfigurations that might be introduced.<\/p>\n

I wanted to write something that was at least partially useful to pentetration testers when they gained access to a low-privilege account and wanted to escalate privileges.\u00a0 There are lots of things that pentesters will check in this situation and one of the most tedious to check is weak file permissions – this of often one of the most fruitful, though, so there’s no avoiding it.<\/p>\n

Disclaimer: Running this script alone isn’t a substitute for proper audit (e.g. following one of the NSA’s excellent configuration guides<\/a>).\u00a0 There are lots of possibilities for escalation that are just too hard to audit using a script.\u00a0 This script is intended to be a shortcut, not a replacement for a proper audit.\u00a0 See the “Limitations” section below for lots of examples of areas not covered by this script.<\/p>\n

So this is a Unix Audit Script?<\/h2>\n

Not in the traditional sense.\u00a0 “Unix Audit” means different things to different people.\u00a0 I understand it to mean checking a whole array of configuration settings including:<\/p>\n