swift

Created by 0v3rride (https://github.com/0v3rride)

Description

The swift command is an interactive environment (REPL) for Swift.

CreatedTacticsTags
2023-12-23Execution Defense Evasionswift repl bash zsh

Paths

  • /usr/bin/swift

Use Cases

Execute Swift code file

Executes the Swift code that is in a .swift file

swift mycode.swift

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

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

echo 'print("loobins")' | swift -

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

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));'

Detections

Resources