Skip to content

Instantly share code, notes, and snippets.

@zer0cat
zer0cat / hex2bin.c
Created March 31, 2022 17:24
Hex Bin in pure C
char *bin2hex(const unsigned char *bin, size_t len)
{
char *out;
size_t i;
if (bin == NULL || len == 0)
return NULL;
out = malloc(len*2+1);
for (i=0; i<len; i++) {
@zer0cat
zer0cat / str_replace.c
Created April 23, 2021 14:24
String replace in pure C
/*
* @brief
* PHP's str_replace ported to C
* @author Silver Moon (m00n.silv3r@gmail.com)
* */
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
@zer0cat
zer0cat / privs.txt
Created January 22, 2021 19:40
List of win privs
Privilege:
SeCreateTokenPrivilege = 1
SeAssignPrimaryTokenPrivilege = 2
SeLockMemoryPrivilege = 3
SeIncreaseQuotaPrivilege = 4
SeUnsolicitedInputPrivilege = 5
SeMachineAccountPrivilege = 6
SeTcbPrivilege = 7
SeSecurityPrivilege = 8
SeTakeOwnershipPrivilege = 9
@zer0cat
zer0cat / wfork.c
Created March 20, 2020 02:44
windows fork
//откуда-то с инетов, вроде с РеактОс. Автор не я, просто выложил
#pragma once
#define _WIN32_WINNT 0x0502 // Change this to the appropriate value to target other versions of Windows.
#define DPRINT(...)
#define DPRINT1(...)
#include <stdlib.h>
#include <tchar.h>
@zer0cat
zer0cat / ntlist.c
Last active September 2, 2021 20:09
Enumerate files with Native Api.
/* example , how to enum files with NtQuerydirectoryFilе */
#include <windows.h>
#include <stdio.h>
typedef LONG NTSTATUS;
typedef NTSTATUS *PNTSTATUS;
typedef DWORD ULONG_PTR;
#define STATUS_SUCCESS (NTSTATUS)0x00000000L
#define NT_SUCCESS(Status) ((NTSTATUS)(Status) >= 0)
@zer0cat
zer0cat / gen_rand_str.c
Created January 21, 2020 11:10
Generate random string in pure C WinApi
#include <windows.h>
#include <ntsecapi.h>
#include <stdio.h>
DWORD random_num(DWORD min, DWORD max)
{
if (min > max)
return 0;
DWORD val;
@zer0cat
zer0cat / dummy_crc32.c
Created January 21, 2020 10:57
calc crc32 for files
#include <windows.h>
typedef DWORD (__stdcall *_RtlComputeCrc32)(DWORD, const BYTE*, INT);
#define CRC32_BLOCK_SIZE 1024
DWORD get_crc32_of_file(LPCSTR sFileName)
{
_RtlComputeCrc32 RtlComputeCrc32 = (_RtlComputeCrc32)GetProcAddress(LoadLibraryA("ntdll.dll"), "RtlComputeCrc32");
@zer0cat
zer0cat / wmi.c
Created November 9, 2019 21:51
WMIC runas elevate example
#include <windows.h>
DWORD GetIntegrityLevel(HANDLE hProcess)
{
DWORD dwIntegrityLevel = 0;
HANDLE hToken;
if (OpenProcessToken(hProcess, TOKEN_QUERY, &hToken)) {
DWORD dwSize;