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

pwntools.adb.wait_for_device() breaks when ro.build.date has non-standard value #2513

Open
mr6r4y opened this issue Jan 2, 2025 · 1 comment

Comments

@mr6r4y
Copy link

mr6r4y commented Jan 2, 2025

Some devices return strange string in ro.build.date property:

$ adb shell getprop ro.build.date
2017年 11月 14日 星期二 09:55:07 CST

That breaks dateutil's parser and when using pwnlib.adb.wait_for_device() the following breaks:

>>> adb.wait_for_device()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/user/venvs/re/lib/python3.11/site-packages/pwnlib/context/__init__.py", line 1582, in setter
    return function(*a, **kw)
           ^^^^^^^^^^^^^^^^^^
  File "/home/user/venvs/re/lib/python3.11/site-packages/pwnlib/adb/adb.py", line 451, in wait_for_device
    _build_date()))
    ^^^^^^^^^^^^^
  File "/home/user/venvs/re/lib/python3.11/site-packages/pwnlib/adb/adb.py", line 1279, in _build_date
    as_datetime =  dateutil.parser.parse(as_string)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/venvs/re/lib/python3.11/site-packages/dateutil/parser/_parser.py", line 1368, in parse
    return DEFAULTPARSER.parse(timestr, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/venvs/re/lib/python3.11/site-packages/dateutil/parser/_parser.py", line 643, in parse
    raise ParserError("Unknown string format: %s", timestr)
dateutil.parser._parser.ParserError: Unknown string format: 2017年 11月 14日 星期二 09:55:07 CST
@RocketMaDev
Copy link

I tested my Xiaomi and it didn't print any chinese characters. It seems that the ro.build.date field depends on the system which built your android system. I notice that ro.build.date.utc is a integer, that should be safe and easy to process compared to ro.build.date.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants