一个mac上的app需要在/Applications/My.app/Contents/MacOS路径下创建一个配置文件,在开启root权限的账户下运行时ok,但是在没有开启root权限的账户下运行时,创建文件会失败,报"Permission Denied"

花时间了解了一下mac上的应用提权,由于安全的原因,提权方式一直在调整,目前苹果推荐的方式是使用Security Manager,并提供了一个例子:SMJobBless

以下引用自stackoverflow http://stackoverflow.com/questions/18404884/c-show-osx-permission-dialog

"

Originally, Apple provided a function 'AuthorizationExecuteWithPrivileges' that allowed an application to launch another with root privileges. This has since been deprecated for security reasons.

The dialog here is a bit misleading. Apple provides authorization services that launches the dialog under various different situations, but usually from an application having called the function AuthorizationCopyRights, after having setup rules in an authorization database (the file at /etc/authorization) and having created the Authorization reference with AuthorizationCreate.

Security on OSX is split between a security daemon, a security agent and applications. An application can restrict features using this system, or request authorisation for the user to enter credentials so it can launch a privileged application, which is what you need to do.

It's important to note that the dialog has not been presented by the application, but by the Security Agent, which is solely responsible for the security GUI. The daemon actually processes the authorization.

Apple's method for elevation is to have all applications run with Standard User rights and should a privileged task be required, then this must be factored out into a separate application which is registered to run with launchd and given the elevated privileges. The example Apple provides isSMJobBless.

While the calling code of the example is written in Objective-C, the important functions are just C functions in the SMJobBlessAppController.m file, most notably AuthorizationCreate to create an authorisation reference and the code in the Objective-C function blessHelperWithLabel:error: at the bottom of the file.

Begin with this help document on SMJobBless, which details the process.

Finally, if you're using Qt, you'll need to include Apple's Security framework for the required function calls. To do that, just add the following to your .pro file: -

  1. QMAKE_LFLAGS += -F /System/Library/Frameworks/Security.framework/
  2. LIBS += -framework Security

"

附:

1.Enable and using the "root" user in mac os x

https://support.apple.com/en-us/HT204012

mac上的应用提权的更多相关文章

  1. iOS冰与火之歌(番外篇) - 基于PEGASUS(Trident三叉戟)的OS X 10.11.6本地提权

    iOS冰与火之歌(番外篇) 基于PEGASUS(Trident三叉戟)的OS X 10.11.6本地提权 蒸米@阿里移动安全 0x00 序 这段时间最火的漏洞当属阿联酋的人权活动人士被apt攻击所使用 ...

  2. CGI PL PERL脚本 提权

    windows 2003 下,安装ActivePerl-5.16.2.1602-MSWin32-x86-296513 IIS 添加CGI支持.并在对应网站配置下面,添加CGI后缀或PL后缀 与 对应的 ...

  3. 从getshell到提权

    从getshell到提权 一.起因 学校推出新的党建系统,之前党建系统还参与开发,后来因为一些原因没有开发,主要想看看这届工作室的学弟.学妹代码水平,把源码撸下来审计一下,工作室用git开发的,记着上 ...

  4. 9.CVE-2016-5195(脏牛)内核提权漏洞分析

    漏洞描述: 漏洞编号:CVE-2016-5195 漏洞名称:脏牛(Dirty COW) 漏洞危害:低权限用户利用该漏洞技术可以在全版本Linux系统上实现本地提权 影响范围:Linux内核>=2 ...

  5. Linux提权小结

    原文链接:http://zone.secevery.com/article/1104 Linux提权1.信息收集2.脏牛漏洞提权3.内核漏洞exp提权4.SUID提权 0x00 基础信息收集(1):内 ...

  6. 脏牛提权CVE-2016-5195

    gcc -pthread dirtyc0w.c -o dirtyc0w 尝试使用gcc -pthread dirtyc0w.c -o dirtyc0w 编译该POC文件 gcc命令是一个编译器套件,可 ...

  7. 记一次 lampiao渗透(Drupal+脏牛提权)

    vulnhub|渗透测试lampiao 题记 最近在打靶机,发现了一个挺有意思的靶机,这里想跟大家分享一下. 环境准备 vulnhub最近出的一台靶机 靶机(https://www.vulnhub.c ...

  8. 通过Mysql提权的几种姿势

    本文记录利用mysql数据库,在拿到shell之后进行提权的两种方法. 一.UDF提权 原理:UDF是mysql的一个拓展接口,UDF(Userdefined function)让用户通过该接口可以自 ...

  9. 史上最全Linux提权后获取敏感信息方法

    http://www.freebuf.com/articles/system/23993.html 在本文开始之前,我想指出我不是专家.据我所知,在这个庞大的区域,没有一个“神奇”的答案.分享,共享( ...

随机推荐

  1. 自己封装的Ajax - JavaScript

    1. [代码][JavaScript]代码      //javascript Object: ajax Object//Created By RexLeefunction Ajax(url,data ...

  2. 【转载】U3D 游戏引擎之游戏架构脚本该如何来写

    原文:http://tech.ddvip.com/2013-02/1359996528190113.html Unity3D 游戏引擎之游戏架构脚本该如何来写   2013-02-05 00:48:4 ...

  3. hdu2552

    点击打开链接 思路: 1.tan(a+b) = ( tan(a) + tan(b) ) / (1 – tan(a) * tan(b) ) 2.tan( atan(x) ) = x arctan(1/s ...

  4. I.MX6 android 源码下载

    /************************************************************************* * I.MX6 android 源码下载 * 说明 ...

  5. BZOJ_1915_[Usaco2010 Open]奶牛的跳格子游戏_DP+单调队列

    BZOJ_1915_[Usaco2010 Open]奶牛的跳格子游戏_DP+单调队列 Description 奶牛们正在回味童年,玩一个类似跳格子的游戏,在这个游戏里,奶牛们在草地上画了一行N个格子, ...

  6. mysql连接过多-报错

    有两种方法: 1,错误连接参数 max_connect_errors,在配置文件中调整增大. 比如:修改mysql配置文件,在[mysqld]字段下面添加 max_connect_errors=102 ...

  7. 一个获取google chrome扩展crx文件信息的PHP操作类

    此类中实现了从crx文件获取扩展的Appid.获取manifest.json文件内容.将crx文件转换为一般zip文件 代码如下: <?php class CrxParserException ...

  8. E20180410-hm

    preface  n. 序言,引语; 开端,前奏; [宗] (弥撒的) 序诵,序祷;        vi. 作序; 作为…的序言,作为…的开端; 给…作序; 开始,导致; continue vi. 持 ...

  9. hdu2476【区间DP,未完待续】

    好难搞得东西.... 题意都懒得写了,看题解的巨巨莫怪啊,未完待续未完待续,回去睡觉.

  10. lightoj 1025【区间DP】

    题意: 给出一个word,求有多少种方法你从这个word清除一些字符而达到一个回文串. 思路: 区间问题,还是区间DP: 我判断小的区间有多少,然后往外扩大一点. dp[i,j]就代表从i到j的方案数 ...