DKIM Strength Checker

From Anna, 5 Years ago, written in Plain Text, viewed 803 times.
URL https://anna.fyi/view/a4214450 Embed
Download Paste or View Raw
  1. #!/bin/bash
  2.  
  3. read -p 'Checking DKIM length for: ' DOMAIN
  4. SELECTOR=default._domainkey
  5.  
  6. # Put the pubkey stuff from the DKIM record into a tmp file
  7. dig txt $SELECTOR.$DOMAIN +short | awk -F'p=' '{print $2}' > /tmp/$DOMAIN.key.txt
  8.  
  9. # Strip out unnecessary characters
  10. sed -i 's/[^a-zA-Z0-9+'/']//g' /tmp/$DOMAIN.key.txt
  11.  
  12. # Line wrap so openssl command will work
  13. fold -w 78 /tmp/$DOMAIN.key.txt > /tmp/$DOMAIN.key
  14. rm -f /tmp/$DOMAIN.key.txt
  15.  
  16. # Insert the pubkey blocks
  17. sed -i '1 i\-----BEGIN PUBLIC KEY-----' /tmp/$DOMAIN.key
  18. echo "-----END PUBLIC KEY-----" >> /tmp/$DOMAIN.key
  19.  
  20. echo " "
  21. echo "DKIM TXT RECORD:"
  22. echo "****************"
  23. dig txt $SELECTOR.$DOMAIN +short
  24. echo " "
  25. echo "PUBKEY:"
  26. echo "*******"
  27. cat /tmp/$DOMAIN.key
  28. echo " "
  29. echo "STRENGTH:"
  30. echo "*********"
  31. openssl rsa -noout -text -pubin < /tmp/$DOMAIN.key
  32.  
  33. rm -f /tmp/$DOMAIN.key

Reply to "DKIM Strength Checker"

Here you can reply to the paste above