mirror of
https://github.com/curl/curl.git
synced 2024-12-15 06:40:09 +08:00
impacket: some more Python 3 code compatibility updates
This makes smbserver load on Python 3, but still not work completely.
This commit is contained in:
parent
ba0e6fbd30
commit
a7e24c7362
@ -57,10 +57,14 @@ import hashlib
|
|||||||
unicode_support = 0
|
unicode_support = 0
|
||||||
unicode_convert = 1
|
unicode_convert = 1
|
||||||
|
|
||||||
try:
|
import sys
|
||||||
from cStringIO import StringIO
|
if sys.version_info.major >= 3:
|
||||||
except ImportError:
|
from io import StringIO
|
||||||
from StringIO import StringIO
|
else:
|
||||||
|
try:
|
||||||
|
from cStringIO import StringIO
|
||||||
|
except ImportError:
|
||||||
|
from StringIO import StringIO
|
||||||
|
|
||||||
# Dialect for SMB1
|
# Dialect for SMB1
|
||||||
SMB_DIALECT = 'NT LM 0.12'
|
SMB_DIALECT = 'NT LM 0.12'
|
||||||
|
@ -29,9 +29,10 @@ import struct
|
|||||||
import sys
|
import sys
|
||||||
if sys.version_info.major >= 3:
|
if sys.version_info.major >= 3:
|
||||||
import configparser
|
import configparser
|
||||||
|
import socketserver
|
||||||
else:
|
else:
|
||||||
import ConfigParser as configparser
|
import ConfigParser as configparser
|
||||||
import SocketServer
|
import SocketServer as socketserver
|
||||||
import threading
|
import threading
|
||||||
import logging
|
import logging
|
||||||
import logging.config
|
import logging.config
|
||||||
@ -3519,7 +3520,7 @@ class Ioctls:
|
|||||||
return validateNegotiateInfo.getData(), errorCode
|
return validateNegotiateInfo.getData(), errorCode
|
||||||
|
|
||||||
|
|
||||||
class SMBSERVERHandler(SocketServer.BaseRequestHandler):
|
class SMBSERVERHandler(socketserver.BaseRequestHandler):
|
||||||
def __init__(self, request, client_address, server, select_poll = False):
|
def __init__(self, request, client_address, server, select_poll = False):
|
||||||
self.__SMB = server
|
self.__SMB = server
|
||||||
self.__ip, self.__port = client_address
|
self.__ip, self.__port = client_address
|
||||||
@ -3528,7 +3529,7 @@ class SMBSERVERHandler(SocketServer.BaseRequestHandler):
|
|||||||
self.__timeOut = 60*5
|
self.__timeOut = 60*5
|
||||||
self.__select_poll = select_poll
|
self.__select_poll = select_poll
|
||||||
#self.__connId = os.getpid()
|
#self.__connId = os.getpid()
|
||||||
SocketServer.BaseRequestHandler.__init__(self, request, client_address, server)
|
socketserver.BaseRequestHandler.__init__(self, request, client_address, server)
|
||||||
|
|
||||||
def handle(self):
|
def handle(self):
|
||||||
self.__SMB.log("Incoming connection (%s,%d)" % (self.__ip, self.__port))
|
self.__SMB.log("Incoming connection (%s,%d)" % (self.__ip, self.__port))
|
||||||
@ -3570,13 +3571,13 @@ class SMBSERVERHandler(SocketServer.BaseRequestHandler):
|
|||||||
# Thread/process is dying, we should tell the main SMB thread to remove all this thread data
|
# Thread/process is dying, we should tell the main SMB thread to remove all this thread data
|
||||||
self.__SMB.log("Closing down connection (%s,%d)" % (self.__ip, self.__port))
|
self.__SMB.log("Closing down connection (%s,%d)" % (self.__ip, self.__port))
|
||||||
self.__SMB.removeConnection(self.__connId)
|
self.__SMB.removeConnection(self.__connId)
|
||||||
return SocketServer.BaseRequestHandler.finish(self)
|
return socketserver.BaseRequestHandler.finish(self)
|
||||||
|
|
||||||
class SMBSERVER(SocketServer.ThreadingMixIn, SocketServer.TCPServer):
|
class SMBSERVER(socketserver.ThreadingMixIn, socketserver.TCPServer):
|
||||||
#class SMBSERVER(SocketServer.ForkingMixIn, SocketServer.TCPServer):
|
#class SMBSERVER(socketserver.ForkingMixIn, socketserver.TCPServer):
|
||||||
def __init__(self, server_address, handler_class=SMBSERVERHandler, config_parser = None):
|
def __init__(self, server_address, handler_class=SMBSERVERHandler, config_parser = None):
|
||||||
SocketServer.TCPServer.allow_reuse_address = True
|
socketserver.TCPServer.allow_reuse_address = True
|
||||||
SocketServer.TCPServer.__init__(self, server_address, handler_class)
|
socketserver.TCPServer.__init__(self, server_address, handler_class)
|
||||||
|
|
||||||
# Server name and OS to be presented whenever is necessary
|
# Server name and OS to be presented whenever is necessary
|
||||||
self.__serverName = ''
|
self.__serverName = ''
|
||||||
|
@ -31,7 +31,7 @@ MechTypes = {
|
|||||||
'*\x86H\x86\xf7\x12\x01\x02\x02': 'KRB5 - Kerberos 5',
|
'*\x86H\x86\xf7\x12\x01\x02\x02': 'KRB5 - Kerberos 5',
|
||||||
'*\x86H\x86\xf7\x12\x01\x02\x02\x03': 'KRB5 - Kerberos 5 - User to User'
|
'*\x86H\x86\xf7\x12\x01\x02\x02\x03': 'KRB5 - Kerberos 5 - User to User'
|
||||||
}
|
}
|
||||||
TypesMech = dict((v,k) for k, v in MechTypes.iteritems())
|
TypesMech = dict((v,k) for k, v in MechTypes.items())
|
||||||
|
|
||||||
def asn1encode(data = ''):
|
def asn1encode(data = ''):
|
||||||
#res = asn1.SEQUENCE(str).encode()
|
#res = asn1.SEQUENCE(str).encode()
|
||||||
|
Loading…
Reference in New Issue
Block a user