{"id":938,"date":"2014-01-25T14:32:52","date_gmt":"2014-01-25T14:32:52","guid":{"rendered":"https:\/\/trouble.org\/?p=938"},"modified":"2014-06-05T01:43:07","modified_gmt":"2014-06-05T01:43:07","slug":"dump-supermicro-stuff","status":"publish","type":"post","link":"https:\/\/trouble.org\/?p=938","title":{"rendered":"dump supermicro stuff"},"content":{"rendered":"<p>A trivial utility to dump password\/account information from a special file found on a SM BMC (see this <a title=\"R7\" href=\"https:\/\/community.rapid7.com\/community\/metasploit\/blog\/2013\/07\/02\/a-penetration-testers-guide-to-ipmi\" target=\"_blank\">R7 post<\/a> about the PSBlock file.)<\/p>\n<p>(Later edit &#8211; put a new version on <a target=\"_blank\" href=\"https:\/\/github.com\/zenfish\/ipmi\/blob\/master\/dump_SM.py\">github<\/a> that fixes a bug)<\/p>\n<div class=\"codecolorer-container python blackboard\" style=\"overflow:auto;white-space:nowrap;height:800px;\"><div class=\"python codecolorer\"><span class=\"co1\">#!\/usr\/bin\/env python<\/span><br \/>\n<br \/>\n<span class=\"co1\"># usage: $0 file<\/span><br \/>\n<br \/>\n<span class=\"co1\">#<\/span><br \/>\n<span class=\"co1\"># (try to) Dump out passwords\/accounts from a SM binary file;<\/span><br \/>\n<span class=\"co1\"># usually this is in \/conf or \/vm on the BMC, and goes by<\/span><br \/>\n<span class=\"co1\"># various names such as PSBlock, PSStore, PMConfig.dat, and<\/span><br \/>\n<span class=\"co1\"># the like. &nbsp;This has *only* been tested on PSBlock files,<\/span><br \/>\n<span class=\"co1\"># but the theory appears to be the same; find the first account<\/span><br \/>\n<span class=\"co1\"># and password pair and march through the file at regular <\/span><br \/>\n<span class=\"co1\"># intervals until you find all the matches.<\/span><br \/>\n<span class=\"co1\">#<\/span><br \/>\n<br \/>\n<span class=\"kw1\">import<\/span> <span class=\"kw3\">re<\/span><br \/>\n<span class=\"kw1\">import<\/span> <span class=\"kw3\">sys<\/span><br \/>\n<br \/>\nACCOUNT_SIZE &nbsp;<span class=\"sy0\">=<\/span> <span class=\"nu0\">16<\/span><br \/>\nPASSWD_SIZE &nbsp; <span class=\"sy0\">=<\/span> <span class=\"nu0\">20<\/span> &nbsp; <span class=\"co1\"># IPMI 2.0<\/span><br \/>\nFIRST_ACCOUNT <span class=\"sy0\">=<\/span> <span class=\"nu0\">85<\/span> &nbsp; <span class=\"co1\"># the fun starts here<\/span><br \/>\nNEXT_ACCOUNT &nbsp;<span class=\"sy0\">=<\/span> <span class=\"nu0\">64<\/span> &nbsp; <span class=\"co1\"># N bytes later<\/span><br \/>\nMAX_ACCOUNTS &nbsp;<span class=\"sy0\">=<\/span> &nbsp;<span class=\"nu0\">9<\/span> &nbsp; <span class=\"co1\"># a guess<\/span><br \/>\n<br \/>\n<span class=\"kw1\">try<\/span>:<br \/>\n&nbsp; &nbsp;sm <span class=\"sy0\">=<\/span> <span class=\"kw2\">open<\/span><span class=\"br0\">&#40;<\/span><span class=\"kw3\">sys<\/span>.<span class=\"me1\">argv<\/span><span class=\"br0\">&#91;<\/span><span class=\"nu0\">1<\/span><span class=\"br0\">&#93;<\/span><span class=\"sy0\">,<\/span> <span class=\"st0\">&quot;rb&quot;<\/span><span class=\"br0\">&#41;<\/span><br \/>\n<br \/>\n<span class=\"kw1\">except<\/span>:<br \/>\n&nbsp; &nbsp;<span class=\"kw1\">print<\/span><span class=\"br0\">&#40;<\/span><span class=\"st0\">&quot;couldn't open %s&quot;<\/span> % <span class=\"kw3\">sys<\/span>.<span class=\"me1\">argv<\/span><span class=\"br0\">&#91;<\/span><span class=\"nu0\">1<\/span><span class=\"br0\">&#93;<\/span><span class=\"br0\">&#41;<\/span><br \/>\n&nbsp; &nbsp;<span class=\"kw3\">sys<\/span>.<span class=\"me1\">exit<\/span><span class=\"br0\">&#40;<\/span><span class=\"nu0\">2<\/span><span class=\"br0\">&#41;<\/span><br \/>\n<br \/>\n<span class=\"co1\"># skip first 84 bytes<\/span><br \/>\nsm.<span class=\"me1\">seek<\/span><span class=\"br0\">&#40;<\/span>FIRST_ACCOUNT<span class=\"sy0\">,<\/span><span class=\"nu0\">0<\/span><span class=\"br0\">&#41;<\/span><br \/>\n<br \/>\n<span class=\"co1\"># loop for accounts\/passwords<\/span><br \/>\n<span class=\"kw1\">for<\/span> i <span class=\"kw1\">in<\/span> <span class=\"kw2\">range<\/span><span class=\"br0\">&#40;<\/span><span class=\"nu0\">0<\/span><span class=\"sy0\">,<\/span>MAX_ACCOUNTS + <span class=\"nu0\">1<\/span><span class=\"br0\">&#41;<\/span>:<br \/>\n<br \/>\n&nbsp; &nbsp;<span class=\"co1\"># go to the right place<\/span><br \/>\n&nbsp; &nbsp;sm.<span class=\"me1\">seek<\/span><span class=\"br0\">&#40;<\/span>FIRST_ACCOUNT + i * NEXT_ACCOUNT<span class=\"sy0\">,<\/span> <span class=\"nu0\">0<\/span><span class=\"br0\">&#41;<\/span><br \/>\n<br \/>\n&nbsp; &nbsp;<span class=\"co1\"># grabit<\/span><br \/>\n&nbsp; &nbsp;account <span class=\"sy0\">=<\/span> sm.<span class=\"me1\">read<\/span><span class=\"br0\">&#40;<\/span>ACCOUNT_SIZE<span class=\"br0\">&#41;<\/span><br \/>\n&nbsp; &nbsp;passwd &nbsp;<span class=\"sy0\">=<\/span> sm.<span class=\"me1\">read<\/span><span class=\"br0\">&#40;<\/span>PASSWD_SIZE<span class=\"br0\">&#41;<\/span><br \/>\n<br \/>\n&nbsp; &nbsp;<span class=\"co1\"># strip nulls<\/span><br \/>\n&nbsp; &nbsp;account <span class=\"sy0\">=<\/span> <span class=\"kw3\">re<\/span>.<span class=\"me1\">sub<\/span><span class=\"br0\">&#40;<\/span><span class=\"st0\">'<span class=\"es0\">\\0<\/span>00*$'<\/span><span class=\"sy0\">,<\/span> <span class=\"st0\">''<\/span><span class=\"sy0\">,<\/span> account<span class=\"br0\">&#41;<\/span><br \/>\n&nbsp; &nbsp;passwd &nbsp;<span class=\"sy0\">=<\/span> <span class=\"kw3\">re<\/span>.<span class=\"me1\">sub<\/span><span class=\"br0\">&#40;<\/span><span class=\"st0\">'<span class=\"es0\">\\0<\/span>00*$'<\/span><span class=\"sy0\">,<\/span> <span class=\"st0\">''<\/span><span class=\"sy0\">,<\/span> passwd<span class=\"br0\">&#41;<\/span><br \/>\n<br \/>\n&nbsp; &nbsp;<span class=\"kw1\">if<\/span> <span class=\"kw2\">len<\/span><span class=\"br0\">&#40;<\/span>account<span class=\"br0\">&#41;<\/span> <span class=\"sy0\">&gt;<\/span> <span class=\"nu0\">0<\/span> <span class=\"kw1\">and<\/span> account<span class=\"br0\">&#91;<\/span><span class=\"nu0\">0<\/span><span class=\"br0\">&#93;<\/span> <span class=\"sy0\">!=<\/span> <span class=\"st0\">'<span class=\"es0\">\\0<\/span>00'<\/span>:<br \/>\n&nbsp; &nbsp; &nbsp; <span class=\"kw1\">print<\/span><span class=\"br0\">&#40;<\/span><span class=\"st0\">&quot;Account [%d]: %s&quot;<\/span> % <span class=\"br0\">&#40;<\/span>i<span class=\"sy0\">,<\/span> account<span class=\"br0\">&#41;<\/span><span class=\"br0\">&#41;<\/span><br \/>\n&nbsp; &nbsp; &nbsp; <span class=\"kw1\">print<\/span><span class=\"br0\">&#40;<\/span><span class=\"st0\">&quot;Password[%d]: %s&quot;<\/span> % <span class=\"br0\">&#40;<\/span>i<span class=\"sy0\">,<\/span> passwd<span class=\"br0\">&#41;<\/span><span class=\"br0\">&#41;<\/span><br \/>\n<br \/>\nsm.<span class=\"me1\">close<\/span><span class=\"br0\">&#40;<\/span><span class=\"br0\">&#41;<\/span><\/div><\/div>\n","protected":false},"excerpt":{"rendered":"<p>A trivial utility to dump password\/account information from a special file found on a SM BMC (see this R7 post about the PSBlock file.) (Later edit &#8211; put a new version on github that fixes a bug) #!\/usr\/bin\/env python # usage: $0 file # # (try to) Dump out passwords\/accounts from a SM binary file; [&hellip;]<\/p>\n","protected":false},"author":44,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[31,176,154,172],"tags":[],"class_list":["post-938","post","type-post","status-publish","format-standard","hentry","category-code","category-embedded","category-ipmi-2","category-python"],"_links":{"self":[{"href":"https:\/\/trouble.org\/index.php?rest_route=\/wp\/v2\/posts\/938","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/trouble.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/trouble.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/trouble.org\/index.php?rest_route=\/wp\/v2\/users\/44"}],"replies":[{"embeddable":true,"href":"https:\/\/trouble.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=938"}],"version-history":[{"count":3,"href":"https:\/\/trouble.org\/index.php?rest_route=\/wp\/v2\/posts\/938\/revisions"}],"predecessor-version":[{"id":998,"href":"https:\/\/trouble.org\/index.php?rest_route=\/wp\/v2\/posts\/938\/revisions\/998"}],"wp:attachment":[{"href":"https:\/\/trouble.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=938"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/trouble.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=938"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/trouble.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=938"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}