|
本帖最后由 222ba 于 2017-8-9 19:02 编辑
事情源于客户比较小白,不懂英文,于是就着手汉化优科的固件。结局却是半途放弃,因为有客户反馈说中文版的稳定性欠佳。
这个不管是不是真的,修改官方固件或多或少会带来不稳定因素,这里记录一下笔记。
其实基本上是依葫芦画瓢,善用Goog基本上能解决大部分问题。
Goog:路由器固件解包,得到《逆向路由器固件之解包 Part1》:
http://www.freebuf.com/sectool/75915.html
binwalk — 通过固件文件头来分析文件和文件系统
Fireware Mod Kit — 自动化分析固件文件的一系列脚本
squashfs-tools — 可以通过apt-get squashfs-tools 来安装。用来处理squashfs的一系列工具
以上三种工具,这里只用了两种,理论上更简单的Firmware mod kit没用,翻看了一下是DD-WRT时代的产品,有点老了。
另外一个帖子是《Binwalk:后门(固件)分析利器》:http://www.freebuf.com/sectool/15266.html
基本上就是对这个工具的更详细介绍。
接下来是重点《路由器固件逆向解包》:http://blog.7web.tk/201701/router-firmware-unpack
示范的是解包的老毛子固件,然后改改里面的LOGO,也是没说出来的情况。
binwalk RT-AC54U-GPIO-1-PSG1208-64M_3.4.3.9-099.trx
分析是比较有用的,用于优科的固件
- binwalk zf7372_9.7.0.0.220.Bl7
- DECIMAL HEXADECIMAL DESCRIPTION
- --------------------------------------------------------------------------------
- 160 0xA0 LZMA compressed data, properties: 0x5D, dictionary size: 16777216 bytes, uncompressed size: 3458300 bytes
- 1179648 0x120000 Squashfs filesystem, little endian, version 4.0, compression:lzma, size: 7130989 bytes, 4493 inodes, blocksize: 131072 bytes, created: 2013-12-06 04:02:07
复制代码
两个部分,前者基本上没用,有用的是如何切割到想要的部分
这里需要dd命令,就是检查备份CFE的那个。
- dd if=zf7372_9.7.0.0.220.Bl7 of=romfs.squashfs bs=1 skip=1179648
复制代码
skip后面就是binwalk分析出的地址,后面没count则表示到尾部
得到的文件就可以用unsquashfs解压了,但是中途遇到一个棘手的问题。
- Filesystem uses lzma compression, this is unsupported by this version
- Decompressors available:
- gzip
- lzo
复制代码
呵呵,放狗搜。https://unix.stackexchange.com/q ... nsquashfs-with-lzma
- Get source here: http://sourceforge.net/projects/squashfs/
- # sudo apt-get install lzma-dev
- # sudo apt-get install liblzma-dev
- # tar -zxvf squashfs4.2.tar.gz
- # cd squashfs4.2/squashfs-tools: Edit Makefile and uncomment this line "LZMA_XZ_SUPPORT = 1"
- # make
- # sudo make install
- # sudo unsquashfs <path/lzma_filename_to_unsquash>
复制代码
取消注释,编译即可。编译安装的位置要注意,和系统默认位置不一样。
- /usr/local/bin/unsquashfs romfs.squashfs
- Parallel unsquashfs: Using 1 processor
- 3892 inodes (4019 blocks) to write
- [===================================================================================================================================\] 4019/4019 100%
- created 3558 files
- created 601 directories
- created 237 symlinks
- created 97 devices
- created 0 fifos
复制代码 成功
然后要的文件就等着你了
- /squashfs-root# ls
- ash_env bin boot ca-certs custom defaults dev etc fl home lib linuxrc mfr mnt opt proc root sbin sys tmp usr var web writable
复制代码
- ls ./web/
- administrator favicon.ico images js oem ruckus_login.asp smartclient3.asp supportinfo.txt
- bottom.asp fingerprints.asp index.asp login.asp quickstart smartclient0.asp smartclient4.asp top.asp
- configuration _help index.html maintenance ruckus_favicon.ico smartclient1.asp smartclient5.asp
- css hotspot.htm internet_down.html nav.asp ruckus_index.asp smartclient2.asp status
复制代码
- cat ./web/bottom.asp
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
- <head>
- <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
- <title><% rsm_webguiqv("getcompanyname", ""); %> Admin</title>
- <style type="text/css">
- body { margin: 0; padding: 0; font: normal 10px "Trebuchet MS", Verdana, Geneva, Arial, Helvetica, sans-serif; background: #f5f5f5 url(/images/bg_bottom.gif) top left repeat-x; color: #000; }
- h1 { margin: 0; font-size: 17px; }
- #copyright { position: absolute; right: 7px; bottom: 5px; }
- #ident { float: left; margin: 10px 0 0 19px; vertical-align: top; }
- #logo { float: left; margin: 10px 0 0 19px; vertical-align: top; }
- #devicename { font-size: 2.2em; margin-top: 8px; }
- </style>
- <!--[if lt IE 7]>
- <style type="text/css">#ident, div#logo { display: inline; }</style>
- <![endif]-->
- </head>
- <body>
- <div id="logo">
- <img src="images/logo.gif" width="133" height="40" alt="<% rsm_webguiqv("getcompanyname", ""); %>" title="<% rsm_webguiqv("getcompanyname", ""); %>" />
- </div>
- <div id="ident">
- <h1 id="devicename"> <% rsm_webguiqv("getmodeldispstring", "ERROR101"); %></h1>
- </div>
- <div id="copyright">© Copyright <% rsm_webguiqv("getcalendaryear", ""); %> <% rsm_webguiqv("getcompanyname", ""); %></div>
- </body>
- </html>
复制代码 这里面想加什么LOGO啊 网址啊 都随便。
接下来打包回去。没研究了。找到这些文件在哪里,就是这番折腾的目的。
其它英文的固件也可以类似解,折腾。
|
|