{"id":6810,"date":"2019-10-03T22:20:43","date_gmt":"2019-10-03T22:20:43","guid":{"rendered":"http:\/\/www.hexacorn.com\/blog\/?p=6810"},"modified":"2019-10-04T08:28:53","modified_gmt":"2019-10-04T08:28:53","slug":"im-so-excited","status":"publish","type":"post","link":"https:\/\/www.hexacorn.com\/blog\/2019\/10\/03\/im-so-excited\/","title":{"rendered":"I&#8217;M SO excited"},"content":{"rendered":"\n<p>MSO.DLL is a &#8216;magic&#8217; Microsoft Library that is HUUUUUGE in size and does most of the Microsoft Office work. I have been massaging it for many years and always doing so with a feeling that I am not understanding anything at all. And I really do not even pretend to have any grasp of any piece of it, but I decided to describe what I found out so far, because it may lead us to some places new.<\/p>\n\n\n\n<p>Okay&#8230; Where do we start?<\/p>\n\n\n\n<p>MSO.DLL is literally 25MB+ long. It&#8217;s a  HUUUUUGE  DLL. It is crazy, it is loco, it exports 9K APIs last time I checked and many of them via ordinal only. IDA won&#8217;t help, and any attempts to analyze it in a conventional way end up with a big, giant, mix of who-knows-what. This code is doing lots of great work, but who knows how it works&#8230; I mean&#8230; really&#8230;<\/p>\n\n\n\n<p>In any case&#8230;  Adding _any_ sense to such a big pile of code is useful. How? For starters, we can identify wrappers. What are these wrappers? It turns out that MSO.DLL exports a lot of functions that do nothing but wrapping common Windows API around. <\/p>\n\n\n\n<p>I know, we need an example&#8230;<\/p>\n\n\n\n<p>Take MSO #222. This function requires two arguments:  address of a buffer, and its size. It then fills in that buffer with&#8230; yup&#8230; whatever a call to GetComputerNameW provides &#8212; it just passes the arguments to the final Windows API! Oh, wrappers are easy!<\/p>\n\n\n\n<p>When I spotted this the first time I started digging more and noticed that there is a clearly visible pattern inside mso.dll that tells us about many exported APIs being nothing more but wrappers. If we are patient enough we may effortlessly identify a meaning of many MSO exported functions by just looking at the wrapped APIs they encapsulate&#8230;!<\/p>\n\n\n\n<p>And to give a quick, although non-nonsensical demo&#8230;. when we run a following export API via rundll:<\/p>\n\n\n\n<blockquote class=\"wp-block-quote\"><p>rundll32 MSO.DLL, #2310<\/p><\/blockquote>\n\n\n\n<p>it gives us this message:<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" loading=\"lazy\" width=\"179\" height=\"154\" src=\"https:\/\/www.hexacorn.com\/blog\/wp-content\/uploads\/2019\/10\/mso_1.png\" alt=\"\" class=\"wp-image-6811\"\/><\/figure>\n\n\n\n<p>It&#8217;s just one of 9K APIs that we just understood at the most possible lowest level &#8212; it is not implemented and we can all move on!<\/p>\n\n\n\n<p>Divide and conquer approach apparently works. The below list summarizes the wrapper info I could gather so far; the arguments these functions take is a different story, but what&#8217;s interesting is that they do wrap lots of common APIs which could be abused in many way.<\/p>\n\n\n\n<p>For starters, imagine an .exe that instead of loading and using common advapi32 or user32.dll APIs to deliver some functionality, proxies it via an existing mso.dll. Ouch. Try to filter this stuff out Mr EDR Threat Hunter!<\/p>\n\n\n\n<p>Yup. Wrapping is condoming. And condoming is avoiding signatures. And to be clear and avoid any doubt: I can imagine a malware taking an advantage of MSO.DLL and delivering lots of its functionality via the wrapped API Calls. Try to sandbox or EDR it out. Good luck!<\/p>\n\n\n\n<p>In any case&#8230; here&#8217;s the list I gathered so far:<\/p>\n\n\n\n<p> MSO_4367    TlsGetValue<br> MSO_865    TlsSetValue<br> MSO_5901    _InterlockedIncrement<br> MSO_8719    _InterlockedIncrement<br> MSO_3166    _InterlockedIncrement<br> MSO_4565    _InterlockedIncrement<br> MSO_7857    _InterlockedIncrement<br> MSO_844    RegSetValueExW<br> MSO_8234    TlsFree<br> MSO_8768    _InterlockedIncrement<br> MSO_6388    GetSystemMetrics<br> MSO_3762    RegQueryInfoKeyW<br> MSO_3213    GetSysColor<br> MSO_2727    CreateFontIndirectW<br> MSO_3029    CompareFileTime<br> MSO_2833    RegQueryValueW<br> MSO_7454    GetFileSizeEx<br> MSO_5917    GetDriveTypeW<br> MSO_6874    GetTempPathW<br> MSO_8807    CreateSemaphoreExW<br> MSO_2466    ShowWindow<br> MSO_6184    EnumFontFamiliesExW<br> MSO_6682    UrlMkSetSessionOption<br> MSO_472    LoadCursorW<br> MSO_9153    GetKeyboardLayoutList<br> MSO_6866    GetKeyboardLayout<br> MSO_4285    AlphaBlend<br> MSO_1613    SetWindowTextW<br> MSO_9656    SetCursor<br> MSO_7047    pow<br> MSO_1322    SHGetSpecialFolderLocation<br> MSO_6104    GetFileVersionInfoSizeW<br> MSO_1029    GetFileVersionInfoW<br> MSO_1500    VerQueryValueW<br> MSO_2182    MsoFreePv<br> MSO_2790    GetWindowLongW<br> MSO_150    CoInternetGetSession<br> MSO_3646    SendMessageA<br> MSO_9800    CopyFileW<br> MSO_3854    GetComputerNameW<br> MSO_9474    CreateStdAccessibleObject<br> MSO_2772    GlobalFree<br> MSO_6086    CopyFileExW<br> MSO_6642    GlobalLock<br> MSO_5402    GlobalSize<br> MSO_7213    GlobalUnlock<br> MSO_2563    GetDateFormatEx<br> MSO_4787    MsoDwRegGetDw<br> MSO_1603    GetKeyState<br> MSO_2137    SetTimer<br> MSO_5880    KillTimer<br> MSO_4342    SystemParametersInfoW<br> MSO_3543    MsoPwchStripWtz<br> MSO_4298    FindMimeFromData<br> MSO_5716    PostMessageW<br> MSO_4008    GetVolumeInformationW<br> MSO_3230    ClosePrinter<br> MSO_8164    GetAsyncKeyState<br> MSO_6862    DefWindowProcW<br> MSO_3611    SetWindowLongW<br> MSO_2213    SetRect<br> MSO_8526    StartDocW<br> MSO_3668    GetTextMetricsA<br> MSO_6277    WTSUnRegisterSessionNotification<br> MSO_2998    WTSRegisterSessionNotification<br> MSO_3627    LresultFromObject<br> MSO_6992    LoadAcceleratorsW<br> MSO_1197    CopyAcceleratorTableW<br> MSO_1656    DestroyAcceleratorTable<br> MSO_1222    GetTimeFormatEx<br> MSO_222    GetComputerNameW<br> MSO_9746    GlobalAlloc<br> MSO_1645    GetObjectW<br> MSO_2208    HlinkOnNavigate<br> MSO_307    CoInternetCompareUrl<br> MSO_1769    SendMessageA<br> MSO_811    ShowWindow<br> MSO_5519    IpcFreeMemory<br> MSO_4234    IpcGetErrorMessageText<br> MSO_2310    MessageBoxW<br> MSO_8408    SendMessageA<br> MSO_392    SendMessageA<br> MSO_2497    SendMessageA<br> MSO_5559    SendMessageA<br> MSO_941    SendMessageA<br> MSO_9758    AppendMenuW<br> MSO_1938    InsertMenuW<br> MSO_9278    log<br> MSO_2662    exp<br> MSO_489    TransparentBlt<br> MSO_7070    AccessibleObjectFromWindow<br> MSO_8160    DragQueryPoint<br> MSO_626    ExtractIconExW<br> MSO_1501    DragQueryFileW<br> MSO_2695    ExtractIconW<br> MSO_9235    SHGetDesktopFolder<br> MSO_3353    ShellExecuteW<br> MSO_1363    PathQuoteSpacesW<br> MSO_879    PathFindFileNameW<br> MSO_441    PathUnquoteSpacesW<br> MSO_8683    PathRemoveFileSpecW<br> MSO_9005    CoInternetParseUrl<br> MSO_2388    CopyStgMedium<br> MSO_9793    CoInternetQueryInfo<br> MSO_3998    CreateURLMonikerEx<br> MSO_2397    InternetCloseHandle<br> MSO_7846    InternetReadFile<br> MSO_352    InternetQueryOptionW<br> MSO_401    InternetSetOptionW<br> MSO_1364    InternetOpenW<br> MSO_437    HttpQueryInfoW<br> MSO_7998    InternetCanonicalizeUrlW<br> MSO_4107    InternetCrackUrlW<br> MSO_4662    GetPrivateProfileIntW<br> MSO_5487    GetProfileIntW<br> MSO_614    FreeLibrary<br> MSO_4224    FormatMessageW<br> MSO_7302    CallWindowProcW<br> MSO_8062    GlobalFlags<br> MSO_9445    MapViewOfFileEx<br> MSO_33    CreateFileMappingW<br> MSO_6589    MsoFRegSetWz<br> MSO_2033    OleSetClipboard<br> MSO_4704    HlinkUpdateStackItem<br> MSO_9546    HlinkSetSpecialReference<br> MSO_3343    RegisterMediaTypeClass<br> MSO_7797    RegisterBindStatusCallback<br> MSO_9678    RevokeBindStatusCallback<br> MSO_8675    SetWindowPos<br> MSO_769_SEH    _CxxFrameHandler3<br> MSO_6604_SEH    _CxxFrameHandler3<br> MSO_7603_SEH    _CxxFrameHandler3<\/p>\n","protected":false},"excerpt":{"rendered":"<p>MSO.DLL is a &#8216;magic&#8217; Microsoft Library that is HUUUUUGE in size and does most of the Microsoft Office work. I have been massaging it for many years and always doing so with a feeling that I am not understanding anything &hellip; <a href=\"https:\/\/www.hexacorn.com\/blog\/2019\/10\/03\/im-so-excited\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[53,67],"tags":[],"_links":{"self":[{"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/posts\/6810"}],"collection":[{"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/comments?post=6810"}],"version-history":[{"count":5,"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/posts\/6810\/revisions"}],"predecessor-version":[{"id":6817,"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/posts\/6810\/revisions\/6817"}],"wp:attachment":[{"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/media?parent=6810"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/categories?post=6810"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hexacorn.com\/blog\/wp-json\/wp\/v2\/tags?post=6810"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}