Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add swift #170

Merged
merged 2 commits into from
Dec 27, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions LOOBins/swift.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: swift
author: 0v3rride (https://github.com/0v3rride)
short_description: Arbitrarily execute swift code from the terminal.
full_description: The swift command is an interactive environment (REPL) for Swift.
created: 2023-12-23
example_use_cases:
- name: Execute Swift code file
description: Executes the Swift code that is in a .swift file
code: swift mycode.swift
tactics:
- Execution
tags:
- swift
- repl
- bash
- zsh
- name: Execute Swift one-liner before swift 5.8 / Xcode 14.3 Beta 1
description: Executes a Swift one-liner by piping an echoed string into the swift command
code: echo 'print("loobins")' | swift -
tactics:
- Execution
- Defense Evasion
tags:
- swift
- repl
- bash
- zsh
- name: Execute Swift one-liner with swift 5.8 / Xcode 14.3 Beta 1 or greater
description: 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
code: "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));'"
tactics:
- Execution
- Defense Evasion
tags:
- swift
- repl
- bash
- zsh
paths:
- /usr/bin/swift
detections:
- name: Process & Command Line Argument Detection (process contains swift)
url: N/A
resources:
- name: 'Introduction to the Swift REPL'
url: https://developer.apple.com/swift/blog/?id=18
- name: 'Scripting and Compiling Swift on the Command Line'
url: https://jblevins.org/log/swift
- name: 'Scripting in Swift is Pretty Awesome'
url: https://krakendev.io/blog/scripting-in-swift
- name: 'Swift -e runs code directly from the command line'
url: https://blog.eidinger.info/swift-e-runs-code-directly-from-the-command-line
- name: 'Swift Programming From The Command Line'
url: https://ed.com/command-line-swift/