Created
January 14, 2015 20:52
-
-
Save tsulej/6a62f6ad7f5d841ea5cc to your computer and use it in GitHub Desktop.
Glitching scripts
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
#!/bin/sh | |
# author: tsulej 2015 // glitching tools | |
# e-mail: [email protected] | |
# Script traverse through the file changes one byte and saves result. Outcome: files with changed first, second, third, ..., nth byte to choosen value | |
# usage: | |
# bash ./all_bytes.sh <filename.ext> <hex value, two letters: 0..f> | |
# warning: use files with small size (<20kb) | |
# example, suppose we have image.gif file with size 999 bytes: | |
# bash ./all_bytes.sh image.gif aa | |
# result is 999 files: 001_image.gif (first byte set to 'aa'), 002_image.gif (second byte set to 'aa'), ..., 999_image.gif (999th byte set to 'aa') | |
# dependencies: sed, xxd, change_byte.sh | |
# can be used under linux or cygwin | |
size=`stat -c '%s' "$1"` | |
name=`echo "$1" | cut -d '.' -f 1` | |
ext=`echo "$1" | cut -d '.' -f 2` | |
for i in `seq -w 1 $size` | |
do | |
echo "Processing byte $i" | |
bash ./change_byte.sh "$1" $i $2 | |
mv "$name".res.$ext "$i"_"$name".$ext | |
done |
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
#!/bin/sh | |
# author: tsulej 2015 // glitching tools | |
# e-mail: [email protected] | |
# bash script which changes choosen byte in the binary file to a value | |
# usage: | |
# bash ./change_byte.sh <filename.ext> <byte number> <hex value, two letters: 0..f> | |
# result is saved in the file "filename.res.ext" | |
# example, change 1000th byte to '9d' value: | |
# bash ./change_byte.sh image.jpg 1000 9d | |
# result save to image.res.jpg | |
# dependencies: sed, xxd | |
# can be used under linux or cygwin | |
echo -n "file $1... " | |
# $1 - filename to process | |
# get name and extention | |
name=`echo "$1" | cut -d '.' -f 1` | |
ext=`echo "$1" | cut -d '.' -f 2` | |
# produce pure hex, each byte in other line | |
# save it in the /name/.hex file | |
xxd -ps -c 1 < "$1" > "$name".hex | |
# replace bytes in line $2 with byte from $3 | |
sed -s "$2 s/^../$3/" < "$name".hex > "$name".2.hex | |
# save to binary back | |
xxd -r -ps -c 1 < "$name".2.hex > "$name".res.$ext | |
# remove all tmp files | |
rm "$name".hex | |
rm "$name".2.hex | |
echo "processed"; |
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
#!/bin/sh | |
# author: tsulej 2015 // glitching tools | |
# e-mail: [email protected] | |
# bash script for batch byte change (see change_byte.sh) | |
# usage: | |
# bash ./process_files.sh <ext - file extension> <byte number> <hex value, two letters: 0..f> | |
# example, change 1000th byte to 'f3' value in all png files in directory: | |
# bash ./process_files.sh png 1000 f3 | |
# | |
# dependencies: sed, xxd, change_byte.sh | |
# can be used under linux or cygwin | |
for i in *.$1 | |
do | |
echo "Processing file: $i" | |
bash ./change_byte.sh "$i" $2 $3 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment