Home | History | Annotate | Download | only in tls
      1 #!/usr/bin/env python
      2 
      3 ## This file is part of Scapy
      4 ## This program is published under a GPLv2 license
      5 
      6 """
      7 Basic TLS client. A ciphersuite may be commanded via a first argument.
      8 Default protocol version is TLS 1.2.
      9 
     10 For instance, "sudo ./client_simple.py c014" will try to connect to any TLS
     11 server at 127.0.0.1:4433, with suite TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA.
     12 """
     13 
     14 import os
     15 import sys
     16 
     17 basedir = os.path.abspath(os.path.join(os.path.dirname(__file__),"../../"))
     18 sys.path=[basedir]+sys.path
     19 
     20 from scapy.layers.tls.automaton_cli import TLSClientAutomaton
     21 from scapy.layers.tls.handshake import TLSClientHello
     22 
     23 
     24 if len(sys.argv) == 2:
     25     ch = TLSClientHello(ciphers=int(sys.argv[1], 16))
     26 else:
     27     ch = None
     28 
     29 t = TLSClientAutomaton(client_hello=ch,
     30                        version="tls13-d18",
     31                        mycert=basedir+"/test/tls/pki/cli_cert.pem",
     32                        mykey=basedir+"/test/tls/pki/cli_key.pem")
     33 t.run()
     34 
     35