applescript-tools
Tools for analysing AppleScript malware, including run-only scripts, without
a Mac VM. They install one command, osatool (Python package
applescript_tools):
osatool decompileturns compiled, run-only.scptfiles back into source; see the blog post for how it works.osatool disassembleprints a compiled script's bytecode. It's built on a vendored copy of Jinmo/applescript-disassembler, which the decompiler also uses to load scripts.osatool emulatetriages a sample: it emulates the script with a fake Mac and reports the commands it runs, what it downloads and uploads, the files it reads and drops, and the IOCs. Nothing is executed.- An offline compiler (
applescript_tools.compiler) parses AppleScript source into the same AST, so source text and compiled scripts are handled alike, on any OS.
Installation
pip install applescript-tools
Python 3.10 or later, on any OS. For the latest from GitHub:
pip install git+https://github.com/pberba/applescript-tools. Or, from a
checkout, with uv:
git clone https://github.com/pberba/applescript-tools
cd applescript-tools
uv sync
uv run osatool --help
Triage a sample
osatool emulate ~/Downloads/<sha256>.zip # a VirusTotal/MalwareBazaar zip (password "infected"), read in memory
The report is the files the script drops and its IOCs: every shell command,
URLs, domains, files written and read, apps. A warning: line says when the
script used something the emulator has no model for. -v adds the trace of
what it did, in order, and the list of what isn't emulated, and -vv the
decoded strings, the questions nothing answered and the next steps for this
sample. Typically:
osatool emulate sample.zip -v # with the trace
osatool emulate sample.zip --brute-force --assume-files # past anti-VM checks, into a stealer's target list
osatool emulate sample.zip --answers a.toml --update-answers # unanswered questions go in a.toml as "?"…
# …replace the ones you know, and run it again
osatool emulate sample.zip -i # or answer on the terminal
See docs/emulator.md.
Decompile or disassemble a script
osatool decompile sample.scpt > sample.applescript # also sample zips and JXA
osatool disassemble sample.scpt # the bytecode
The decompiled output compiles, and recompiles to the same bytecode as the original. See docs/decompiler.md and docs/disassembler.md.
Demo
osacompile -x -o demo/demo_runonly.scpt demo/demo_source.applescript # compile run-only
osadecompile demo/demo_runonly.scpt # errOSASourceNotAvailable (-1756)
osatool decompile demo/demo_runonly.scpt > demo/demo_output.out
osatool emulate demo/demo_runonly.scpt -k
Before applescript-tools
This project was applescript-decompiler. The old names keep working: the
commands applescript_decompile, applescript_disassemble and
applescript_emulate, and the imports applescript_decompiler.*, which are
the same modules as applescript_tools.*.
Documentation
| Tool | Docs |
|---|---|
osatool emulate |
emulator.md: triage, the report, getting further, options · answers-file.md: answering what the emulator can't, changing the fake Mac · brute-force.md: how --brute-force explores both sides of ifs · emulation-model.md: what's modelled, limits, where IOCs come from, code layout |
osatool decompile |
decompiler.md: usage, and how decompilation works · scripting-dictionaries.md: adding app dictionaries |
osatool disassemble |
disassembler.md |
| offline compiler | compiler.md: parsing source text without osacompile |
| the Python library | library-usage.md |
| development | development.md: setup · testing.md: tests, fixtures, debugging a decompilation |
Metadata
Release files for applescript-tools 3.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| applescript_tools-3.0.0.tar.gz | 442.0 kB | Without provenance | Details for applescript_tools-3.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| applescript_tools-3.0.0-py3-none-any.whl | Python 3 | none | any | Details for applescript_tools-3.0.0-py3-none-any.whl |
Total release size: 791.2 kB
Release files / applescript_tools-3.0.0.tar.gz
| Download URL | applescript_tools-3.0.0.tar.gz |
|---|---|
| Size | 442.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e186f25e707dfb9c12e50463abc6950cd69fb722f5b46acd8603c7e55330563e
|
|
BLAKE2b-256 checksum How to use checksums |
583a436481ecb1396c13e81e3fa5cec64fa7e9e3bfc060e789b77d72b49c1ef9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.13.6 {"installer":{"name":"uv","version":"0.13.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / applescript_tools-3.0.0-py3-none-any.whl
| Download URL | applescript_tools-3.0.0-py3-none-any.whl |
|---|---|
| Size | 349.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e48eb3d906e93abb55a566d2f043d328304c4dfaeb610b2f5b12442b6d417fcc
|
|
BLAKE2b-256 checksum How to use checksums |
35559c5694339002ec2daf46c00b8f29d34c292d682560883ebe242bc01e53a6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.13.6 {"installer":{"name":"uv","version":"0.13.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for applescript-tools 3.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.