aboutsummaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
authorheqnx <root@heqnx.com>2025-06-03 23:07:00 +0300
committerheqnx <root@heqnx.com>2025-06-03 23:07:00 +0300
commitcd9b4c799f7aaa069fafe52270bb5452c7618f78 (patch)
tree9e3d3daa304f7834be7ef363a0073ded71f7e461 /main.go
parentd5eb3ce8e0dece3ead36006db8ae04e5ca26a32f (diff)
downloadgo-fakessl-cd9b4c799f7aaa069fafe52270bb5452c7618f78.tar.gz
go-fakessl-cd9b4c799f7aaa069fafe52270bb5452c7618f78.zip
added author
Diffstat (limited to 'main.go')
-rw-r--r--main.go33
1 files changed, 26 insertions, 7 deletions
diff --git a/main.go b/main.go
index 8d9a57f..fd2d37b 100644
--- a/main.go
+++ b/main.go
@@ -117,9 +117,9 @@ func cloneCertificate(urlStr string) (certFilename, keyFilename string) {
fmt.Fprintf(writer, "%s\t%s\t%s", host, certFilename, keyFilename)
writer.Flush()
fmt.Println()
- fmt.Println()
- fmt.Println("[inf] start an https server to test cloned certificate with:")
- fmt.Printf("$ %s -cert %s -key %s -port 8000\n", os.Args[0], certFilename, keyFilename)
+ fmt.Println()
+ fmt.Println("[inf] start an https server to test cloned certificate with:")
+ fmt.Printf("$ %s -cert %s -key %s -port 8000\n", os.Args[0], certFilename, keyFilename)
fmt.Println()
fmt.Println("[inf] manually inspect and diff the original certificate and cloned certificate with:")
fmt.Printf("$ openssl s_client -connect %s </dev/null 2>/dev/null | openssl x509 -noout -text > %s_original.txt\n", host, parsedURL.Host)
@@ -133,12 +133,27 @@ func runHTTPSServer(certPath, keyPath string, portNumber string) {
fmt.Fprintln(w, "Hello, world!")
})
fmt.Printf("[inf] starting https server on https://127.0.0.1:%s\n", portNumber)
- err := http.ListenAndServeTLS("127.0.0.1:"+portNumber, certPath, keyPath, nil)
+ err := http.ListenAndServeTLS("127.0.0.1:"+portNumber, certPath, keyPath, nil)
if err != nil {
log.Fatalf("[err] failed to start httpsserver: %v", err)
}
}
+func init() {
+ const usageHeader = `
+tool designed to clone SSL/TLS certificates from a target server and create a new, self-signed look-alike certificate using its public key
+
+author: heqnx - https://heqnx.com
+
+`
+ flag.Usage = func() {
+ fmt.Fprint(os.Stderr, usageHeader)
+ fmt.Fprintf(os.Stderr, "usage of %s:\n", os.Args[0])
+ flag.PrintDefaults()
+ }
+ flag.CommandLine.SetOutput(os.Stderr)
+}
+
func main() {
urlFlag := flag.String("url", "", "target https url to clone certificate from (e.g. https://google.com)")
certFlag := flag.String("cert", "", "path to certificate file to use for a test https server")
@@ -146,6 +161,11 @@ func main() {
portFlag := flag.String("port", "8000", "port to use for a test https server")
flag.Parse()
+ if flag.NFlag() == 0 && flag.NArg() == 0 {
+ flag.Usage()
+ os.Exit(1)
+ }
+
if *certFlag != "" || *keyFlag != "" {
if *certFlag == "" || *keyFlag == "" {
log.Fatal("[err] both -cert and -key must be supplied to run the HTTPS server")
@@ -159,7 +179,6 @@ func main() {
return
}
- flag.Usage()
- os.Exit(1)
+ flag.Usage()
+ os.Exit(1)
}
-