|
1 | 1 | package main |
2 | 2 |
|
3 | 3 | import ( |
| 4 | + "bytes" |
4 | 5 | "fmt" |
5 | 6 | "io" |
6 | 7 | "log" |
|
53 | 54 | func printHelp() { |
54 | 55 | fmt.Println("usage: ", filepath.Base(os.Args[0]), "--[foreground|fingerprint|proxy|process_name] -d|--destination <server_address>") |
55 | 56 | 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") |
56 | 58 | fmt.Println("\t\t--foreground\tCauses the client to run without forking to background") |
57 | 59 | 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") |
58 | 61 | fmt.Println("\t\t--proxy\tLocation of HTTP connect proxy to use") |
59 | 62 | fmt.Println("\t\t--ntlm-proxy-creds\tNTLM proxy credentials in format DOMAIN\\USER:PASS") |
60 | 63 | fmt.Println("\t\t--process_name\tProcess name shown in tasklist/process list") |
@@ -125,6 +128,22 @@ func main() { |
125 | 128 | userSpecifiedFingerprint, err := line.GetArgString("fingerprint") |
126 | 129 | if err == nil { |
127 | 130 | 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 | + } |
128 | 147 | } |
129 | 148 |
|
130 | 149 | userSpecifiedSNI, err := line.GetArgString("sni") |
@@ -155,7 +174,18 @@ func main() { |
155 | 174 |
|
156 | 175 | tempDestination, err := line.GetArgString("d") |
157 | 176 | 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 | + } |
159 | 189 | } |
160 | 190 |
|
161 | 191 | if len(tempDestination) > 0 { |
|
0 commit comments