infosecB/LOOBins

Add LOOBin for swift

0v3rride opened this issue · 0 comments

LOOBin description

Starting in swift 5.8 / Xcode 14.3 Beta 1 a new command line option was added.

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

This allows users to execute swift one-liners from the command line. This does not require compilation first beforehand with swiftc nor specifying a particular *.swift file that can be ran with the swift command in the terminal.

Previous versions of swift allow one-line executions of swift code in the terminal by piping the code into the swift command.

i.e.: echo 'print("good")' | swift -

More information can be found at the following link.
https://blog.eidinger.info/swift-e-runs-code-directly-from-the-command-line