MCPcopy Index your code
hub / github.com/secdev/scapy / _get_file

Method _get_file

scapy/layers/smbclient.py:1554–1590  ·  view source on GitHub ↗

Gets the file bytes from a remote host

(self, file, fd)

Source from the content-addressed store, hash-verified

1552 print(result)
1553
1554 def _get_file(self, file, fd):
1555 """
1556 Gets the file bytes from a remote host
1557 """
1558 # Get pwd of the ls
1559 fpath = self.pwd / file
1560 self.smbsock.set_TID(self.current_tree)
1561 # Open file
1562 fileId = self.smbsock.create_request(
1563 self.normalize_path(fpath),
1564 type="file",
1565 extra_create_options=[
1566 "FILE_SEQUENTIAL_ONLY",
1567 ]
1568 + self.extra_create_options,
1569 )
1570 # Get the file size
1571 info = FileAllInformation(
1572 self.smbsock.query_info(
1573 FileId=fileId,
1574 InfoType="SMB2_0_INFO_FILE",
1575 FileInfoClass="FileAllInformation",
1576 )
1577 )
1578 length = info.StandardInformation.EndOfFile
1579 offset = 0
1580 # Read the file
1581 while length:
1582 lengthRead = min(self.smbsock.session.MaxReadSize, length)
1583 fd.write(
1584 self.smbsock.read_request(fileId, Length=lengthRead, Offset=offset)
1585 )
1586 offset += lengthRead
1587 length -= lengthRead
1588 # Close the file
1589 self.smbsock.close_request(fileId)
1590 return offset
1591
1592 def _send_file(self, fname, fd):
1593 """

Callers 2

getMethod · 0.95
catMethod · 0.95

Calls 8

normalize_pathMethod · 0.95
FileAllInformationClass · 0.90
set_TIDMethod · 0.80
create_requestMethod · 0.80
query_infoMethod · 0.80
read_requestMethod · 0.80
close_requestMethod · 0.80
writeMethod · 0.45

Tested by

no test coverage detected