Advertisement
ALTracer

Weird script 1

Jul 21st, 2019
594
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.07 KB | None | 0 0
  1. #!/bin/bash
  2. # Weird bash magic from japanese twitters
  3. # shellcheck disable=SC1090
  4. original(){
  5. . /???/??/$?<<<.\ /???/??/$?\<\<\<\$\'\\$(($$/$$))$(($$/$$<<$$/$$<<$$/$$))$(($$/$$<<$$/$$<<$$/$$))\\$(($$/$$))$(($$/$$<<$$/$$<<$$/$$))$(($$/$$))\\$(($$/$$<<($$/$$<<$$/$$<<$$/$$)))$(($$/$$<<$$/$$<<$$/$$))\\$(($$/$$))$(($$/$$<<$$/$$<<$$/$$))$(($$$?/$$/($$/$$<<$$/$$)))\'
  6. }
  7.  
  8. breakdown(){
  9. # 1)
  10. # . /???/??/$?<<<
  11. # source /dev/fd/0 (stdin),
  12. # where '???' matches 'dev' and '??' matches 'fd';
  13. # '$?' is previous command status, usually '0' which is why this script doesn't always work
  14.  
  15. # 2)
  16. # .\ /???/??/$?\<\<\<
  17. # <<< is HERE STRING like << is HERE DOC
  18. # source /dev/fd/0 (stdin) again, but the space is escaped and <<< are escaped as well
  19. # Note: I broke it with \ into three lines as executed in `bash -x`
  20.  
  21. . /???/??/$?<<<\
  22. .\ /???/??/$?\<\<\<\
  23. \$\'\\$(($$/$$))$(($$/$$<<$$/$$<<$$/$$))$(($$/$$<<$$/$$<<$$/$$))\\$(($$/$$))$(($$/$$<<$$/$$<<$$/$$))$(($$/$$))\\$(($$/$$<<($$/$$<<$$/$$<<$$/$$)))$(($$/$$<<$$/$$<<$$/$$))\\$(($$/$$))$(($$/$$<<$$/$$<<$$/$$))$(($$$?/$$/($$/$$<<$$/$$)))\'
  24.  
  25. # 3)
  26. cat <<EOF >/dev/null
  27. \$\'
  28. \\$(($$/$$))
  29. $(($$/$$<<$$/$$<<$$/$$))
  30. $(($$/$$<<$$/$$<<$$/$$))
  31. #$'
  32. #\1
  33. #4
  34. #1
  35. \\$(($$/$$))
  36. $(($$/$$<<$$/$$<<$$/$$))
  37. $(($$/$$))
  38. #\1
  39. #4
  40. #4
  41. \\$(($$/$$<<($$/$$<<$$/$$<<$$/$$)))
  42. $(($$/$$<<$$/$$<<$$/$$))
  43. #\16
  44. #4
  45. \\$(($$/$$))
  46. $(($$/$$<<$$/$$<<$$/$$))
  47. $(($$$?/$$/($$/$$<<$$/$$)))
  48. #\1
  49. #4
  50. #5 as 10*pidof/pidof/2
  51. \'
  52. EOF
  53. # $'' works like printf ''
  54. # $$ is pidof script, $(()) is arithmetic evaluation
  55. # $$ divided by $$ is always 1, 1<<1 is (shr/shl) 2, 2<<1 is 4
  56. # after evaluation we get escaped backslashes and digits
  57. # -- that might be an octal representation of some ASCII symbols
  58. # btw, oct '\144\141\164\145' is
  59. # hex '\x64\x61\x74\x65' or
  60. # dec 100,97,116,101 or
  61. # ASCII 'date'
  62.  
  63. # Conclusion:
  64. # This one-liner sources stdin for two subshells passing octal 'date'
  65. # as long as $? was 0
  66. # printing current local time and date into current terminal.
  67. }
  68.  
  69. cleanver(){
  70. . /dev/fd/$?<<<.\ /dev/fd/$?\<\<\<$'\144\141\164\145'
  71. }
  72.  
  73. original
  74. breakdown
  75. cleanver
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement