|
@@ -130,82 +130,6 @@ class DnsQuery(APIView):
|
|
|
'_nameserver': desecio.nameservers
|
|
|
})
|
|
|
|
|
|
-class ScanLogjam(APIView):
|
|
|
- def get(self, request, format=None):
|
|
|
- # retrieve address to connect to
|
|
|
- addr = str(request.GET['host']) + ':' + str(int(request.GET['port']))
|
|
|
- starttls = str(request.GET['starttls'])
|
|
|
-
|
|
|
- def getOpenSSLOutput(cipher, connect, starttls=None, openssl='openssl-1.0.2a'):
|
|
|
- if starttls not in ['smtp', 'pop3', 'imap', 'ftp', 'xmpp']:
|
|
|
- starttls = None
|
|
|
-
|
|
|
- if starttls:
|
|
|
- starttlsparams = ['-starttls', starttls]
|
|
|
- else:
|
|
|
- starttlsparams = []
|
|
|
-
|
|
|
- if cipher:
|
|
|
- cipherparams = ['-cipher', cipher]
|
|
|
- else:
|
|
|
- cipherparams = []
|
|
|
-
|
|
|
- cmd = [
|
|
|
- openssl,
|
|
|
- 's_client',
|
|
|
- '-connect',
|
|
|
- connect
|
|
|
- ] + starttlsparams + cipherparams
|
|
|
- p_openssl = subprocess.Popen(cmd,
|
|
|
- stdin=subprocess.PIPE,
|
|
|
- stdout=subprocess.PIPE,
|
|
|
- stderr=subprocess.PIPE)
|
|
|
- stdout, stderr = p_openssl.communicate()
|
|
|
-
|
|
|
- return (stdout, stderr)
|
|
|
-
|
|
|
- # check if there is an SSL-enabled host
|
|
|
- output = getOpenSSLOutput(None, addr, openssl='openssl')
|
|
|
- if (not re.search('SSL-Session:', output[0])):
|
|
|
- raise Http404('Can\'t connect via SSL/TLS')
|
|
|
-
|
|
|
- # find DH size
|
|
|
- dhsize = None
|
|
|
- output = getOpenSSLOutput('EDH', addr, starttls)
|
|
|
- res = re.search('Server Temp Key: DH, ([0-9]+) bits', output[0])
|
|
|
- if res:
|
|
|
- dhsize = int(res.group(1))
|
|
|
- else:
|
|
|
- if (re.search('handshake failure:', output[1])):
|
|
|
- # server does not accept EDH connections, or no connections at all
|
|
|
- pass
|
|
|
- else:
|
|
|
- raise Http404('Failed to determine DH key size.')
|
|
|
-
|
|
|
- # check EXP cipher suits
|
|
|
- exp = True
|
|
|
- output = getOpenSSLOutput('EXP', addr, starttls)
|
|
|
- res = re.search('handshake failure:', output[1])
|
|
|
- if res:
|
|
|
- exp = False
|
|
|
- else:
|
|
|
- if (re.search('SSL-Session:', output[0])):
|
|
|
- # connection was established
|
|
|
- exp = True
|
|
|
- else:
|
|
|
- raise Exception('Failed to check for EXP cipher suits.')
|
|
|
-
|
|
|
- return Response({
|
|
|
- 'openssl': {
|
|
|
- 'addr': addr,
|
|
|
- 'logjam': {
|
|
|
- 'dhsize': dhsize,
|
|
|
- 'expcipher': exp
|
|
|
- },
|
|
|
- 'version': 'openssl-1.0.2a',
|
|
|
- }
|
|
|
- })
|
|
|
-
|
|
|
|
|
|
class DynDNS12Update(APIView):
|
|
|
authentication_classes = (TokenAuthentication, BasicTokenAuthentication, URLParamAuthentication,)
|