zerons's Blog

For The Dream

bash CVE-2014-6271 CVE-2014-7169

zerons posted @ 2014年9月26日 18:31 in sec , 930 阅读

昨天CVE-2014-6271曝出, 网上给出的测试代码env X='() { :; }; echo vuln' bash -c "echo ..."很好理解, 原因也很好找, http://www.zhihu.com/question/25539470/answer/31055176?utm_source=weibo&utm_medium=weibo_share&utm_content=share_answer&utm_campaign=share_button.

但是对第二个绕过测试代码很不解, env X='() { (a)=>\' bash -c "echo echo vuln";cat echo

这段测试代码目的是造成bash错误, 即(a)=   这段语句会语法出错, 

这时, 一个全局变量eol_ungetc_lookahead为'>'

然后yyerror会被调用, 输出语法错误提示, 并且调用reset_parser, 之后回到variables.c中的initilize_shell_variables函数, 调用report_error, 由于exit_immediately_on_error仍然为0, 所以程序会继续运行. 

当调用shell_getc时, 因为eol_ungetc_lookahead不为空, 那么返回它的值, 也即为之前出错的时候的字符'>'

然后读取后面将执行的命令, "echo echo vuln"   合并即为">echo echo vuln"   就会创建一个新文件

同样, 将'>'字符改成'<', 会读取系统一些文件, 如env -i X='() { (a)=>\' bash -c "/etc/passwd cat".

补充: 为什么要在最后加上\, 因为shell_getc在碰到\的时候, 会restart_read, 然后直接返回EOF, 同时会触发两次shell_ungetc, 让eol_ungetc_lookahead变量得到'>'. 没有\的时候, shell_ungetc的执行路径会不同, 

 

通过输入精心制造的特殊数据, 控制程序的执行路径向自己希望的方向走, nice

Avatar_small
unblocked games 66 说:
2022年8月20日 03:08

Play Bartender Perfect Mix Game. We Unblocked it For You to Play at School. We at Unblocked Games 66 77 99 Unblocks All Games Like Bartender Perfect 2021. Unblocked Games GOGO is one of the game sites that are unblocked games at school that I secretly created. unblocked games for school, unblocked games 66 unblocked games 66,unblocked games happy wheels,unblocked games google sites,unblocked games 77,unblocked games 99.

Avatar_small
HBSE Question Paper 说:
2022年9月03日 18:12

Haryana Board Model Paper 2023 Class 5 Pdf Download with Answers for English Medium, Hindi Medium, Urdu Medium & Students for Small Answers, Long Answer, Very Long Answer Questions, and Essay Type Questions to Term1 & Term2 Exams at official website. HBSE Question Paper Class 5 New Exam Scheme or Question Pattern for Sammittive Assignment Exams (SA1 & SA2): Very Long Answer (VLA), Long Answer (LA), Small Answer (SA), Very Small Answer (VSA), Single Answer, Multiple Choice and etc.

Avatar_small
boardmodelpaper.com 说:
2024年1月10日 14:00

The Board model paper" typically refers to a sample or model question paper that is designed by educational boards or institutions for various exams. These papers serve as practice material for students preparing for exams, providing them with an idea of the question format, difficulty level, and the type of content that may be covered in the actual examination. boardmodelpaper.com Model papers are usually created for specific subjects or courses. They cover a range of topics and chapters that students are expected to have studied during the academic term. Students often use these educational board model papers as an integral part of their exam preparation strategy, helping them familiarize themselves with the exam pattern and refine their understanding of the subject matter.


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter