示例#1
0
async def filereader_test(connection_string, filename, proxy=None):
    #target = SMBTarget.from_connection_string(connection_string)
    #if proxy is not None:
    #	target.proxy = SMBTargetProxy.from_connection_string(proxy)
    #	print(str(target))
    #
    #credential = SMBCredential.from_connection_string(connection_string)
    cu = SMBConnectionURL(connection_string)
    credential = cu.get_credential()
    target = cu.get_target()

    print(credential)
    print(target)
    input()

    spneg = AuthenticatorBuilder.to_spnego_cred(credential, target)

    async with SMBConnection(spneg, target) as connection:
        await connection.login()

        async with SMBFileReader(connection) as reader:
            await reader.open(filename)
            data = await reader.read()
            print(data)
            """
示例#2
0
	def __init__(self, connection, filename):
		self.target = connection.target
		self.filename = filename
		self.connection = connection
		self.pipe_reader = SMBFileReader(connection)
		
		self._max_send_frag =  None
示例#3
0
async def read_file(connection_string, filename):
	target = SMBTarget.from_connection_string(connection_string)
	credential = SMBCredential.from_connection_string(connection_string)
	
	spneg = AuthenticatorBuilder.to_spnego_cred(credential, target)
	
	async with SMBConnection(spneg, target) as connection: 
		await connection.login()
		
		async with SMBFileReader(connection) as reader:
			await reader.open(filename)
			data = await reader.read()
			print(data)
示例#4
0
    async def put_file_raw(self, local_path, remote_path):
        """
		remote_path must be a full UNC path with the file name included!

		"""
        with open(local_path, 'rb') as f:
            async with SMBFileReader(self.connection) as writer:
                await writer.open(remote_path, 'w')
                while True:
                    await asyncio.sleep(0)
                    data = f.read(1024)
                    if not data:
                        break
                    await writer.write(data)
示例#5
0
async def filereader_test(target):
    #setting up NTLM auth
    template_name = 'Windows10_15063_knowkey'
    credential = Credential()
    credential.username = '******'
    credential.password = '******'
    credential.domain = 'TEST'

    settings = NTLMHandlerSettings(credential,
                                   mode='CLIENT',
                                   template_name=template_name)
    handler = NTLMAUTHHandler(settings)

    #setting up SPNEGO
    spneg = SPNEGO()
    spneg.add_auth_context(
        'NTLMSSP - Microsoft NTLM Security Support Provider', handler)
    async with SMBConnection(spneg, target) as connection:
        await connection.login()

        async with SMBFileReader(connection) as reader:
            await reader.open(
                '\\\\10.10.10.2\\Users\\Administrator\\Desktop\\smb_test\\testfile1.txt'
            )
            data = await reader.read()
            print(data)
            await reader.seek(0, 0)
            data = await reader.read()
            print(data)
            await reader.seek(10, 0)
            data = await reader.read()
            print(data)
            await reader.seek(10, 0)
            data = await reader.read(5)
            print(data)
            await reader.seek(-10, 2)
            data = await reader.read(5)
            print(data)