diff options
| author | heqnx <root@heqnx.com> | 2025-06-03 23:07:00 +0300 | 
|---|---|---|
| committer | heqnx <root@heqnx.com> | 2025-06-03 23:07:00 +0300 | 
| commit | cd9b4c799f7aaa069fafe52270bb5452c7618f78 (patch) | |
| tree | 9e3d3daa304f7834be7ef363a0073ded71f7e461 | |
| parent | d5eb3ce8e0dece3ead36006db8ae04e5ca26a32f (diff) | |
| download | go-fakessl-cd9b4c799f7aaa069fafe52270bb5452c7618f78.tar.gz go-fakessl-cd9b4c799f7aaa069fafe52270bb5452c7618f78.zip | |
added author
| -rw-r--r-- | main.go | 33 | 
1 files changed, 26 insertions, 7 deletions
| @@ -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)  } - |