2 ms·
> and you can see this if you modify a shell script file on disk as it's running, they will actually pick up the changes as they keep reading the lines while ex
by derefr 6y ago
> and you can see this if you modify a shell script file on disk as it's running, they will actually pick up the changes as they keep reading the lines while executing.
Better yet—you can stream a script into bash, and each line will be executed as it's received over the pipe.
In theory, one of those `curl ... | bash` stanzas could actually be talking to a little web-app backend that writes lines of script to the HTTP socket one at a time (maybe using Chunked transfer, but not necessarily), and waits for those individual lines to be executed; where some of those lines are expected to make other curl requests back to the same server; where those other requests in turn change backend state that the original script-streaming session can see; and that state further determines what lines of script get written to the HTTP socket.
In other words, just by piping to bash, you're actually giving whatever's on the other end of the pipe an interactive shell on your computer, even without the script installing any separate CNC agent!
- saagarjha 6y agoSounds like a security nightmare :P