Skip to content

Instantly share code, notes, and snippets.

View Frago9876543210's full-sized avatar

Frago9876543210

View GitHub Profile
@arq5x
arq5x / test.sh
Last active November 30, 2023 12:50
Compress and then Decompress a string with zlib.
# compile
$ g++ zlib-example.cpp -lz -o zlib-example
# run
$ ./zlib-example
Uncompressed size is: 36
Uncompressed string is: Hello Hello Hello Hello Hello Hello!
----------
@aras-p
aras-p / preprocessor_fun.h
Last active July 16, 2024 02:50
Things to commit just before leaving your job
// Just before switching jobs:
// Add one of these.
// Preferably into the same commit where you do a large merge.
//
// This started as a tweet with a joke of "C++ pro-tip: #define private public",
// and then it quickly escalated into more and more evil suggestions.
// I've tried to capture interesting suggestions here.
//
// Contributors: @r2d2rigo, @joeldevahl, @msinilo, @_Humus_,
// @YuriyODonnell, @rygorous, @cmuratori, @mike_acton, @grumpygiant,
@dergachev
dergachev / setuid-root-backdoor.md
Last active May 24, 2024 13:43
How to use setuid to install a root backdoor.

Why You Can't Un-Root a Compromised Machine

Let's say somebody temporarily got root access to your system, whether because you "temporarily" gave them sudo rights, they guessed your password, or any other way. Even if you can disable their original method of accessing root, there's an infinite number of dirty tricks they can use to easily get it back in the future.

While the obvious tricks are easy to spot, like adding an entry to /root/.ssh/authorized_keys, or creating a new user, potentially via running malware, or via a cron job. I recently came across a rather subtle one that doesn't require changing any code, but instead exploits a standard feature of Linux user permissions system called setuid to subtly allow them to execute a root shell from any user account from the system (including www-data, which you might not even know if compromised).

If the "setuid bit" (or flag, or permission mode) is set for executable, the operating system will run not as the cur

@ccbrown
ccbrown / DumpHex.c
Last active March 27, 2024 17:32
Compact C Hex Dump Function w/ASCII
#include <stdio.h>
void DumpHex(const void* data, size_t size) {
char ascii[17];
size_t i, j;
ascii[16] = '\0';
for (i = 0; i < size; ++i) {
printf("%02X ", ((unsigned char*)data)[i]);
if (((unsigned char*)data)[i] >= ' ' && ((unsigned char*)data)[i] <= '~') {
ascii[i % 16] = ((unsigned char*)data)[i];
@ipbastola
ipbastola / clean-up-boot-partition-ubuntu.md
Last active June 5, 2024 21:05
Safest way to clean up boot partition - Ubuntu 14.04LTS-x64, Ubuntu 16.04LTS-x64

Safest way to clean up boot partition - Ubuntu 14.04LTS-x64, Ubuntu 16.04LTS-x64

Reference

Case I: if /boot is not 100% full and apt is working

1. Check the current kernel version

$ uname -r 
@shoghicp
shoghicp / run.php
Last active September 26, 2020 10:33
Header Extractor - Usage: php run.php --input libminecraftpe.so --output headers/ --pointer-size 4 --asm
<?php
/**
* Minecraft: Pocket Edition header extractor
*
* This tool needs objdump (and objdump-multiarch + arm variants) installed on the current system
*
*/
const VERSION = "0.0.1";
@dktapps
dktapps / MCPE-1.0-NETWORK-CHUNK-SPEC.md
Last active September 29, 2019 11:52
Network chunk specification as of MCPE 1.0

MCPE 1.0 Network Chunk specification

Note: the accuracy of this specification may be flawed. This specification is believed to be correct as of beta 1.0.0.7, but its accuracy is by no means guaranteed.

Basic changes

Biome colour removal

The ability to set biome colours disappeared this update, which is a shame. The old method using biome IDs is back; colours and gradients are now handled automatically client side. While this is a bonus for PocketMine in the way that biome colours in Anvil worlds will now work correctly again, it's a shame to see that capability disappear.

@codedokode
codedokode / proxy.php
Created December 23, 2016 22:22
Простой прокси-сервер на PHP для изучения и модификации данных, передаваемых между браузером и сторонним сервером
<?php
/**
* Простой прокси-сервер на PHP для изучения и модификации данных,
* передаваемых между браузером и сторонним сервером.
*
* Запуск:
*
* указать URL сайта в $base
* php -S 127.0.0.1:9001 proxy.php
*
@FergusInLondon
FergusInLondon / snoopy.c
Created March 28, 2017 07:02
snoopy.c - process_vm_readv() demonstration.
/**
* snoopy.c - Snoop on another tasks memory.
* Fergus In London <fergus@fergus.london>
*
* This is a pretty basic demo of the process_vm_readv syscall, a syscall which
* provides a nicer interface than ptrace for accessing memory used by another
* task.
*
* To play with simply use `ps` to get a PID for the process you'd like to snoop
* on, and `pmap` for the relevant memory address.
{
"geometry.humanoid": {
"bones": [
{
"name": "body",
"pivot": [ 0.0, 24.0, 0.0 ],
"cubes": [
{
"origin": [ -4.0, 12.0, -2.0 ],
"size": [ 8, 12, 4 ],