{"id":25230259,"url":"https://github.com/zeroepoch/ibatlvl","last_synced_at":"2025-10-26T07:32:20.202Z","repository":{"id":12946400,"uuid":"15624439","full_name":"zeroepoch/ibatlvl","owner":"zeroepoch","description":"iOS Console Battery Level","archived":false,"fork":false,"pushed_at":"2015-12-11T04:00:00.000Z","size":16,"stargazers_count":10,"open_issues_count":0,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2023-05-22T16:15:42.960Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zeroepoch.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-01-04T02:05:55.000Z","updated_at":"2020-10-21T14:53:43.000Z","dependencies_parsed_at":"2022-09-24T06:58:22.906Z","dependency_job_id":null,"html_url":"https://github.com/zeroepoch/ibatlvl","commit_stats":null,"previous_names":[],"tags_count":0,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zeroepoch%2Fibatlvl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zeroepoch%2Fibatlvl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zeroepoch%2Fibatlvl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zeroepoch%2Fibatlvl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zeroepoch","download_url":"https://codeload.github.com/zeroepoch/ibatlvl/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238289992,"owners_count":19447509,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-02-11T11:58:44.268Z","updated_at":"2025-10-26T07:32:19.870Z","avatar_url":"https://github.com/zeroepoch.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"iBatLvl\n=======\n\niOS Console Battery Level\n\nThis is a console application, meaning no GUI or launch icon. It requires a\njailbroken iPhone to run. When this program is executed it prints the battery\ncharge level once as a percent then quits.\n\nIn order to build this application you must have XCode installed and the\niOS 7.0 SDK, which should be included with XCode. Also see the prerequisites\nbelow. To run the application type `make` then copy the `ibatlvl` executable\nto your phone using SSH and run it.\n\nThis application was compiled on a MacMini running Mac OS X 10.9.1. The\napplication was tested on an iPhone 5s GSM running 7.0.4 with the evasi0n7\njailbreak.\n\nPrerequisites\n=============\n\nBefore you can use IOKit with iOS 7.0 you need to create the symlink below\nwhich allows the compiler to find the IOKit framework during linking.\n\n```\ncd /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk/System/Library/Frameworks/IOKit.framework\nsudo ln -s Versions/A/IOKit\n```\n\nHeaders\n=======\n\nThe following headers were used to access the private APIs within IOKit on iOS.\nThese headers were copied from the desktop platform which fortunately uses the\nsame APIs.\n\n* /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/System/Library/Frameworks/IOKit.framework/Headers/ps/IOPSKeys.h\n* /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/System/Library/Frameworks/IOKit.framework/Headers/ps/IOPowerSources.h\n\nAlternatives\n============\n\nThe same information can actually be found using the `scutil` command.\n\n```\n$ scutil\n\u003e show State:/IOKit/PowerSources/InternalBattery-0\n\u003cdictionary\u003e {\n  Battery Provides Time Remaining : TRUE\n  BatteryHealth : Good\n  Current Capacity : 100\n  DesignCycleCount : 300\n  Is Charged : TRUE\n  Is Charging : FALSE\n  Is Present : TRUE\n  Max Capacity : 100\n  Name : InternalBattery-0\n  Power Source State : AC Power\n  Time to Empty : 0\n  Time to Full Charge : 0\n  Transport Type : Internal\n  Type : InternalBattery\n}\n\u003e quit\n```\n\nDebugger Script\n===============\n\nMostly for my own reference, `lldb-trace.py` is a python script for instruction\ntracing that uses lldb. The lldb client installed on the Mac desktop connects\nto a remote debug server running on the iPhone. The steps below describe how to\nprepare the `debugserver` for an iPhone 5s, how to start the `debugserver` on\nthe iPhone, and how to run the instruction tracing script on the Mac. See the\n[iPhone Development Wiki](http://iphonedevwiki.net/index.php/Debugserver) for\nadditional information. You will need to first enable developer mode on the\niPhone using the XCode organizer.\n\n```\nmac$ scp mobile@\u003ciphone_ip\u003e:/Developer/usr/bin/debugserver ~/debugserver\nmac$ /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/lipo -thin arm64 ~/debugserver -output ~/debugserver.arm64\nmac$ vim ent.xml  # see file ent.xml below\nmac$ codesign -s - --entitlements ent.xml -f ~/debugserver.arm64\nmac$ scp ~/debugserver.arm64 mobile@\u003ciphone_ip\u003e:~/debugserver.arm64\n\nios$ sudo cp ~/debugserver.arm64 /usr/bin/debugserver\n```\n\nFile: `ent.xml`\n\n```\n\u003c!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\"\u003e\n\u003cplist version=\"1.0\"\u003e\n\u003cdict\u003e\n    \u003ckey\u003ecom.apple.springboard.debugapplications\u003c/key\u003e\n    \u003ctrue/\u003e\n    \u003ckey\u003eget-task-allow\u003c/key\u003e\n    \u003ctrue/\u003e\n    \u003ckey\u003etask_for_pid-allow\u003c/key\u003e\n    \u003ctrue/\u003e\n    \u003ckey\u003erun-unsigned-code\u003c/key\u003e\n    \u003ctrue/\u003e\n\u003c/dict\u003e\n\u003c/plist\u003e\n```\n\nStart debugserver on the iPhone\n\n```\nios$ debugserver 0.0.0.0:2159 \u003cbinary\u003e\n```\n\nRun lldb python script on the Mac\n\n```\nmac$ ./lldb-trace.py -b \u003cbinary\u003e -s main\n       1: dyld[0x2be01028]:  mov    r8, sp\n       2: dyld[0x2be0102c]:  sub    sp, sp, #16\n       3: dyld[0x2be01030]:  bic    sp, sp, #7\n       4: dyld[0x2be01034]:  ldr    r3, [pc, #112]\n       5: dyld[0x2be01038]:  sub    r0, pc, #8\n       6: dyld[0x2be0103c]:  ldr    r3, [r0, r3]\n       7: dyld[0x2be01040]:  sub    r3, r0, r3\n       8: dyld[0x2be01044]:  ldr    r0, [r8]\n       9: dyld[0x2be01048]:  ldr    r1, [r8, #4]\n      10: dyld[0x2be0104c]:  add    r2, r8, #8\n```\n\nThe constants at the top of `lldb-trace.py`, such as the remote hostname, may\nneed to be modified to fit your environment.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzeroepoch%2Fibatlvl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzeroepoch%2Fibatlvl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzeroepoch%2Fibatlvl/lists"}