silverhack / monkey365

Monkey365 provides a tool for security consultants to easily conduct not only Microsoft 365, but also Azure subscriptions and Microsoft Entra ID security configuration reviews.
https://silverhack.github.io/monkey365/
Apache License 2.0
846 stars 92 forks source link

[Bug]: with import-module command #124

Open sebfun opened 3 days ago

sebfun commented 3 days ago

What happened?
Can't execute import-module command. Receiving error ("unable to find a module file")

How to reproduce it
Steps to reproduce the behavior:

  1. PS C:\WINDOWS\system32> Get-ChildItem -Recurse c:\audit\M365 | Unblock-File OK no error

  2. PS C:\WINDOWS\system32> Import-Module monkey365
    Import-Module : Le module « monkey365 » spécifié n'a pas été chargé, car aucun fichier de module valide n'a été trouvé dans un répertoire de module.
    Au caractère Ligne:1 : 1
    + Import-Module monkey365
    + ~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ResourceUnavailable: (monkey365:String) [Import-Module], FileNotFoundException
    + FullyQualifiedErrorId : Modules_ModuleNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand
  3. Trying to move to the right directory PS C:\WINDOWS\system32> cd C:\audit\M365 OK

  4. Retrying import command with -Force

    
    PS C:\audit\M365> Import-Module C:\audit\M365 -Force

Import-Module : Le module « C:\audit\M365 » spécifié n'a pas été chargé, car aucun fichier de module valide n'a été trouvé dans un répertoire de module. Au caractère Ligne:1 : 1

PS C:\audit\M365> dir *.ps*

Mode                 LastWriteTime         Length Name                                                                                                                                                                                                           
----                 -------------         ------ ----                                                                                                                                                                                                           
------        13/11/2024     13:36           2571 build.ps1                                                                                                                                                                                                      
------        13/11/2024     13:36          27204 Invoke-Monkey365.ps1                                                                                                                                                                                           
------        13/11/2024     13:36            718 monkey365.ps1                                                                                                                                                                                                  
------        13/11/2024     13:36           5097 monkey365.psd1                                                                                                                                                                                                 
------        13/11/2024     13:36           3235 monkey365.psm1     
  1. I also try using backslash at the end of the directory (in the import module command), same result

Expected behavior
Well, I expect to successfully run the import module command

Screenshots or Logs
Not Applicable

From where are you running Monkey365?
Please, complete the following information:

 Name                           Value                                                                                                                                                                                                                             
----                           -----                                                                                                                                                                                                                             
PSVersion                      5.1.26100.2161                                                                                                                                                                                                                    
PSEdition                      Desktop                                                                                                                                                                                                                           
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}                                                                                                                                                                                                           
BuildVersion                   10.0.26100.2161                                                                                                                                                                                                                   
CLRVersion                     4.0.30319.42000                                                                                                                                                                                                                   
WSManStackVersion              3.0                                                                                                                                                                                                                               
PSRemotingProtocolVersion      2.3                                                                                                                                                                                                                               
SerializationVersion           1.1.0.1    

Additional context Nothing else

silverhack commented 3 days ago

Hi @sebfun,

It is not a bug and you're import it incorrectly. You're seeing these errors because the folder does not have the same name as the PSD1. You should rename the folder from M365 to Monkey365. Once the name is changed you will be able to import the module. And all is explained here.

Please, see docs about how to import a PowerShell module. https://silverhack.github.io/monkey365/install-instructions/ https://learn.microsoft.com/en-us/powershell/scripting/developer/module/importing-a-powershell-module?view=powershell-7.3