Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated to correctly process data of new Telegram client version #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 19 additions & 10 deletions src/TelegramStorageParser/TelegramDesktop/BlockIDs/DataBlockID.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ internal enum DataBlockID
dbiDcOptionOldOld = 0x02,
dbiChatSizeMax = 0x03,
dbiMutePeer = 0x04,
dbiSendKey = 0x05,
dbiSendKeyOld = 0x05,
dbiAutoStart = 0x06,
dbiStartMinimized = 0x07,
dbiSoundNotify = 0x08,
Expand All @@ -21,10 +21,10 @@ internal enum DataBlockID
// 0x10 reserved
dbiDefaultAttach = 0x11,
dbiCatsAndDogs = 0x12,
dbiReplaceEmoji = 0x13,
dbiReplaceEmojiOld = 0x13,
dbiAskDownloadPath = 0x14,
dbiDownloadPathOld = 0x15,
dbiScale = 0x16,
dbiScaleOld = 0x16,
dbiEmojiTabOld = 0x17,
dbiRecentEmojiOldOld = 0x18,
dbiLoggedPhoneNumber = 0x19,
Expand All @@ -45,13 +45,13 @@ internal enum DataBlockID
dbiTryIPv6 = 0x28,
dbiSongVolume = 0x29,
dbiWindowsNotificationsOld = 0x30,
dbiIncludeMuted = 0x31,
dbiIncludeMutedOld = 0x31,
dbiMegagroupSizeMax = 0x32,
dbiDownloadPath = 0x33,
dbiAutoDownload = 0x34,
dbiAutoDownloadOld = 0x34,
dbiSavedGifsLimit = 0x35,
dbiShowingSavedGifsOld = 0x36,
dbiAutoPlay = 0x37,
dbiAutoPlayOld = 0x37,
dbiAdaptiveForWide = 0x38,
dbiHiddenPinnedMessages = 0x39,
dbiRecentEmoji = 0x3a,
Expand All @@ -69,15 +69,24 @@ internal enum DataBlockID
dbiDcOptions = 0x4a,
dbiMtpAuthorization = 0x4b,
dbiLastSeenWarningSeenOld = 0x4c,
dbiAuthSessionSettings = 0x4d,
dbiSessionSettings = 0x4d,
dbiLangPackKey = 0x4e,
dbiConnectionType = 0x4f,
dbiStickersFavedLimit = 0x50,
dbiSuggestStickersByEmoji = 0x51,
dbiSuggestEmoji = 0x52,
dbiTxtDomainString = 0x53,
dbiSuggestStickersByEmojiOld = 0x51,
dbiSuggestEmojiOld = 0x52,
dbiTxtDomainStringOld = 0x53,
dbiThemeKey = 0x54,
dbiTileBackground = 0x55,
dbiCacheSettingsOld = 0x56,
dbiAnimationsDisabled = 0x57,
dbiScalePercent = 0x58,
dbiPlaybackSpeed = 0x59,
dbiLanguagesKey = 0x5a,
dbiCallSettings = 0x5b,
dbiCacheSettings = 0x5c,
dbiTxtDomainString = 0x5d,
dbiApplicationSettings = 0x5e,

dbiEncryptedWithSalt = 333,
dbiEncrypted = 444,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,24 @@ internal enum LocalStorageKey
lskUserMap = 0x00,
lskDraft = 0x01, // data: PeerId peer
lskDraftPosition = 0x02, // data: PeerId peer
lskImages = 0x03, // data: StorageKey location
lskLegacyImages = 0x03, // data: StorageKey location
lskLocations = 0x04, // no data
lskStickerImages = 0x05, // data: StorageKey location
lskAudios = 0x06, // data: StorageKey location
lskLegacyStickerImages = 0x05, // data: StorageKey location
lskLegacyAudios = 0x06, // data: StorageKey location
lskRecentStickersOld = 0x07, // no data
lskBackgroundOld = 0x08, // no data
lskUserSettings = 0x09, // no data
lskRecentHashtagsAndBots = 0x0a, // no data
lskStickersOld = 0x0b, // no data
lskSavedPeers = 0x0c, // no data
lskReportSpamStatuses = 0x0d, // no data
lskSavedPeersOld = 0x0c, // no data
lskReportSpamStatusesOld = 0x0d, // no data
lskSavedGifsOld = 0x0e, // no data
lskSavedGifs = 0x0f, // no data
lskStickersKeys = 0x10, // no data
lskTrustedBots = 0x11, // no data
lskFavedStickers = 0x12, // no data
lskExportSettings = 0x13, // no data
lskBackground = 0x14, // no data
lskSelfSerialized = 0x15 // serialized self
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ internal enum ConnectionType
HttpAuto = 1,
HttpProxy = 2,
TcpProxy = 3,
ProxiesList = 4,
ProxiesListOld = 4,
ProxiesList = 5,
}
}
4 changes: 4 additions & 0 deletions src/TelegramStorageParser/TelegramDesktop/LocalStorage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,10 @@ internal void TryParse_ExportSettings(FileKey fileKey)

