Files
MrAle98-sliver/client/command/jobs/https.go
T
2021-07-04 13:08:15 -05:00

76 lines
2.1 KiB
Go

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"
"io/ioutil"
"github.com/bishopfox/sliver/client/console"
"github.com/bishopfox/sliver/protobuf/clientpb"
"github.com/desertbit/grumble"
)
// HTTPSListenerCmd - Start an HTTPS listener
func HTTPSListenerCmd(ctx *grumble.Context, con *console.SliverConsoleClient) {
domain := ctx.Flags.String("domain")
website := ctx.Flags.String("website")
lport := uint16(ctx.Flags.Int("lport"))
cert, key, err := getLocalCertificatePair(ctx)
if err != nil {
con.Println()
con.PrintErrorf("Failed to load local certificate %s\n", err)
return
}
con.PrintInfof("Starting HTTPS %s:%d listener ...\n", domain, lport)
https, err := con.Rpc.StartHTTPSListener(context.Background(), &clientpb.HTTPListenerReq{
Domain: domain,
Website: website,
Port: uint32(lport),
Secure: true,
Cert: cert,
Key: key,
ACME: ctx.Flags.Bool("lets-encrypt"),
Persistent: ctx.Flags.Bool("persistent"),
})
con.Println()
if err != nil {
con.PrintErrorf("%s\n", err)
} else {
con.PrintInfof("Successfully started job #%d\n", https.JobID)
}
}
func getLocalCertificatePair(ctx *grumble.Context) ([]byte, []byte, error) {
if ctx.Flags.String("cert") == "" && ctx.Flags.String("key") == "" {
return nil, nil, nil
}
cert, err := ioutil.ReadFile(ctx.Flags.String("cert"))
if err != nil {
return nil, nil, err
}
key, err := ioutil.ReadFile(ctx.Flags.String("key"))
if err != nil {
return nil, nil, err
}
return cert, key, nil
}