Created
January 8, 2020 21:57
-
-
Save kkirsche/5f6d201c14160e8cc8106e035965d551 to your computer and use it in GitHub Desktop.
The danger of just trusting the cat command
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
hidden_cmd = "echo 'You forgot to check `cat -A`!' > oops" | |
visible_cmd = "echo 'Hello world!'" | |
if __name__ == "__main__": | |
with open("demo.sh", "w") as f: | |
txt = "#!/bin/sh\n" | |
txt += hidden_cmd + ";" + visible_cmd + " #\r" + visible_cmd + " " * (len(hidden_cmd) + 3) + "\n" | |
f.write(txt) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment