Advertisement
Python253

smb1_smb2_verify

Apr 12th, 2024
938
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # Filename: smb1_smb2_verify.ps1
  2. # Version: 1.0.0
  3. # Author: Jeoi Reqi
  4.  
  5. <#
  6. .SYNOPSIS
  7.     Verify the status of SMB1 and SMB2 protocols on the system.
  8.  
  9. .DESCRIPTION
  10.     This script checks whether SMB1 and SMB2 protocols are enabled or disabled on the system.
  11.     It provides a warning if both SMB1 and SMB2 are enabled, indicating a high risk of vulnerability to exploits such as EternalBlue.
  12.  
  13. .NOTES
  14.     Author: Jeoi Reqi
  15.     Version: 1.0.0
  16.     Last Updated: April 2024
  17. #>
  18.  
  19. function Verify-SMB1Status {
  20.     try {
  21.         # Check the value of the SMB1 registry key
  22.         $result = Get-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Services\LanmanServer\Parameters" -Name "SMB1" -ErrorAction Stop
  23.         if ($result.SMB1 -eq 1) {
  24.             Write-Host "`nSMB1 is enabled. `n`t`t:: ⚠️ Warning ⚠ ::`n`n`t- Enabling SMB1 exposes your system to potential vulnerabilities such as EternalBlue.`n"
  25.             return $true
  26.         }
  27.         elseif ($result.SMB1 -eq 0) {
  28.             Write-Host "`nSMB1 is disabled.`n"
  29.             return $false
  30.         }
  31.         else {
  32.             Write-Host "`nSMB1 status could not be determined or registry key not found on the system.`n"
  33.             return $null
  34.         }
  35.     }
  36.     catch {
  37.         Write-Host "`nAn error occurred while checking SMB1 status: $($Error[0].Exception.Message)`n"
  38.         return $null
  39.     }
  40. }
  41.  
  42. function Verify-SMB2Status {
  43.     $smb2Enabled = (Get-SmbServerConfiguration).EnableSMB2Protocol
  44.     if ($smb2Enabled) {
  45.         return $true
  46.     }
  47.     else {
  48.         return $false
  49.     }
  50. }
  51.  
  52. $smb1Enabled = Verify-SMB1Status
  53. $smb2Enabled = Verify-SMB2Status
  54.  
  55. if ($smb1Enabled -eq $true -and $smb2Enabled -eq $true) {
  56.     Write-Host "`n⚠️ Warning: Both SMB1 and SMB2 are enabled!`nYour system is at high risk due to vulnerabilities such as EternalBlue.`n"
  57. }
  58. else {
  59.     Write-Host "`nNo vulnerability to EternalBlue exploits detected.`n"
  60. }
  61.  
  62.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement