Skip to content

Commit

Permalink
stdin input and help menu
Browse files Browse the repository at this point in the history
  • Loading branch information
s0md3v committed Mar 20, 2022
1 parent 7f8cbfd commit c941871
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 4 deletions.
9 changes: 6 additions & 3 deletions internal/core/argparser.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"strings"
)

var reValidPair = regexp.MustCompile(`^([-]{1,2}[A-Za-z-]+)?(\d.*)`)
var reValidPair = regexp.MustCompile(`^([-]{1,2}[A-Za-z-]+)?(\d.*)?`)

var validArgs = map[string]bool{ // name : is_boolean_type
"iL": false,
Expand Down Expand Up @@ -175,10 +175,13 @@ func ParseArgs() (map[string]string, []string, bool) {
} else {
argPair[cleaned] = strings.Replace(token, thisArgName+"=", "", 1)
}
} else {
return argPair, extra, true
} else if action == 0 {
argPair[cleaned] = ""
} else if action == 2 {
extra = append(extra, cleaned)
}
lastArg = thisArgName
lastAction = action
continue
}
cleaned, action := whatToDo(token, lastAction)
Expand Down
8 changes: 7 additions & 1 deletion internal/core/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,11 @@ func processScanObject(object scanObject) {
func Init() {
args, extra, invalid := ParseArgs()
if invalid {
fmt.Println("One or more of your arguments are invalid. Refer to docs.\nQUITTING!")
os.Exit(1)
} else if _, ok := args["h"]; ok {
fmt.Print(db.HelpText)
os.Exit(0)
}
g.Args = args
json.Unmarshal(db.NmapSigs, &Probes)
Expand All @@ -258,7 +262,7 @@ func Init() {
if err := scanner.Err(); err != nil {
os.Exit(1)
}
} else {
} else if len(extra) != 0 {
threads := make(chan bool, 3)
for _, arg := range extra {
activeObjects.Add(1)
Expand All @@ -270,6 +274,8 @@ func Init() {
}(arg)
}
activeObjects.Wait()
} else {
fmt.Println("WARNING: No targets were specified, so 0 hosts scanned.")
}
activeScans.Wait()
close(targetsChannel)
Expand Down
17 changes: 17 additions & 0 deletions internal/db/help_text.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package db

var HelpText = `Smap 9.99
Usage: smap <targets here>
TARGET SPECIFICATION:
Valid targets are hostnames, IP addresses, networks, etc.
Ex: scanme.nmap.org, microsoft.com/24, 192.168.0.1, 10.0.0-255.1-254
-iL <filename>: Input from list of hosts/networks. Use - as filename to use stdin input.
OUTPUT:
Specify a file to write the output or use - as filename to write it to stdout (terminal).
Ex: -oX <filename>
-oX XML
-oG Greppable
-oN Nmap
-oA All 3 above
-oJ JSON
`

0 comments on commit c941871

Please sign in to comment.