osx firewall configuration file is : /Library/Preferences/com.apple.alf.plist

the default plist and firewall programs are under:/usr/libexec/ApplicationFirewall

To configure the firewall to block all incoming traffic:

  /usr/libexec/ApplicationFirewall/socketfilterfw --setblockall on

To see if block all is enabled:

  /usr/libexec/ApplicationFirewall/socketfilterfw --getblockall

  The output would be as follows, if successful:

    Firewall is set to block all non-essential incoming connections

A couple of global options that can be set. Stealth Mode:

  /usr/libexec/ApplicationFirewall/socketfilterfw --setstealthmode on

To check if stealth mode is enabled:

  /usr/libexec/ApplicationFirewall/socketfilterfw --getstealthmode

To turn on firewall logging:

  /usr/libexec/ApplicationFirewall/socketfilterfw --setloggingmode on

To control the verbosity of logs, using throttled, brief or detail:

  /usr/libexec/ApplicationFirewall/socketfilterfw --setloggingopt: detail

To start the firewall:

  /usr/libexec/ApplicationFirewall/socketfilterfw --setglobalstate on

To sanity check whether it’s started:

  /usr/libexec/ApplicationFirewall/socketfilterfw --getglobalstate

To allow signed applications:

  /usr/libexec/ApplicationFirewall/socketfilterfw --setallowsigned on

To check if you allow signed apps:

  /usr/libexec/ApplicationFirewall/socketfilterfw --getallowsigned

To show the status of each filtered application:

  /usr/libexec/ApplicationFirewall/socketfilterfw --listapps

To check if an app is blocked:

  /usr/libexec/ApplicationFirewall/socketfilterfw –getappblocked /Applications/MyApp.app/Contents/MacOS/myapp

This shows the number of exceptions, explicitly allowed apps and signed exceptions as well as process names and allowed app statuses. There is also a list of TRUSTEDAPPS, which will initially be populated by Apple tools with sharing capabilities (e.g. httpd & smbd). If you are enabling the firewall using a script, first sign your applications that need to allow sharing but are not in the TRUSTEDAPPS section by using the -s option along with the application binary (not the .app bundle):

    /usr/libexec/ApplicationFirewall/socketfilterfw -s /Applications/MyApp.app/Contents/MacOS/myapp

  Once signed, verify the signature:

    /usr/libexec/ApplicationFirewall/socketfilterfw -v /Applications/MyApp.app/Contents/MacOS/myapp

  Once signed, trust the application using the –add option:

    /usr/libexec/ApplicationFirewall/socketfilterfw --add /Applications/MyApp.app/Contents/MacOS/myapp

To see a list of trusted applications:

  /usr/libexec/ApplicationFirewall/socketfilterfw -l

config OSX firewall programmatically的更多相关文章

  1. Sharepoint学习笔记—习题系列--70-576习题解析 -(Q78-Q80)

    Question 78 You are designing an application configuration approach for a custom SharePoint 2010 app ...

  2. Linux 服务器安全技巧

    毋庸置疑,对于系统管理员,提高服务器的安全性是最重要的事情之一.因此,也就有了许多针对这个话题而生的文章.博客和论坛帖子. 一台服务器由大量功能各异的部件组成,这一点使得很难根据每个人的需求去提供定制 ...

  3. Cisco ASA 高级配置

    Cisco ASA 高级配置 一.防范IP分片攻击 1.Ip分片的原理: 2.Ip分片的安全问题: 3.防范Ip分片. 这三个问题在之前已经详细介绍过了,在此就不多介绍了.详细介绍请查看上一篇文章:I ...

  4. Windows后渗透

    My 命令行下收集主机信息 使用wmic识别安装到系统中的补丁情况: wmic qfe get description,installedOn 识别正在运行的服务: sc query type= se ...

  5. openwrt手动wifi设成client模式[笔记]

    说明:刚刷好的OPENWRT,默认是不带luci-web管理的,所以得手工SSH或TELNET上去改WIFI模式,以便通过WIFI连到现有的ROUTER去下载安装luci...: root@OpenW ...

  6. 开源入侵检测系统SELKS系统搭建

      一.系统环境配置 系统环境:centos7x64      ip地址:172.16.91.130 1.设置静态IP地址 [root@localhost backlion]#vi  /etc/sys ...

  7. shell脚本——项目1

    案例名称:系统初始化 背景:10台已装有linux系统的服务器 需求: 1.设置时区同步 2.禁用selinux 3.清空防火墙策略 4.历史命令显示操作时间 5.禁止root远程登录 6.禁止定时任 ...

  8. pfSense QoS IDS

    pfSense QoS IDS 来源 https://blanboom.org/2018/pfsense-setup/ 之前我使用的无线路由器是 RT1900ac,其内置了 QoS 和 IDS/IPS ...

  9. Hadoop_Hbase集群完全离线安装[CDH 5.13.1]

    here 一.环境准备:(这儿准备了三台虚拟机:内存6-3-3) JDK: -openjdk rpm -e java--openjdk-headless rpm -e java--openjdk-he ...

随机推荐

  1. English - Mosquitos

    Smith's house is full of mosquitos. Every night they bite him. He can not sleep because the mosquito ...

  2. ActiveMQ集群支持Master/Slave模式

    现在ActiveMQ, 在Failover方面有两种解决方案:Pure Master Slave和Shared File System Master Slave.      先看Pure Master ...

  3. Spring3中@Value注解的使用

    Spring可以通过@Value注解来直接获取properties文件里面配置的值. 1. 首先要在spring的配置文件中指明properties文件的位置: <context:propert ...

  4. [CF161D]Distance in Tree-树状dp

    Problem Distance in tree 题目大意 给出一棵树,求这棵树上有多少个最短距离为k的点对. Solution 这个题目可以用点分治来做,然而我到现在还是没有学会点分治,所以只好用树 ...

  5. JS内置对象学习总结

    日期对象: 创建日期对象: var date=new Date();//创建日期对象 设置/返回年份方法: date.getFullYear(); date.setFullYear(); 返回星期的方 ...

  6. 对于mariadb安装后可以默认使用无密码登录的问题解决方案

    mariadb安装后默认可以无密码登录 所以首先我们要设置root用户的密码 mysqladmin -u root -p password 密码 [遇到enter直接enter就行,注意,如果是重新设 ...

  7. Jvm垃圾收集器和垃圾回收算法

    概述: 目前内存的动态分配和内存的回收技术已经相当成熟,一切看起来都已经进入了“自动化”时代,为什么还要去了解GC和内存分配呢?原因很简单:当需要排查各种内存泄漏.内存溢出问题时,当垃圾收集器成为系统 ...

  8. Java并发编程——线程安全及解决机制简介

    简介: 本文主要介绍了Java多线程环境下,可能会出现的问题(线程不安全)以及相应的解决措施.通过本文,你将学习到如下几块知识: 1. 为什么需要多线程(多线程的优势) 1. 多线程带来的问题—线程安 ...

  9. tcp netstat用法 TIME_WAIT状态解析 MTU以及MSS

    带着问题写博客 问题1:使用netstat查看有源TCP连接的状态时,经常会看到established状态,那么还有哪些状态,这些状态是如何变化的呢? 问题2:TIME_WAIT状态存在的必要? 问题 ...

  10. Infer - 文件说明

    Infer - 文件说明 Infer - bin目录下的文件 主要命令 文件名 意义 infer 运行infer,python脚本.可以看详细的说明文档了解使用细节 inferTest 执行测试,sh ...