Skip to content

Commit

Permalink
added few tests
Browse files Browse the repository at this point in the history
  • Loading branch information
saschamonteiro committed Jul 27, 2024
1 parent b598904 commit 74a1013
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 4 deletions.
24 changes: 23 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,28 @@ A utility to scan for TLS certificates in a network segment in CIDR format to qu

This is written in GO and the assets are currently only build for Linux amd64.

The concurrency for host cert checking is currently set to 128.
The concurrency for host cert checking is currently set to 128, tested 1024 which is faster.

## Usage

### Command Flags
```
Usage information:
-cidr string
network cidr list (default "192.168.10.0/24,192.168.11.0/24")
-conc int
concurrent connections (default 128)
-html string
html output file
-json string
json output file
-ports string
tcp port list (default "443,636,587,8443")
-skipnodns
skip no dns found
-v version
```

### Linux amd64
```
#single subnet, single port, output to console only
Expand All @@ -21,6 +40,9 @@ The concurrency for host cert checking is currently set to 128.
#multiple subnets, multiple ports, output to console only
./certchecker_linux -cidr=10.10.10.0/24,10.10.20.0/24 -ports=443,8443
#multiple subnets, multiple ports, output to console only, 1024 concurrent checks
./certchecker_linux -cidr=10.10.10.0/24,10.10.20.0/24 -ports=443,8443 -conc=1024
```
## Output
### Console
Expand Down
9 changes: 7 additions & 2 deletions internal/output/output.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func CreateOutFile(data []certs.TlsCert, fileName string, templateFile string, A
fmt.Printf("error execute template: %v\n", err)
return
}

fmt.Printf("Output file created: %s\n", fileName)
}

// JsonMeta holds the metadata
Expand All @@ -99,7 +99,12 @@ func CreateJsonFile(data []certs.TlsCert, fileName string) {
fmt.Println("error parsing data to json: ", err)
return
}
f.Write(jsonData)
_, err = f.Write(jsonData)
if err != nil {
fmt.Println("error writing data to file: ", err)
return
}
fmt.Printf("Output file created: %s\n", fileName)
}

// exp formats the expired status
Expand Down
8 changes: 7 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,19 @@ var buildTime string

func main() {

flag.Usage = func() {
fmt.Fprintf(flag.CommandLine.Output(), "Cert Checker git-sha1:%v buildtime:%v\n", sha1ver, buildTime)
fmt.Fprintf(flag.CommandLine.Output(), "Usage information:\n")
flag.PrintDefaults()
}

cidrAddressList := flag.String("cidr", "192.168.10.0/24,192.168.11.0/24", "network cidr list")
portList := flag.String("ports", "443,636,587,8443", "tcp port list")
skipNoDnsFound := flag.Bool("skipnodns", false, "skip no dns found")
htmlOut := flag.String("html", "", "html output file")
jsonOut := flag.String("json", "", "json output file")
concurrent := flag.Int("conc", 128, "concurrent connections")
ver := flag.Bool("v", false, fmt.Sprintf("version (sha:%s buildtime:%s)", sha1ver, buildTime))
ver := flag.Bool("v", false, "version")
flag.Parse()
if *ver {
fmt.Printf("version: %s\n", sha1ver)
Expand Down

0 comments on commit 74a1013

Please sign in to comment.