Skip to content

Instantly share code, notes, and snippets.

@nmggithub
nmggithub / sudo.swift
Last active December 27, 2024 16:32
Silent privilege escalation in Swift (password is needed)
import Foundation
/// Run a command as root.
@MainActor // This *will* hang if it is not run on the main thread.
func sudo(_ command: String, username: String = NSUserName(), password: String) throws -> String? {
guard
let script = NSAppleScript(
source:
"""
do shell script "\(command)" user name "\(username)" password "\(password)" with administrator privileges
@nmggithub
nmggithub / command.js
Last active August 29, 2015 14:02 — forked from JoelBesada/README.md
Spoof Page and Icon
/* NOTE: Comments need to be in multiline format like this, instead of "// Comment" */
var url = prompt('Enter the url you want to spoof the icon of');var title = prompt('Enter the title you want to spoof');var link = document.createElement('link');link.type = 'image/x-icon';link.rel = 'shortcut icon';link.href = 'http://g.etfv.co/' + url;document.getElementsByTagName('head')[0].appendChild(link);document.title = title; return;

This is an example command for Backtick. A Backtick command consists of some executable JavaScript and a bit of metadata in JSON.

Here are the required steps to create a command:

  1. Create a new Gist with a command.js and command.json file, or simply fork this one.

  2. Write your JavaScript in command.js. This will be injected into and executed on the page the user is currently on when they run it.

  3. Add some metadata to the command.json file:

  • name: The name of the command.