Bash
www.iimc.kyoto-u.ac.jp https://www.iimc.kyoto-u.ac.jp/services/comp/pdf/file_loss_insident_20211228.pdf bash ã¯ãã·ã§ã«ã¹ã¯ãªããã®å®è¡ä¸ã«é©æã·ã§ã«ã¹ã¯ãªãããèªã¿è¾¼ã¿ã¾ãããã®æåã«ã ãå¯ä½ç¨ãèªèã§ãã¦ããããå®è¡ä¸ã®ã¹ã¯ãªãããåâ¦
ã·ã§ã«ã¹ã¯ãªãã(bash)ã¯ã³ãã³ãã失æãã¦ã次ã®ã³ãã³ããå®è¡ãã¦ãã¾ãã®ã§æãâset -eãã¦ããã¨ãã話ã¯ããããããå®éã©ãã¾ã§æå¹ãªã®ãã åºæ¬ ã³ãã³ãã®æ»ãå¤ã0ã«ãªã£ãæã«ã·ã§ã«ãçµäºãã #!/bin/bash set -e echo "before false" falseâ¦
echo(ãã«ãã¤ã³ã³ãã³ã)ã使ãã®ã¨ $ echo -e '\u3042' ã$'string'ã使ãæ¹æ³ããã $ echo $'\u3042' ããã¼ã¸ã§ã³4ããã¿ããã ãããã¨ãbashãã®ãã®ã§ã¯ãªããã©GNU coreutilsã®printfã¤ããã¨ã³ã¼ããã¤ã³ããæå®ãã¦åºåã§ãããã©ãã $ printf â¦
bashã§$'string'ã¨å ¥åããã¨ãæååã®å é¨ã®ANSI Cã©ã¤ã¯ãªã¨ã¹ã±ã¼ãã·ã¼ã±ã³ã¹ã解éãã¦ãããã¨ããæ©è½ããããã§ããã¡ãã®æ¬ã®ä¸ã§ããã¯extquoteã¨å¼ã¶ã¨æ¸ãã¦ãã£ã¦ãã£ãã®ã§ãå¼ã³åããããã ã¨æã£ãã®ã ããã·ã§ã«ããã°ã©ãã³ã°å®ç¨ãã¯ãâ¦
Shellshocké¢ä¿ã§bashãã¢ãããã¼ãããå¾ã«bashãå©ç¨ãã¦ããããã»ã¹ãåèµ·åãããã©ããã¨ãã話ã Mitigating the shellshock vulnerability (CVE-2014-6271 and CVE-2014-7169) - Red Hat Customer Portal RHELã®ææ¸ã¯ã¡ãã£ã¨æ··ä¹±ãã¦ãã¦æåã¯åâ¦
ä»åã®Shellshockåé¡ã®å¯¾çã¨ãã¦ã¯æ®éã«bashã®ã¢ãããã¼ãã§è¯ãã®ã ãã©ããRedHatã«ModSecurityã§é²ãæ¹æ³ãè¼ã£ã¦ããã The following mod_security rules can be used to reject HTTP requests containing data that may be interpreted by Bash asâ¦
CVE - CVE-2014-6271 Bash Code Injection Vulnerability via Specially Crafted Environment Variables (CVE-2014-6271, CVE-2014-7169) - Red Hat Customer Portal ããã¯ã²ã©ãããããªæãã§ç°å¢å¤æ°ã«è¨å®ããã¹ã¯ãªãããå®è¡ãã¦ãã¾ãã $ env x='()â¦
some_command if [ $? -ne 0 ] then echo "failed to execute some_command" exit 1 fi ã¨ãæ¯åããã®ã¯ããã©ãã®ã§ã err_handler() { echo "failed to execute '$BASH_COMMAND'" exit 1 } trap err_handler ERR some_command ... ã¨ããã°ãããtrapã¯ã·â¦
ãããOKãã¨ãªãã¨ã次ãOKã§ãããããå½ç¶ã for x in 1 2 3; do; echo $x; doneã¬ã¼ã³ããã¡ãªãã ã£ã¦ãã syntax error near unexpected token `;' ã·ã§ã«ã¹ã¯ãªããã®ã»ãã³ãã³ã®æã¡æããããã - æªå±±æ£å¹¸ã®ããã¤ã©é£¼è²è¨ foræã®æ¹è¡ã';'ã«ç½®â¦
Some examples and what they expand to: {aa,bb,cc,dd} => aa bb cc dd {0..12} => 0 1 2 3 4 5 6 7 8 9 10 11 12 {3..-2} => 3 2 1 0 -1 -2 {a..g} => a b c d e f g {g..a} => g f e d c b a Bash Brace Expansion | Linux Journal æåã®ãã¤ã¯ç¥ã£ã¦ãâ¦