how to load injection lib in mac applications at application start? - objective-c

I have a dynamic library, I intent to inject in running application & newly launched applications.
I can inject it in running applications with the help of a process running with root user permissions.
Now I am trying that library should get loaded as soon as application is launched. I know one such library capable of doing this called, application enhancer. I am looking for similar behavior.
Does anyone has an Idea how can this be achieved?

Look at SIMBL agent code. It adds a observer to application launch notification and then injects. You can follow the same approach.

Related

I Want to create a application which display list of installed application with help of android service

I Want to create a application which display list of installed application with help of android service.
Which android service to use in this scenario?
It depends on what you want, you can use WorkManager , it runs synchronously in the background, and it is very flexible, espcially if you want to schedule your work. You can also use Foreground Service if you want to show a notification while your app is running. You can use Bound Service if you want to exchange data between an activty and the service.
Before android Oreo, you could useIntent Service, but starting from Oreo, it started to cause an exception. You can also still use AsyncTask but it has serveral drawbacks and AsyncTask may be deprecated in the future.
This is an overview, you haven't mentioned specific details about your app, hope this overview will help choose which way you go.

Providing a Blazor GUI from a .NET Core Console App

I am developing a computation and resource heavy back-end .NET Core console application that runs continuously in the background. In Windows, this console application will run as a Windows Service using something like NSSM. In Linux, it will run as a daemon.
In order to configure this background application, I would like to provide a Razor-based HTML5 GUI. In principle, this is similar to how a house-hold router works -- runs in the background and provides an HTML admin GUI.
QUESTION 1: Is it possible to achieve this?
QUESTION 2: Can you provide general outline of the startup/config code to make this work?

how to use privileged helper tool(installed using SMJobless) to launch other application in root privileges on osx

I have a application inside which i have kept other applications.I want to launch other application in root privilege through main application.As we know AuthorizationExecuteWithPrivileges() has been deprecated, so that i have created a privileged helper tool. I am using Main application to install this helper tool through SMJobBless() function , and communicate through XPC mechanism. Every thing is working fine, Main application sending message(Path of application to be launch) to helper tool that is already running in root mode. The helper tool is able to launch that application provided in path, but the problem is, launched application doesn't have root privilege. Can anyone tell me how i can use this helper tool to launch another application in root privilege.Or is there any other mechanism to achieve it, i will ever thankful for this.

Communicate between finder sync extension and XPC

I am working on a Finder Sync Extension for OS X and want to use a background XPC service.
I can start in the main app and have it launch the XPC and run correctly but nothing happens when I attempt to access it from the Finder Sync. both the finder sync and the XPC are their own bundles so that may be the reason why. What I am wanting is for the finder sync to talk to the XPC about the status of the files and the main app to talk to both the finder sync and XPC about the list of folders to watch.
Has anyone had any luck with this? Is there a better way for a on demand background service? Is it possible to talk between two XPC services?
Working with some Apple Engineers they realized this was a problem and suggested using a LoginItem until a better solution is in place.
So, it is sort of an XPC service, just one that constantly runs. XPC communication is available to both extension and host app.
It works, although it is not the most ideal solution. I recommend the apple sample project that deals with XPC login items for an example of how to get this working.
I implemented MainApp <-> FinderSyncExtension communication via CFMessagePorts. See my question and answer for some details:
How should Finder Sync Extension and Main App communicate?
You can't communicate directly between the container application and the extension, but you can do it indirectly using shared resources. I did exactly what you have done which is completely incorrect. I hope you store the file status in the database, if not store it and then share the database between the container application and the extension. I know, why do you want to use XPCService as it is in the Apple's FinderSync Doc. (Actually for the performance reason, Create a NSXPCService to the extension and from the XPCService, access the shared database)
For more information about sharing database:
http://blog.sam-oakley.co.uk/post/92323630293/sharing-core-data-between-app-and-extension-in-ios-8
Hope this helps you,
I had stubbornly ignored utahwithak's answer and tried to get it to work anyway. I eventually had to ask a similar question on Apple Developer Forums and finally received a definitive answer on why connecting the Finder Sync Extension to an embedded XPC service is not a viable system design.
Essentially:
Finder Sync Extension essentially behaves like a third party app in that it does not have the same scope as the host app to be able to establish an XPC connection with the embedded XPC service.
utahwithak's answer is correct in that in order to allow the Finder Sync Extension to communicate with the XPC service, it needs to be an XPC login item. However there are some caveats to this:
This seems to be an accidental feature. Not sure if it's something that might eventually be fixed/removed
The XPC will have to be always running even if it doesn't need to, by virtue of being an login item
If it's a login item, the user will need to explicitly opt in for this feature and be able to opt out.
Source:
Establishing an NSXPCConnection from a Finder Sync Extension to an XPC Service

need a way to securely communicate between Priviliged Helper Tool (installed using SMJobBless) and the application

I am trying to install a privileged helper tool to perform some elevated work. I am using SMJobBless for the same.
I am able to install the tool fine and also able to communicate with it. I am using Mac OS X 10.8.4 and using NSXPCConnection for the same.
I have added .mach service in the plist which will be installed in /Library/LaunchDaemons. I am using [initWithMachServiceName:options:] in the app as the helper is privileged tool and [– initWithMachServiceName:] in the helper to listen. The communication is working fine.
But the problem is I tried the same communication with another application I created which did not have any codesign at all (the helper tool installer earlier was codesigned). I tried to connect to the mach service of the helper tool and was able to connect easily. This is a problem because anybody can communicate with it then and make it do anything.
I wanted some way to securely communicate between my application and the helper tool.
Thanks a lot.
As you've said that you're not signing the second app, I believe that that is the problem that is allowing a 2nd app from calling the helper application. From the Apple docs and specifically the ReadMe file in SMJobBless, it states: -
The Service Management framework uses code signatures to ensure that the helper tool is the one expected to be run by the main application
This document should be able to assist you in getting the helper app correctly associated with its owner.
Note that it references a python script, which is provided here.
Answering my own question: I had logged a radar bug for the same and Apple said that the behavior was intended:
"It is up to the privileged helper to not expose insecure operations"