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

17
cmd.go

@ -32,6 +32,13 @@ var suggestions = []cli.Suggest{
{"eros recall all", {"eros recall all",
"Retrieve info on all devices"}, "Retrieve info on all devices"},
{"eros backup",
"Backup all databases to the supplied directory"},
{"arboghast start",
"Start entropic fuzzing via advertising"},
/* /*
{"wrath", {"wrath",
"attack by address"}, "attack by address"},
@ -138,7 +145,17 @@ func executor(cmd string) {
Int16("Current_RSSI", fromEros.RSSIlast). Int16("Current_RSSI", fromEros.RSSIlast).
Int("Service_Count", len(fromEros.Services)). Int("Service_Count", len(fromEros.Services)).
Msg("EROS_RECALL") 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": case "help":

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

@ -15,10 +15,10 @@ import (
// ScanMgr will keep track of concurrently running scans // ScanMgr will keep track of concurrently running scans
var ScanMgr *Meta var ScanMgr *Meta
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
// 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 // 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 // See: Remember function as it is defined in eros/eros.go
@ -31,7 +31,7 @@ func (m *Meta) NewScan() *Scan {
// ref: https://gobyexample.com/mutexes // ref: https://gobyexample.com/mutexes
// ref: https://golang.org/pkg/sync/#Mutex // ref: https://golang.org/pkg/sync/#Mutex
// ref: https://www.geeksforgeeks.org/mutex-in-golang-with-examples/ // ref: https://www.geeksforgeeks.org/mutex-in-golang-with-examples/
func (m *Meta) NewScan() *Scan {
newid := len(m.Scans) newid := len(m.Scans)
m.Scans[newid] = &Scan{ m.Scans[newid] = &Scan{
@ -141,7 +141,7 @@ func (s *Scan) resultHandler(scanAdapter *bluetooth.Adapter, result bluetooth.Sc
log.Info(). log.Info().
Str("Name", fromEros.Name). Str("Name", fromEros.Name).
Str("Addr", fromEros.Addr). 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). Int16("Current_RSSI", fromEros.RSSIlast).
Int("Service_Count", len(fromEros.Services)). Int("Service_Count", len(fromEros.Services)).
Msg("EROS_RECALL") Msg("EROS_RECALL")

@ -7,11 +7,11 @@ import (
) )
/* /*
Why the Meta struct? This shit is a fucking maze. Why the Meta struct?
Well in theory we will have multiple types of scans in the future, 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 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 { type Meta struct {
Count int Count int

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