-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #378 from BishopFox/stage
Improved CLI UX
- Loading branch information
Showing
5 changed files
with
75 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,59 @@ | ||
package cli | ||
|
||
import ( | ||
"fmt" | ||
"log" | ||
"os" | ||
"runtime/debug" | ||
|
||
"github.com/bishopfox/sliver/server/assets" | ||
"github.com/bishopfox/sliver/server/c2" | ||
"github.com/bishopfox/sliver/server/certs" | ||
"github.com/bishopfox/sliver/server/configs" | ||
"github.com/bishopfox/sliver/server/daemon" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
var daemonCmd = &cobra.Command{ | ||
Use: "daemon", | ||
Short: "Start server in daemon mode", | ||
Short: "Force start server in daemon mode", | ||
Long: ``, | ||
Run: func(cmd *cobra.Command, args []string) { | ||
daemon.Start() | ||
force, err := cmd.Flags().GetBool(forceFlagStr) | ||
if err != nil { | ||
fmt.Printf("Failed to parse --%s flag %s\n", forceFlagStr, err) | ||
return | ||
} | ||
lhost, err := cmd.Flags().GetString(lhostFlagStr) | ||
if err != nil { | ||
fmt.Printf("Failed to parse --%s flag %s\n", lhostFlagStr, err) | ||
return | ||
} | ||
lport, err := cmd.Flags().GetUint16(lportFlagStr) | ||
if err != nil { | ||
fmt.Printf("Failed to parse --%s flag %s\n", lportFlagStr, err) | ||
return | ||
} | ||
|
||
appDir := assets.GetRootAppDir() | ||
logFile := initLogging(appDir) | ||
defer logFile.Close() | ||
|
||
defer func() { | ||
if r := recover(); r != nil { | ||
log.Printf("panic:\n%s", debug.Stack()) | ||
fmt.Println("stacktrace from panic: \n" + string(debug.Stack())) | ||
os.Exit(99) | ||
} | ||
}() | ||
|
||
assets.Setup(force, false) | ||
certs.SetupCAs() | ||
certs.SetupWGKeys() | ||
|
||
serverConfig := configs.GetServerConfig() | ||
c2.StartPersistentJobs(serverConfig) | ||
|
||
daemon.Start(lhost, uint16(lport)) | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,6 +37,6 @@ var unpackCmd = &cobra.Command{ | |
return | ||
} | ||
|
||
assets.Setup(force) | ||
assets.Setup(force, true) | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters