Skip to content

Instantly share code, notes, and snippets.

View SevenLayerJedi's full-sized avatar

Keith Smith SevenLayerJedi

  • CO
View GitHub Profile
# CMD
ver
# .Net Library - OSVersion property of the System.Environment class
[System.Environment]::OSVersion.Version
# .Net Library - OSVersion property of the Environment class
[Environment]::OSVersion
# Check Registry
# Commands to allow/disallow through Windows Firewall
# NETSH
netsh firewall set service type = remotedesktop mode = enable
# Registry
REG ADD "HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server" /v fDenyTSConnections /t REG_DWORD /d 0 /f
# PowerShell
$FireWall = New-Object -comObject HNetCfg.FwPolicy2
# PS Function to parse Nessus Targets
function Scrape-NessusTargets{
$nessusFiles = Get-ChildItem -Filter "*.nessus"
$allNessusTargets = @()
foreach ($file in $nessusFiles){
[xml]$XmlDocument = New-Object System.Xml.XmlDocument
[xml]$XmlDocument = Get-Content $file
$NessusPreferences = $XmlDocument.NessusClientData_v2.Policy.Preferences.ServerPreferences.preference
$targets = $NessusPreferences | ?{$_.name -eq "target"} | %{$_.value}
# Default location Windows 2003
%SystemRoot%\System32\Dns
# Default location Windows 2008
%SystemRoot%\System32\Winevt\Logs\DNS Server.evtx
# Default location of enhanced DNS Windows 2012 R2
%SystemRoot%\System32\Winevt\Logs\Microsoft-Windows-DNSServer%4Analytical.etl
# IP Configuration
ipconfig /all
# Local and DNS Cache
ipconfig /displaydns
# Show Open Connections
netstat -ano
# Netstat Loop
# Get List of Users
net user
# Get List of Local Groups
net localgroup
# Create user "bmarley"
net user /add bmarley S3cretP@ssword /add
# Add BMARLEY to local administrators group
# UFW Commands to make your life eaiser
# Install UFW
sudo apt-get update
sudo apt-get install ufw
# View UFW Status
sudo ufw status
# Enable UFW
# Display all the passwords stored in the Windows Credential Manager
Function Get-WindowsCredentialManagerPasswords{
[void][Windows.Security.Credentials.PasswordVault,Windows.Security.Credentials,ContentType=WindowsRuntime]
$vault = New-Object Windows.Security.Credentials.PasswordVault
$vault.RetrieveAll() | % { $_.RetrievePassword();$_ }
}
Get-WindowsCredentialManagerPasswords
# Random Exchange Commands
# View free space on each DB
Get-MailboxDatabase -Status | sort name | select name,@{Name='DB Size (Gb)';Expression={$_.DatabaseSize.ToGb()}},@{Name='Available New Mbx Space Gb)';Expression={$_.AvailableNewMailboxSpace.ToGb()}}
# Check Exchange Servers Service Health
Test-ServiceHealth
# Return list of Databases (Name, Server, isMounted)