Work on command line interface, add arboghast

This commit is contained in:
kayos 2021-06-30 20:40:33 -07:00
parent d535711880
commit 4428ac4da7
8 changed files with 145 additions and 47 deletions

39
cmd.go

@ -8,7 +8,7 @@ import (
"github.com/rs/zerolog/log"
"os"
"protomolecule/src/eros"
// "protomolecule/src/wrath"
// "protomolecule/src/wrath"
projVars "protomolecule/src/vars"
"strings"
)
@ -32,10 +32,17 @@ var suggestions = []cli.Suggest{
{"eros recall all",
"Retrieve info on all devices"},
/*
{"wrath",
"attack by address"},
*/
{"eros backup",
"Backup all databases to the supplied directory"},
{"arboghast start",
"Start entropic fuzzing via advertising"},
/*
{"wrath",
"attack by address"},
*/
{"exit",
"Exit ProtoMolecule"},
@ -138,7 +145,17 @@ func executor(cmd string) {
Int16("Current_RSSI", fromEros.RSSIlast).
Int("Service_Count", len(fromEros.Services)).
Msg("EROS_RECALL")
case "backup":
if len(args) < 3 {
getHelp("eros backup")
return
}
if err := eros.Backup(args[3]); err != nil {
log.Error().Err(err).Msg("Failed to backup databases!")
}
}
}
case "help":
@ -232,12 +249,12 @@ func executor(cmd string) {
}
/*
case "wrath":
if len(args) < 2 {
getHelp("wrath")
return
}
wrath(args[1])
case "wrath":
if len(args) < 2 {
getHelp("wrath")
return
}
wrath(args[1])
*/
case "clear":

@ -67,6 +67,7 @@ func cliFlags() {
}
if *projVars.DFlag {
projVars.Debug = true
zerolog.SetGlobalLevel(zerolog.DebugLevel)
}

@ -0,0 +1,52 @@
// arboghast is a package focused on fuzzing BLE devices
package arboghast
import (
projVars "protomolecule/src/vars"
bluetooth "git.tcp.direct/kayos/prototooth"
"sync"
)
type Circus struct {
Trick map[int]*Fuzzy
uuid_pool []bluetooth.UUID
mu *sync.Mutex
}
type Fuzzy struct {
config *bluetooth.AdvertisementOptions
ad *bluetooth.Advertisement
mu *sync.Mutex
}
var circus *Circus
func Awaken() {
circus = &Circus{
Trick: make(map[int]*Fuzzy),
uuid_pool: []bluetooth.UUID{},
mu: &sync.Mutex{},
}
}
func NewEntropicFuzzer() *Fuzzy {
options := &bluetooth.AdvertisementOptions{
LocalName: RandomAlpha(16),
// Interval:
}
mutex := &sync.Mutex{}
ad := projVars.ScanAdapter.DefaultAdvertisement()
ad.Configure(options)
return &Fuzzy{
config: options,
ad: ad,
mu: mutex,
}
}
func (f *Fuzzy) StartAd() {
f.ad.Start()
}

34
src/arboghast/entropy.go Normal file

@ -0,0 +1,34 @@
package arboghast
import (
"math/rand"
"time"
"unsafe"
)
var src = rand.NewSource(time.Now().UnixNano())
const (
letterBytes = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
letterIdxBits = 6 // 6 bits to represent a letter index
letterIdxMask = 1<<letterIdxBits - 1 // All 1-bits, as many as letterIdxBits
letterIdxMax = 63 / letterIdxBits // # of letter indices fitting in 63 bits
)
func RandomAlpha(n int) string {
b := make([]byte, n)
// A src.Int63() generates 63 random bits, enough for letterIdxMax characters!
for i, cache, remain := n-1, src.Int63(), letterIdxMax; i >= 0; {
if remain == 0 {
cache, remain = src.Int63(), letterIdxMax
}
if idx := int(cache & letterIdxMask); idx < len(letterBytes) {
b[i] = letterBytes[idx]
i--
}
cache >>= letterIdxBits
remain--
}
return *(*string)(unsafe.Pointer(&b))
}

