Exemplo n.º 1
0
 def authSelected(self, method):
     method = to_binary(method)
     if method not in self.w.factory.methods:
         raise e.MethodsNotAcceptedError('no method proprosed was accepted',
                                         self.w.factory.methods, method)
     authMethod = getattr(self.w, 'auth_' + self.w.authMethodMap[method])
     authMethod(*self.w.factory.methods[method])
Exemplo n.º 2
0
 def sendLogin(self, username, password):
     self.transport.write(b'\x01' + to_binary(chr(len(username))) +
                          username + to_binary(chr(len(password))) +
                          password)
Exemplo n.º 3
0
 def sendRequest(self, host, port, user):
     ipaddr = socket.inet_aton(socket.gethostbyname(host))
     data = struct.pack(">BBH", c.VER_SOCKS4, c.CMD_CONNECT, port)
     self.transport.write(data + ipaddr + to_binary(user) + b'\0')
Exemplo n.º 4
0
def socks_host(host):
    return to_binary(chr(c.ATYP_DOMAINNAME)) + to_binary(chr(len(host))) + host