最近在研究家用路由器那本书,很不顺利,在看到P72页的时候遇到以下一些问题,做一些记录,并总结一下,给我自己和后来人借鉴借鉴:
当前环境是:Linux ubuntu 4.2.0-42-generic #49~14.04.1-Ubuntu SMP Wed Jun 29 20:22:18 UTC 2016 i686 i686 i686 GNU/Linux这个虚拟机 是网上的attifyOS
经过查阅资料(揭秘家用路由器0day漏洞挖掘艺术)发现确实是有可能存在下面这么一种情况的:
static bool elf_check_ehdr(struct elfhdr *ehdr)
{
return (elf_check_arch(ehdr->e_machine)
&& ehdr->e_ehsize == sizeof(struct elfhdr)
&& ehdr->e_phentsize == sizeof(struct elf_phdr)
&& ehdr->e_shentsize == sizeof(struct elf_shdr)
&& (ehdr->e_type == ET_EXEC || ehdr->e_type == ET_DYN));
}
&& ehdr->e_shentsize == sizeof(struct elf_shdr) 这句话是说 节头大小要和elf_shdr大小相等,将这句注释掉;
但是我这里是这样的:
到这里,也就是说修改qemu的源文件这种方法也不行了!
3.设置好LD_LIBRARY_PATH
export LD_LIBRARY_PATH=/home/oit/Downloads/_605.bin.extracted/squashfs-root-0/lib
root@ubuntu:/home/oit/Downloads/_605.bin.extracted/squashfs-root-0# chroot . ./qemu-mips ./bin/boa
./bin/boa: Invalid ELF image for this architecture
root@ubuntu:/home/oit/Downloads/_605.bin.extracted/squashfs-root-0# chroot . ./qemu-arm ./bin/boa
./qemu-arm: error while loading shared libraries: libz.so.1: cannot open shared object file: No such file or directory
root@ubuntu:/home/oit/Downloads/_605.bin.extracted/squashfs-root-0# file ./bin/boa
./bin/boa: ELF 32-bit MSB executable, MIPS, MIPS-I version 1 (SYSV), dynamically linked (uses shared libs), corrupted section header size
root@ubuntu:/home/oit/Downloads/_605.bin.extracted/squashfs-root-0# ldd qemu-arm
linux-gate.so.1 => (0xb77db000)
librt.so.1 => /lib/i386-linux-gnu/librt.so.1 (0xb55f4000)
libglib-2.0.so.0 => /lib/i386-linux-gnu/libglib-2.0.so.0 (0xb54e8000)
libz.so.1 => /lib/i386-linux-gnu/libz.so.1 (0xb54ce000)
libstdc++.so.6 => /usr/lib/i386-linux-gnu/libstdc++.so.6 (0xb53e6000)
libm.so.6 => /lib/i386-linux-gnu/libm.so.6 (0xb539f000)
libgcc_s.so.1 => /lib/i386-linux-gnu/libgcc_s.so.1 (0xb5382000)
libpthread.so.0 => /lib/i386-linux-gnu/libpthread.so.0 (0xb5366000)
libc.so.6 => /lib/i386-linux-gnu/libc.so.6 (0xb51b5000)
libpcre.so.3 => /lib/i386-linux-gnu/libpcre.so.3 (0xb5177000)
/lib/ld-linux.so.2 (0x80007000)
root@ubuntu:/home/oit/Downloads/_605.bin.extracted/squashfs-root-0# ldd qemu-mips
linux-gate.so.1 => (0xb77d0000)
librt.so.1 => /lib/i386-linux-gnu/librt.so.1 (0xb55ef000)
libglib-2.0.so.0 => /lib/i386-linux-gnu/libglib-2.0.so.0 (0xb54e3000)
libm.so.6 => /lib/i386-linux-gnu/libm.so.6 (0xb549d000)
libgcc_s.so.1 => /lib/i386-linux-gnu/libgcc_s.so.1 (0xb5480000)
libpthread.so.0 => /lib/i386-linux-gnu/libpthread.so.0 (0xb5463000)
libc.so.6 => /lib/i386-linux-gnu/libc.so.6 (0xb52b2000)
libpcre.so.3 => /lib/i386-linux-gnu/libpcre.so.3 (0xb5274000)
/lib/ld-linux.so.2 (0x800ea000)
root@ubuntu:/home/oit/Downloads/_605.bin.extracted/squashfs-root-0# cp /lib/i386-linux-gnu/librt.so.1 ./lib
root@ubuntu:/home/oit/Downloads/_605.bin.extracted/squashfs-root-0# cp /lib/i386-linux-gnu/libglib-2.0.so.0 ./lib
root@ubuntu:/home/oit/Downloads/_605.bin.extracted/squashfs-root-0# cp /lib/i386-linux-gnu/libm.so.6 ./lib
root@ubuntu:/home/oit/Downloads/_605.bin.extracted/squashfs-root-0# cp /lib/i386-linux-gnu/libgcc_s.so.1 ./lib
root@ubuntu:/home/oit/Downloads/_605.bin.extracted/squashfs-root-0# cp /lib/i386-linux-gnu/libpthread.so.0 ./lib
root@ubuntu:/home/oit/Downloads/_605.bin.extracted/squashfs-root-0# cp /lib/i386-linux-gnu/libc.so.6 ./lib
root@ubuntu:/home/oit/Downloads/_605.bin.extracted/squashfs-root-0# cp /lib/i386-linux-gnu/libpcre.so.3 ./lib
root@ubuntu:/home/oit/Downloads/_605.bin.extracted/squashfs-root-0# cp /lib/ld-linux.so.2 ./lib
root@ubuntu:/home/oit/Downloads/_605.bin.extracted/squashfs-root-0# chroot . ./qemu-arm ./bin/boa./qemu-arm: error while loading shared libraries: libz.so.1: cannot open shared object file: No such file or directory
root@ubuntu:/home/oit/Downloads/_605.bin.extracted/squashfs-root-0# echo $LD_LIBRARY_PATH /home/oit/Downloads/_605.bin.extracted/squashfs-root-0/lib
root@ubuntu:/home/oit/Downloads/_605.bin.extracted/squashfs-root-0# chroot . ./qemu-arm ./bin/boa./qemu-arm: error while loading shared libraries: libz.so.1: cannot open shared object file: No such file or directory
至此,我tmd还能说什么,依赖库也考到相应的目录下面了,该做的基本都做了,我换个系统试试看
换了一个系统之后:
用的是Debian9.5;
root@debianRichard:/home/richard/下载/_605.bin.extracted/squashfs-root-0# qemu-mips -version
qemu-mips version 2.8.1(Debian 1:2.8+dfsg-6+deb9u4)
Copyright (c) 2003-2016 Fabrice Bellard and the QEMU Project developers
root@debianRichard:/home/richard/下载/_605.bin.extracted/squashfs-root-0# ldd qemu-mips
linux-gate.so.1 (0xb7738000)
libgmodule-2.0.so.0 => /usr/lib/i386-linux-gnu/libgmodule-2.0.so.0 (0xb5484000)
libglib-2.0.so.0 => /lib/i386-linux-gnu/libglib-2.0.so.0 (0xb5358000)
librt.so.1 => /lib/i386-linux-gnu/librt.so.1 (0xb534d000)
libm.so.6 => /lib/i386-linux-gnu/libm.so.6 (0xb52f8000)
libgcc_s.so.1 => /lib/i386-linux-gnu/libgcc_s.so.1 (0xb52da000)
libpthread.so.0 => /lib/i386-linux-gnu/libpthread.so.0 (0xb52bd000)
libc.so.6 => /lib/i386-linux-gnu/libc.so.6 (0xb5106000)
libdl.so.2 => /lib/i386-linux-gnu/libdl.so.2 (0xb5101000)
libpcre.so.3 => /lib/i386-linux-gnu/libpcre.so.3 (0xb5088000)
/lib/ld-linux.so.2 (0xb773a000)
root@debianRichard:/home/richard/下载/_605.bin.extracted/squashfs-root-0# mkdir lib
mkdir: 无法创建目录"lib": 文件已存在
root@debianRichard:/home/richard/下载/_605.bin.extracted/squashfs-root-0# cp /usr/lib/i386-linux-gnu/libgmodule-2.0.so.0 ./
root@debianRichard:/home/richard/下载/_605.bin.extracted/squashfs-root-0# cp /lib/i386-linux-gnu/libglib-2.0.so.0 ./lib
root@debianRichard:/home/richard/下载/_605.bin.extracted/squashfs-root-0# cp /lib/i386-linux-gnu/librt.so.1 ./lib
root@debianRichard:/home/richard/下载/_605.bin.extracted/squashfs-root-0# cp /lib/i386-linux-gnu/libgcc_s.so.1 ./lib
root@debianRichard:/home/richard/下载/_605.bin.extracted/squashfs-root-0# cp /lib/i386-linux-gnu/libgcc_s.so.1 ./lib
root@debianRichard:/home/richard/下载/_605.bin.extracted/squashfs-root-0# cp /lib/i386-linux-gnu/libm.so.6 ./lib
root@debianRichard:/home/richard/下载/_605.bin.extracted/squashfs-root-0# cp /lib/i386-linux-gnu/libpthread.so.0 ./lib
root@debianRichard:/home/richard/下载/_605.bin.extracted/squashfs-root-0# cp /lib/i386-linux-gnu/libc.so.6 ./lib
root@debianRichard:/home/richard/下载/_605.bin.extracted/squashfs-root-0# cp /lib/i386-linux-gnu/libdl.so.2 ./lib
root@debianRichard:/home/richard/下载/_605.bin.extracted/squashfs-root-0# cp /lib/i386-linux-gnu/libpcre.so.3 ./lib
root@debianRichard:/home/richard/下载/_605.bin.extracted/squashfs-root-0# cp /lib/ld-linux.so.2 ./lib
以上所做的工作是吧依赖库拷贝至对应的目录下面;
继续执行下面命令:
root@debianRichard:/home/richard/下载/_605.bin.extracted/squashfs-root-0# sudo chroot . ./qemu-mips ./bin/boa
./qemu-mips: error while loading shared libraries: libgmodule-2.0.so.0: cannot open shared object file: No such file or directory
做出如下修改:
root@debianRichard:/home/richard/下载/_605.bin.extracted/squashfs-root-0# cp /usr/lib/i386-linux-gnu/libgmodule-2.0.so.0 ./lib
终于出现了跟家用路由器一书中p72页面类似的状况!
由此确定在attfyOS里面极有可能就是软件版本的问题;
但是我有点不解的是为什么软件升级不了(在affifyOS和Bebian里面都没有升级了)???我不知道我哪里的操作出了问题,小白初次发帖,还请大佬指点一 波