亚洲av成人无遮挡网站在线观看,少妇性bbb搡bbb爽爽爽,亚洲av日韩精品久久久久久,兔费看少妇性l交大片免费,无码少妇一区二区三区
Chinaunix
標(biāo)題:
[漏洞相關(guān)]bash的匿名函數(shù)在man page的哪部分有體現(xiàn)?
[打印本頁(yè)]
作者:
nswcfd
時(shí)間:
2016-01-28 11:31
標(biāo)題:
[漏洞相關(guān)]bash的匿名函數(shù)在man page的哪部分有體現(xiàn)?
本帖最后由 nswcfd 于 2016-01-28 11:32 編輯
破殼漏洞(shellshock,
http://drops.wooyun.org/papers/3268
)利用了bash自身的一個(gè)漏洞,
其中涉及到'匿名'函數(shù) (其實(shí)也不是‘匿名’,只是語(yǔ)法上比較奇特)
varf='() { echo anoymous; }'
export varf
bash -c varf
問題是,這部分內(nèi)容在bash的man pages里有體現(xiàn)么?
有沒有正式的文字說明,bash在啟動(dòng)時(shí)遇到'() {'開始的環(huán)境變量會(huì)解釋為函數(shù)?
源代碼里當(dāng)然有,我想知道這部分邏輯在man bash或者info bash里面有沒有體現(xiàn),它是undocumented,還是documented?
作者:
yjh777
時(shí)間:
2016-01-28 14:01
你測(cè)試用的 什么版本?
作者:
yjh777
時(shí)間:
2016-01-28 14:11
RHEL-6 RHEL-7 試了一下, 發(fā)現(xiàn)沒有這個(gè)問題;
是代碼缺陷,而不是特性吧?
作者:
yjh777
時(shí)間:
2016-01-28 14:34
找舊版本裝上, 復(fù)現(xiàn)了: 挺有意思的, 明顯是個(gè)bug; bash 的qe怎么沒有測(cè)出來了呢
[root@hp-dl380pg8-14 ~]# VAR='() { :;}; echo Bash is vulnerable!' bash -c "echo Bash Test"
Bash is vulnerable!
Bash Test
[root@hp-dl380pg8-14 ~]# HELLO="() { echo 'Hello'; }" bash -c HELLO
Hello
[root@hp-dl380pg8-14 ~]# LANG=C bash --version
GNU bash, version 4.0.28(1)-release (x86_64-redhat-linux-gnu)
Copyright (C) 2009 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
[root@hp-dl380pg8-14 ~]# LANG=C rpm -qi bash-4.0.28-1.el6
Name : bash Relocations: (not relocatable)
Version : 4.0.28 Vendor: Red Hat, Inc.
Release : 1.el6 Build Date: Wed Sep 2 04:27:56 2009
Install Date: Thu Jan 28 14:22:44 2016 Build Host: x86-001.build.bos.redhat.com
Group : System Environment/Shells Source RPM: bash-4.0.28-1.el6.src.rpm
Size : 2641765 License: GPLv2+
Signature : (none)
Packager : Red Hat, Inc. <http://bugzilla.redhat.com/bugzilla>
URL : http://www.gnu.org/software/bash
Summary : The GNU Bourne Again shell
Description :
The GNU Bourne Again shell (Bash) is a shell or command language
interpreter that is compatible with the Bourne shell (sh). Bash
incorporates useful features from the Korn shell (ksh) and the C shell
(csh). Most sh scripts can be run by bash without modification.
[root@hp-dl380pg8-14 ~]# HELLO="() { echo 'Hello'; }; echo fff" bash -c "echo kkk"
fff
kkk
復(fù)制代碼
作者:
ziyunfei
時(shí)間:
2016-01-28 15:58
Bash文檔只會(huì)講export過的函數(shù)會(huì)被子進(jìn)程Shell繼承到,不會(huì)講具體的實(shí)現(xiàn)細(xì)節(jié)。
這個(gè)bug早就被修復(fù)了,即便是舊版本的Bash,也已經(jīng)打了補(bǔ)丁。
可以看看我的博客 cnblogs.com/ziyunfei/p/4828767.html
作者:
ydzcjj
時(shí)間:
2016-01-28 16:17
樓上大神 。。。。。 學(xué)習(xí)一下
作者:
yjh777
時(shí)間:
2016-01-28 17:00
本帖最后由 yjh777 于 2016-01-28 17:03 編輯
多謝 5樓 分享; 原來 export -f 實(shí)現(xiàn)版本之間有差異;
f=() { echo f
}
通過在 function 的變量名里面加入 shell 變量不支持的符號(hào),避免了邏輯歧義:
BASH_FUNC_f()=() { echo f
}
這樣用戶就沒有辦法在shell里面,通過自定義環(huán)境變量,來注入函數(shù)了.
作者:
nswcfd
時(shí)間:
2016-01-29 13:21
回復(fù)
5#
ziyunfei
一直沒有看過shell的實(shí)現(xiàn),所以當(dāng)?shù)谝淮慰吹铰┒吹腜OC時(shí)感到很奇怪,怎么可以這樣去導(dǎo)出函數(shù)啊?(常規(guī)的方式是先定義再去export -f)
拋開漏洞本身不談,環(huán)境變量里有“() {”表示函數(shù)(看代碼還必須有空格,即4個(gè)字符),估計(jì)這是一個(gè)“慣用用法”吧。
有沒有任何書面的資料在描述這個(gè)“慣用用法”?(稍微有些強(qiáng)迫癥
凡事都要找個(gè)出處……)
作者:
nswcfd
時(shí)間:
2016-01-29 15:10
贊一下5樓的博客!
env可以看到export -f的結(jié)果,這樣的話就算沒有明確的文檔說明,也是事實(shí)上的標(biāo)準(zhǔn)了。
歡迎光臨 Chinaunix (http://www.72891.cn/)
Powered by Discuz! X3.2