Skip to content

Commit

Permalink
- Updated to fix a bug where PublicKeys were not loaded
Browse files Browse the repository at this point in the history
- Updated to XMT v0.5.1-b1
- Code reformatting changes
  • Loading branch information
iDigitalFlame committed Mar 22, 2023
1 parent d013142 commit 9722cf1
Show file tree
Hide file tree
Showing 10 changed files with 51 additions and 57 deletions.
69 changes: 35 additions & 34 deletions cirrus/cirrus.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,26 +48,25 @@ const (
// Cirrus also supplies a stats module that can be used to log and track
// event counts.
type Cirrus struct {
srv http.Server
ctx context.Context
ws *websocket.Upgrader

s *c2.Server
st *stats
ch chan struct{}
mux *routex.Mux
log logx.Log
cancel context.CancelFunc

log logx.Log
ctx context.Context
cancel context.CancelFunc
jobs *jobManager
st *stats
ch chan struct{}
mux *routex.Mux
ws *websocket.Upgrader
listeners *listenerManager
s *c2.Server
events *eventManager
packets *packetManager
scripts *scriptManager
profiles *profileManager
sessions *sessionManager
listeners *listenerManager

Auth string
Auth string
srv http.Server

Timeout time.Duration
}

Expand Down Expand Up @@ -138,26 +137,7 @@ func (c *Cirrus) Load(s string) error {
if err = json.Unmarshal(b, &m); err != nil {
return err
}
if t, ok := m["scripts"]; ok {
if err = json.Unmarshal(t, &c.scripts); err != nil {
return err
}
}
if t, ok := m["profiles"]; ok {
if err = json.Unmarshal(t, &c.profiles); err != nil {
return err
}
}
if t, ok := m["listeners"]; ok {
if err = json.Unmarshal(t, &c.listeners); err != nil {
return err
}
}
if t, ok := m["timeout"]; ok {
if err = json.Unmarshal(t, &c.Timeout); err != nil {
return err
}
}
// Load keys first.
if t, ok := m["keys"]; ok {
var v map[string]string
if err = json.Unmarshal(t, &v); err != nil {
Expand All @@ -176,11 +156,32 @@ func (c *Cirrus) Load(s string) error {
}
}
}
if t, ok := m["auth"]; ok && len(t) > 2 {
if t, ok := m["auth"]; ok {
if err = json.Unmarshal(t, &c.Auth); err != nil {
return err
}
}
if t, ok := m["timeout"]; ok {
if err = json.Unmarshal(t, &c.Timeout); err != nil {
return err
}
}
if t, ok := m["profiles"]; ok {
if err = json.Unmarshal(t, &c.profiles); err != nil {
return err
}
}
if t, ok := m["scripts"]; ok {
if err = json.Unmarshal(t, &c.scripts); err != nil {
return err
}
}
// Load listeners since they rely on all the above to work.
if t, ok := m["listeners"]; ok {
if err = json.Unmarshal(t, &c.listeners); err != nil {
return err
}
}
return nil
}

Expand Down
3 changes: 1 addition & 2 deletions cirrus/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,9 @@ import (
const msgNoJob = "job was not found"

type jobManager struct {
sync.RWMutex
*Cirrus

e map[uint64]*c2.Job
sync.RWMutex
}

func (j *jobManager) pruneSessions() {
Expand Down
3 changes: 1 addition & 2 deletions cirrus/listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,8 @@ type listener struct {
}
type listenerManager struct {
*Cirrus
sync.RWMutex

e map[string]*listener
sync.RWMutex
}

func (l *listener) MarshalJSON() ([]byte, error) {
Expand Down
3 changes: 1 addition & 2 deletions cirrus/packet.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,8 @@ type packet struct {
}
type packetManager struct {
*Cirrus
sync.RWMutex

e map[string]*packet
sync.RWMutex
}

func (c *Cirrus) packetNew(n *com.Packet) {
Expand Down
3 changes: 1 addition & 2 deletions cirrus/profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,8 @@ const msgNoProfile = "profile was not found"

type profileManager struct {
*Cirrus
sync.RWMutex

e map[string]cfg.Config
sync.RWMutex
}

func (p *profileManager) MarshalJSON() ([]byte, error) {
Expand Down
13 changes: 6 additions & 7 deletions cirrus/script.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,12 @@ var (
)

type script struct {
last time.Time
s *task.Script
path string
c []string
r []uint64
sync.Mutex
last time.Time
s *task.Script
path string
c []string
r []uint64
loaded bool
}
type scriptArgs struct {
Expand All @@ -81,9 +81,8 @@ type scriptArgs struct {
}
type scriptManager struct {
*Cirrus
sync.RWMutex

e map[string]*script
sync.RWMutex
}

func ws(s val.Set) val.Set {
Expand Down
7 changes: 2 additions & 5 deletions cirrus/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,18 +42,15 @@ var (
)

type session struct {
sync.RWMutex
s *c2.Session
j []uint16
sync.RWMutex
h uint32
}
type sessionManager struct {
*Cirrus
sync.RWMutex

// TODO(dij): Work on naming sessions
// n map[string]*session
e map[string]*session
sync.RWMutex
}

func (c *Cirrus) newSession(s *c2.Session) {
Expand Down
4 changes: 2 additions & 2 deletions cirrus/stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ const (
)

type stats struct {
_ [0]func()
sync.Mutex
_ [0]func()
f, t *os.File
ch chan struct{}
ej chan statJobEvent
es chan statSessionEvent
ep chan statPacketEvent
e [0xFF]uint64
j, s uint64
sync.Mutex
}
type statJobEvent struct {
_ [0]func()
Expand Down
1 change: 1 addition & 0 deletions cirrus/values.go
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,7 @@ type taskAssembly struct {
taskExecute
}
type taskWorkHours struct {
_ [0]func()
Line string `json:"line"`
Days string `json:"days"`
StartHour uint8 `json:"start_hour"`
Expand Down
2 changes: 1 addition & 1 deletion src

0 comments on commit 9722cf1

Please sign in to comment.