Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # Weird bash magic from japanese twitters
- # shellcheck disable=SC1090
- original(){
- . /???/??/$?<<<.\ /???/??/$?\<\<\<\$\'\\$(($$/$$))$(($$/$$<<$$/$$<<$$/$$))$(($$/$$<<$$/$$<<$$/$$))\\$(($$/$$))$(($$/$$<<$$/$$<<$$/$$))$(($$/$$))\\$(($$/$$<<($$/$$<<$$/$$<<$$/$$)))$(($$/$$<<$$/$$<<$$/$$))\\$(($$/$$))$(($$/$$<<$$/$$<<$$/$$))$(($$$?/$$/($$/$$<<$$/$$)))\'
- }
- breakdown(){
- # 1)
- # . /???/??/$?<<<
- # source /dev/fd/0 (stdin),
- # where '???' matches 'dev' and '??' matches 'fd';
- # '$?' is previous command status, usually '0' which is why this script doesn't always work
- # 2)
- # .\ /???/??/$?\<\<\<
- # <<< is HERE STRING like << is HERE DOC
- # source /dev/fd/0 (stdin) again, but the space is escaped and <<< are escaped as well
- # Note: I broke it with \ into three lines as executed in `bash -x`
- . /???/??/$?<<<\
- .\ /???/??/$?\<\<\<\
- \$\'\\$(($$/$$))$(($$/$$<<$$/$$<<$$/$$))$(($$/$$<<$$/$$<<$$/$$))\\$(($$/$$))$(($$/$$<<$$/$$<<$$/$$))$(($$/$$))\\$(($$/$$<<($$/$$<<$$/$$<<$$/$$)))$(($$/$$<<$$/$$<<$$/$$))\\$(($$/$$))$(($$/$$<<$$/$$<<$$/$$))$(($$$?/$$/($$/$$<<$$/$$)))\'
- # 3)
- cat <<EOF >/dev/null
- \$\'
- \\$(($$/$$))
- $(($$/$$<<$$/$$<<$$/$$))
- $(($$/$$<<$$/$$<<$$/$$))
- #$'
- #\1
- #4
- #1
- \\$(($$/$$))
- $(($$/$$<<$$/$$<<$$/$$))
- $(($$/$$))
- #\1
- #4
- #4
- \\$(($$/$$<<($$/$$<<$$/$$<<$$/$$)))
- $(($$/$$<<$$/$$<<$$/$$))
- #\16
- #4
- \\$(($$/$$))
- $(($$/$$<<$$/$$<<$$/$$))
- $(($$$?/$$/($$/$$<<$$/$$)))
- #\1
- #4
- #5 as 10*pidof/pidof/2
- \'
- EOF
- # $'' works like printf ''
- # $$ is pidof script, $(()) is arithmetic evaluation
- # $$ divided by $$ is always 1, 1<<1 is (shr/shl) 2, 2<<1 is 4
- # after evaluation we get escaped backslashes and digits
- # -- that might be an octal representation of some ASCII symbols
- # btw, oct '\144\141\164\145' is
- # hex '\x64\x61\x74\x65' or
- # dec 100,97,116,101 or
- # ASCII 'date'
- # Conclusion:
- # This one-liner sources stdin for two subshells passing octal 'date'
- # as long as $? was 0
- # printing current local time and date into current terminal.
- }
- cleanver(){
- . /dev/fd/$?<<<.\ /dev/fd/$?\<\<\<$'\144\141\164\145'
- }
- original
- breakdown
- cleanver
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement