Skip to content

Instantly share code, notes, and snippets.

@RabaDabaDoba
RabaDabaDoba / ANSI-color-codes.h
Last active May 5, 2024 22:35 — forked from iamnewton/bash-colors.md
The entire table of ANSI color codes working in C!
/*
* This is free and unencumbered software released into the public domain.
*
* For more information, please refer to <https://unlicense.org>
*/
//Regular text
#define BLK "\e[0;30m"
#define RED "\e[0;31m"
#define GRN "\e[0;32m"
@itdaniher
itdaniher / compile.py
Last active October 28, 2023 20:33
compile python script to ELF on Linux via cython and gcc
import subprocess
import sys
import tempfile
from Cython.Compiler import Main, CmdLine, Options
in_file_name = sys.argv[1]
source = open(in_file_name).read()
out_file_name = in_file_name.replace('.py', '.out')
temp_py_file = tempfile.NamedTemporaryFile(suffix='.py', delete=False)
@merryhime
merryhime / text.md
Last active February 19, 2024 13:05
Playing with segment registers fs and gs on x64

GSBASE and FSBASE

When you're running out of registers while writing a JIT, you might resort to more unconventional methods for memory access. You might choose to resort to segment registers if you need a fixed register for memory offsets.

Instructions such as:

lea    rax,gs:[rcx+rdx*8]
mov    rax,gs:[rcx+rdx*8]

would then be available for your use.

@jen20
jen20 / HexDumpUtil.java
Created May 19, 2015 14:33
Dump byte array in hex dump format in Java
import java.io.UnsupportedEncodingException;
public final class HexDumpUtil {
public static String formatHexDump(byte[] array, int offset, int length) {
final int width = 16;
StringBuilder builder = new StringBuilder();
for (int rowOffset = offset; rowOffset < offset + length; rowOffset += width) {
builder.append(String.format("%06d: ", rowOffset));
@davidzchen
davidzchen / sample-linux.c
Last active January 19, 2024 21:20
Sample C code using the Linux kernel coding style
/*
* Sample file using the Linux kernel coding convention.
*
* https://www.kernel.org/doc/Documentation/CodingStyle
*
* General rules:
* - Indents are tabs and must be 8 spaces wide.
* - Each line must be at most 80 characters long.
* - Use C-style comments.
* - File names should be lower-case.c
/*
* CVE-2013-1763 SOCK_DIAG bug in kernel 3.3-3.8
*
* Ported by fuzion24
*
* Tested on Nexus 4
* cshell@mako:/ $ cat /proc/version
* Linux version 3.4.0-perf-gf43c3d9 (android-build@vpbs1.mtv.corp.google.com) (gcc version 4.6.x-google 20120106 (prerelease) (GCC) ) #1 SMP PREEMPT Mon Jun 17 16:55:05 PDT 2013
* shell@mako:/data/local/tmp $ ./diag_sock_exploit
* Sock diag handlers c11d8048
@securitytube
securitytube / Execve-Stack.nasm
Created April 5, 2013 11:58
Execve /bin/sh using the Stack Method
; Author: Vivek Ramachandran
; Website: http://securitytube.net
; Training: http://securitytube-training.com
;
global _start
section .text
_start: