Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
288 views
in Technique[技术] by (71.8m points)

bash - Bypassing bad CRC with unzip tool

I am trying to unzip a file with a password that I know is between 900000000 and 900999999 but I am met with an bad crc error and a gov.csv that contains some non sense. How can I get past this without ending the program? I know what the actual password is, but creating this "brute force" attempt is part of a homework assignment. The error that I come across seems to be stemming from the unzip apt. My code is below. The yes was added because I was continually being asked to replace the file even though it was the wrong password.

for word in $(echo 900{000000..999999})
{
echo $word
yes | unzip -q -P $word $1
if [ -s gov.csv ]
then
echo "$word is the password"
exit
fi
}

I have tried adding an additional if statement that does nothing to improve the situation.

if yes | unzip -q -P $word $1 | grep -i "bad crc"
then
rm gov.csv
fi

I would also like to apologize if my formatting for the code section is bad, first time posting on this site.

question from:https://stackoverflow.com/questions/65925925/bypassing-bad-crc-with-unzip-tool

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
#!/bin/bash
for id in $(echo 900{000000..999999})
{
  echo $id
  unzip -q -o -P "$id" "$1"
  if [[ $? -eq 0 ]]
  then
    echo "Password is $id"
    exit
  fi
}

Thank y'all for the help, the -o is what replaced the yes pipeline, as well as $? -eq 0 verifying that the previous command did not return an error. I'm still learning and appreciate all the help offered.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...