Skip to content

Instantly share code, notes, and snippets.

#if _WIN32_WINNT < 0x0500
# error "should be NT"
#endif
#include <windows.h>
#include <tlhelp32.h>
#include <winternl.h>
#include <stdio.h>
DWORD getppid()
{
public class NetFwMgr : DynamicComBase
{
/// <summary>
/// Default constructor.
/// </summary>
public NetFwMgr()
{
// Initialize the COM object.
Type fwMgrType = Type.GetTypeFromProgID("HNetCfg.FwMgr");
base.comObj = Activator.CreateInstance(fwMgrType);
@jvranish
jvranish / stack_traces.c
Last active July 24, 2024 06:00
An example of catching exceptions and printing stack traces in C on Windows, Linux and OS X
/* compile with:
on linux: gcc -g stack_traces.c
on OS X: gcc -g -fno-pie stack_traces.c
on windows: gcc -g stack_traces.c -limagehlp
*/
#include <signal.h>
#include <stdio.h>
#include <assert.h>
@kingbin
kingbin / vcvarsall.bat
Created April 17, 2013 19:16
vcvarsall.bat
@echo off
if "%1" == "" goto x86
if not "%2" == "" goto usage
@set IE_BIN=%ProgramFiles%\Internet Explorer\iexplore.exe
@set PHANTOMJS_BIN=%APPDATA%\npm\node_modules\phantomjs\lib\phantom\phantomjs.exe
@doskey subl="C:\Program Files\Sublime Text 2\sublime_text.exe" $*
if /i %1 == x86 goto x86
@willurd
willurd / web-servers.md
Last active July 25, 2024 14:04
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@mikesmullin
mikesmullin / x86-assembly-notes.md
Last active July 18, 2024 01:57
Notes on x86-64 Assembly and Machine Code

Mike's x86-64 Assembly (ASM) Notes

Assembling Binary Machine Code

Operating Modes:

These determine the assumed/default size of instruction operands, and restricts which opcodes are available, and how they are used.

Modern operating systems, booted inside Real mode,

@williballenthin
williballenthin / flare-on-6__extract_buffer.py
Last active February 25, 2023 17:26
IDAPython script to extract contents of global byte array in the FLARE-On Challenge #6
from idaapi import *
GEN_REG = 0x1
MEM_REF = 0x2
BASE_INDEX = 0x3
BASE_INDEX_DISP = 0x4
IMMED = 0x5
def doone(ea):
xrefs = []
@aidanhs
aidanhs / gist:5ac9088ca0f6bdd4a370
Last active March 19, 2024 16:01
Rust binary tree worked example

PLEASE DON'T USE THIS GUIDE

It's over 9 years old (as of 2024-02-18), there are many better guides! You might like https://rust-unofficial.github.io/too-many-lists/

% Let's build a binary tree!

Let's build a binary tree of strings in Rust. To recap, each node in a binary tree:

  1. must have a value
@antopor
antopor / StreamPipe.cs
Created March 7, 2015 04:14
How to redirect Process' standart input/output (C#, .net 4.5, async code)
using System;
using System.Diagnostics;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
namespace Test
{
class Program
{
@Spl3en
Spl3en / ModulesFromPeb.c
Created May 9, 2015 10:09
Get current process modules from PEB
#include <windows.h>
#include <subauth.h>
#include <stdio.h>
/* Windows structures */
typedef struct _PEB_LDR_DATA {
BYTE Reserved1[8];
PVOID Reserved2[3];
LIST_ENTRY InMemoryOrderModuleList;
} PEB_LDR_DATA, *PPEB_LDR_DATA;