pwntools
pwntools copied to clipboard
`pwntools.adb.wait_for_device()` breaks when `ro.build.date` has non-standard value
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
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.