Skip to content

Instantly share code, notes, and snippets.

@cluosh
Last active April 13, 2021 20:10
Show Gist options
  • Save cluosh/10bc047125be2aafc7c2 to your computer and use it in GitHub Desktop.
Save cluosh/10bc047125be2aafc7c2 to your computer and use it in GitHub Desktop.
Cicada 3301 4chan checker
#!/bin/bash
# Create necessary files
hitfile=$1_hits
checkfile=$1_checkedImgs
echo -n "" > $hitfile
while :
do
# Grab a list of images from a 4chan board
imglist=$(curl --silent http://boards.4chan.org/$1/catalog |
grep -oE '"imgurl":"[^"]+"' |
sed -r "s#\"imgurl\":\"([0-9]+)\"#http://i.4cdn.org/$1/\1\.jpg#g")
# Write checked image file if it doesn't exist
if [ ! -f $checkfile ] ; then
echo "$imglist" > $checkfile
xargs -n 1 curl --silent -O < $checkfile
else
# Loop over all images and make sure, they
# are in the checked images list
for i in $imglist
do
grep -q $i $checkfile
if [ $? -ne 0 ] ; then
echo "New image: $i"
echo $i >> $checkfile
curl --silent -O $i
fi
done
fi
# Check all downloaded images for outguess/signature
for file in *.jpg
do
grep -q $file $hitfile
if [ -f $file -a $? -ne 0 ] ; then
# Check for outguess
outguess -r $file $file.txt
if [ $? -eq 0 ] ; then
# Check for valid signature
gpg --verify $file.txt
if [ $? -eq 0 ] ; then
echo $file >> $hitfile
else
rm $file $file.txt
fi
else
rm $file $file.txt
fi
fi
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment