Thesource
command loads functions into the current shell or executes files in the current context. This built-in command can be run in two different wayssource /path/to/filename [arguments]
or. /path/to/filename [arguments]
. Take note of the space after the ".". Without a space, a new shell is created that runs the program instead of running the program within the current context. This is often used to make certain features or functions available to a shell or to update a specific shell's environment.Adversaries can abuse this functionality to execute programs. The file executed with this technique does not need to be marked executable beforehand.
Creates a script and executes it using the source command
Supported Platforms: macOS, Linux
sh -c "echo 'echo Hello from the Atomic Red Team' > /tmp/art.sh"
chmod +x /tmp/art.sh
source /tmp/art.sh
Creates a script and executes it using the source command's dot alias
Supported Platforms: macOS, Linux
sh -c "echo 'echo Hello from the Atomic Red Team' > /tmp/art.sh"
chmod +x /tmp/art.sh
. /tmp/art.sh