无法自动挂载 TrueCrypt 卷

无法自动挂载 TrueCrypt 卷

我有用于猜测 TrueCrypt 卷密码的脚本。它应该可以工作,但 TrueCrypt 或 VeraCrypt 说它是使用错误的命令行参数调用的。有人能帮忙吗?

#!/bin/bash
working="working.txt"
tc=veracrypt
prefix="--text --keyfiles= --protect-hidden=no --non-interactive -p "
sufix="gentle.tc /mnt"
count=0

echo archive=gentle.tc

while read -r p; do

    echo -en "\033[2K\r$p"

    if $tc "$prefix\"$p\" $sufix"; then echo "$p" >>$working ; exit ; fi

    if $tc "$prefix\"$p\n\" $sufix"; then echo "$p" >>$working ; exit ; fi

    if $tc "$prefix\"$p\r\" $sufix"; then echo "$p" >>$working ; exit ; fi

    if $tc "$prefix\"$p\r\n\" $sufix"; then echo "$p" >>$working ; exit ; fi

    b64=$(echo -n "$p" | base64)
    md5=$(echo -n "$p" | md5sum | gawk '{print $1}')
    sha1=$(echo -n "$p" | sha1sum | gawk '{print $1}')
    sha256=$(echo -n "$p" | sha256sum | gawk '{print $1}')

    if $tc "$prefix\"$b64\" $sufix"; then echo "$p" >>$working ; exit ; fi

    if $tc "$prefix\"$md5\" $sufix"; then echo "$p" >>$working ; exit ; fi

    if $tc "$prefix\"$sha1\" $sufix"; then echo "$p" >>$working ; exit ; fi

    if $tc "$prefix\"$sha256\" $sufix"; then echo "$p" >>$working ; exit ; fi

    count=$((count+1))

done < list.txt
echo COUNT=$count

答案1

好的,我已将脚本改为没有变量,现在它可以正常工作:

#!/bin/bash
working="working.txt"
count=0

echo archive=gentle.tc

while read -r p; do

    echo -en "\033[2K\r$p"
    echo "$p" >> tested.txt

    if truecrypt --text --keyfiles= --protect-hidden=no --non-interactive -p "$p" gentle.tc /mnt 2>>errors.txt; then echo "$p" >>$working ; exit ; fi

    if truecrypt --text --keyfiles= --protect-hidden=no --non-interactive -p "$p\n" gentle.tc /mnt 2>>errors.txt; then echo "$p" >>$working ; exit ; fi

    if truecrypt --text --keyfiles= --protect-hidden=no --non-interactive -p "$p\r" gentle.tc /mnt 2>>errors.txt; then echo "$p" >>$working ; exit ; fi

    if truecrypt --text --keyfiles= --protect-hidden=no --non-interactive -p "$p\r\n" gentle.tc /mnt 2>>errors.txt; then echo "$p" >>$working ; exit ; fi

    b64=$(echo -n "$p" | base64)
    md5=$(echo -n "$p" | md5sum | gawk '{print $1}')
    sha1=$(echo -n "$p" | sha1sum | gawk '{print $1}')
    sha256=$(echo -n "$p" | sha256sum | gawk '{print $1}')

    if truecrypt --text --keyfiles= --protect-hidden=no --non-interactive -p "$b64" gentle.tc /mnt 2>>errors.txt; then echo "$p" >>$working ; exit ; fi

    if truecrypt --text --keyfiles= --protect-hidden=no --non-interactive -p "$md5" gentle.tc /mnt 2>>errors.txt; then echo "$p" >>$working ; exit ; fi

    if truecrypt --text --keyfiles= --protect-hidden=no --non-interactive -p "$sha1" gentle.tc /mnt 2>>errors.txt; then echo "$p" >>$working ; exit ; fi

    if truecrypt --text --keyfiles= --protect-hidden=no --non-interactive -p "$sha256" gentle.tc /mnt 2>>errors.txt; then echo "$p" >>$working ; exit ; fi

    count=$((count+1))

done < list.txt
echo COUNT=$count

相关内容