Skip to content

Instantly share code, notes, and snippets.

View tthtlc's full-sized avatar

Peter Teoh tthtlc

View GitHub Profile
@tthtlc
tthtlc / sockex2_user.c
Created December 27, 2018 01:27
Linux kernel samples/bpf/sockex2_user.c
// SPDX-License-Identifier: GPL-2.0
#include <stdio.h>
#include <assert.h>
#include <linux/bpf.h>
#include <bpf/bpf.h>
#include "bpf_load.h"
#include "sock_example.h"
#include <unistd.h>
#include <arpa/inet.h>
#include <sys/resource.h>
#include <uapi/linux/bpf.h>
#include "bpf_helpers.h"
#include <uapi/linux/in.h>
#include <uapi/linux/if.h>
#include <uapi/linux/if_ether.h>
#include <uapi/linux/ip.h>
#include <uapi/linux/ipv6.h>
#include <uapi/linux/if_tunnel.h>
#define IP_MF 0x2000
#define IP_OFFSET 0x1FFF
@tthtlc
tthtlc / nvidia_410_installation.log
Created March 3, 2019 00:29
How installation of Nvidia drivers in Ubuntu integrate with DKMS
sudo apt-get install nvidia-410
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following package was automatically installed and is no longer required:
libllvm5.0
Use 'sudo apt autoremove' to remove it.
The following additional packages will be installed:
bbswitch-dkms dkms fakeroot lib32gcc1 libc6-i386 libcuda1-410 libfakeroot
libjansson4 libxnvctrl0 nvidia-opencl-icd-410 nvidia-prime nvidia-settings
@tthtlc
tthtlc / simplec_harness.py
Created March 15, 2019 17:54
using python to emulate assembly instructions
"""
template_test_harness.py
Template which loads the context of a process into a Unicorn Engine,
instance, loads a custom (mutated) inputs, and executes the
desired code. Designed to be used in conjunction with one of the
Unicorn Context Dumper scripts.
Author:
Nathan Voss <[email protected]>
@tthtlc
tthtlc / ARMDebianUbuntu.md
Created April 14, 2019 16:49 — forked from bruce30262/ARMDebianUbuntu.md
Emulating ARM on Debian/Ubuntu

You might want to read this to get an introduction to armel vs armhf.

If the below is too much, you can try Ubuntu-ARMv7-Qemu but note it contains non-free blobs.

Running ARM programs under linux (without starting QEMU VM!)

First, cross-compile user programs with GCC-ARM toolchain. Then install qemu-arm-static so that you can run ARM executables directly on linux

If there's no qemu-arm-static in the package list, install qemu-user-static instead

@tthtlc
tthtlc / build.sh
Created April 14, 2019 16:49 — forked from julianxhokaxhiu/build.sh
How to build minimal AARCH64 QEMU Static from sources with EXECVE
#!/bin/bash
#
# IMPORTANT!
# At the moment this script is forged only for Debian ( tested on 8.x release ).
# Although my efforts were put on building this also on Arch Linux or Alpine, at the moment only Debian seems to be able to build it.
# Also, not sure why these instructions where nowhere on the internet, therefore I leave them here for whoever need them.
#
###########
# Add Backports repo support
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@tthtlc
tthtlc / pentagon_torus.py
Created June 29, 2019 02:39
Pentagonal Torus
import sys
try:
from OpenGL.GLUT import *
from OpenGL.GL import *
from OpenGL.GLU import *
except:
print ''' Error: PyOpenGL not installed properly '''
sys.exit( )
import array
@tthtlc
tthtlc / pentagon_torus_3d.py
Created June 29, 2019 02:54
Pentagonal Torus in 3D
#!/usr/bin/env python
#### sudo pip install pyglet
from math import pi, sin, cos
import pyglet
from pyglet.gl import *
mywidth=0
@tthtlc
tthtlc / hexagonv2.py
Created June 29, 2019 14:31
Rotating triangles around a hexagon
import pygame
import math
# Initialize the game engine
pygame.init()
# Define the colors we will use in RGB format
black = [ 0, 0, 0]
white = [255,255,255]
blue = [ 0, 0,255]