Skip to content

Instantly share code, notes, and snippets.

View nanzhipro's full-sized avatar

南知 nanzhipro

View GitHub Profile
@nanzhipro
nanzhipro / gist:cef54dbe32075972d8455549f50e7ff4
Created March 9, 2022 12:52 — forked from mattstevens/gist:4400775
Resizing an NSImage on retina Macs for output as a 1x image
NSImage *computerImage = [NSImage imageNamed:NSImageNameComputer];
NSInteger size = 256;
NSBitmapImageRep *rep = [[NSBitmapImageRep alloc]
initWithBitmapDataPlanes:NULL
pixelsWide:size
pixelsHigh:size
bitsPerSample:8
samplesPerPixel:4
hasAlpha:YES
@nanzhipro
nanzhipro / SigCheck.py
Created March 24, 2022 03:10 — forked from richiercyrus/SigCheck.py
Python code for checking whether there are any processes running on a macOS system that are missing the LC_CODE_SIGNATURE command. This may be indicative of a LC_LOAD_DYLIB addition attack: https://attack.mitre.org/techniques/T1161/
import os
import sys
import shlex
import argparse
import subprocess
import macholib
import json
import hashlib
#This script is designed to detect the following MITRE ATT&CK Technique:
@nanzhipro
nanzhipro / git_rename.sh
Created July 22, 2022 06:00 — forked from robotdana/git_rename.sh
Use git .mailmap
#!/bin/bash
# based on: https://gist.github.com/octocat/0831f3fbd83ac4d46451#gistcomment-2178506
# will use the .mailmap file to rewrite all names/emails
function correct_names () {
( git shortlog -sen ; git shortlog -secn ) | cut -f2 | sort | uniq
}
function all_names () {
( git log --format="%an <%ae>" ; git log --format="%cn <%ce>" ) | sort | uniq

Last updated: 2014-12-25

mdfind commands

Find all the file types in a given directory

mdfind -attr kMDItemContentType "kMDItemContentType == '*'" -onlyin . | awk -F"kMDItemContentType =" '{print $2}' | sort | uniq -c | sort -r

Get Last 5 Files Added in Dropbox Folders

import Cocoa
protocol AXUIProtocol {
func AXUIWindowArray(processIdentifier pid:pid_t) -> [AXUIElement]
func AXUIWindowArray(bundleIdentifier bid:NSString) -> [AXUIElement]
}
extension AXUIProtocol {
func AXUIWindowArray(processIdentifier pid:pid_t) -> [AXUIElement] {
let windowList : UnsafeMutablePointer<AnyObject?> = UnsafeMutablePointer<AnyObject?>.alloc(1)
@nanzhipro
nanzhipro / library_injector.cpp
Created December 19, 2023 10:20 — forked from saagarjha/library_injector.cpp
Load a library into newly spawned processes (using DYLD_INSERT_LIBRARIES and EndpointSecurity)
// To compile: clang++ -arch x86_64 -arch arm64 -std=c++20 library_injector.cpp -lbsm -lEndpointSecurity -o library_injector,
// then codesign with com.apple.developer.endpoint-security.client and run the
// program as root.
#include <EndpointSecurity/EndpointSecurity.h>
#include <algorithm>
#include <array>
#include <bsm/libbsm.h>
#include <cstdint>
#include <cstdlib>
@nanzhipro
nanzhipro / agent loop
Created March 11, 2025 07:16 — forked from jlia0/agent loop
Manus tools and prompts
You are Manus, an AI agent created by the Manus team.
You excel at the following tasks:
1. Information gathering, fact-checking, and documentation
2. Data processing, analysis, and visualization
3. Writing multi-chapter articles and in-depth research reports
4. Creating websites, applications, and tools
5. Using programming to solve various problems beyond development
6. Various tasks that can be accomplished using computers and the internet