1

So I'm trying to add a countdown timer to show on screen while john is running based on user input, I can get the timer to run after john but not at the same time, this what I have so far.

timeout=$(($timeout))
    while timeout $timeout /usr/sbin/john --fork=2 NT.out &>/dev/null >> johnlog.txt; do
    while [ $timeout -gt 0 ]; do
       echo -ne "$timeout\033[0K\r"
       sleep 1
       : $((timeout--))
    done
  done

Any Help is much appreciated.

Stephen Kitt
  • 411,918
  • 54
  • 1,065
  • 1,164
  • what does this mean? `based on user input` – jsotola Jul 20 '19 at 16:45
  • So because john will run for ages if its just left, a user may have a small hash list they want to crack so the user can define the timeout in seconds like so: `echo echo "How long would you like john to run for?" echo read -p "Answer in Seconds: " timeout` – Danny Mastik Jul 20 '19 at 16:48

1 Answers1

1
timeout=$(($timeout))

Crack_hashes_with_john() {
  echo
  echo "How long would you like john to run for?"
  echo
  read -p "Answer in Seconds: " timeout
  cd /root/.john && rm john.pot &>/dev/null
    cd /root/libesedb-20181229/esedbtools
    ./esedbexport -t /root/Desktop/ntds $ditpath
    cd /root/Desktop/ntds.export/
    mkdir extract
    python /root/ntdsxtract/dsusers.py datatable.4 link_table.7 extract/ --lmoutfile LM.out --ntoutfile NT.out --passwordhashes --pwdformat john --syshive $binpath &>/dev/null
    cd extract
    rm johnlog.txt &>/dev/null

  echo -e "\e[31m      ==================                            \e[0m"
  echo -e "\e[1;31m      Cracking with John                          \e[0m"
  echo -e "\e[31m      ==================                            \e[0m"
    sleep 1
     timeout $timeout /usr/sbin/john --fork=2 NT.out &>/dev/null >> johnlog.txt
    while [ $timeout -gt 0 ]; do
       echo -ne "$timeout\033[0K\r"
       sleep 1
       : $((timeout--))
    done 
    cat johnlog.txt
}

This is whole piece of code, as it is at the minute the timer runs after john has ran but I want it to run whilst john is running.