Click here to Skip to main content
15,902,189 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have an xml output file from sslyze_cli.py with following content.
<?xml version="1.0" encoding="utf-8"?>
<document SSLyzeVersion="0.13.4" SSLyzeWeb="https://github.com/nabla-c0d3/sslyze" title="SSLyze Scan Results">
  <invalidTargets/>
  <results networkMaxRetries="4" networkTimeout="5" totalScanTime="14.9100000858">
    <target host="www.loremipsum.com" ip="10.10.10.10" port="443" tlsWrappedProtocol="https">
      <sslv3 isProtocolSupported="True" title="SSLV3 Cipher Suites">
        <preferredCipherSuite>
          <cipherSuite anonymous="False" keySize="128" name="TLS_RSA_WITH_RC4_128_SHA"/>
        </preferredCipherSuite>
        <acceptedCipherSuites>
          <cipherSuite anonymous="False" keySize="256" name="TLS_RSA_WITH_AES_256_CBC_SHA"/>
          <cipherSuite anonymous="False" keySize="128" name="TLS_RSA_WITH_AES_128_CBC_SHA"/>
          <cipherSuite anonymous="False" keySize="128" name="TLS_RSA_WITH_RC4_128_SHA"/>
          <cipherSuite anonymous="False" keySize="128" name="TLS_RSA_WITH_RC4_128_MD5"/>
          <cipherSuite anonymous="False" keySize="112" name="TLS_RSA_WITH_3DES_EDE_CBC_SHA"/>
        </acceptedCipherSuites>
      </sslv3>


There is similar content for SSLv2 as well when we go ahead in xml file.

I want to extract accepted cipher name and keysize for sslv3 and sslv2 elements.

How do I iterate through child elements and validate certain ciphersuite elements belong to sslv2 and others belowng to sslv3 parent element for accepted ciphers?

Thanks.

What I have tried:

I tried using lxml module but I am not successful with it. when I import it, I don't get much options which are mentioned in its documentation.

I am using xml module now. I have been able to iterate through root and get sslv3 element and check if it is supported or not.
for _sslv3 in _root.iter('sslv3'):
			_sslv3 = _sslv3.attrib
			_result = str(_sslv3['isProtocolSupported'])


Not sure, how to proceed further. Any help is much appreciated.
Posted
Updated 3-Mar-16 22:44pm

1 solution

alright, found solution by implementing below code.
for _ver3 in _root.iter('sslv3'):
    for _accepted in _ver3.findall('acceptedCipherSuites'):
        for _ciphers in _accepted.findall('cipherSuite'):
            _ciphers = _ciphers.attrib
            if int(_ciphers['keySize']) <= 128:
                print 'Weak cipher found'
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900