Skip to content

Instantly share code, notes, and snippets.

Avatar

stavros vagionitis svagionitis

View GitHub Profile
@svagionitis
svagionitis / copy-wic-rootfs.sh
Created May 13, 2020
This script mounts the rootfs partition of a wic.xz image and copy the rootfs to a directory. The roofs partition is at partition 3.
View copy-wic-rootfs.sh
#!/bin/sh -eu
# shellcheck shell=ash
# This script mounts the rootfs partition of a wic.xz image and copy the rootfs
# to a directory. The roofs partition is at partition 3.
if ! command -v losetup > /dev/null ; then
echo "ERROR: losetup is missing" >&2
exit 1
fi
@svagionitis
svagionitis / record-terminal-session.sh
Last active Apr 16, 2020
Record terminal sessions
View record-terminal-session.sh
# Create a log for the sessions
# Record terminal sessions.
# https://unix.stackexchange.com/questions/25639/how-to-automatically-record-all-your-terminal-sessions-with-script-utility
# https://www.2daygeek.com/automatically-record-all-users-terminal-sessions-activity-linux-script-command/
# TODO When changing tabs does not keep the directory
SESSION_LOGS_DIR="$HOME/.session_logs"
if [ ! -d "${SESSION_LOGS_DIR}" ]; then
mkdir -p "${SESSION_LOGS_DIR}"
fi
@svagionitis
svagionitis / stringify_newline.c
Created Aug 2, 2017
A function to stringify the newline character.
View stringify_newline.c
/** @brief Stringify the newline character of a string.
*
* In detail, the newline character, '\n' is not supported on
* json string, so it needs to split in two characters "\n".
*
* @param [in] src The string to stringify
* @return the stringified string on success<br>
* NULL otherwise
*
*/
@svagionitis
svagionitis / tpm-tools_build.sh
Created May 11, 2017
tpm-tools build script
View tpm-tools_build.sh
#!/bin/sh -ex
mkdir -p sysroot
PREFIX_DIR=$(readlink -e sysroot)
mkdir -p $PREFIX_DIR/include
INCLUDE_DIR=$(readlink -e $PREFIX_DIR/include/)
mkdir -p $PREFIX_DIR/lib
LIB_DIR=$(readlink -e $PREFIX_DIR/lib/)
mkdir -p $LIB_DIR/pkgconfig
PKG_CONFIG_PATH=$(readlink -e $LIB_DIR/pkgconfig/)
@svagionitis
svagionitis / Makefile
Last active Oct 16, 2020
This small utility shows how to use the `getifaddrs` and get information for network interfaces.
View Makefile
all: get-network-interfaces get-gateway-ip
get-network-interfaces: get-network-interfaces.c
gcc -o get-network-interfaces -ggdb -O1 -Wall -W -ansi -pedantic -std=gnu99 get-network-interfaces.c
get-gateway-ip: get-gateway-ip.c
gcc -o get-gateway-ip -ggdb -O1 -Wall -W -ansi -pedantic -std=gnu99 get-gateway-ip.c
clean:
rm -rf get-network-interfaces
@svagionitis
svagionitis / stash-get-clone-repos.sh
Created Oct 27, 2016
Clone repositories for projects in Stash
View stash-get-clone-repos.sh
#!/bin/sh
JQ="`which jq` -r"
CURL="`which curl` -s"
BASENAME="`which basename`"
GIT="`which git`"
STASH_SERVER=""
STASH_PROJECTS="${STASH_SERVER}/rest/api/1.0/projects"
@svagionitis
svagionitis / bitbucket-clone-user-repos.sh
Last active Jul 10, 2017
Clone a user repos from bitbucket using it's REST API
View bitbucket-clone-user-repos.sh
#!/bin/bash -ex
BITBUCKET_SERVER_API="https://api.bitbucket.org"
USER_REPOSITORIES="${BITBUCKET_SERVER_API}/1.0/user/repositories"
# Utilites to be used
CURL="`which curl` -s"
JQ="`which jq`"
GIT="`which git`"
@svagionitis
svagionitis / fix_pem.c
Last active Sep 27, 2020
Fix certificates in PEM format which don't have newlines
View fix_pem.c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#define PEM_CERTIFICATE_HEADER "-----BEGIN CERTIFICATE-----"
@svagionitis
svagionitis / ssha.c
Last active Sep 27, 2020
SSHA encoding and decoding (bruteforce)
View ssha.c
#include <stdio.h>
#include <string.h>
#include <stdint.h>
#include <ctype.h>
#include <openssl/rand.h>
#include <openssl/sha.h>
#define NUM_SALT_BYTES 8
#define SHA1_LENGTH 20
View gist:489472062a3718899f80a921fcc74c17
/* ========================================================================
$File: tools/ctime/ctime.c $
$Date: 2016/05/08 04:16:55PM $
$Revision: 7 $
$Creator: Casey Muratori $
$Notice:
The author of this software MAKES NO WARRANTY as to the RELIABILITY,
SUITABILITY, or USABILITY of this software. USE IT AT YOUR OWN RISK.
You can’t perform that action at this time.