CatalogLOOBins

ORCHARD · Tool

swift

3 techniquesmacOSLOOBinsGPL-3.0

Execute Swift code file

ExecutionmacOS

Executes the Swift code that is in a .swift file

swift mycode.swift
Evidence
Upstream reference
Environment
Local host
Compatibility
Imported from LOOBins; availability and behaviour depend on macOS version, privacy permissions and installed components. Not lab tested here.
Native
Execution
Detection
Process & Command Line Argument Detection (process contains swift): Process & Command Line Argument Detection (process contains swift)
Jamf Protect: Detect arbitrary code execution using a swift one-liner: github.com/jamf/jamfprotect/blob/main/custom_analytic_detections/swift_oneline_command_execution

Execute Swift one-liner before swift 5.8 / Xcode 14.3 Beta 1

ExecutionDefense EvasionmacOS

Executes a Swift one-liner by piping an echoed string into the swift command

echo 'print("loobins")' | swift -
Evidence
Upstream reference
Environment
Local host
Compatibility
Imported from LOOBins; availability and behaviour depend on macOS version, privacy permissions and installed components. Not lab tested here.
Native
Execution, Defense Evasion
Detection
Process & Command Line Argument Detection (process contains swift): Process & Command Line Argument Detection (process contains swift)
Jamf Protect: Detect arbitrary code execution using a swift one-liner: github.com/jamf/jamfprotect/blob/main/custom_analytic_detections/swift_oneline_command_execution

Execute Swift one-liner with swift 5.8 / Xcode 14.3 Beta 1 or greater

ExecutionDefense EvasionmacOS

Executes a Swift one-liner that executes the ls command to list the current directory using the -e option that was implemented in swift 5.8 / Xcode 14.3 Beta 1

swift -e 'import Foundation; let process = Process(); process.executableURL = URL(fileURLWithPath:"/bin/bash"); process.arguments = ["-c", "ls -alh"]; let stdout = Pipe(); let stderr = Pipe(); process.standardOutput = stdout; process.standardError = stderr; try process.run(); print(String(decoding: stdout.fileHandleForReading.readDataToEndOfFile(), as: UTF8.self)); print(String(decoding: stderr.fileHandleForReading.readDataToEndOfFile(), as: UTF8.self));'
Evidence
Upstream reference
Environment
Local host
Compatibility
Imported from LOOBins; availability and behaviour depend on macOS version, privacy permissions and installed components. Not lab tested here.
Native
Execution, Defense Evasion
Detection
Process & Command Line Argument Detection (process contains swift): Process & Command Line Argument Detection (process contains swift)
Jamf Protect: Detect arbitrary code execution using a swift one-liner: github.com/jamf/jamfprotect/blob/main/custom_analytic_detections/swift_oneline_command_execution