Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <#
- TITLE - hardenSMB
- FILENAME - hardensmb.ps1
- DESCRIPTION - Disables SMBv1 protocol on server/workstation and enables SMBv2/3
- AUTHOR -
- COMPANY -
- #>
- Write-Host "*********************************************" -ForegroundColor Yellow
- Write-Host " _ _ ___ __ __ ___ "
- Write-Host " | |_ __ _ _ _ __| |___ _ _ / __| \/ | _ ) "
- Write-Host " | ' \/ _` | '_/ _` / -_) ' \\__ \ |\/| | _ \ "
- Write-Host " |_||_\__,_|_| \__,_\___|_||_|___/_| |_|___/ "
- Write-Host " h4ck7h3pl@n37 "
- Write-Host "**********************************************" -ForegroundColor Yellow
- Write-host "+++++++++++++++" -ForegroundColor Red
- Write-Host "INITIALIZING..."
- Write-host "+++++++++++++++" -ForegroundColor Red
- Start-Sleep -Seconds 3
- $servers = Get-Content <path to server list file>
- $results = @()
- Write-host "+++++++++++++++++++++" -ForegroundColor Red
- Write-Host "EXECUTING PROGRAM... "
- Write-Host "hold on to your butts"
- Write-host "+++++++++++++++++++++" -ForegroundColor Red
- Start-Sleep -Seconds 3
- foreach($server in $servers){
- Write-Host "Pinging " $server -ForegroundColor Red
- $ping = Test-Connection -Count 1 -ComputerName $server -ErrorAction SilentlyContinue
- if ( $ping -ne $null ){
- Write-Host $server 'is up. Attemptin to JACK IN...' -ForegroundColor Yellow
- $testSession = New-PSSession -ComputerName $server -ErrorAction SilentlyContinue
- if ( $testSession -ne $null ) {
- Write-Host 'Successful REMCON...Modifying Configuration' -ForegroundColor Green
- Invoke-Command -ComputerName $server -FilePath '<path to list of commands.ps1>'
- Write-Host 'SMBv1 disable and SMBv2/3 enable successful on ' $server -ForegroundColor Green
- $status = 'COMPLETED'
- } else {
- write-host 'REMCON failure to ' $server -ForegroundColor Red
- $status = 'COULD NOT ESTABLISH REMOTE SESSION'
- }
- } else {
- Write-Host $server ' appears to be down' -ForegroundColor red
- $status = 'NO PING'
- }
- Write-Host 'Writing d3375 to 0u7pu7'
- $itemDetails = [PSCustomObject]@{
- ServerName = $server
- Status = $status
- }
- Write-Host '+++++++++++++++++++++'
- Write-Host 'Compiling d3375 4rr4y' -ForegroundColor DarkYellow
- Write-Host '+++++++++++++++++++++'
- $results += $itemDetails
- }
- Write-Host '+++++++++++++++++++++' -ForegroundColor Green
- Write-Host 'Dropping d3375 to CSV'
- Write-Host '+++++++++++++++++++++' -ForegroundColor Green
- $results | export-csv <output path>
Advertisement
Add Comment
Please, Sign In to add comment