This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
TOTP() { | |
TOTP_SECRET="${1:-GEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQ}" | |
TOTP_DIGITS="${2:-6}" | |
TOTP_STEP="${3:-30}" | |
TOTP_TIME="${4:-"$(date '+%s')"}" | |
TOTP_COUNTER="$((TOTP_TIME / TOTP_STEP))" | |
printf '%016x' "${5:-$TOTP_COUNTER}" | xxd -r -p \ | |
| openssl dgst -sha1 -hmac "$(printf '%s' "$TOTP_SECRET" | base32 -d)" \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
TARGET="${1:-./narnia}" | |
narnia() { | |
base64 -d <<EOF | |
f0VMRgIBAQAAAAAAAAAAAAMAPgABAAAAeABAAAAAAABAAAAAAAAAAAAAAAAAAAAAAAAAAEAAOAAB | |
AEAAAAAAAAEAAAAFAAAAAAAAAAAAAAAAAEAAAAAAAAAAQAAAAAAApgAAAAAAAACmAAAAAAAAAAAQ | |
AAAAAAAAMf9XampqaVgPBVhfDwVIuC9iaW4vc2gASInmUEiJ50itSIk+SI1UxghqO1gPBQ== | |
EOF | |
} | |
if ! narnia | cmp -s "$TARGET" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Linux x86(-64) - execve("/bin/sh", ["/bin/sh", 0], 0) shellcode (38 bytes) | |
* 31c050488b1424eb105478065e5fb03b0f05595b40b00bcd80e8ebffffff2f62696e2f736800 | |
* | |
* - offset - bytes 32-bit code 64-bit code | |
* 0x00000000 31c0 xor eax, eax xor eax, eax | |
* 0x00000002 50 push eax push rax | |
* 0x00000003 48 dec eax rex.w | |
* 0x00000004 8b1424 mov edx, dword [esp] mov rdx, qword [rsp] | |
* 0x00000007 eb10 jmp 0x19 jmp 0x19 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "rb_tree.h" | |
#define PARENT_BIT 1 | |
#define COLOR_BIT 2 | |
#define PARENT_MASK (PARENT_BIT | COLOR_BIT) | |
#define rb_is_red(n) ((n) != (void *)0 && ((n)->parent & COLOR_BIT)) | |
#define rb_is_black(n) ((n) == (void *)0 || !((n)->parent & COLOR_BIT)) | |
#define rb_set_red(n) ((n)->parent |= COLOR_BIT) | |
#define rb_set_black(n) ((n)->parent &= ~COLOR_BIT) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stddef.h> | |
#include <stdint.h> | |
#define LOAD32_LE(p) \ | |
( ((uint32_t)((p)[0]) << 0) \ | |
| ((uint32_t)((p)[1]) << 8) \ | |
| ((uint32_t)((p)[2]) << 16) \ | |
| ((uint32_t)((p)[3]) << 24) \ | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# Show battery information similar to `acpi -b` | |
if [ -n "${*:-$BAT}" ]; then for BAT in "${@:-$BAT}"; do echo "$BAT"; done | |
else find /sys/class/power_supply/ -maxdepth 1 -name 'BAT*' | LC_ALL=C sort | |
fi | while IFS= read -r BAT; do | |
if [ ! -r "$BAT" ] || [ ! -r "$BAT/uevent" ]; then | |
printf '%s unreadable\n' "$BAT" >&2 | |
continue | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <errno.h> | |
#include <stdint.h> | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include <sys/ptrace.h> | |
#include <sys/types.h> | |
#include <unistd.h> | |
struct elf { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* The Z array of a string S[0..n-1] gives for each suffix S[i..n-1], | |
* 0<=i<=n-1, the length of the longest common prefix with S. Example: | |
* | |
* i | 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | |
* -----+--------------------------------------------------- | |
* S[i] | a a a b a a b b a a a b a a a a b | |
* Z[i] | 17 2 1 0 2 1 0 0 6 2 1 0 3 4 2 1 0 | |
* | |
* The Z algorithm computes the Z array in linear time, which has many |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// you faggots probably know the de bruijn trick to count trailing zeros: | |
inline int ctz32_retarded(uint32_t x) | |
{ | |
static const unsigned char debruijn_ctz32[32] = { | |
0, 1, 28, 2, 29, 14, 24, 3, 30, 22, 20, 15, 25, 17, 4, 8, | |
31, 27, 13, 23, 21, 19, 16, 7, 26, 12, 18, 6, 11, 5, 10, 9 | |
}; | |
return debruijn_ctz32[((x & -x) * 0x077CB531) >> 27]; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "sha512.h" | |
#define ROR64(x, c) (((x) >> (c)) | ((x) << (64 - (c)))) | |
#define LOAD64_BE(p) \ | |
( ((uint64_t)((p)[7]) << 0) \ | |
| ((uint64_t)((p)[6]) << 8) \ | |
| ((uint64_t)((p)[5]) << 16) \ | |
| ((uint64_t)((p)[4]) << 24) \ | |
| ((uint64_t)((p)[3]) << 32) \ |