Skip to content

Instantly share code, notes, and snippets.

View jrelo's full-sized avatar

hed0rah jrelo

View GitHub Profile
@jrelo
jrelo / dream_survery.html
Created May 5, 2024 02:43
Evil Portal - Happy Valley Dream Survey
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
body {
font-family: Arial, sans-serif;
background-color: #f2f2f2;
display: flex;
justify-content: center;
@jrelo
jrelo / sgp30_crc.py
Created April 25, 2024 20:11
Calculate CRC checksum for SGP30 co2 & VOC sensor
#!/usr/bin/env python3
import sys
def crc8(data: int) -> int:
crc = 0xFF
polynom = 0x31
data_bytes = data.to_bytes(2, 'big')
for byte in data_bytes:
@jrelo
jrelo / gcc-security.txt
Last active April 23, 2024 22:38
GCC security related flags reference.
Source material:
http://security.stackexchange.com/questions/24444/what-is-the-most-hardened-set-of-options-for-gcc-compiling-c-c
https://wiki.gentoo.org/wiki/Hardened_Gentoo
https://wiki.debian.org/Hardening
================================================================================================================>
GCC Security related flags and options:
CFLAGS="-fPIE -fstack-protector-all -D_FORTIFY_SOURCE=2"
LDFLAGS="-Wl,-z,now -Wl,-z,relro"
@jrelo
jrelo / killcx
Created July 21, 2018 19:35 — forked from kisel/killcx
killcx
#!/usr/bin/perl
######################################################################
# killcx :
#
# Close a TCP connection under Linux.
#
# (c) Jerome Bruandet - <floodmon@spamcleaner.org>
#
# version 1.0.3 - 18-May-2011
#
@jrelo
jrelo / guide-to-x86_64.txt
Created April 16, 2017 18:51
x86_64 assembly guide
x86-64 (also known as just x64 and/or AMD64) is the 64-bit version of the x86/IA32 instruction set. Below is our overview of its features that are relevant to CS107. There is more extensive coverage on these topics in Chapter 3 of the B&O textbook. See also our x86-64 sheet for a compact one-page reference.
Registers
The table below lists the commonly used registers (sixteen general-purpose plus two special). Each register is 64 bits wide; the lower 32-, 16- and 8-bit portions are selectable by a pseudo-register name. Some registers are designated for a certain purpose, such as %rsp being used as the stack pointer or %rax for the return value from a function. Other registers are all-purpose, but have a conventional use depending on whether caller-saved or callee-saved. If the function binky calls winky, we refer to binky as the caller and winky as the callee. For example, the registers used for the first 6 arguments and return value are all caller-saved. The callee can freely use those registers, overwriting
@jrelo
jrelo / hardened_gcc.txt
Created April 24, 2017 23:23
Hardened GCC flags
-Wall -Wextra
Turn on all warnings to help ensure the underlying code is secure.
-Wconversion -Wsign-conversion
Warn on unsign/sign conversion
-Wformat­security
Warn about uses of format functions that represent possible security problems
-Werror
Turns all warnings into errors.
-arch x86_64
Compile for 64-bit to take max advantage of address space (important for ASLR; more virtual address space to chose from when randomising layout).
@jrelo
jrelo / simple_socket_example.c
Created March 13, 2017 02:47 — forked from browny/simple_socket_example.c
simple socket example in C
/* --- Usage --- */
g++ server.c -o server
g++ client.c -o client
./server
./client 127.0.0.1
/* --- server.c --- */
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
@jrelo
jrelo / trap-control.sh
Created May 4, 2018 14:12
trap control
#!/bin/bash
#
# Trap control-C (SIGINT) and instead send signal specified as
# arg 1 to a program which is the rest of the arguments
#
# e.g.
# intrap USR1 dd if=/dev/urandom of=/dev/null bs=1024 count=10000
#
# ... will send SIGUSR1 to the specified dd process (causing it
# to dump status information). Note that if you do this, you'll
@jrelo
jrelo / mrecent_string_block.sh
Created September 5, 2019 16:58
simple iptables -m recent string block
iptables -t mangle -N badz
iptables -t mangle -N blockz
iptables -t mangle -A PREROUTING -p tcp -m tcp --dport 80 -j blockz
iptables -t mangle -A badz -m recent --set --name terrible --rsource
iptables -t mangle -A blockz -p tcp -m tcp --dport 80 --tcp-flags FIN,SYN,RST,ACK SYN -m recent --update --seconds 3600 --name terrible --rsource -j DROP
iptables -t mangle -A blockz -p tcp -m tcp --dport 80 -m string --string "malicious_string" --algo bm --to 65535 -m recent --set --name bad --rsource
iptables -t mangle -A blockz -p tcp -m tcp --dport 80 -m string --string "malicious_string" --algo bm --to 65535 -m recent --update --seconds 10 --hitcount 3 --name bad --rsource -j badz

Download Audio from YouTube

-i - ignore errors

-c - continue

-t - use video title as file name

--extract-audio - extract audio track