@ -1,5 +1,3 @@
package eros
// Eros controls the Bitcask db that holds the devices captured during scanning
//
// Addr (Key)
@ -10,6 +8,7 @@ package eros
// TODO:
// Output to report
//
package eros
import (
"bufio"
@ -27,15 +26,11 @@ import (
)
var (
// devices will hold details about devices discovered
// exploits will hold details about exploits to be used against BLE devices
// services will hold definitions of various bluetook services and will ultimately be updated via an HTTP repository
// manufacturers will hold manufacturer to UUID correlations
dbs = []string{
"devices",
"exploits",
"services",
"manufacturers",
"devices", // details about devices discovered
"exploits", // details about exploits to be used against BLE devices
"services", // definitions of various bluetook services and will ultimately be updated via an HTTP repository
"manufacturers", // manufacturer to UUID correlations and info
}
err error
@ -239,16 +234,16 @@ func Recall(Addr string) (Device, error) {
return member, err
}
func Backup(path string) {
func Backup(path string) error {
for _, db := range DB {
db.Merge()
db.Sync()
err := db.Backup(path)
if err != nil {
panic(err.Error())
return err
}
}
return nil
}
// Hypnosis - retrieve new exploits/attacks from a remote http repository

@ -15,23 +15,23 @@ import (
// ScanMgr will keep track of concurrently running scans
var ScanMgr *Meta
// NewScan - here we are creating an "anonymous" instance of a Scan struct
// You'll notice it doesn't contain most of the data that actually is supposed to live within that struct
//
// This works because the integer ID is being used as a key that will have a global scope
//
// See: Remember function as it is defined in eros/eros.go
// Remember usage in this file (scanStuff/scanStuff.go
//
// In these examples we are sending an instance of a struct with some data to eros; allowing it to finish filling out the rest
// This can be done with just structs, but becomes problematic when trying to refer to them later
//
//TODO: implement Mutex locking from sync in most of these structs to prevent concurrent read/write operations from causing a race w̶a̶r̶ condition
// ref: https://gobyexample.com/mutexes
// ref: https://golang.org/pkg/sync/#Mutex
// ref: https://www.geeksforgeeks.org/mutex-in-golang-with-examples/
func (m *Meta) NewScan() *Scan {
// Here we are creating an "anonymous" instance of a Scan struct
// You'll notice it doesn't contain most of the data that actually is supposed to live within that struct
// This works because the integer ID is being used as a key that will have a global scope
//
// See: Remember function as it is defined in eros/eros.go
// Remember usage in this file (scanStuff/scanStuff.go
//
// In these examples we are sending an instance of a struct with some data to eros; allowing it to finish filling out the rest
// This can be done with just structs, but becomes problematic when trying to refer to them later
//
//TODO: implement Mutex locking from sync in most of these structs to prevent concurrent read/write operations from causing a race w̶a̶r̶ condition
// ref: https://gobyexample.com/mutexes
// ref: https://golang.org/pkg/sync/#Mutex
// ref: https://www.geeksforgeeks.org/mutex-in-golang-with-examples/
newid := len(m.Scans)
m.Scans[newid] = &Scan{
@ -141,7 +141,7 @@ func (s *Scan) resultHandler(scanAdapter *bluetooth.Adapter, result bluetooth.Sc
log.Info().
Str("Name", fromEros.Name).
Str("Addr", fromEros.Addr).
Str("ManuF", EnumedManuf). //needs to be changed back to fromEros.Manufacturer
Str("ManuF", fromEros.Manufacturer). //needs to be changed back to fromEros.Manufacturer
Int16("Current_RSSI", fromEros.RSSIlast).
Int("Service_Count", len(fromEros.Services)).
Msg("EROS_RECALL")

@ -7,11 +7,11 @@ import (
)
/*
Why the Meta struct? This shit is a fucking maze.
Well in theory we will have multiple types of scans in the future,
if that's the case this is going to become necessary very quickly
Why the Meta struct?
In theory we will have multiple types of scans in the future,
if that's the case this is going to become necessary very quickly
I've mocked up some commented out examples below.
I've mocked up some commented out examples in the source code below.
*/
type Meta struct {
Count int

@ -2,8 +2,8 @@ package wrath
import (
bluetooth "git.tcp.direct/kayos/prototooth"
"github.com/rs/zerolog/log"
"github.com/rs/zerolog"
"github.com/rs/zerolog/log"
projVars "protomolecule/src/vars"
"tinygo.org/x/bluetooth/rawterm"
)
@ -157,5 +157,4 @@ func Start() {
}
}
}
}