Advertisement
SuperJediWombat

validate3ofM.sh

Mar 22nd, 2014
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.38 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. IFS=$'\n'
  4.  
  5. case "$1" in
  6.   *.pdf|*.png|*.jpg)
  7.     FILE=($(zbarimg -q --raw -Sdisable -Sqrcode.enable $1))
  8.     lines=$(zbarimg --raw -Sdisable -Sqrcode.enable $1 | wc -l)
  9.     ;;
  10.   "")
  11.     echo "You need to put a filename as the first argument.
  12.  
  13. If it's a pdf, png or jpg image it will be scanned for barcodes. If it's anything else then it will be scanned for secrets, one per line. If you have a webcam you can scan your barcodes using this command
  14.  zbarcam -q --raw -Sdisable -Sqrcode.enable >> qrcodes
  15. and then validate them by running
  16.  sudo ./validate3ofM qrcodes"
  17.     ;;
  18.   *)
  19.     FILE=($(sed --quiet --regexp-extended '/^[0-9]+-[0-9a-f]*$/p' "$1" | sort -u))
  20.     lines=$(sed --quiet --regexp-extended '/^[0-9]+-[0-9a-f]*$/p' "$1" | sort -u | wc -l)
  21.     ;;
  22. esac
  23.  
  24. list=$(seq 1 $lines)
  25. for c1 in $list; do
  26.     for c2 in $list; do
  27.         if [[ $c2 != $c1 && $c1 -lt $c2 ]]; then
  28.             for c3 in $list; do
  29.                 if [[ $c3 != $c2 && $c3 != $c1 && $c2 -lt $c3 && $c1 -lt $c2 ]]; then
  30.                     printf "$c1-$c2-$c3: "
  31.                     printf "${FILE[$c1-1]}\n${FILE[$c2-1]}\n${FILE[$c3-1]}\n" | ssss-combine -q -t 3
  32.                     if [[ $? -ne 0 ]]; then
  33.                         printf "${FILE[$c1-1]}\n${FILE[$c2-1]}\n${FILE[$c3-1]}\n"
  34.                     fi
  35.                 fi
  36.             done
  37.         fi
  38.     done
  39. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement