获取linux命令的源码

来源:互联网 发布:des 算法F函数 编辑:程序博客网 时间:2024/06/05 15:28

如果想对linux某命令获取源码进行fuzz测试,除了去网上搜索下载,还有一种更快捷的方式

系统:基于Debian的deepin

首先确定命令所在文件位置,以pic为例

$ whereis picpic: /usr/bin/pic /usr/share/man/man1/pic.1.gz

然后使用“Debian” 专门开发的套件管理系统dpkg,查找pic属于哪个已安装包,命令’dpkg -S /path/file’

$ dpkg -S /usr/bin/picgroff-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,耗时 1432秒 (4,853 B/s)                                                                     dpkg-source: info: extracting groff in groff-1.22.3dpkg-source: info: unpacking groff_1.22.3.orig.tar.gzdpkg-source: info: unpacking groff_1.22.3-9.debian.tar.xzdpkg-source: info: applying bash-scripts.patchdpkg-source: info: applying mdate-perl.patchdpkg-source: info: applying nroff-ifs.patchdpkg-source: info: applying awk-path.patchdpkg-source: info: applying papersize-pre-html.patchdpkg-source: info: applying doc-gfdl.patchdpkg-source: info: applying doc-gzipped.patchdpkg-source: info: applying make-targets.patchdpkg-source: info: applying pic-eqn-warnings.patchdpkg-source: info: applying extratmacdirs.patchdpkg-source: info: applying papersize-config.patchdpkg-source: info: applying load-desc-failure.patchdpkg-source: info: applying no-validation-icons.patchdpkg-source: info: applying mmse-note.patchdpkg-source: info: applying source-date-epoch.patchdpkg-source: info: applying hdtbl-examples-less-random.patchdpkg-source: info: applying display-utc-times.patchdpkg-source: info: applying sort-perl-hash-keys.patchdpkg-source: info: applying zh-tmac.patchW: 由于文件'groff_1.22.3-9.dsc'无法被用户'_apt'访问,已脱离沙盒并提权为根用户来进行下载。 - pkgAcquire::Run (13: 权限不够)$ lsgroff-1.22.3groff_1.22.3-9.debian.tar.xzgroff_1.22.3-9.dscgroff_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),方式相同,命令稍有差异。