| 1781 | |
| 1782 | |
| 1783 | class SMB2_Header(Packet): |
| 1784 | __slots__ = ["_decrypted"] |
| 1785 | |
| 1786 | name = "SMB2 Header" |
| 1787 | fields_desc = [ |
| 1788 | StrFixedLenField("Start", b"\xfeSMB", 4), |
| 1789 | LEShortField("StructureSize", 64), |
| 1790 | LEShortField("CreditCharge", 0), |
| 1791 | LEIntEnumField("Status", 0, STATUS_ERREF), |
| 1792 | LEShortEnumField("Command", 0, SMB2_COM), |
| 1793 | LEShortField("CreditRequest", 0), |
| 1794 | FlagsField( |
| 1795 | "Flags", |
| 1796 | 0, |
| 1797 | -32, |
| 1798 | { |
| 1799 | 0x00000001: "SMB2_FLAGS_SERVER_TO_REDIR", |
| 1800 | 0x00000002: "SMB2_FLAGS_ASYNC_COMMAND", |
| 1801 | 0x00000004: "SMB2_FLAGS_RELATED_OPERATIONS", |
| 1802 | 0x00000008: "SMB2_FLAGS_SIGNED", |
| 1803 | 0x10000000: "SMB2_FLAGS_DFS_OPERATIONS", |
| 1804 | 0x20000000: "SMB2_FLAGS_REPLAY_OPERATION", |
| 1805 | }, |
| 1806 | ), |
| 1807 | XLEIntField("NextCommand", 0), |
| 1808 | LELongField("MID", 0), # MessageID |
| 1809 | # ASYNC |
| 1810 | ConditionalField( |
| 1811 | LELongField("AsyncId", 0), lambda pkt: pkt.Flags.SMB2_FLAGS_ASYNC_COMMAND |
| 1812 | ), |
| 1813 | # SYNC |
| 1814 | ConditionalField( |
| 1815 | LEIntField("PID", 0), # Reserved, but PID per wireshark |
| 1816 | lambda pkt: not pkt.Flags.SMB2_FLAGS_ASYNC_COMMAND, |
| 1817 | ), |
| 1818 | ConditionalField( |
| 1819 | LEIntField("TID", 0), # TreeID |
| 1820 | lambda pkt: not pkt.Flags.SMB2_FLAGS_ASYNC_COMMAND, |
| 1821 | ), |
| 1822 | # COMMON |
| 1823 | LELongField("SessionId", 0), |
| 1824 | XStrFixedLenField("SecuritySignature", 0, length=16), |
| 1825 | ] |
| 1826 | |
| 1827 | _SMB2_OK_RETURNCODES = ( |
| 1828 | # sect 3.3.4.4 |
| 1829 | (0xC0000016, 0x0001), # STATUS_MORE_PROCESSING_REQUIRED |
| 1830 | (0x80000005, 0x0008), # STATUS_BUFFER_OVERFLOW (Read) |
| 1831 | (0x80000005, 0x0010), # STATUS_BUFFER_OVERFLOW (QueryInfo) |
| 1832 | (0x80000005, 0x000B), # STATUS_BUFFER_OVERFLOW (IOCTL) |
| 1833 | (0xC000000D, 0x000B), # STATUS_INVALID_PARAMETER |
| 1834 | (0x0000010C, 0x000F), # STATUS_NOTIFY_ENUM_DIR |
| 1835 | ) |
| 1836 | |
| 1837 | def __init__(self, *args, **kwargs): |
| 1838 | # The parent passes whether this packet was decrypted or not. |
| 1839 | self._decrypted = kwargs.pop("_decrypted", False) |
| 1840 | super(SMB2_Header, self).__init__(*args, **kwargs) |
no test coverage detected
searching dependent graphs…