Skip to content

Instantly share code, notes, and snippets.

@PanosGreg
PanosGreg / Encrypt-Decrypt-WithDotNet.ps1
Last active April 1, 2024 17:13
Encryption & Decryption using native .NET classes
## Encryption & Decryption using native .NET functions
## This is Symetrical encryption. Which means the same key is used to both encrypt and decrypt.
## The encryption method is based on AES 256bit.
## The major difference between this option and the ConvertFrom/To-SecureString functions
## is that this way produces much smaller encrypted files.
## I have not compared the 2 options in regards to performance though, as-in which one is faster.
@gioxx
gioxx / O365LicenseFriendlyName.txt
Created March 7, 2022 10:38
Una lista di mappatura tra licenze Office 365 (SkuPartNumber via PowerShell) e nome più amichevole (la base è stata curata da https://o365reports.com/2021/11/23/office-365-license-reporting-and-management-using-powershell, in seguito modificata da me) - https://gioxx.org
AAD_BASIC= Azure Active Directory Basic
AAD_PREMIUM= Azure Active Directory Premium
AAD_PREMIUM_P1= Azure Active Directory Premium P1
AAD_PREMIUM_P2= Azure Active Directory Premium P2
ADALLOM_O365= Office 365 Advanced Security Management
ADALLOM_STANDALONE= Microsoft Cloud App Security
ADALLOM_S_O365= POWER BI STANDALONE
ADALLOM_S_STANDALONE= Microsoft Cloud App Security
ATA= Azure Advanced Threat Protection for Users
ATP_ENTERPRISE= Exchange Online Advanced Threat Protection
@SwitHak
SwitHak / 20211210-TLP-WHITE_LOG4J.md
Last active June 28, 2024 12:07
BlueTeam CheatSheet * Log4Shell* | Last updated: 2021-12-20 2238 UTC

Security Advisories / Bulletins / vendors Responses linked to Log4Shell (CVE-2021-44228)

Errors, typos, something to say ?

  • If you want to add a link, comment or send it to me
  • Feel free to report any mistake directly below in the comment or in DM on Twitter @SwitHak

Other great resources

  • Royce Williams list sorted by vendors responses Royce List
  • Very detailed list NCSC-NL
  • The list maintained by U.S. Cybersecurity and Infrastructure Security Agency: CISA List
function PNValidate {
$Results = [PSCustomObject]@{
Spooler = $null
PatchInstalled = $false
RestrictDriverInstallationToAdministrators = $null
NoWarningNoElevationOnInstall = $null
UpdatePromptSettings = $null
Exploitable = $true
Explanation = $null
}
@maxkoshevoi
maxkoshevoi / download-latest-release.ps1
Created April 9, 2021 18:05
Download latest GitHub release via Powershell
$repoName = "PowerShell/PowerShell"
$assetPattern = "*-win-x64.msi"
$extractDirectory = "C:\Users\Public\Downloads"
$releasesUri = "https://api.github.com/repos/$repoName/releases/latest"
$asset = (Invoke-WebRequest $releasesUri | ConvertFrom-Json).assets | Where-Object name -like $assetPattern
$downloadUri = $asset.browser_download_url
$extractPath = [System.IO.Path]::Combine($extractDirectory, $asset.name)
{
"final_space": true,
"console_title": true,
"console_title_style": "folder",
"blocks": [
{
"type": "prompt",
"alignment": "left",
"horizontal_offset": 0,
"vertical_offset": 0,
@ffeldhaus
ffeldhaus / oauth-authentication-powershell.ps1
Last active June 11, 2024 15:19
Using OAuth 2.0 with PowerShell to authenticate against Google Services
# configuration (adapt to your setup!)
$CertFile = "$HOME/certificate.p12"
$CertPassword = "notasecret"
$Project = "myproject"
$ServiceAccountName = "service-account"
$ServiceAccount = "$ServiceAccountName@$Project.iam.gserviceaccount.com"
$Scope = "https://www.googleapis.com/auth/cloud-platform"
$ExpirationSeconds = 3600
# import certificate
Add-Type @"
namespace System.Security.Cryptography.X509Certificates {
public enum X509KeySpecFlags {
None = 0,
AT_KEYEXCHANGE = 1,
AT_SIGNATURE = 2
}
}
"@
function Convert-PemToPfx {
@cdelashmutt-pivotal
cdelashmutt-pivotal / Create-OpenSSHPubAndPrivateKeys.ps1
Created June 26, 2020 15:21
Generate OpenSSH compatible public and private key files in Powershell
<#
.SYNOPSIS
Create an OpenSSH compatible Public and Private Key in pure Powershell
.DESCRIPTION
Many scripts rely on the openssh or openssl tools to be available to generate public and private keys compatible with OpenSSH, but this script relies purely on Powershell (and some .NET classes already included) to generate public and private keys.
.EXAMPLE
PS /git/scripts> ./Create-OpenSSHPubAndPrivateKeys.ps1 -PublicKeyPath my-key.pub -PrivateKeyPath my-key
.LINK
mailto:grog@grogscave.net
#>
@StephenFordham
StephenFordham / method_decorators_example2.py
Created May 13, 2020 09:13
method_decorators_example2
def integer_check(method):
def inner(ref, expo=None):
if expo == None:
if not isinstance(ref._val1, int) or not isinstance(ref._val2, int):
raise TypeError('Please enter numerical numbers for val1 and val2')
else:
return method(ref)
if expo:
if not isinstance(ref._val1, int) or not isinstance(ref._val2, int)\
or not isinstance(expo, int):