-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjdump.sh
More file actions
executable file
·31 lines (21 loc) · 911 Bytes
/
Copy pathjdump.sh
File metadata and controls
executable file
·31 lines (21 loc) · 911 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/bin/bash
# JPEG DUMP
# Simple script for glitching jpeg images
# Check for mandatory parameter: INPUT FILE
[ -z $1 ] && echo -e "No input file provided. \n Usage: jdump.sh INPUT_FILE [VALUE [REPLACE [OCURRENCE [OUTPUT_FILE]]]]" && exit
# Set INPUT FILE
IFILE="$1"
# Preset parameters
# For random nibble values, convert from decimal to hex
[ -z $2 ] && VALUE="$(printf "%x" "$((RANDOM&15))")" || VALUE="$2"
[ -z $3 ] && REPLACE="$(printf "%x" "$((RANDOM&15))")" || REPLACE="$3"
[ -z $4 ] && OCURR=$((RANDOM%15+1)) || OCURR="$4"
[ -z $5 ] && OFILE="glitch.jpg" || OFILE="$5"
# Optional OUTPUT FILE name
# OFILE="${VALUE}${REPLACE}${OCURR}.jpg"
# Debug mode on (so the parameters are visible)
set -x
# + xxd -p Hex dump in plain mode
# + sed Replace the $OCURR ocurrence of $VALUE with $REPLACE
# + xxd -r -p Reverse dump
xxd -p $IFILE | sed "s/$VALUE/$REPLACE/$OCURR" | xxd -r -p > $OFILE