Last active
November 1, 2018 00:16
-
-
Save efrecon/d153029cac92ecf681b522aa6e18e648 to your computer and use it in GitHub Desktop.
Uses steganography to hide a snapshot of all public projects for a github user inside a JPEG or similar. Source JPEG file should be given as an argument
This file contains hidden or 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
#! /usr/bin/env bash | |
VERBOSE=0 | |
GHUSER=efrecon | |
SNAPSHOT=0 | |
while [ $# -gt 0 ] | |
do | |
case "$1" in | |
-u | --user) | |
GHUSER=$2 | |
shift 2 | |
;; | |
-v | --verbose) | |
VERBOSE=1 | |
shift 1 | |
;; | |
-s | --snapshot) | |
SNAPSHOT=1 | |
shift 1 | |
;; | |
*) | |
break | |
;; | |
esac | |
done | |
log() { | |
if [ "$VERBOSE" -ne 0 ]; then echo $1 1>&2; fi | |
} | |
# From: https://stackoverflow.com/a/33159888 | |
log "Collecting all repos for $GHUSER" | |
REPOS=$(curl -qsL "https://api.github.com/users/$GHUSER/repos?per_page=100" | grep -w clone_url | grep -o '[^"]\+://.\+.git') | |
log "Clone all repos in $GHUSER subdirectory" | |
mkdir -p $GHUSER | |
CWD=`pwd` | |
cd $GHUSER | |
for r in $REPOS; do | |
git clone --recurse-submodules $r | |
done | |
if [ "$SNAPSHOT" -ne 0 ]; then | |
log "Removing git history from all projects" | |
find . -name ".git" -type d -exec rm -rf {} \; | |
fi | |
cd $CWD | |
log "Creating zip file" | |
zip -9r ${GHUSER}.zip $GHUSER | |
rm -rf $GHUSER | |
image=$(basename -- "$1") | |
DEST=${GHUSER}."${image##*.}" | |
log "Appending to JPEG to create $DEST" | |
cat $1 ${GHUSER}.zip > $DEST | |
zip -A $DEST | |
rm -f ${GHUSER}.zip |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment