-
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.
- Loading branch information
Showing
11 changed files
with
665 additions
and
573 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
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 |
---|---|---|
@@ -0,0 +1,128 @@ | ||
package jobs | ||
|
||
/* | ||
Sliver Implant Framework | ||
Copyright (C) 2019 Bishop Fox | ||
This program is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
import ( | ||
"context" | ||
"net/url" | ||
"strconv" | ||
|
||
"github.com/bishopfox/sliver/client/command/generate" | ||
"github.com/bishopfox/sliver/client/console" | ||
"github.com/bishopfox/sliver/protobuf/clientpb" | ||
"github.com/desertbit/grumble" | ||
) | ||
|
||
// StageListenerCmd --url [tcp://ip:port | http://ip:port ] --profile name | ||
func StageListenerCmd(ctx *grumble.Context, con *console.SliverConsoleClient) { | ||
profileName := ctx.Flags.String("profile") | ||
listenerURL := ctx.Flags.String("url") | ||
|
||
if profileName == "" || listenerURL == "" { | ||
con.PrintErrorf("Missing required flags, see `help stage-listener` for more info\n") | ||
return | ||
} | ||
|
||
// parse listener url | ||
stagingURL, err := url.Parse(listenerURL) | ||
if err != nil { | ||
con.PrintErrorf("Listener-url format not supported") | ||
return | ||
} | ||
stagingPort, err := strconv.ParseUint(stagingURL.Port(), 10, 32) | ||
if err != nil { | ||
con.PrintErrorf("error parsing staging port: %v\n", err) | ||
return | ||
} | ||
|
||
profile := generate.GetImplantProfileByName(profileName, con) | ||
if profile != nil { | ||
con.PrintErrorf("Profile not found\n") | ||
return | ||
} | ||
stage2, err := generate.GetSliverBinary(profile, con) | ||
if err != nil { | ||
con.PrintErrorf("%s\n", err) | ||
return | ||
} | ||
|
||
switch stagingURL.Scheme { | ||
case "http": | ||
ctrl := make(chan bool) | ||
con.SpinUntil("Starting HTTP staging listener...", ctrl) | ||
stageListener, err := con.Rpc.StartHTTPStagerListener(context.Background(), &clientpb.StagerListenerReq{ | ||
Protocol: clientpb.StageProtocol_HTTP, | ||
Data: stage2, | ||
Host: stagingURL.Hostname(), | ||
Port: uint32(stagingPort), | ||
}) | ||
ctrl <- true | ||
<-ctrl | ||
if err != nil { | ||
con.PrintErrorf("Error starting HTTP staging listener: %s\n", err) | ||
return | ||
} | ||
con.PrintInfof("Job %d (http) started\n", stageListener.GetJobID()) | ||
case "https": | ||
cert, key, err := getLocalCertificatePair(ctx) | ||
if err != nil { | ||
con.Println() | ||
con.PrintErrorf("Failed to load local certificate %s\n", err) | ||
return | ||
} | ||
ctrl := make(chan bool) | ||
con.SpinUntil("Starting HTTPS staging listener...", ctrl) | ||
stageListener, err := con.Rpc.StartHTTPStagerListener(context.Background(), &clientpb.StagerListenerReq{ | ||
Protocol: clientpb.StageProtocol_HTTPS, | ||
Data: stage2, | ||
Host: stagingURL.Hostname(), | ||
Port: uint32(stagingPort), | ||
Cert: cert, | ||
Key: key, | ||
ACME: ctx.Flags.Bool("lets-encrypt"), | ||
}) | ||
ctrl <- true | ||
<-ctrl | ||
if err != nil { | ||
con.PrintErrorf("Error starting HTTPS staging listener: %v\n", err) | ||
return | ||
} | ||
con.PrintInfof("Job %d (https) started\n", stageListener.GetJobID()) | ||
case "tcp": | ||
ctrl := make(chan bool) | ||
con.SpinUntil("Starting TCP staging listener...", ctrl) | ||
stageListener, err := con.Rpc.StartTCPStagerListener(context.Background(), &clientpb.StagerListenerReq{ | ||
Protocol: clientpb.StageProtocol_TCP, | ||
Data: stage2, | ||
Host: stagingURL.Hostname(), | ||
Port: uint32(stagingPort), | ||
}) | ||
ctrl <- true | ||
<-ctrl | ||
if err != nil { | ||
con.PrintErrorf("Error starting TCP staging listener: %v\n", err) | ||
return | ||
} | ||
con.PrintInfof("Job %d (tcp) started\n", stageListener.GetJobID()) | ||
|
||
default: | ||
con.PrintErrorf("Unsupported staging protocol: %s\n", stagingURL.Scheme) | ||
return | ||
} | ||
} |
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
Oops, something went wrong.