1*7dc08ffcSJunyu Lai#!/usr/bin/env python 2*7dc08ffcSJunyu Lai 3*7dc08ffcSJunyu Lai## This file is part of Scapy 4*7dc08ffcSJunyu Lai## This program is published under a GPLv2 license 5*7dc08ffcSJunyu Lai 6*7dc08ffcSJunyu Lai""" 7*7dc08ffcSJunyu LaiBasic TLS server. A preferred ciphersuite may be provided as first argument. 8*7dc08ffcSJunyu Lai 9*7dc08ffcSJunyu LaiFor instance, "sudo ./server_simple.py c014" will start a server accepting 10*7dc08ffcSJunyu Laiany TLS client connection. If provided, TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA 11*7dc08ffcSJunyu Laiwill be preferred to any other suite the client might propose. 12*7dc08ffcSJunyu Lai""" 13*7dc08ffcSJunyu Lai 14*7dc08ffcSJunyu Laiimport os 15*7dc08ffcSJunyu Laiimport sys 16*7dc08ffcSJunyu Lai 17*7dc08ffcSJunyu Laibasedir = os.path.abspath(os.path.join(os.path.dirname(__file__),"../../")) 18*7dc08ffcSJunyu Laisys.path=[basedir]+sys.path 19*7dc08ffcSJunyu Lai 20*7dc08ffcSJunyu Laifrom scapy.layers.tls.automaton_srv import TLSServerAutomaton 21*7dc08ffcSJunyu Lai 22*7dc08ffcSJunyu Lai 23*7dc08ffcSJunyu Laiif len(sys.argv) == 2: 24*7dc08ffcSJunyu Lai pcs = int(sys.argv[1], 16) 25*7dc08ffcSJunyu Laielse: 26*7dc08ffcSJunyu Lai pcs = None 27*7dc08ffcSJunyu Lai 28*7dc08ffcSJunyu Lait = TLSServerAutomaton(mycert=basedir+'/test/tls/pki/srv_cert.pem', 29*7dc08ffcSJunyu Lai mykey=basedir+'/test/tls/pki/srv_key.pem', 30*7dc08ffcSJunyu Lai preferred_ciphersuite=pcs) 31*7dc08ffcSJunyu Lait.run() 32*7dc08ffcSJunyu Lai 33