Skip to content

Instantly share code, notes, and snippets.

View StefanoBelli's full-sized avatar

ste StefanoBelli

  • Rome, Italy
View GitHub Profile
@StefanoBelli
StefanoBelli / disable_gpe6F.service
Last active June 24, 2023 09:08
Temporary fix for ACPI (GPE iinterrupts) failure , disable GPE6f interrupts, probably motherboard faulty ACPI implementation (reflash/update BIOS) [[!!You should take action!!]]. Install this in /usr/lib/systemd/system and run systemctl enable disable_gpe6F
[Unit]
Description=Disable GPE6F interrupts
[Service]
Type=oneshot
ExecStart=/bin/bash -c "echo disable > /sys/firmware/acpi/interrupts/gpe6F"
[Install]
WantedBy=multi-user.target
@StefanoBelli
StefanoBelli / broken_stackframe_setjmp.c
Last active February 22, 2022 12:54
setjmp experiments
#include <stdio.h>
#include <stdlib.h>
#include <setjmp.h>
typedef unsigned long long __u64;
#define get_rsp(into) \
__asm__ __volatile__("movq %%rsp, %0;" : "=m"(into) :: "memory")
#ifndef PUSH_RET_ADDR
@StefanoBelli
StefanoBelli / dgcchk.py
Last active January 30, 2022 19:39
Digital Green Certificate decoder and validator 4fun
#!/usr/bin/python
# Stefano Belli
# Digital Green Certificate decoder and validator 4fun
# Changelog
# * -- First change since publishing --
# - fix datetime.now offset-awareness
# - fix incorrect vaccine data retrieved from DGC led to wrong test results
# - fix incorrect comparison between dose number and scheduled total doses to check vaccination completeness
@StefanoBelli
StefanoBelli / mmap_shellcode.c
Last active December 25, 2021 16:35
Run shellcode using mmap()
//gcc -m32 mmap_shellcode.c
//spawn a /bin/sh shell
#include <stdio.h>
#include <string.h>
#include <sys/mman.h>
unsigned char bytes[] = \
"\x31\xc0\x50\x68\x6e\x2f\x73\x68\x68\x2f\x2f\x62\x69\x89\xe3\x50\x89\xe2\x53\x89\xe1\xb0\x0b\xcd\x80";
int main() {
@StefanoBelli
StefanoBelli / nvapiinterface.cpp
Last active April 26, 2021 07:03
nvapi interface
#include <cstring>
#include <Windows.h>
#include <string>
#include <iostream>
#include <memory>
#include <vector>
#define MAKE_VERSION(stype, ver) static_cast<std::uint32_t>( sizeof(stype) | ((ver) << 16) )
#include <Windows.h>
void ClearConsole(HANDLE console) {
const COORD origin = { 0,0 };
DWORD writtenBytes;
DWORD consoleSize;
CONSOLE_SCREEN_BUFFER_INFO info;
GetConsoleScreenBufferInfo(console, &info);
#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
SHELL=/bin/sh
AS=as
LD=ld
OBJS=obj.o obj1.o
OUT=executable
all:$(OBJS)
@for OBJ in $(OBJS); do echo -e "\tLD $$OBJ"; done
@$(LD) $(OBJS) -o $(OUT) && echo -e '\tOUT $(OUT)'
@StefanoBelli
StefanoBelli / num.h
Last active April 26, 2021 06:59
More than simple math (math utils for C++)
#ifndef NUMERIC_H
#define NUMERIC_H
#include <initializer_list>
#include <type_traits>
#include <sstream>
#include <string>
#include <exception>
#include <vector>
#include <array>
@StefanoBelli
StefanoBelli / macOS_launcher.sh
Last active April 11, 2021 05:43
Fast OS X launch on QEMU with KVM support enabled. Credits to: https://github.com/kholia, original repository: https://github.com/kholia/OSX-KVM
#!/bin/sh
# qemu-img create -f qcow2 mac_hdd.img 64G
# echo 1 > /sys/module/kvm/parameters/ignore_msrs
#
# Type the following after boot,
# -v "KernelBooter_kexts"="Yes" "CsrActiveConfig"="103"
#
# printf 'DE:AD:BE:EF:%02X:%02X\n' $((RANDOM%256)) $((RANDOM%256))
#