LSDTrip - Take a ride down the LaunchServices.framework
rabbithole
What is this?
(yet another) simple command line utility, which can be used to explore the lesser known reaches of
The tool behaves differently on MacOS and the iOS variants. In the former, you have full LS*
calls (re-exported by LSApplication[Workspace/Proxy]
. Which explains the messy performSelector
in the code - I wanted to do this in pure C, but ended up resorting to Obj-c eventually.
This is (somewhat messy) open source, so you can learn a lot on how to use these many useful functions, like finding which app is in the foreground/visible, dumping info, finding item claims, etc..
Examples
All flavors:
Usage: lsdtrip [apps|plugins] [-v] app _bundle_id_ (implies -v for this app) whohas _url_ types dump
- apps will give you a list of all the apps.
-v
will dump verbose, as will... - app bundle_id dumps verbose information for that spefic bundle identifier (implies -v). Note that this is only partial info, but I left comments in the code to show the full scope - which basically boils down to dumping
LSApplicationProxy
- plugins will give you a list of all the app plugins. But you knew that already. No -v here.
- whohas: Shows all claims to the particular URL scheme. For example to find your default browser:
- types: shows all the UTIs (terrible acronym, guys) known to the system (i.e. registered by Apps with
CFBundleDocumentTypes
) - dump: Spits out the full LaunchServices database. This is super useful, pretty neat, and is exactly like the
lsregister
function of the same name.
MacOS:
app _bundle_id_ (implies -v for this app) front [-v] visible listen (Get app launch/foreground notifications - cool) shmem metainfo [app|memory|notification|port|session]status whohas _url_ types dump
After reversing the shiznits out of lsappinfo(8)
, MacOS's hidden gem, I replicated its best functionality, including some undocumented (the ...stati calls up there). This provides great samples on how to get the frontmost application (which will be the Terminal usually, but you can prepend sleep 5;
before lsdtrip
and switch app to test this, as well as the visible
application list.
A not-so-new feature which was just disabled for the longest time is "listen", which registers a notification handler for application lifecycle and visibility events:
Another useful feature is shmem
which dumps the shared memory provided by launchservicesd
. This shared memory region (usually 4 pages) captures the visibility state of all applications, and helps determine the frontmost application and z-indices (though there are LS* wrappers to do all that as well).
metainfo
is really interesting, as are the various stati. Tons of output, so try it for yourself. Haven't found *OS counterparts for this , yet.
*OS:
Usage: lsdtrip [apps|plugins|publicurls|privateurls] [-v] launch _bundle_id_ advid [clear]
- publicurls and privateurls: Gets you a list of all DocumentURLTypes registered, as well as the identity of their default claim, with
-v
. This is super useful to test applications (possibly finding an interesting attack surface). And you can launch the URLs, too. Try diags://foo in MobileSafari. :-) - launch: 'Nuff said. (and also useful to launch SBAppTags Hidden apps)
- advid Your advertising identifier
Entitlements:
- MacOS: None (yet - still works well in 10.13!)
- iOS: Who cares? you can
jtool --sign --ent ls.ent --inplace
(see Makefile).
Downloads
License, etc:
As will my other open sources, free - but be so kind as to at least leave the sources intact, give credit, or something. At the very least, don't github this and claim it as your own. People have been doing that, and it's $%#$% annoying and makes me want to quit releasing these things openly.
Code is messy and could seriously use cleanup. I keep updating this as I go along, so wait for those "notyet"s :-)
Comments/Feedback:
Via the Book Forum, please
If you haven't checked out MOXiI Volume I's Table of Contents - give it a glance. It's pretty much final, but I'm always flexible for last minute suggestions (via forum)