A solution would be to stop shipping macs with the terminal app\s. Computers are now used by a wide variety of people, some without technical knowledge, maybe a default switch on macOS that displays warnings on rather trivial attacks would help.
[dead]
How is that a solution? These attacks would just tell you to install terminal if you don't already have it.