DataStream stream = file.DataStream;

}
internal void TryParse_SelfSerialized(byte[] array)
{

}
internal void TryParse_ThemeLegacy(FileKey fileKey)
{
Expand Down
15 changes: 9 additions & 6 deletions src/TelegramStorageParser/TelegramDesktop/Map.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,27 +55,31 @@ private static bool ReadKey(LocalStorageKey storageKey, DataStream stream, Local
storage._draftsMap = stream.ReadDraftsMap();
return true;

case LocalStorageKey.lskSelfSerialized:
storage.TryParse_SelfSerialized(stream.ReadByteArray());
return true;

case LocalStorageKey.lskDraftPosition:
storage._draftCursorsMap = stream.ReadDraftsMap();
return true;

case LocalStorageKey.lskImages:
case LocalStorageKey.lskLegacyImages:
storage._imagesMap = stream.ReadStorageMap();
return true;

case LocalStorageKey.lskStickerImages:
case LocalStorageKey.lskLegacyStickerImages:
storage._stickersMap = stream.ReadStorageMap();
return true;

case LocalStorageKey.lskAudios:
case LocalStorageKey.lskLegacyAudios:
storage._audiosMap = stream.ReadStorageMap();
return true;

case LocalStorageKey.lskLocations:
storage.TryParse_Locations(stream.ReadUInt64());
return true;

case LocalStorageKey.lskReportSpamStatuses:
case LocalStorageKey.lskReportSpamStatusesOld:
storage.TryParse_ReportSpamStatuses(stream.ReadUInt64());
return true;

Expand Down Expand Up @@ -127,15 +131,14 @@ private static bool ReadKey(LocalStorageKey storageKey, DataStream stream, Local
storage.TryParse_SavedGifs(stream.ReadUInt64());
return true;

case LocalStorageKey.lskSavedPeers:
case LocalStorageKey.lskSavedPeersOld:
storage.TryParse_SavedPeers(stream.ReadUInt64());
return true;

case LocalStorageKey.lskExportSettings:
storage.TryParse_ExportSettings(stream.ReadUInt64());
return true;


default:
return false;
}
Expand Down
59 changes: 48 additions & 11 deletions src/TelegramStorageParser/TelegramDesktop/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,13 @@ private static bool TryReadSetting(DataBlockID blockId, DataStream stream, Local
storage.SoundNotify = stream.ReadBool();
return true;

case DataBlockID.dbiAutoDownload:
case DataBlockID.dbiAutoDownloadOld:
storage.AutoDownloadPhoto = stream.ReadBool();
storage.AutoDownloadAudio = stream.ReadBool();
storage.AutoDownloadGif = stream.ReadBool();
return true;

case DataBlockID.dbiAutoPlay:
case DataBlockID.dbiAutoPlayOld:
storage.AutoPlayGif = stream.ReadBool();
return true;

Expand All @@ -135,7 +135,7 @@ private static bool TryReadSetting(DataBlockID blockId, DataStream stream, Local
storage.ModerateModeEnabled = stream.ReadBool();
return true;

case DataBlockID.dbiIncludeMuted:
case DataBlockID.dbiIncludeMutedOld:
storage.IncludeMuted = stream.ReadBool();
return true;

Expand Down Expand Up @@ -165,7 +165,7 @@ private static bool TryReadSetting(DataBlockID blockId, DataStream stream, Local
storage.LastSeenWarningSeen = stream.ReadBool();
return true;

case DataBlockID.dbiAuthSessionSettings:
case DataBlockID.dbiSessionSettings:
storage.TryDeserialize_AuthSessionSettings(stream.ReadByteArray());
return true;

Expand All @@ -177,6 +177,10 @@ private static bool TryReadSetting(DataBlockID blockId, DataStream stream, Local
storage.TxtDomainString = stream.ReadString();
return true;

case DataBlockID.dbiTxtDomainStringOld:
stream.ReadString();
return true;

case DataBlockID.dbiConnectionTypeOld:
ConnectionType connectionTypeOld = (ConnectionType)stream.ReadInt32();
if (connectionTypeOld == ConnectionType.HttpProxy || connectionTypeOld == ConnectionType.TcpProxy)
Expand All @@ -190,7 +194,7 @@ private static bool TryReadSetting(DataBlockID blockId, DataStream stream, Local

case DataBlockID.dbiConnectionType:
ConnectionType connectionType = (ConnectionType)stream.ReadInt32();
if (connectionType == ConnectionType.ProxiesList)
if (connectionType == ConnectionType.ProxiesListOld || connectionType == ConnectionType.ProxiesList)
{
int proxyCount = stream.ReadInt32();
int proxyIndex = stream.ReadInt32();
Expand Down Expand Up @@ -269,7 +273,7 @@ private static bool TryReadSetting(DataBlockID blockId, DataStream stream, Local
storage.LoggedPhoneNumber = stream.ReadString().Replace(" ", "");
return true;

case DataBlockID.dbiSendKey:
case DataBlockID.dbiSendKeyOld:
storage.SendKey = (SendKey)stream.ReadInt32();
return true;

Expand All @@ -286,15 +290,15 @@ private static bool TryReadSetting(DataBlockID blockId, DataStream stream, Local
storage.AutoLockSeconds = stream.ReadInt32();
return true;

case DataBlockID.dbiReplaceEmoji:
case DataBlockID.dbiReplaceEmojiOld:
storage.ReplaceEmoji = stream.ReadBool();
return true;

case DataBlockID.dbiSuggestEmoji:
case DataBlockID.dbiSuggestEmojiOld:
storage.SuggestEmoji = stream.ReadBool();
return true;

case DataBlockID.dbiSuggestStickersByEmoji:
case DataBlockID.dbiSuggestStickersByEmojiOld:
storage.SuggestStickersByEmoji = stream.ReadBool();
return true;

Expand Down Expand Up @@ -338,10 +342,10 @@ private static bool TryReadSetting(DataBlockID blockId, DataStream stream, Local
storage.VideoVolume = (stream.ReadInt32() / 1e6f).Snap(0f, 1f);
return true;


// Discard - either discarded by the client or just not useful for anything

case DataBlockID.dbiScale:
case DataBlockID.dbiScaleOld:
case DataBlockID.dbiScalePercent:
case DataBlockID.dbiEmojiTabOld:
case DataBlockID.dbiDefaultAttach:
case DataBlockID.dbiShowingSavedGifsOld:
Expand Down Expand Up @@ -403,6 +407,39 @@ private static bool TryReadSetting(DataBlockID blockId, DataStream stream, Local
stream.SeekForward(4);
return true;

case DataBlockID.dbiCacheSettingsOld:
stream.SeekForward(8); //size
stream.SeekForward(4); //time
return true;

case DataBlockID.dbiCacheSettings:
stream.SeekForward(8); //size
stream.SeekForward(4); //time
stream.SeekForward(8); //sizeBig
stream.SeekForward(4); //timeBig
return true;

case DataBlockID.dbiLanguagesKey:
stream.SeekForward(8); //languagesKey
return true;

case DataBlockID.dbiPlaybackSpeed:
stream.SeekForward(4); //v
return true;

case DataBlockID.dbiCallSettings:
stream.ReadByteArray(); //callSettings
return true;


case DataBlockID.dbiApplicationSettings:
stream.ReadByteArray(); //serialized
return true;

case DataBlockID.dbiAnimationsDisabled:
stream.SeekForward(4); //disabled
return true;


default:
return false;
Expand Down