如果想对linux某命令获取源码进行fuzz测试,除了去网上搜索下载,还有一种更快捷的方式
系统:基于Debian的deepin
首先确定命令所在文件位置,以pic为例
$ whereis pic
pic: /usr/bin/pic /usr/share/man/man1/pic.1.gz
然后使用“Debian” 专门开发的套件管理系统dpkg,查找pic属于哪个已安装包,命令’dpkg -S /path/file’
$ dpkg -S /usr/bin/pic
groff-base: /usr/bin/pic
接下来是使用’apt-get source package’来获取源码
$ sudo apt-get update
$ sudo apt-get source groff-base
正在读取软件包列表... 完成
选择 groff 作为源代码包而非 groff-base
提示:groff 的打包工作被维护于以下位置的 Git 版本控制系统中:
https://anonscm.debian.org/git/users/cjwatson/groff.git
请使用:
git clone https://anonscm.debian.org/git/users/cjwatson/groff.git
获得该软件包的最近更新(可能尚未正式发布)。
需要下载 4,236 kB 的源代码包。
获取:1 http://packages.deepin.com/deepin panda/main groff 1.22.3-9 (dsc) [2,129 B]
获取:2 http://packages.deepin.com/deepin panda/main groff 1.22.3-9 (tar) [4,189 kB]
获取:3 http://packages.deepin.com/deepin panda/main groff 1.22.3-9 (diff) [45.4 kB]
已下载 4,236 kB,耗时 14分 32秒 (4,853 B/s)
dpkg-source: info: extracting groff in groff-1.22.3
dpkg-source: info: unpacking groff_1.22.3.orig.tar.gz
dpkg-source: info: unpacking groff_1.22.3-9.debian.tar.xz
dpkg-source: info: applying bash-scripts.patch
dpkg-source: info: applying mdate-perl.patch
dpkg-source: info: applying nroff-ifs.patch
dpkg-source: info: applying awk-path.patch
dpkg-source: info: applying papersize-pre-html.patch
dpkg-source: info: applying doc-gfdl.patch
dpkg-source: info: applying doc-gzipped.patch
dpkg-source: info: applying make-targets.patch
dpkg-source: info: applying pic-eqn-warnings.patch
dpkg-source: info: applying extratmacdirs.patch
dpkg-source: info: applying papersize-config.patch
dpkg-source: info: applying load-desc-failure.patch
dpkg-source: info: applying no-validation-icons.patch
dpkg-source: info: applying mmse-note.patch
dpkg-source: info: applying source-date-epoch.patch
dpkg-source: info: applying hdtbl-examples-less-random.patch
dpkg-source: info: applying display-utc-times.patch
dpkg-source: info: applying sort-perl-hash-keys.patch
dpkg-source: info: applying zh-tmac.patch
W: 由于文件'groff_1.22.3-9.dsc'无法被用户'_apt'访问,已脱离沙盒并提权为根用户来进行下载。 - pkgAcquire::Run (13: 权限不够)
$ ls
groff-1.22.3
groff_1.22.3-9.debian.tar.xz
groff_1.22.3-9.dsc
groff_1.22.3.orig.tar.gz
期间有些小问题
$ sudo apt-get source pic
正在读取软件包列表... 完成
E: 您必须在 sources.list 中指定代码源(deb-src) URI
我的apt源是没有指定’deb-src URI’的,修改/etc/apt/source.list增加合适的源,并更新apt源
$ sudo vim /etc/apt/sources.list
$ sudo apt-get update
如果使用的是rpm这种package manager(比如Centos),方式相同,命令稍有差异。