日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

破解ar9331路由器的boot密码

發布時間:2023/12/20 编程问答 23 豆豆
生活随笔 收集整理的這篇文章主要介紹了 破解ar9331路由器的boot密码 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

如何破解基于Atheros AR9931路由器中U-Boot的串口密碼

大部分基于Atheros AR9331的路由器,U-Boot都是在Atheros SDK中U-Boot的基礎上做些修改,然后用到產品中。我們可以從很多廠商的GPL release代碼中找到Atheros SDK中的U-Boot代碼。


互聯網上已經有很多人在GPL release的代碼基礎上做一些U-Boot的修改和開發,比如下面這個項目(波蘭文,請借助goolge翻譯閱讀):

http://www.tech-blog.pl/2013/03/29/zmodyfikowany-u-boot-dla-routerow-tp-link-z-atheros-ar9331-z-trybem-aktualizacji-oprogramowania-przez-www-i-konsola-sieciowa-netconsole/


我將利用上面這個項目中的U-Boot代碼來分析如何破解AR9331 U-Boot中的串口密碼,代碼下載地址:

http://www.tech-blog.pl/pliki/u-boot_for_tp-link_AR9331_by_pepe2k.tar.gz

(也可以從我的baidu網盤下載:http://pan.baidu.com/share/link?shareid=268403347&uk=3392498151)


稍做修改后,然后編譯這個項目,首先我們要看看最終的U-Boot是如何生成的,只有了解了它的生成過程,才會知道如何破解!

略掉很多細節,直接看關鍵的部分:


mips-openwrt-linux-uclibc-ld -Bstatic -T /home/build/ar9331/uboot/u-boot_sources_for_tp-link_AR9331_by_pepe2k/u-boot/board/ar7240/ap121/u-boot.lds -Ttext 0x80010000? -G 0 -static -n -nostdlib $UNDEF_SYM cpu/mips/start.o \
?? ??? ??? ?--start-group lib_generic/libgeneric.a common/libcommon.a board/ar7240/ap121/libap121.a cpu/mips/libmips.a cpu/mips/ar7240/libar7240.a drivers/libdrivers.a lib_mips/libmips.a net/libnet.a rtc/librtc.a? --end-group -L /home/build/ar9331/uboot/u-boot_sources_for_tp-link_AR9331_by_pepe2k/toolchain/bin/../lib/gcc/mips-openwrt-linux-uclibc/4.6.3 -lgcc \
?? ??? ??? ?-Map u-boot.map -o u-boot
mips-openwrt-linux-uclibc-objcopy --gap-fill=0xff -O srec u-boot u-boot.srec
mips-openwrt-linux-uclibc-objcopy --gap-fill=0xff -O binary u-boot u-boot.bin

?? ???? mips-openwrt-linux-uclibc-ld -Bstatic -T /home/build/ar9331/uboot/u-boot_sources_for_tp-link_AR9331_by_pepe2k/u-boot/board/ar7240/ap121/u-boot-bootstrap.lds -Ttext 0x9F000000? -G 0 -static -n -nostdlib $UNDEF_SYM cpu/mips/start_bootstrap.o \
?? ??? ??? ?--start-group lib_bootstrap/libbootstrap.a? board/ar7240/ap121/libap121.a? cpu/mips/libmips.a cpu/mips/ar7240/libar7240.a --end-group -L /home/build/ar9331/uboot/u-boot_sources_for_tp-link_AR9331_by_pepe2k/toolchain/bin/../lib/gcc/mips-openwrt-linux-uclibc/4.6.3 -lgcc \
?? ??? ??? ?-Map bootstrap.map -o bootstrap
mips-openwrt-linux-uclibc-objcopy --gap-fill=0xff -O binary bootstrap bootstrap.bin
/home/build/ar9331/uboot/u-boot_sources_for_tp-link_AR9331_by_pepe2k/host_util/lzma e u-boot.bin u-boot.bin.lzma
./tools/mkimage -A mips -T firmware -C lzma \
?? ??? ?-a 0x80010000 \
?? ??? ?-e 0x80010000 \
?? ??? ?-n 'u-boot image' -d u-boot.bin.lzma u-boot.lzimg

Image Name:?? u-boot image
Created:????? Thu Jul? 4 13:19:14 2013
Image Type:?? MIPS Linux Firmware (lzma compressed)
Data Size:??? 43056 Bytes = 42.05 kB = 0.04 MB
Load Address: 0x80010000
Entry Point:? 0x80010000
cat bootstrap.bin > tuboot.bin
cat u-boot.lzimg >> tuboot.bin


重點關注上面紅色標注的部分,可以看出,最終的tuboot.bin由bootstrap.bin和u-boot.lzimg通過cat命令組合在一起構成。而u-boot.lzimg是u-boot.bin.lzma通過mkimage加一個header構成,而u-boot.bin.lzma是u-boot.bin通過lzma壓縮而成。


如果你直接通過hex編輯工具打開u-boot.bin,U-Boot串口密碼是可以直接看見的(為什么可以直接看見?此處略去技術細節的解釋,有興趣的朋友可以配合代碼,去了解一些編譯,鏈接的知識,以及objcopy等工具的使用)。


分析到這里,發現其實破解很簡單,得到為未壓縮的u-boot.bin,用hex編輯工具就可以查看到串口密碼,這里我們用TP-LINK官方網站release的firmware文件做小白鼠(firmware的路由器型號是WR703N,也是基于AR9331),來演示整個過程。

小白鼠下載地址:

http://pan.baidu.com/share/link?shareid=24218525&uk=3392498151

(也可以從TP-LINK官方網站下載,為了防止以后死鏈出現,我在自己的baidu網盤里備份了一份。TP-LINK官方下載地址:http://service.tp-link.com.cn/detail_download_1016.html)


?
?

解壓以后會得到:wr703nv1.bin,按照上面的分析思路,我們首先要獲取到tuboot.bin,由于Bootloader一般都是放在整個firmware的最前面,根據一定的經驗就可以判斷出tuboot.bin的大小,參考下圖:

通過dd命令截取tuboot.bin:

dd if=wr703nv1.bin of=tuboot.bin bs=48274 count=1


由于u-boot.lzimg是U-Boot工具mkimage生成的文件,參考u-boot/include/image.h:

=================================================

#define IH_MAGIC??????? 0x27051956????? /* Image Magic Number?????????? */
#define IH_NMLEN??????????????? 32????? /* Image Name Length??????????? */

/*
?* all data in network byte order (aka natural aka bigendian)
?*/

typedef struct image_header {
??????? uint32_t??????? ih_magic;?????? /* Image Header Magic Number??? */
??????? uint32_t??????? ih_hcrc;??????? /* Image Header CRC Checksum??? */
??????? uint32_t??????? ih_time;??????? /* Image Creation Timestamp???? */
??????? uint32_t??????? ih_size;??????? /* Image Data Size????????????? */
??????? uint32_t??????? ih_load;??????? /* Data? Load? Address????????? */
??????? uint32_t??????? ih_ep;????????? /* Entry Point Address????????? */
??????? uint32_t??????? ih_dcrc;??????? /* Image Data CRC Checksum????? */
??????? uint8_t???????? ih_os;????????? /* Operating System???????????? */
??????? uint8_t???????? ih_arch;??????? /* CPU architecture???????????? */
??????? uint8_t???????? ih_type;??????? /* Image Type?????????????????? */
??????? uint8_t???????? ih_comp;??????? /* Compression Type???????????? */
??????? uint8_t???????? ih_name[IH_NMLEN];????? /* Image Name?????????? */
} image_header_t;
=================================================
?
?

所以只要查找IH_MAGIC 0x27051956就可以知道u-boot.lzimg在整個tuboot.bin中的起始地址,見下圖:

通過dd命令截取獲得u-boot.lzimg:


dd if=tuboot.bin of=u-boot.lzimg bs=15440 skip=1

然后根據struct image_header的大小,截取獲得u-boot.bin.lzma:

dd if=u-boot.lzimg of=u-boot.bin.lzma bs=64 skip=1


解壓縮u-boot.bin.lzma:

lzma -d u-boot.bin.lzma

然后通過hex編輯器查看u-boot.bin:

TP-LINK默認的U-Boot串口密碼是“tpl”。玩OpenWrt的人都熟知這個密碼,所以我這里直接拿“tpl”做搜索的關鍵字。在實際破解中你肯定不會知道需要破解的密碼,所以你可以根據上圖中“tpl”前面的"seconds"做關鍵字。


本文主要提供一個破解思路,所以很多技術細節沒有深入,描述也不是很準確。但你可以嘗試著通過本文提供的方法,獲取串口密碼。有了串口密碼,進入U-Boot串口命令行,我們可以通過U-Boot中的命令升級firmware(比如刷OpenWrt)。

總結

以上是生活随笔為你收集整理的破解ar9331路由器的boot密码的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。