Skip to content

Instantly share code, notes, and snippets.

@MarioHewardt
MarioHewardt / enable_ebpf_on_wsl2
Last active August 12, 2024 02:32
Enable EBPF on WSL2
By default, EBPF programs will not run on WSL2 due to required kernel modules missing. The following example error is an
indication of this problem:
modprobe: ERROR: ../libkmod/libkmod.c:586 kmod_search_moddep() could not open moddep file '/lib/modules/4.19.84-microso
ft-standard/modules.dep.bin'
modprobe: FATAL: Module kheaders not found in directory /lib/modules/4.19.84-microsoft-standard
chdir(/lib/modules/4.19.84-microsoft-standard/build): No such file or directory
To fix this you need to rebuild the WSL2 kernel with the missing kernel modules. The below instructions are for Ubuntu 18.04 WSL2.
1. git clone https://github.com/microsoft/WSL2-Linux-Kernel.git
#include <stdlib.h>
#include <stdio.h>
#include <stdint.h>
int
main(void) {
int ii;
uint8_t buf[8192] = { 0 };
// Worlds most impressive exploit
@schirrmacher
schirrmacher / frida-struct-pointer-pointer.js
Last active February 3, 2024 12:32
Frida: How to read a struct or a struct pointer or a pointer of a struct pointer?
/*
typedef struct {
int size;
char* data;
} test_struct;
void some_func(test_struct **s);
@georgexsh
georgexsh / goto.py
Created September 18, 2017 07:47
python goto with system trace function
import sys
def j(lineno):
frame = sys._getframe().f_back
called_from = frame
def hook(frame, event, arg):
if event == 'line' and frame == called_from:
try:
frame.f_lineno = lineno
@sudhackar
sudhackar / frida-socket.js
Last active June 5, 2024 02:42
frida socket hook
'use strict';
var connect = new NativeFunction(
Module.findExportByName(null, "connect"),
'int',
['int', 'pointer', 'int']
);
Interceptor.replace(connect, new NativeCallback(function (sockfd, addr, addrlen) {
console.log(sockfd, addr, addrlen);
@iMilnb
iMilnb / snsread.py
Created August 2, 2015 20:20
Basic Flask snippet to handle AWS SNS messages and subscription
from flask import Flask, request
import requests
import json
app = Flask(__name__)
def msg_process(msg, tstamp):
js = json.loads(msg)
msg = 'Region: {0} / Alarm: {1}'.format(
js['Region'], js['AlarmName']