Advertisement
Guest User

cc2file/Crome cahce file bin export

a guest
Feb 8th, 2013
391
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/bash
  2. if [ -z "$1" ]; then
  3.     echo -e "  Usage $0 cache_file [out_file]\n  If out_file not given will generate full original path/name in current dir\n  If '-' is given for out_file will print to stdout " >&2
  4.     exit;
  5. fi
  6. orig=$(cat "$1" | head -n 5 | awk '{pp=index($0,"\x3ctable\x3e"); if (pp) { pp+=7; pe=index($0,"\x3chr\x3e"); if (pe>pp) print substr($0,pp,pe-pp); } }')
  7. if [ -z $orig ]; then echo "Bad File?"; exit; fi
  8. re=$(cat "$1" | head -n 5 | awk '{pp=index($0,"\x3cpre\x3e"); if (pp) { pp+=5; print substr($0,pp,200); } }')
  9. echo -e "Processing:\t$1" >&2
  10. echo -e "  Found:\t$orig" >&2
  11. if [ "$2" == "-" ]; then ex="/dev/stdout"; else
  12.   if [ -z "$2" ]; then ex="$(pwd)/$orig"; mkdir -p $(dirname $ex); else ex=$2; fi fi
  13. echo -e "  Save to:\t$ex" >&2
  14. echo -e "  Req. Result:\t$re" >&2
  15.  
  16. cat "$1" | awk \
  17. 'BEGIN { fou=0; }
  18. { if (fou<2) { fff=index($0,"\x3c""pre""\x3e""00000000:"); if (fff) { fou++; $0=substr($0,fff+5,4*16-2+11); } }
  19. if (fou<2) { next; }
  20. fff=index($0,"\x3c""\x2f""pre""\x3e");
  21. if (fff==1) exit;
  22. $0=substr($0,12,4*16-2);
  23. print $0;
  24. #for (ch=1; ch<NF+1; ch++) printf("%c",strtonum( "0x"$ch))
  25. }' | xxd -r -p > $ex
Advertisement
RAW Paste Data Copied
Advertisement