Skip to content

Commit 189da99

Browse files
authored
Add DisableWindowsDefender.ps1 and update README
Added DisableWindowsDefender.ps1 script and updated usage instructions.
1 parent 455ab9c commit 189da99

File tree

1 file changed

+38
-21
lines changed

1 file changed

+38
-21
lines changed

README.md

Lines changed: 38 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ PowerShell-Scripts/
1111
│ └── Base64Tool.ps1
1212
│ └── Test-Feeds3.ps1
1313
│ └── domains2ipsipv4Only.ps1
14+
│ └── DisableWindowsDefender.ps1
1415
├── Azure Active Directory/
1516
│ └── get_az_token.ps1
1617
│ └── aadinternals_audit6.ps1 (Uses AADInternals)
@@ -52,10 +53,10 @@ Usage:
5253
1. Clone the repository:
5354
git clone https://github.com/rolling-code/PowerShell-Scripts.git
5455

55-
2. Navigate to the desired folder:
56+
2. Navigate to the desired folder, eg:
5657
cd "PowerShell-Scripts/Azure Active Directory"
5758

58-
3. Run the script using PowerShell:
59+
3. Run the script using PowerShell, or Python eg:
5960
.\get_az_token.ps1
6061

6162
Notes:
@@ -393,6 +394,31 @@ This is a great tool to uncover secrets on a LAN. Corporations unknowingly share
393394
Use like:
394395
`.\lan_audit_full2.ps1 "\\somedc.somedomain.net\UNCName\Any Folders" audit_report.csv`
395396

397+
---
398+
### `CheckWritableAttributesADUsers.py|.ps1`
399+
400+
The Python svcript uses strictly LDAP3 to enumerate the AD users (use the -dc-ip parameter to specify your Domain Controller IP).
401+
Then it will attempt to write "temp" to attributes to determine if any is writeable.
402+
Although not the most elegent solution - it works! It will write a users.cvs file, which should only contain your own AD account-any others are worhty of ivestigation!
403+
Use like so:
404+
405+
`python3 CheckWritableAttributesADUsers.py DOMAIN/mcontestabile:'XXX' -dc-ip 1.2.3.4`
406+
407+
The PowerShell version does the same thing - but with a twist.
408+
Firstly, it will try to use ADWS first before falling back to LDAP.
409+
Secondly, it also produces a ADUsers.csv output file but it contains the "WriteableAttributes" for each user.
410+
Users with excessive permissions will stand out!
411+
412+
Use with parameters and it will use your current Windows account. You can specify like so:
413+
`-Dc 1.2.0.10 -Out investigate_UsersPS.csv`
414+
415+
or specify other creds like so:
416+
417+
`$cred = Get-Credential domain\otheruser
418+
.\CheckWritableAttributesADUsers.ps1 -Credential $cred`
419+
420+
Use `-PageSize 200` for large directories.
421+
396422
## ── 📂 Section: Generic Directory ──
397423
---
398424
### `Test-Feeds3.ps1`
@@ -438,27 +464,18 @@ Results piped to all_domains.txt which we will feed into the script like so:
438464
`.\domains2ipsipv4Only.ps1 -InputPath all_domains.txt -OutputPath ips.txt`
439465

440466
---
441-
### `CheckWritableAttributesADUsers.py|.ps1`
442-
443-
The Python svcript uses strictly LDAP3 to enumerate the AD users (use the -dc-ip parameter to specify your Domain Controller IP).
444-
Then it will attempt to write "temp" to attributes to determine if any is writeable.
445-
Although not the most elegent solution - it works! It will write a users.cvs file, which should only contain your own AD account-any others are worhty of ivestigation!
446-
Use like so:
447-
448-
`python3 CheckWritableAttributesADUsers.py DOMAIN/mcontestabile:'XXX' -dc-ip 1.2.3.4`
467+
### `DisableWindowsDefender.ps1`
449468

450-
The PowerShell version does the same thing - but with a twist.
451-
Firstly, it will try to use ADWS first before falling back to LDAP.
452-
Secondly, it also produces a ADUsers.csv output file but it contains the "WriteableAttributes" for each user.
453-
Users with excessive permissions will stand out!
469+
Disables Windows Defender Services. Need to run as admin.
454470

455-
Use with parameters and it will use your current Windows account. You can specify like so:
456-
`-Dc 1.2.0.10 -Out investigate_UsersPS.csv`
471+
If you want to automatically do so after every reboot & login event, run this PowerSHell to create a Scheduled Task which will run that .ps1 for you under SYSTEM.
457472

458-
or specify other creds like so:
459-
`$cred = Get-Credential domain\otheruser
460-
.\CheckWritableAttributesADUsers.ps1 -Credential $cred`
461-
462-
Use `-PageSize 200` for large directories.
473+
`$Action = New-ScheduledTaskAction -Execute 'powershell.exe' -Argument '-NoProfile -ExecutionPolicy Bypass -WindowStyle Hidden -File "C:\Users\mcontestabile\DisableWindowsDefender.ps1"'
474+
$Triggers = @(
475+
New-ScheduledTaskTrigger -AtStartup
476+
New-ScheduledTaskTrigger -AtLogOn
477+
)
478+
$Principal = New-ScheduledTaskPrincipal -UserId "SYSTEM" -RunLevel Highest
479+
Register-ScheduledTask -TaskName "Git-PostLogonScript" -Action $Action -Trigger $Triggers -Principal $Principal -Description "Run post-logon script elevated"`
463480

464481

0 commit comments

Comments
 (0)