def get_smb_platform_data(platform: str, timestamp: float): """ Gets platform-dependent data for SMB 2 packets :param platform: the platform for which to get SMB 2 packet data :param timestamp: a timestamp for calculating the boot-time :return: server_guid, security_blob, capabilities, data_size and server_start_time of the given platform """ Util.check_platform(platform) if platform == "linux": server_guid = "ubuntu" security_blob = security_blob_ubuntu capabilities = 0x5 data_size = 0x800000 server_start_time = 0 elif platform == "macos": server_guid = binascii.b2a_hex(os.urandom(15)).decode() security_blob = security_blob_macos capabilities = 0x6 data_size = 0x400000 server_start_time = 0 else: server_guid = binascii.b2a_hex(os.urandom(15)).decode() security_blob = security_blob_windows capabilities = 0x7 data_size = 0x100000 server_start_time = Util.get_filetime_format( Util.get_rnd_boot_time(timestamp)) return server_guid, security_blob, capabilities, data_size, server_start_time
def test_get_rnd_boot_time_win(self): self.assertTrue(Utility.get_rnd_boot_time(100, "win7") < 100)
def test_get_rnd_boot_time_macos(self): self.assertTrue(Utility.get_rnd_boot_time(100, "macos") < 100)
def test_get_rnd_boot_time_linux(self): self.assertTrue(Utility.get_rnd_boot_time(100, "linux") < 100)
def test_get_rnd_boot_time_invalid(self): with self.assertRaises(ValueError): Utility.get_rnd_boot_time(10, "abc")