Skip to content

Conversation

@MalwareEZ
Copy link

@MalwareEZ MalwareEZ commented Dec 22, 2025

Description

While using GHunt 2.3.3, an IndexError: list index out of range occurs when fetching Google Maps data (email and gaia commands).

The crash happens in ghunt/helpers/gmaps.py inside get_reviews(), where the code assumes that the Maps response always contains specific indexes (data[24] for reviews and data[22] for photos). In practice, Google sometimes returns shorter or structurally different responses (private profiles, empty data, or format changes), which causes GHunt to crash instead of handling the situation gracefully.

Fix:
This PR adds defensive length checks before accessing those indexes:

  • If the expected index does not exist or is empty, the function returns "private" instead of raising an exception.
  • This preserves the existing logic while preventing GHunt from crashing.

Impact:

  • Fixes crashes on ghunt email and ghunt gaia
  • No behavior change when data is present
  • Makes Google Maps parsing more robust against response format changes

Details

Before :

🗺️ Maps data
Traceback (most recent call last):
  File "/root/.local/bin/ghunt", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/root/.local/share/pipx/venvs/ghunt/lib/python3.11/site-packages/ghunt/ghunt.py", line 18, in main
    parse_and_run()
  File "/root/.local/share/pipx/venvs/ghunt/lib/python3.11/site-packages/ghunt/cli.py", line 63, in parse_and_run
    process_args(args)
  File "/root/.local/share/pipx/venvs/ghunt/lib/python3.11/site-packages/ghunt/cli.py", line 73, in process_args
    asyncio.run(email.hunt(None, args.email_address, args.json))
  File "/root/.pyenv/versions/3.11.13/lib/python3.11/asyncio/runners.py", line 190, in run
    return runner.run(main)
           ^^^^^^^^^^^^^^^^
  File "/root/.pyenv/versions/3.11.13/lib/python3.11/asyncio/runners.py", line 118, in run
    return self._loop.run_until_complete(task)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.pyenv/versions/3.11.13/lib/python3.11/asyncio/base_events.py", line 654, in run_until_complete
    return future.result()
           ^^^^^^^^^^^^^^^
  File "/root/.local/share/pipx/venvs/ghunt/lib/python3.11/site-packages/ghunt/modules/email.py", line 117, in hunt
    err, stats, reviews, photos = await gmaps.get_reviews(as_client, target.personId)
                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/root/.local/share/pipx/venvs/ghunt/lib/python3.11/site-packages/ghunt/helpers/gmaps.py", line 84, in get_reviews
    if not data[24]:
           ~~~~^^^^
IndexError: list index out of range

The crash is caused by unsafe indexing in ghunt/helpers/gmaps.py, where the Google Maps response is assumed to always contain specific indexes:

# Reviews
if category == "reviews":
    if not data[24]:
        return "private", stats, [], []
elif category == "photos":
    if not data[22]:
        return "private", stats, [], []

When the Maps response is shorter or structured differently, accessing data[24] or data[22] raises:

IndexError: list index out of range

Fix (defensive checks)

# Reviews
if category == "reviews":
    if len(data) <= 24 or not data[24]:
        return "private", stats, [], []
# Photos
elif category == "photos":
    if len(data) <= 22 or not data[22]:
        return "private", stats, [], []

After

🗺️ Maps data

Profile page : https://www.google.com/maps/contrib/<id_anonyme>/reviews

[Statistics]
Reviews : 2
Answers : 17

[-] Reviews are private.

🗓️ Calendar data

[-] No public Google Calendar.

While using GHunt 2.3.3, an IndexError: list index out of range occurs when fetching Google Maps data (email and gaia commands).

The crash happens in ghunt/helpers/gmaps.py inside get_reviews(), where the code assumes that the Maps response always contains specific indexes (data[24] for reviews and data[22] for photos).
In practice, Google sometimes returns shorter or structurally different responses (private profiles, empty data, or format changes), which causes GHunt to crash instead of handling the situation gracefully.

Fix:
This PR adds defensive length checks before accessing those indexes:

If the expected index does not exist or is empty, the function returns "private" instead of raising an exception.

This preserves the existing logic while preventing GHunt from crashing.

Impact:
Fixes crashes on ghunt email and ghunt gaia

No behavior change when data is present

Makes Google Maps parsing more robust against response format changes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant