Я начал писать bash скрипт на Python, но застрял в вопросе да / нет и некоторое время l oop внутри цикла while - PullRequest
0 голосов
/ 04 мая 2020

Я должен создать вопрос «да» или «нет», а затем вернуть что-то из ответа, если ответ «да», я задаю ему вопрос, и пользователь должен дать мне ввод, который я должен сохранить в переменной, а затем спросить его, если он хочет дать мне другой (да, без вопросов снова) и сделать то же самое, если ответ «нет», просто продолжайте с кодом. Это раздел кода, где я застрял. Я надеюсь, что вы можете помочь мне, спасибо!

    while true
do
    read -p $'\033[0;35mGood! Do you want to set a duplicity limit for a different character? Y/N: \033[0m' answer
    case $answer in
    [yY]* ) echo -e "${PURPLE}Excellent, remember:
    ${YELLOW}@ ${PURPLE}symbol is for any lowercase letter, 
    ${YELLOW}, ${PURPLE}symbol is for any uppercase letter, 
    ${YELLOW}% ${PURPLE}is for any number, 
    ${YELLOW}^ ${PURPLE}is for any symbol.
    Now tell me:${NC}"
    read DupLimit2

    while true
    do  
        read -p $'\033[0;35mSet, another one? Y/N: \033[0m' answer
        case $answer in
        [yY]* ) echo -e "${PURPLE}Ok, go ahead.${NC}"
        read DupLimit3

        while true
        do  
            read -p $'\033[0;35mOne more left. Will you? Y/N: \033[0m' answer
            case $answer in
            [yY]* ) echo -e "${PURPLE}Give it to me.${NC}"
            read DupLimit4

                while true
                do
                    read -p $'\033[0;35mDo you have any idea of how could the password start based on the characters you gave me? Y/N: \033[0m' answer
                    case $answer in
                    [yY]* ) echo -e "${PURPLE}Excellent, how?${NC}"
                    read PassStart
                    echo -e "${PURPLE}Well done, maybe this is gonna help us to crack the password faster, we are almost done, now just specify the directory, name and format of the output file: ${NC}"
                    read DirNameFormat
                    echo -e "${YELLOW}We are all set, Lets create this shit!${NC}"
                    echo -e "${YELLOW}Starting..."
                    crunch $MinLength $MaxLength $CharactersLower$CharactersUpper$Numbers$Symbols -d $DupLimit -d $DupLimit2 -d $DupLimit3 -d $DupLimit4 -s $PassStart -o $DirNameFormat
                    break;;
                    [nN]* ) echo -e "${PURPLE}Do not worry, it is not necessary.${NC}"
                    echo -e "${PURPLE}We are almost done, now just specify the directory, name and format of the output file: ${NC}"
                    read DirNameFormat
                    echo -e "${YELLOW}Well done, maybe this is gonna help us to crack this password faster, we are all set. Lets create this shit!${NC}"
                    echo -e "${YELLOW}Starting..."
                    crunch $MinLength $MaxLength $CharactersLower$CharactersUpper$Numbers$Symbols -d $DupLimit -d $DupLimit2 -d $DupLimit3 -d $DupLimit4 -o $DirNameFormat
                    break;;
                    * ) echo -e "${RED}Dude, just enter Y or N, please.${NC}";;
                    esac
                done
                break;;

            [nN]* ) echo -e "${PURPLE}Do not worry.${NC}"

                while true
                do
                    read -p $'\033[0;35m Do you have any idea of how could the password start based on the characters you gave me? Y/N: \033[0m' answer
                    case $answer in
                    [yY]* ) echo -e "${PURPLE}Excellent, how?${NC}"
                    read PassStart
                    echo -e "${PURPLE}We are almost done, now just specify the directory, name and format of the output file: ${NC}"
                    read DirNameFormat
                    echo -e "${YELLOW}Well done, maybe this is gonna help us to crack this password faster, we are all set. Lets create this shit!${NC}"
                    echo -e "${YELLOW}Starting..."
                    crunch $MinLength $MaxLength $CharactersLower$CharactersUpper$Numbers$Symbols -d $DupLimit -d $DupLimit2 -d $DupLimit3 -s $PassStart -o $DirNameFormat
                    break;;
                    [nN]* ) echo -e "${PURPLE}Do not worry, it is not necessary.${NC}"
                    echo -e "${PURPLE}We are almost done, now just specify the directory, name and format of the output file: ${NC}"
                    read DirNameFormat
                    echo -e "${YELLOW}Well done, maybe this is gonna help us to crack this password faster, we are all set. Lets create this shit!${NC}"
                    echo -e "${YELLOW}Starting..."
                    crunch $MinLength $MaxLength $CharactersLower$CharactersUpper$Numbers$Symbols -o $DirNameFormat
                    break;;
                    * ) echo -e "${RED}Dude, just enter Y or N, please.${NC}";;
                    esac
                done
                break;;

            * ) echo -e "${RED}Dude, just enter Y or N, please.${NC}";;
            esac
        done
        break;;

        [nN]* ) echo -e "${PURPLE}Do not worry.${NC}"
...