Skip to content

Commit db2ea90

Browse files
committed
optimize print
1 parent 3e11adf commit db2ea90

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

cmd/rootCmd.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ var RootCmd = &cobra.Command{
2020
" \\___ \\ / _ \\ '__\\ \\ / / _ \\ '__| |/ _ \\/ __/ __| | |_) / _ \\| '__| __\\___ \\ / __/ _` | '_ \\ \n" +
2121
" ___) | __/ | \\ V / __/ | | | __/\\__ \\__ \\ | __/ (_) | | | |_ ___) | (_| (_| | | | | \n" +
2222
" |____/ \\___|_| \\_/ \\___|_| |_|\\___||___/___/___|_| \\___/|_| \\__|____/ \\___\\__,_|_| |_| " +
23-
" |_____| \n" +
23+
"\n" +
2424
`
2525
github.com/shadowabi/Serverless_PortScan
2626
@@ -39,6 +39,8 @@ Serverless_PortScan is used to scan ports using cloud functions.
3939
}
4040
},
4141
Run: func(cmd *cobra.Command, args []string) {
42+
cmd.Println(cmd.Long) // print title
43+
4244
if define.Port == "" {
4345
define.Port = config.C.PortList
4446
}
@@ -55,6 +57,7 @@ Serverless_PortScan is used to scan ports using cloud functions.
5557
reqList := pkg.ConvertToReqList(define.Port, hostList...)
5658
resp := pkg.FetchPortData(client, reqList...)
5759

60+
cmd.Println("scan result:")
5861
writeList := pkg.GetResult(resp...)
5962
pkg.WriteToFile(writeList, define.OutPUT)
6063
},

pkg/output.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,20 @@ package pkg
33
import (
44
"bufio"
55
"fmt"
6-
"github.com/shadowabi/Serverless_PortScan_rebuild/utils/Error"
76
"os"
87
"sort"
98
"strings"
9+
10+
"github.com/shadowabi/Serverless_PortScan_rebuild/utils/Error"
1011
)
1112

1213
func GetResult(respData ...ResponseData) (writeResultList []string) {
1314
if len(respData) != 0 {
1415
for _, data := range respData {
1516
dataBody := strings.Trim(data.body, "\"")
17+
if dataBody == "" {
18+
continue
19+
}
1620
ports := strings.Split(dataBody, ",")
1721
for _, port := range ports {
1822
fmt.Println(fmt.Sprintf("[+] %s:%s TCP OPEN.", data.host, port))

0 commit comments

Comments
 (0)