Skip to content

Instantly share code, notes, and snippets.

@chvancooten
Last active September 17, 2022 11:00
Show Gist options
  • Save chvancooten/34f26f90c1e174e16e4228764e9c5dcb to your computer and use it in GitHub Desktop.
Save chvancooten/34f26f90c1e174e16e4228764e9c5dcb to your computer and use it in GitHub Desktop.

Revisions

  1. chvancooten renamed this gist Apr 24, 2020. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. chvancooten created this gist Apr 24, 2020.
    38 changes: 38 additions & 0 deletions decrypter.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,38 @@
    #!/bin/bash
    ### 0xc4s OpenSSL bruter for HTB's 'Hawk'

    # Declare wordlists
    wordlist = '/usr/share/wordlists/rockyou.txt'

    # Declare array of possible ciphers (based on common ones from 'openssl help')
    ciphers=(
    -aes-256-cbc
    -aes-128-cbc
    -aes-256-ecb
    -aes-128-ecb
    )

    # Loop through ciphers
    for cipher in "${ciphers[@]}"; do
    echo "TRYING CIPHER: $cipher"

    # Loop through wordlist
    while read passTry; do
    openssl enc -d -a $cipher -k $passTry -in drupal.txt.enc -out tmp &>/dev/null

    if [ $? -eq 0 ]; then
    echo "PASSWORD FOUND!"
    echo "Pass is: $passTry"
    echo "===DECRYPTED TEXT BELOW==="
    cat tmp
    echo "===END DECRYPTED TEXT==="
    # For Hawk, it gets the correct password on first try
    # However, a 0-exit code doesn't always mean getting the key right
    # As such, don't exit (spam alert!)
    #exit 0
    fi
    rm tmp
    done < $wordlist
    done

    rm tmp