############################################################################### # makefile ############################################################################### .ONESHELL: ############################################################################### MD5 = $(TXT:.txt=.md5) OPT = $(MD5) SHA = $(TXT:.txt=.sha) SHA256 = $(TXT:.txt=.sha256) SHA512 = $(TXT:.txt=.sha512) TXT = password.txt ############################################################################### define header @printf '%78s\n' | tr ' ' '#' printf '# $(1)\n' printf '%78s\n' | tr ' ' '#' endef ############################################################################### all: brute show ascii: $(OPT) @$(call header,john --incremental=ascii $<) john --incremental=ascii $< best: dict2 brute brute: $(OPT) @$(call header,john $<) john $< clean: -rm -fv $(MD5) $(SHA) $(SHA256) $(SHA512) $(TXT) ~/.john/* *~ dict: $(OPT) @$(call header,john --wordlist=ingles.txt $<) john --wordlist=ingles.txt $< dict2: $(OPT) | dict @$(call header,john --rules --wordlist=ingles.txt $<) john --rules --wordlist=ingles.txt $< digits: $(OPT) @$(call header,john --incremental=digits $<) john --incremental=digits $< lower: $(OPT) @$(call header,john --incremental=lower $<) john --incremental=lower $< show: $(OPT) @$(call header,john --show $<) john --show $< ############################################################################### $(TXT): ingles.txt peores.txt @$(call header,generating $@) pass() { tr -cd '[:alpha:]' < /dev/urandom | fold -c$$1 | head -n1; } claves=("" "user1" "$$(shuf -n1 peores.txt)" "$$(shuf -n1 ingles.txt)") for (( i=1; i<2; ++i )); do claves+=("$$(pass $$i)") done for (( i=0; i<$${#claves[@]}; ++i )) do echo "user$$i:$${claves[$$i]}" done | tee $@ ############################################################################### %.md5: %.txt @$(call header,generating $@) while IFS=':' read -r user passwd; do echo -n "$$user:" perl -e "print crypt($$passwd, '\$$1\$$0\$$')" 2> /dev/null echo ':::::::' done < $< | tee $@ %.sha: %.txt @$(call header,generating $@) while IFS=':' read -r user passwd; do echo -n "$$user:" perl -e "print crypt($$passwd, '\$$6\$$0\$$')" 2> /dev/null echo ':::::::' done < $< | tee $@ %.sha256: %.txt @$(call header,generating $@) salt() { tr -cd '[:alpha:]' < /dev/urandom | fold -c3 | head -n1; } while IFS=':' read -r user passwd; do echo "$$user:$$(openssl passwd -5 -salt $$(salt) $$user):::::::" done < $< | tee $@ %.sha512: %.txt @$(call header,generating $@) salt() { tr -cd '[:alpha:]' < /dev/urandom | fold -c3 | head -n1; } while IFS=':' read -r user passwd; do echo "$$user:$$(openssl passwd -6 -salt $$(salt) $$user):::::::" done < $< | tee $@ ############################################################################### .PHONY: all ascci best brute clean dict dict2 digit lower show .PRECIOUS: $(OPT) $(SHA) $(TXT) ############################################################################### # %.stdin: % # @$(call header,'john --stdin $< \< \<\(cat $(<:.*=.txt) \| tr \':\' \'\n\'\)') # john --stdin $< < <(cat $(<:.*=.txt) | tr ':' '\n') ###############################################################################