easybox keygen - Bash Shell-Skript


SUBMITTED BY: Guest

DATE: Dec. 3, 2013, 1:27 p.m.

FORMAT: Bash

SIZE: 1.3 kB

HITS: 922

  1. #!/bin/bash
  2. #
  3. # easybox_keygen.sh (c) 2012 GPLv3
  4. #
  5. # www.wotan.cc
  6. #
  7. MAC=$1
  8. # Take the last 2 Bytes of the MAC-Address (0B:EC), and convert it to decimal.
  9. take5=${MAC:12}
  10. last4=${take5/:/}
  11. # Fill up to 4 places with zeros, if necessary:
  12. deci=($(printf "%04d" "0x$last4" | sed 's/.*\(....\)/\1/;s/./& /g'))
  13. echo M4: ${deci[@]}
  14. #
  15. # The digits M9 to M12 are just the last digits (9.-12.) of the MAC:
  16. hexi=($(echo ${MAC:12:5} | sed 's/://;s/./& /g'))
  17. echo 'M4 (Hex): ' ${hexi[@]}
  18. # K1 = last byte of (d0 + d1 + h2 + h3)
  19. # K2 = last byte of (h0 + h1 + d2 + d3)
  20. c1=$(printf "%d + %d + %d + %d" ${deci[0]} ${deci[1]} 0x${hexi[2]} 0x${hexi[3]})
  21. c2=$(printf "%d + %d + %d + %d" 0x${hexi[0]} 0x${hexi[1]} ${deci[2]} ${deci[3]})
  22. K1=$((($c1)%16))
  23. K2=$((($c2)%16))
  24. printf "K1: %x\n" $K1
  25. printf "K2: %x\n" $K2
  26. X1=$((K1^${deci[3]}))
  27. X2=$((K1^${deci[2]}))
  28. X3=$((K1^${deci[1]}))
  29. Y1=$((K2^0x${hexi[1]}))
  30. Y2=$((K2^0x${hexi[2]}))
  31. Y3=$((K2^0x${hexi[3]}))
  32. Z1=$((0x${hexi[2]}^${deci[3]}))
  33. Z2=$((0x${hexi[3]}^${deci[2]}))
  34. Z3=$((K1^K2))
  35. printf "WPA-KEY: %x%x%x%x%x%x%x%x%x\n" $X1 $Y1 $Z1 $X2 $Y2 $Z2 $X3 $Y3 $Z3 | tr a-f A-F

comments powered by Disqus