GithubHelp home page GithubHelp logo

ruilisi / swiftprivilegedhelper Goto Github PK

View Code? Open in Web Editor NEW

This project forked from erikberglund/swiftprivilegedhelper

0.0 2.0 0.0 917 KB

Example application using a privileged helper tool with authentication in an unsandboxed application written in Swift

License: MIT License

Swift 88.63% Shell 11.37%

swiftprivilegedhelper's Introduction

SwiftPrivilegedHelper

This is an example application to demonstrate how to use a privileged helper tool with authentication in Swift 4.2.

NOTE: Privilege escalation is not supported in sandboxed applications.

Please undestand the code and improve and customize it to suit your needs and your application.

Updated for Swift 4.2

I have rewritten the whole project for Swift 4.2 and improved the example in many places:

  • Automatic Code Signing
    Now the project uses automatic code signing, you no longer have to manually edit the code signing information in the app or helper plists.

  • Connection Validation
    Now the helper validates that the calling application is signed using the same signing certificate as the calling application to avoid a simple attack vector for helper tools.

Index

Requirements

  • Tool and language versions
    This project was created and only tested using Xcode Version 10.0 (10A255) and Swift 4.2.

  • Developer Certificate
    To use a privileged helper tool the application and helper has to be signed by a valid deverloper certificate.

  • SMJobBlessUtil
    The python tool for verifying signing of applications using SMJobBless included in the SMJobBless example project is extremely useful for troubleshooting signing issues.

Dowload it here: SMJobBlessUtil.py

Use it like this: ./SMJobBlessUtil.py check /path/to/MyApplication.app

Setup

To test the project, you need to update it to use your own signing certificate.

Select signing team

  1. Select the project in the navigator.
  2. For both the application and helper targets:
  3. Change the signing Team to your Team.

Signing Troubleshooting

Use SMJobBlessUtil.py and correct all issues reported until it doesn't show any output.

Note: Changing BundleIdentifier

The project uses a bash script to automatically update the needed code signing requirements for your current certificate so that they will be correct both during normal builds and archiving.

This script has hardcoded bundle identifiers for the app and the helper, so if you change the bundle identifiers for any of these you have to update the script accordingly.

Application

The helper is installed by using SMJobBless.

When installed, you can enter a directory path in the text field at the top and select to run the /bin/ls command (with the entered path as argument) using the helper tool with or without requiring authorization.

The application caches the authorization reference which means that you only have to authorize that action once until you press the "Destroy Cached Authorization" or restart the application.

This behaviour can easily be changed to either require authrization every time, after x seconds or never.

Adding or removing code in the helper

If you modify or add/remove code that's used in the helper tool you MUST update the helper bundle version so when run the next time the application will recognize the helper has to be updated. Or else your new code will never be run.

References

Links to documentation on the authorization system on macOS.

swiftprivilegedhelper's People

Contributors

erikberglund avatar cybertunnel avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.