Skip to content

Instantly share code, notes, and snippets.

View hed0rah's full-sized avatar

hed0rah hed0rah

View GitHub Profile
@hed0rah
hed0rah / Makefile
Created April 24, 2016 02:38
Basic linux kernel module Makefile.
obj-m += test_module.o
all:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
clean:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
@hed0rah
hed0rah / japanese_colors.sh
Created May 9, 2016 18:01
Echo japanese color names in their respective colors using ascii color codes.
#!/bin/bash
echo -e "\e[34m青い \e[31m赤い \e[32m緑 \e[93m黄色い \e[35m紫 \e[95mピンク \e[30m黒い \e[97m白い \e[33mオレンギ"
@hed0rah
hed0rah / rsync_parallel.sh
Last active May 10, 2016 04:38 — forked from rcoup/rsync_parallel.sh
Parallel-ise an rsync transfer when you want multiple concurrent transfers happening,
#!/bin/bash
set -e
# Usage:
# rsync_parallel.sh [--parallel=N] [rsync args...]
#
# Options:
# --parallel=N Use N parallel processes for transfer. Defaults to 10.
#
# Notes:
@hed0rah
hed0rah / sysinitv_to_systemd.md
Last active January 11, 2025 22:18
sysinitv -> systemd cheat sheet from fedoraproject.org
Sysvinit Command Systemd Command Notes
service frobozz start systemctl start frobozz Used to start a service (not reboot persistent)
service frobozz stop systemctl stop frobozz Used to stop a service (not reboot persistent)
service frobozz restart systemctl restart frobozz Used to stop and then start a service
service frobozz reload systemctl reload frobozz When supported, reloads the config file without interrupting pending operations.
service frobozz condrestart systemctl condrestart frobozz Restarts if the service is already running.
service frobozz status systemctl status frobozz Tells whether a service is currently running.
ls /etc/rc.d/init.d/ systemctl (or) systemctl list-unit-files --type=service (or) ls /lib/systemd/system/.service /etc/systemd/system/.service Used to list the services that can be started or stopped. Used to list all the services and other units.
chkconfig frobozz on syst
@hed0rah
hed0rah / bitflip.pl
Created May 26, 2016 21:24
flip single bit using perl.
[16:25:27] root@na:~ # echo "A"|xxd -b
0000000: 01000001 00001010 A.
[16:25:30] root@na:~ # echo "A"|perl -e '$byte=shift(@ARGV);$bit=shift(@ARGV);undef $/; $in=<>; substr($in,$byte,1) = substr($in,$byte,1) ^ chr(1<<$bit); print $in' 0 1|xxd -b
0000000: 01000011 00001010 C.
@hed0rah
hed0rah / gcc-security.txt
Last active November 15, 2025 23:46
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"
@hed0rah
hed0rah / gist:183328e6dfabf8103ba5ea491808ae65
Created October 7, 2016 13:54 — forked from afair/gist:2402068
Perl References for Kittens

Perl References

Simple Perl variables are called scalars. Examples of scalar values are

   $number      = 123;
   $string      = "String";
   $file_handle = open "<filename";
   $null_value  = undef;
 $reference = \"Reference of a String";
@hed0rah
hed0rah / print_env.c
Created October 25, 2016 01:15
Test setenv and print environment variables from *envp[] arg in main() versus extern char** environ;
#include <stdio.h>
#include <stdlib.h>
extern char** environ;
int main(int argc, char *argv[], char *envp[])
{
int i;
setenv("TESTVAR", "watvalue123", 1);
printf("From char *envp[]:\n");
@hed0rah
hed0rah / ulli.c
Created November 10, 2016 20:50
unsigned long long int
#include <stdio.h>
#include <limits.h>
int main() {
unsigned long long ulli;
printf("%d", sizeof(ulli));
printf("%llu\n", ULLONG_MAX);
printf("%llu ... or \n", ~(unsigned long long)0);
printf("%llu\n", (unsigned long long)0 - 1);
return 0;
@hed0rah
hed0rah / ftrace-it.sh
Created November 10, 2016 20:51
ftrace it
#!/bin/bash
DEBUGFS=`grep debugfs /proc/mounts | awk '{ print $2; }'`
echo $$ > $DEBUGFS/tracing/set_ftrace_pid
echo function > $DEBUGFS/tracing/current_tracer
echo 1 > $DEBUGFS/tracing/tracing_on
exec $*
echo 0 > $DEBUGFS/tracing/tracing_on