tintinweb / scapy-ssl_tls

SSL/TLS layers for scapy the interactive packet manipulation tool
GNU General Public License v2.0
417 stars 157 forks source link

bind multiple TLSSockets #133

Closed 4Kp3n closed 6 years ago

4Kp3n commented 6 years ago

Hi, I'm not able to use multiple TLSSockets on one machine. Binding one Socket to my local ip and port 5555 and one to same ip and port 6666 results in following error:

    226 
    227 def meth(name,self,*args):
--> 228     return getattr(self._sock,name)(*args)
    229 
    230 for _m in _socketmethods:

error: [Errno 22] Invalid argument

Using normal python sockets doesn't result in this error. Is this behaviour intended?

alexmgr commented 6 years ago

Hi @skllrn,

Not intended, I'm not sure why it's happening (something to do with socket.socket() not liking to be used as a default arg I think?).

Can you replace the beginning of the constructor for TLSSocket in scapy_ssl_tls\ssl_tls.py by the following:

class TLSSocket(object):

    def __init__(self, sock=None, client=None, tls_ctx=None):
        self._s = sock or socket.socket()

        if client is None:
            self.client = self._is_listening()

Let us know if that fixes it.

4Kp3n commented 6 years ago

Hi @alexmgr,

Declaring the socket inside the __init__ function as you stated did the trick.

Thanks a lot!