TP-Link 路由器配置 config.bin 解密工具 python 代码 (转载)

转自吾爱破解

https://www.52pojie.cn/forum.php?mod=viewthread&tid=574222

 需要安装crypto

#!/usr/bin/env python
# decrypt tp-link config.bin file
# coded by no mail
 
from Crypto.Cipher import DES
from hashlib import md5
import sys
 
# backup your config.bin from 192.168.x.1
# usage find PPPOE account
# ./run.py wan_ppp_usr
# keys: wan_ppp_usr,wan_ppp_pwd
 
 
key = '\x47\x8D\xA5\x0B\xF9\xE3\xD2\xCF'
crypto = DES.new(key, DES.MODE_ECB)
 
data = open('config.bin', 'rb').read()
data_decrypted = crypto.decrypt(data).rstrip('\0')
assert data_decrypted[:16] == md5(data_decrypted[16:]).digest()
data_decrypted_finally = data_decrypted[16:]
data_decrypted_dict = {}
data_decrypted_array = data_decrypted_finally.split('\r\n')
for item in data_decrypted_array:
    if not item:
        continue
    item_array = item.split(' ', 1)
    item_key = item_array[0]
    item_value = item_array[1]
    data_decrypted_dict[item_key] = item_value
 
if len(sys.argv) > 1:
    print data_decrypted_dict[sys.argv[1]]
open('config.bin.txt', 'wb').write(data_decrypted_finally)

代码py 2.7的 配置信息直接进onfig.bin.txt里面找吧

或是用配置名称作为参数获取直接的配置

$ python2.7 config-tp.py wan_ppp_pwd 

会直接返回pppoe密码

wan_ppp_usr是pppoe用户名

linux下 openssl进行解密

openssl enc -d -des-ecb -nopad -K 478DA50BF9E3D2CF -in config.bin

 搭配grep

openssl enc -d -des-ecb -nopad -K 478DA50BF9E3D2CF -in config.bin | grep -aE 'wan_ppp_usr|wan_ppp_pwd'

猜你喜欢

转载自www.cnblogs.com/jeroen/p/9833022.html