Skip to content

Instantly share code, notes, and snippets.

View kim4apple's full-sized avatar

kim4apple kim4apple

  • Shenzhen, China
View GitHub Profile
@pudquick
pudquick / 8021x_inspect.py
Last active September 27, 2022 10:04
802.1x configuration / data collection on OS X using python and the PrivateFramework "EAP8021X.framework"
# This was all run from user space
# I haven't tested it with root
# ... but it didn't prompt for any permissions under userspace ^_^
# Tested on 10.11.5
import objc
from Foundation import NSBundle
EAP8021X_bundle = NSBundle.bundleWithPath_('/System/Library/PrivateFrameworks/EAP8021X.framework')
Security_bundle = NSBundle.bundleWithIdentifier_('com.apple.security')
@aleclaws
aleclaws / seckeyrefnsdata.c
Last active September 1, 2021 05:32
SecKeyRef to NSData
// HELPER QUERIES
void queryValueToData(NSMutableDictionary *query, void * value) {
query[(__bridge id)kSecValueRef] = (__bridge id)value ;
query[(__bridge id)kSecReturnData] = @YES ;
}
void queryDataToValue(NSMutableDictionary *query, id data) {
func encrypt(data: NSData) -> NSData {
var error: Unmanaged<CFErrorRef>? = nil
let parameters: [NSString: NSString] = [
kSecAttrKeyType: kSecAttrKeyTypeRSA,
kSecAttrKeyClass: kSecAttrKeyClassPublic
]
let keyString = "MIGeMA0GCSqGSIb3DQEBAQUAA4GMADCBiAKBgQCVXkvZifORfS8VVEp+BQTrnXu2a2+KL+Rw5FPHeSAOXjrS5DoC0GxK29jTKPGkJrg2WOiL/ZSbKvTq8wBUZzoUGaJQ+kzBJ40ShVtbJYGNFixubuKrSjUNQB149t25lxHnJia0i9i1sLfzrPnqPJ4ABf7lnhkTbNt8g/KriwoqmQICAQE="
let keyData = NSData(base64EncodedString: keyString, options: .IgnoreUnknownCharacters)!
@dkniffin
dkniffin / terminal_cheatsheet.md
Last active April 21, 2021 06:50
Terminal 101/Cheat sheet/rosetta stone

The goal of this gist is to provide a list of the most common/useful shell commands.

Commands

command stands for common usage description
man manual man display the man page for the given comand. If you're wondering how to use any command, this is the go-to place for help. It provides information about what the command does, how to use it, what flags it has, and lots more.
<command> --help While it's not an actual command, I thought it'd be useful to include it. While man will get you the most thorough information about a command, many commands don't provide man pages. Also sometimes it's useful to get a less verbose help message. In those cases, --help/-h is what you want.
<command> -h ^ see above ^
cd change directory cd move to the given directory
Title : Revisiting Mac OS X Kernel Rootkits
Author : fG!
Date : April 18, 2014
|=----------------------------------------------------------------------------=|
|=----------------=[ Revisiting Mac OS X Kernel Rootkits ]=-------------------=|
|=----------------------------------------------------------------------------=|
|=------------------------=[ fG! <[email protected]> ]=---------------------------=|
|=----------------------------------------------------------------------------=|
@you-think-you-are-special
you-think-you-are-special / Singleton.js
Created February 18, 2015 10:52
ES6 Singleton example. Use: import Singleton from 'Singleton'; let instance = Singleton.instance;
'use strict';
/**
* Created by Alexander Litvinov
* Email: [email protected]
* May be freely distributed under the MIT license
*/
let singleton = Symbol();
let singletonEnforcer = Symbol();
@rtrouton
rtrouton / gist:4ff699b3f7660ae06a13
Created December 27, 2014 15:59
Software Update keys in Yosemite's /Library/Preferences/com.apple.SoftwareUpdate.plist
Automatically check for updates:
Enable: sudo defaults write /Library/Preferences/com.apple.SoftwareUpdate AutomaticCheckEnabled -bool TRUE
Disable: sudo defaults write /Library/Preferences/com.apple.SoftwareUpdate AutomaticCheckEnabled -bool FALSE
Download newly available updates in the background:
Enable: sudo defaults write /Library/Preferences/com.apple.SoftwareUpdate AutomaticDownload -bool TRUE
Disable: sudo defaults write /Library/Preferences/com.apple.SoftwareUpdate AutomaticDownload -bool FALSE
@nathwill
nathwill / pf.conf
Last active December 22, 2024 17:33
a dummy's sample pf.conf
# $OpenBSD: pf.conf,v 1.52 2013/02/13 23:11:14 halex Exp $
#
# See pf.conf(5) for syntax and examples.
#
# Remember to set net.inet.ip.forwarding=1 and/or net.inet6.ip6.forwarding=1
# in /etc/sysctl.conf if packets are to be forwarded between interfaces.
### Macros
# system
@bzerangue
bzerangue / macs-on-active-directory.md
Last active October 12, 2023 21:07
Binding and Unbinding to Active Directory from Mac OS via Command Line

Binding and Unbinding to Active Directory from Mac OS via Command Line

  • Open the Terminal Application
  • Type in sudo -i and type in your Mac Administrator account password. sudo gives you root level or administrator level privileges.

To View current Active Directory Settings

dsconfigad -show

To Unbind a Computer from an Active Directory Domain

@rpechayr
rpechayr / watchSound.m
Last active August 27, 2019 09:17
Watch source change (Headphone vs. Internal Speaker)
NSLog(@"Starting");
AudioDeviceID defaultDevice = 0;
UInt32 defaultSize = sizeof(AudioDeviceID);
const AudioObjectPropertyAddress defaultAddr = {
kAudioHardwarePropertyDefaultOutputDevice,
kAudioObjectPropertyScopeGlobal,
kAudioObjectPropertyElementMaster
};