mirror of
https://github.com/BishopFox/sliver.git
synced 2026-11-07 17:08:13 -10:00
Compare commits
5
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f1030ebaa4 | ||
|
|
39da957b7c | ||
|
|
4ffb75fa15 | ||
|
|
f9bc1a7bd3 | ||
|
|
a29135770f |
No files matched your search
@@ -131,6 +131,7 @@ var rootCmd = &cobra.Command{
|
||||
|
||||
serverConfig := configs.GetServerConfig()
|
||||
c2.StartPersistentJobs(serverConfig)
|
||||
console.StartPersistentJobs(serverConfig)
|
||||
if serverConfig.DaemonMode {
|
||||
daemon.Start(daemon.BlankHost, daemon.BlankPort)
|
||||
} else {
|
||||
|
||||
@@ -177,6 +177,16 @@ func kickOperatorCmd(ctx *grumble.Context) {
|
||||
fmt.Printf(Info+"Operator %s has been kicked out.\n", operator)
|
||||
}
|
||||
|
||||
func StartPersistentJobs(cfg *configs.ServerConfig) error {
|
||||
if cfg.Jobs == nil {
|
||||
return nil
|
||||
}
|
||||
for _, j := range cfg.Jobs.Multiplayer {
|
||||
jobStartClientListener(j.Host, j.Port)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func startMultiplayerModeCmd(ctx *grumble.Context) {
|
||||
lhost := ctx.Flags.String("lhost")
|
||||
lport := uint16(ctx.Flags.Int("lport"))
|
||||
|
||||
+104
-14
@@ -39,9 +39,16 @@ var (
|
||||
|
||||
// ImplantConfigByID - Fetch implant build by name
|
||||
func ImplantConfigByID(id string) (*models.ImplantConfig, error) {
|
||||
if len(id) < 1 {
|
||||
return nil, ErrRecordNotFound
|
||||
}
|
||||
configID := uuid.FromStringOrNil(id)
|
||||
if configID == uuid.Nil {
|
||||
return nil, ErrRecordNotFound
|
||||
}
|
||||
config := models.ImplantConfig{}
|
||||
err := Session().Where(&models.ImplantConfig{
|
||||
ID: uuid.FromStringOrNil(id),
|
||||
ID: configID,
|
||||
}).First(&config).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -79,6 +86,9 @@ func ImplantBuilds() ([]*models.ImplantBuild, error) {
|
||||
|
||||
// ImplantBuildByName - Fetch implant build by name
|
||||
func ImplantBuildByName(name string) (*models.ImplantBuild, error) {
|
||||
if len(name) < 1 {
|
||||
return nil, ErrRecordNotFound
|
||||
}
|
||||
build := models.ImplantBuild{}
|
||||
err := Session().Where(&models.ImplantBuild{
|
||||
Name: name,
|
||||
@@ -126,6 +136,9 @@ func ImplantProfiles() ([]*models.ImplantProfile, error) {
|
||||
|
||||
// ImplantProfileByName - Fetch implant build by name
|
||||
func ImplantProfileByName(name string) (*models.ImplantProfile, error) {
|
||||
if len(name) < 1 {
|
||||
return nil, ErrRecordNotFound
|
||||
}
|
||||
profile := models.ImplantProfile{}
|
||||
err := Session().Where(&models.ImplantProfile{
|
||||
Name: name,
|
||||
@@ -170,6 +183,9 @@ func ImplantProfileNames() ([]string, error) {
|
||||
|
||||
// ProfileByName - Fetch a single profile from the database
|
||||
func ProfileByName(name string) (*models.ImplantProfile, error) {
|
||||
if len(name) < 1 {
|
||||
return nil, ErrRecordNotFound
|
||||
}
|
||||
dbProfile := &models.ImplantProfile{}
|
||||
err := Session().Where(&models.ImplantProfile{Name: name}).Find(&dbProfile).Error
|
||||
return dbProfile, err
|
||||
@@ -184,6 +200,9 @@ func ListCanaries() ([]*models.DNSCanary, error) {
|
||||
|
||||
// CanaryByDomain - Check if a canary exists
|
||||
func CanaryByDomain(domain string) (*models.DNSCanary, error) {
|
||||
if len(domain) < 1 {
|
||||
return nil, ErrRecordNotFound
|
||||
}
|
||||
dbSession := Session()
|
||||
canary := models.DNSCanary{}
|
||||
err := dbSession.Where(&models.DNSCanary{Domain: domain}).First(&canary).Error
|
||||
@@ -192,6 +211,9 @@ func CanaryByDomain(domain string) (*models.DNSCanary, error) {
|
||||
|
||||
// WebsiteByName - Get website by name
|
||||
func WebsiteByName(name string) (*models.Website, error) {
|
||||
if len(name) < 1 {
|
||||
return nil, ErrRecordNotFound
|
||||
}
|
||||
website := models.Website{}
|
||||
err := Session().Where(&models.Website{Name: name}).First(&website).Error
|
||||
if err != nil {
|
||||
@@ -235,9 +257,16 @@ func HostByHostID(id uuid.UUID) (*models.Host, error) {
|
||||
|
||||
// HostByHostUUID - Get host by the session's reported HostUUID
|
||||
func HostByHostUUID(id string) (*models.Host, error) {
|
||||
if len(id) < 1 {
|
||||
return nil, ErrRecordNotFound
|
||||
}
|
||||
hostID := uuid.FromStringOrNil(id)
|
||||
if hostID == uuid.Nil {
|
||||
return nil, ErrRecordNotFound
|
||||
}
|
||||
host := models.Host{}
|
||||
err := Session().Where(
|
||||
&models.Host{HostUUID: uuid.FromStringOrNil(id)},
|
||||
&models.Host{HostUUID: hostID},
|
||||
).Preload("IOCs").Preload("ExtensionData").First(&host).Error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -247,18 +276,32 @@ func HostByHostUUID(id string) (*models.Host, error) {
|
||||
|
||||
// IOCByID - Select an IOC by ID
|
||||
func IOCByID(id string) (*models.IOC, error) {
|
||||
if len(id) < 1 {
|
||||
return nil, ErrRecordNotFound
|
||||
}
|
||||
ioc := &models.IOC{}
|
||||
iocID := uuid.FromStringOrNil(id)
|
||||
if iocID == uuid.Nil {
|
||||
return nil, ErrRecordNotFound
|
||||
}
|
||||
err := Session().Where(
|
||||
&models.IOC{ID: uuid.FromStringOrNil(id)},
|
||||
&models.IOC{ID: iocID},
|
||||
).First(ioc).Error
|
||||
return ioc, err
|
||||
}
|
||||
|
||||
// BeaconByID - Select a Beacon by ID
|
||||
func BeaconByID(id string) (*models.Beacon, error) {
|
||||
if len(id) < 1 {
|
||||
return nil, ErrRecordNotFound
|
||||
}
|
||||
beaconID := uuid.FromStringOrNil(id)
|
||||
if beaconID == uuid.Nil {
|
||||
return nil, ErrRecordNotFound
|
||||
}
|
||||
beacon := &models.Beacon{}
|
||||
err := Session().Where(
|
||||
&models.Beacon{ID: uuid.FromStringOrNil(id)},
|
||||
&models.Beacon{ID: beaconID},
|
||||
).First(beacon).Error
|
||||
return beacon, err
|
||||
}
|
||||
@@ -267,8 +310,14 @@ func BeaconByID(id string) (*models.Beacon, error) {
|
||||
// by default will not fetch the request/response columns since
|
||||
// these could be arbitrarily large.
|
||||
func BeaconTasksByBeaconID(beaconID string) ([]*models.BeaconTask, error) {
|
||||
beaconTasks := []*models.BeaconTask{}
|
||||
if len(beaconID) < 1 {
|
||||
return nil, ErrRecordNotFound
|
||||
}
|
||||
id := uuid.FromStringOrNil(beaconID)
|
||||
if id == uuid.Nil {
|
||||
return nil, ErrRecordNotFound
|
||||
}
|
||||
beaconTasks := []*models.BeaconTask{}
|
||||
err := Session().Select([]string{
|
||||
"ID", "EnvelopeID", "BeaconID", "CreatedAt", "State", "SentAt", "CompletedAt",
|
||||
"Description",
|
||||
@@ -278,10 +327,17 @@ func BeaconTasksByBeaconID(beaconID string) ([]*models.BeaconTask, error) {
|
||||
|
||||
// BeaconTaskByID - Select a specific BeaconTask by ID, this
|
||||
// will fetch the full request/response
|
||||
func BeaconTaskByID(taskID string) (*models.BeaconTask, error) {
|
||||
func BeaconTaskByID(id string) (*models.BeaconTask, error) {
|
||||
if len(id) < 1 {
|
||||
return nil, ErrRecordNotFound
|
||||
}
|
||||
taskID := uuid.FromStringOrNil(id)
|
||||
if taskID == uuid.Nil {
|
||||
return nil, ErrRecordNotFound
|
||||
}
|
||||
task := &models.BeaconTask{}
|
||||
err := Session().Where(
|
||||
&models.BeaconTask{ID: uuid.FromStringOrNil(taskID)},
|
||||
&models.BeaconTask{ID: taskID},
|
||||
).First(task).Error
|
||||
return task, err
|
||||
}
|
||||
@@ -294,9 +350,16 @@ func ListBeacons() ([]*models.Beacon, error) {
|
||||
}
|
||||
|
||||
// RenameBeacon - Rename a beacon
|
||||
func RenameBeacon(beaconID string, name string) error {
|
||||
func RenameBeacon(id string, name string) error {
|
||||
if len(id) < 1 {
|
||||
return ErrRecordNotFound
|
||||
}
|
||||
beaconID := uuid.FromStringOrNil(id)
|
||||
if beaconID == uuid.Nil {
|
||||
return ErrRecordNotFound
|
||||
}
|
||||
err := Session().Where(&models.Beacon{
|
||||
ID: uuid.FromStringOrNil(beaconID),
|
||||
ID: beaconID,
|
||||
}).Updates(models.Beacon{Name: name}).Error
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -305,11 +368,18 @@ func RenameBeacon(beaconID string, name string) error {
|
||||
}
|
||||
|
||||
// PendingBeaconTasksByBeaconID - Select a Beacon by ID, ordered by creation time
|
||||
func PendingBeaconTasksByBeaconID(beaconID string) ([]*models.BeaconTask, error) {
|
||||
func PendingBeaconTasksByBeaconID(id string) ([]*models.BeaconTask, error) {
|
||||
if len(id) < 1 {
|
||||
return nil, ErrRecordNotFound
|
||||
}
|
||||
beaconID := uuid.FromStringOrNil(id)
|
||||
if beaconID == uuid.Nil {
|
||||
return nil, ErrRecordNotFound
|
||||
}
|
||||
tasks := []*models.BeaconTask{}
|
||||
err := Session().Where(
|
||||
&models.BeaconTask{
|
||||
BeaconID: uuid.FromStringOrNil(beaconID),
|
||||
BeaconID: beaconID,
|
||||
State: models.PENDING,
|
||||
},
|
||||
).Order("created_at").Find(&tasks).Error
|
||||
@@ -317,9 +387,16 @@ func PendingBeaconTasksByBeaconID(beaconID string) ([]*models.BeaconTask, error)
|
||||
}
|
||||
|
||||
// UpdateBeaconCheckinByID - Update the beacon's last / next checkin
|
||||
func UpdateBeaconCheckinByID(beaconID string, next int64) error {
|
||||
func UpdateBeaconCheckinByID(id string, next int64) error {
|
||||
if len(id) < 1 {
|
||||
return ErrRecordNotFound
|
||||
}
|
||||
beaconID := uuid.FromStringOrNil(id)
|
||||
if beaconID == uuid.Nil {
|
||||
return ErrRecordNotFound
|
||||
}
|
||||
err := Session().Where(&models.Beacon{
|
||||
ID: uuid.FromStringOrNil(beaconID),
|
||||
ID: beaconID,
|
||||
}).Updates(models.Beacon{
|
||||
LastCheckin: time.Now(),
|
||||
NextCheckin: time.Now().Unix() + next,
|
||||
@@ -329,10 +406,17 @@ func UpdateBeaconCheckinByID(beaconID string, next int64) error {
|
||||
|
||||
// BeaconTasksByEnvelopeID - Select a (sent) BeaconTask by its envelope ID
|
||||
func BeaconTaskByEnvelopeID(beaconID string, envelopeID int64) (*models.BeaconTask, error) {
|
||||
if len(beaconID) < 1 {
|
||||
return nil, ErrRecordNotFound
|
||||
}
|
||||
beaconUUID := uuid.FromStringOrNil(beaconID)
|
||||
if beaconUUID == uuid.Nil {
|
||||
return nil, ErrRecordNotFound
|
||||
}
|
||||
task := &models.BeaconTask{}
|
||||
err := Session().Where(
|
||||
&models.BeaconTask{
|
||||
BeaconID: uuid.FromStringOrNil(beaconID),
|
||||
BeaconID: beaconUUID,
|
||||
EnvelopeID: envelopeID,
|
||||
State: models.SENT,
|
||||
},
|
||||
@@ -342,6 +426,9 @@ func BeaconTaskByEnvelopeID(beaconID string, envelopeID int64) (*models.BeaconTa
|
||||
|
||||
// CountTasksByBeaconID - Select a (sent) BeaconTask by its envelope ID
|
||||
func CountTasksByBeaconID(beaconID uuid.UUID) (int64, int64, error) {
|
||||
if beaconID == uuid.Nil {
|
||||
return 0, 0, ErrRecordNotFound
|
||||
}
|
||||
allTasks := int64(0)
|
||||
completedTasks := int64(0)
|
||||
err := Session().Model(&models.BeaconTask{}).Where(
|
||||
@@ -363,6 +450,9 @@ func CountTasksByBeaconID(beaconID uuid.UUID) (int64, int64, error) {
|
||||
|
||||
// OperatorByToken - Select an operator by token value
|
||||
func OperatorByToken(value string) (*models.Operator, error) {
|
||||
if len(value) < 1 {
|
||||
return nil, ErrRecordNotFound
|
||||
}
|
||||
operator := &models.Operator{}
|
||||
err := Session().Where(&models.Operator{
|
||||
Token: value,
|
||||
|
||||
Reference in new issue
Block a user