KnugiHK / WhatsApp-Chat-Exporter

A customizable Android and iOS/iPadOS WhatsApp database parser that will give you the history of your WhatsApp conversations in HTML and JSON. Android Backup Crypt12, Crypt14, Crypt15, and new schema supported.
https://wts.knugi.dev/
MIT License
518 stars 76 forks source link

[BUG] Error when extracting iPhone media from WhatsApp backup using wtsexporter #98

Closed damianjude closed 5 days ago

damianjude commented 2 months ago

Must have

If it is an error yield by Python, please also provide the traceback

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Users\home\AppData\Roaming\Python\Python312\Scripts\wtsexporter.exe\__main__.py", line 7, in <module>
  File "C:\Users\home\AppData\Roaming\Python\Python312\site-packages\Whatsapp_Chat_Exporter\__main__.py", line 292, in main
    extract_iphone_media.extract_media(args.backup, identifiers, args.preserve_timestamp)
  File "C:\Users\home\AppData\Roaming\Python\Python312\site-packages\Whatsapp_Chat_Exporter\extract_iphone_media.py", line 85, in extract_media
    extract_encrypted(base_dir, password, identifiers, preserve_timestamp)
  File "C:\Users\home\AppData\Roaming\Python\Python312\site-packages\Whatsapp_Chat_Exporter\extract_iphone_media.py", line 23, in extract_encrypted
    backup.extract_file(
  File "C:\Users\home\AppData\Roaming\Python\Python312\site-packages\iphone_backup_decrypt\iphone_backup.py", line 272, in extract_file
    decrypted_data = self.extract_file_as_bytes(relative_path, domain)
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\home\AppData\Roaming\Python\Python312\site-packages\iphone_backup_decrypt\iphone_backup.py", line 249, in extract_file_as_bytes
    file_id, file_bplist = result
    ^^^^^^^^^^^^^^^^^^^^
TypeError: cannot unpack non-iterable NoneType object

Nice to have

Describe the bug The backup is old (from 2022), I've followed the instructions, including using the modified version of https://github.com/KnugiHK/iphone_backup_decrypt, however, it shows the same error both on macOS Sonoma and Windows 11.

To Reproduce Steps to reproduce the behaviour:

  1. pip install git+https://github.com/KnugiHK/iphone_backup_decrypt
  2. pip install whatsapp-chat-exporter
  3. wtsexporter -i -b "C:\Users\home\Desktop\00008030-00161D2634A2802E" -o "C:\Users\home\Desktop\WhatsApp"

Additional context The backup is perfectly fine AFAIK and I've extracted photos from the backup using jsharkey13/iphone_backup_decrypt version 0.6.0

KnugiHK commented 2 months ago

It could be the domain or the relative path in the database file has been changed.

damianjude commented 2 months ago

I don't think that's the issue, here are the files in the directory:

Directory of C:\Users\home\Desktop\00008030-00161D2634A2802E

01/05/2024  12:52 pm    <DIR>          .
01/05/2024  12:19 pm    <DIR>          ..
01/05/2024  12:19 pm    <DIR>          00
01/05/2024  12:19 pm    <DIR>          01
01/05/2024  12:19 pm    <DIR>          02
01/05/2024  12:20 pm    <DIR>          03
01/05/2024  12:20 pm    <DIR>          04
01/05/2024  12:20 pm    <DIR>          05
01/05/2024  12:20 pm    <DIR>          06
01/05/2024  12:20 pm    <DIR>          07
01/05/2024  12:20 pm    <DIR>          08
01/05/2024  12:20 pm    <DIR>          09
01/05/2024  12:20 pm    <DIR>          0a
01/05/2024  12:20 pm    <DIR>          0b
01/05/2024  12:21 pm    <DIR>          0c
01/05/2024  12:21 pm    <DIR>          0d
01/05/2024  12:21 pm    <DIR>          0e
01/05/2024  12:21 pm    <DIR>          0f
01/05/2024  12:21 pm    <DIR>          10
01/05/2024  12:21 pm    <DIR>          11
01/05/2024  12:21 pm    <DIR>          12
01/05/2024  12:21 pm    <DIR>          13
01/05/2024  12:22 pm    <DIR>          14
01/05/2024  12:22 pm    <DIR>          15
01/05/2024  12:22 pm    <DIR>          16
01/05/2024  12:22 pm    <DIR>          17
01/05/2024  12:22 pm    <DIR>          18
01/05/2024  12:22 pm    <DIR>          19
01/05/2024  12:23 pm    <DIR>          1a
01/05/2024  12:23 pm    <DIR>          1b
01/05/2024  12:23 pm    <DIR>          1c
01/05/2024  12:23 pm    <DIR>          1d
01/05/2024  12:23 pm    <DIR>          1e
01/05/2024  12:23 pm    <DIR>          1f
01/05/2024  12:23 pm    <DIR>          20
01/05/2024  12:24 pm    <DIR>          21
01/05/2024  12:24 pm    <DIR>          22
01/05/2024  12:24 pm    <DIR>          23
01/05/2024  12:24 pm    <DIR>          24
01/05/2024  12:24 pm    <DIR>          25
01/05/2024  12:24 pm    <DIR>          26
01/05/2024  12:24 pm    <DIR>          27
01/05/2024  12:24 pm    <DIR>          28
01/05/2024  12:25 pm    <DIR>          29
01/05/2024  12:25 pm    <DIR>          2a
01/05/2024  12:25 pm    <DIR>          2b
01/05/2024  12:25 pm    <DIR>          2c
01/05/2024  12:25 pm    <DIR>          2d
01/05/2024  12:25 pm    <DIR>          2e
01/05/2024  12:25 pm    <DIR>          2f
01/05/2024  12:25 pm    <DIR>          30
01/05/2024  12:25 pm    <DIR>          31
01/05/2024  12:26 pm    <DIR>          32
01/05/2024  12:26 pm    <DIR>          33
01/05/2024  12:26 pm    <DIR>          34
01/05/2024  12:26 pm    <DIR>          35
01/05/2024  12:26 pm    <DIR>          36
01/05/2024  12:26 pm    <DIR>          37
01/05/2024  12:26 pm    <DIR>          38
01/05/2024  12:26 pm    <DIR>          39
01/05/2024  12:26 pm    <DIR>          3a
01/05/2024  12:26 pm    <DIR>          3b
01/05/2024  12:27 pm    <DIR>          3c
01/05/2024  12:27 pm    <DIR>          3d
01/05/2024  12:27 pm    <DIR>          3e
01/05/2024  12:27 pm    <DIR>          3f
01/05/2024  12:27 pm    <DIR>          40
01/05/2024  12:27 pm    <DIR>          41
01/05/2024  12:27 pm    <DIR>          42
01/05/2024  12:27 pm    <DIR>          43
01/05/2024  12:28 pm    <DIR>          44
01/05/2024  12:28 pm    <DIR>          45
01/05/2024  12:28 pm    <DIR>          46
01/05/2024  12:28 pm    <DIR>          47
01/05/2024  12:28 pm    <DIR>          48
01/05/2024  12:28 pm    <DIR>          49
01/05/2024  12:28 pm    <DIR>          4a
01/05/2024  12:28 pm    <DIR>          4b
01/05/2024  12:28 pm    <DIR>          4c
01/05/2024  12:28 pm    <DIR>          4d
01/05/2024  12:28 pm    <DIR>          4e
01/05/2024  12:29 pm    <DIR>          4f
01/05/2024  12:29 pm    <DIR>          50
01/05/2024  12:29 pm    <DIR>          51
01/05/2024  12:29 pm    <DIR>          52
01/05/2024  12:29 pm    <DIR>          53
01/05/2024  12:29 pm    <DIR>          54
01/05/2024  12:29 pm    <DIR>          55
01/05/2024  12:29 pm    <DIR>          56
01/05/2024  12:30 pm    <DIR>          57
01/05/2024  12:30 pm    <DIR>          58
01/05/2024  12:30 pm    <DIR>          59
01/05/2024  12:30 pm    <DIR>          5a
01/05/2024  12:30 pm    <DIR>          5b
01/05/2024  12:30 pm    <DIR>          5c
01/05/2024  12:30 pm    <DIR>          5d
01/05/2024  12:30 pm    <DIR>          5e
01/05/2024  12:30 pm    <DIR>          5f
01/05/2024  12:30 pm    <DIR>          60
01/05/2024  12:30 pm    <DIR>          61
01/05/2024  12:30 pm    <DIR>          62
01/05/2024  12:31 pm    <DIR>          63
01/05/2024  12:31 pm    <DIR>          64
01/05/2024  12:31 pm    <DIR>          65
01/05/2024  12:31 pm    <DIR>          66
01/05/2024  12:31 pm    <DIR>          67
01/05/2024  12:31 pm    <DIR>          68
01/05/2024  12:31 pm    <DIR>          69
01/05/2024  12:31 pm    <DIR>          6a
01/05/2024  12:32 pm    <DIR>          6b
01/05/2024  12:32 pm    <DIR>          6c
01/05/2024  12:32 pm    <DIR>          6d
01/05/2024  12:32 pm    <DIR>          6e
01/05/2024  12:32 pm    <DIR>          6f
01/05/2024  12:32 pm    <DIR>          70
01/05/2024  12:32 pm    <DIR>          71
01/05/2024  12:32 pm    <DIR>          72
01/05/2024  12:32 pm    <DIR>          73
01/05/2024  12:33 pm    <DIR>          74
01/05/2024  12:33 pm    <DIR>          75
01/05/2024  12:33 pm    <DIR>          76
01/05/2024  12:33 pm    <DIR>          77
01/05/2024  12:33 pm    <DIR>          78
01/05/2024  12:33 pm    <DIR>          79
01/05/2024  12:33 pm    <DIR>          7a
01/05/2024  12:33 pm    <DIR>          7b
01/05/2024  12:34 pm    <DIR>          7c
01/05/2024  12:34 pm    <DIR>          7d
01/05/2024  12:34 pm    <DIR>          7e
01/05/2024  12:34 pm    <DIR>          7f
01/05/2024  12:34 pm    <DIR>          80
01/05/2024  12:34 pm    <DIR>          81
01/05/2024  12:34 pm    <DIR>          82
01/05/2024  12:35 pm    <DIR>          83
01/05/2024  12:35 pm    <DIR>          84
01/05/2024  12:35 pm    <DIR>          85
01/05/2024  12:35 pm    <DIR>          86
01/05/2024  12:35 pm    <DIR>          87
01/05/2024  12:35 pm    <DIR>          88
01/05/2024  12:35 pm    <DIR>          89
01/05/2024  12:35 pm    <DIR>          8a
01/05/2024  12:35 pm    <DIR>          8b
01/05/2024  12:36 pm    <DIR>          8c
01/05/2024  12:36 pm    <DIR>          8d
01/05/2024  12:36 pm    <DIR>          8e
01/05/2024  12:36 pm    <DIR>          8f
01/05/2024  12:36 pm    <DIR>          90
01/05/2024  12:36 pm    <DIR>          91
01/05/2024  12:36 pm    <DIR>          92
01/05/2024  12:36 pm    <DIR>          93
01/05/2024  12:36 pm    <DIR>          94
01/05/2024  12:36 pm    <DIR>          95
01/05/2024  12:37 pm    <DIR>          96
01/05/2024  12:37 pm    <DIR>          97
01/05/2024  12:37 pm    <DIR>          98
01/05/2024  12:37 pm    <DIR>          99
01/05/2024  12:37 pm    <DIR>          9a
01/05/2024  12:37 pm    <DIR>          9b
01/05/2024  12:37 pm    <DIR>          9c
01/05/2024  12:37 pm    <DIR>          9d
01/05/2024  12:38 pm    <DIR>          9e
01/05/2024  12:38 pm    <DIR>          9f
01/05/2024  12:38 pm    <DIR>          a0
01/05/2024  12:38 pm    <DIR>          a1
01/05/2024  12:38 pm    <DIR>          a2
01/05/2024  12:38 pm    <DIR>          a3
01/05/2024  12:38 pm    <DIR>          a4
01/05/2024  12:38 pm    <DIR>          a5
01/05/2024  12:38 pm    <DIR>          a6
01/05/2024  12:38 pm    <DIR>          a7
01/05/2024  12:39 pm    <DIR>          a8
01/05/2024  12:39 pm    <DIR>          a9
01/05/2024  12:39 pm    <DIR>          aa
01/05/2024  12:39 pm    <DIR>          ab
01/05/2024  12:39 pm    <DIR>          ac
01/05/2024  12:39 pm    <DIR>          ad
01/05/2024  12:40 pm    <DIR>          ae
01/05/2024  12:40 pm    <DIR>          af
01/05/2024  12:40 pm    <DIR>          b0
01/05/2024  12:40 pm    <DIR>          b1
01/05/2024  12:40 pm    <DIR>          b2
01/05/2024  12:40 pm    <DIR>          b3
01/05/2024  12:40 pm    <DIR>          b4
01/05/2024  12:40 pm    <DIR>          b5
01/05/2024  12:40 pm    <DIR>          b6
01/05/2024  12:40 pm    <DIR>          b7
01/05/2024  12:41 pm    <DIR>          b8
01/05/2024  12:41 pm    <DIR>          b9
01/05/2024  12:41 pm    <DIR>          ba
01/05/2024  12:41 pm    <DIR>          bb
01/05/2024  12:41 pm    <DIR>          bc
01/05/2024  12:43 pm    <DIR>          bd
01/05/2024  12:43 pm    <DIR>          be
01/05/2024  12:43 pm    <DIR>          bf
01/05/2024  12:43 pm    <DIR>          c0
01/05/2024  12:44 pm    <DIR>          c1
01/05/2024  12:44 pm    <DIR>          c2
01/05/2024  12:44 pm    <DIR>          c3
01/05/2024  12:44 pm    <DIR>          c4
01/05/2024  12:44 pm    <DIR>          c5
01/05/2024  12:45 pm    <DIR>          c6
01/05/2024  12:45 pm    <DIR>          c7
01/05/2024  12:45 pm    <DIR>          c8
01/05/2024  12:45 pm    <DIR>          c9
01/05/2024  12:46 pm    <DIR>          ca
01/05/2024  12:46 pm    <DIR>          cb
01/05/2024  12:46 pm    <DIR>          cc
01/05/2024  12:46 pm    <DIR>          cd
01/05/2024  12:46 pm    <DIR>          ce
01/05/2024  12:46 pm    <DIR>          cf
01/05/2024  12:46 pm    <DIR>          d0
01/05/2024  12:46 pm    <DIR>          d1
01/05/2024  12:47 pm    <DIR>          d2
01/05/2024  12:47 pm    <DIR>          d3
01/05/2024  12:47 pm    <DIR>          d4
01/05/2024  12:47 pm    <DIR>          d5
01/05/2024  12:47 pm    <DIR>          d6
01/05/2024  12:47 pm    <DIR>          d7
01/05/2024  12:48 pm    <DIR>          d8
01/05/2024  12:48 pm    <DIR>          d9
01/05/2024  12:48 pm    <DIR>          da
01/05/2024  12:48 pm    <DIR>          db
01/05/2024  12:48 pm    <DIR>          dc
01/05/2024  12:48 pm    <DIR>          dd
01/05/2024  12:49 pm    <DIR>          de
01/05/2024  12:49 pm    <DIR>          df
01/05/2024  12:49 pm    <DIR>          e0
01/05/2024  12:49 pm    <DIR>          e1
01/05/2024  12:49 pm    <DIR>          e2
01/05/2024  12:49 pm    <DIR>          e3
01/05/2024  12:49 pm    <DIR>          e4
01/05/2024  12:49 pm    <DIR>          e5
01/05/2024  12:50 pm    <DIR>          e6
01/05/2024  12:50 pm    <DIR>          e7
01/05/2024  12:50 pm    <DIR>          e8
01/05/2024  12:50 pm    <DIR>          e9
01/05/2024  12:50 pm    <DIR>          ea
01/05/2024  12:50 pm    <DIR>          eb
01/05/2024  12:50 pm    <DIR>          ec
01/05/2024  12:50 pm    <DIR>          ed
01/05/2024  12:50 pm    <DIR>          ee
01/05/2024  12:50 pm    <DIR>          ef
01/05/2024  12:50 pm    <DIR>          f0
01/05/2024  12:50 pm    <DIR>          f1
01/05/2024  12:51 pm    <DIR>          f2
01/05/2024  12:51 pm    <DIR>          f3
01/05/2024  12:51 pm    <DIR>          f4
01/05/2024  12:51 pm    <DIR>          f5
01/05/2024  12:51 pm    <DIR>          f6
01/05/2024  12:51 pm    <DIR>          f7
01/05/2024  12:51 pm    <DIR>          f8
01/05/2024  12:51 pm    <DIR>          f9
01/05/2024  12:51 pm    <DIR>          fa
01/05/2024  12:51 pm    <DIR>          fb
01/05/2024  12:52 pm    <DIR>          fc
01/05/2024  12:52 pm    <DIR>          fd
01/05/2024  12:52 pm    <DIR>          fe
01/05/2024  12:52 pm    <DIR>          ff
24/08/2022  05:40 pm           138,696 Info.plist
24/08/2022  05:34 pm        12,320,784 Manifest.db
24/08/2022  05:34 pm            89,809 Manifest.plist
24/08/2022  05:36 pm               189 Status.plist
KnugiHK commented 2 months ago

I mean the data inside Manifest.db. You can try to investigate the database with DB Browser for SQLite.

damianjude commented 1 month ago

Sorry for the late reply, I tried opening it in DB Browser, it gives an error saying "file is not a database", which is quite weird considering that jsharkey13/iphone_backup_decrypt could do it. Any ideas on how to fix it? Or what is the error about?

KnugiHK commented 1 week ago

Could you try again with the dev branch of both this exporter and KnugiHK/iphone_backup_decrypt?

damianjude commented 1 week ago

I installed the dev branch of both KnugiHK/WhatsApp-Chat-Exporter and KnugiHK/iphone_backup_decrypt using pip install git+https://github.com/KnugiHK/WhatsApp-Chat-Exporter.git@dev and pip install git+https://github.com/KnugiHK/iphone_backup_decrypt.git@dev respectively, here's the error when I run the command:

PS C:\Users\home> wtsexporter -i -b "C:\Users\home\Desktop\00008030-00161D2634A2802E" -o "C:\Users\home\Desktop\WhatsApp"
Encryption detected on the backup!
Enter the password for the backup:
Trying to decrypt the iOS backup...Done
Decrypting WhatsApp database...Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Users\home\AppData\Roaming\Python\Python312\Scripts\wtsexporter.exe\__main__.py", line 7, in <module>
  File "C:\Users\home\AppData\Roaming\Python\Python312\site-packages\Whatsapp_Chat_Exporter\__main__.py", line 406, in main
    ios_media_handler.extract_media(args.backup, identifiers, args.decrypt_chunk_size)
  File "C:\Users\home\AppData\Roaming\Python\Python312\site-packages\Whatsapp_Chat_Exporter\ios_media_handler.py", line 83, in extract_media
    extract_encrypted(base_dir, password, identifiers, decrypt_chunk_size)
  File "C:\Users\home\AppData\Roaming\Python\Python312\site-packages\Whatsapp_Chat_Exporter\ios_media_handler.py", line 28, in extract_encrypted
    backup.extract_file(
  File "C:\Users\home\AppData\Roaming\Python\Python312\site-packages\iphone_backup_decrypt\iphone_backup.py", line 292, in extract_file
    file_id, file_bplist = self._file_metadata_from_manifest(relative_path, domain_like)
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\home\AppData\Roaming\Python\Python312\site-packages\iphone_backup_decrypt\iphone_backup.py", line 170, in _file_metadata_from_manifest
    raise FileNotFoundError
FileNotFoundError
KnugiHK commented 6 days ago

It seems that the required files are not presented in your manifest database. Could you open your manifest file and look for files with the following identifiers?

damianjude commented 5 days ago

Both of them aren't present, may I know what those files are?

KnugiHK commented 5 days ago

Those files are from WhatsApp's chat and contact database. Is it possible that the WhatsApp you have installed is the business version?

damianjude commented 5 days ago

Oh, that's interesting. Not at all, I had installed the normal WhatsApp. It's weird considering that I had backed up WhatsApp. Let me try to decrypt with jsharkey13/iphone_backup_decrypt

damianjude commented 5 days ago

I tried to decrypt the backup using jsharkey13/iphone_backup_decrypt, and it turns out that I hadn't backed up WhatsApp at all. My apologies for the oversight. Thank you for your assistance!

KnugiHK commented 5 days ago

I do have a takeaway that we could improve the exception handling to clearly tell the user that the WhatsApp files are not present in their backup.