Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ Usage:

Flags:
INPUT:
-a, -asn string[] target asn to lookup, example: -a AS5650
-a, -asn string[] target asn to lookup, example: -a AS5650, -a 5650
-i, -ip string[] target ip to lookup, example: -i 100.19.12.21, -i 2a10:ad40::
-d, -domain string[] target domain to lookup, example: -d google.com, -d facebook.com
-org string[] target organization to lookup, example: -org GOOGLE
Expand Down
7 changes: 3 additions & 4 deletions runner/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"errors"
"io"
"os"
"strings"

asnmap "github.com/projectdiscovery/asnmap/libs"
"github.com/projectdiscovery/goflags"
Expand Down Expand Up @@ -77,8 +76,8 @@ func (options *Options) validateOptions() error {
// validate asn input
if options.Asn != nil {
for _, asn := range options.Asn {
if !strings.HasPrefix(strings.ToUpper(asn), "AS") {
return errors.New("invalid ASN given. it should start with prefix 'AS', example : AS14421")
if t := asnmap.IdentifyInput(asn); t != asnmap.ASN && t != asnmap.ASNID {
return errors.New("invalid ASN given, example: AS14421 or 14421")
}
}
}
Expand All @@ -93,7 +92,7 @@ func ParseOptions() *Options {

// Input
flagSet.CreateGroup("input", "Input",
flagSet.StringSliceVarP(&options.Asn, "asn", "a", nil, "target asn to lookup, example: -a AS5650", goflags.FileNormalizedStringSliceOptions),
flagSet.StringSliceVarP(&options.Asn, "asn", "a", nil, "target asn to lookup, example: -a AS5650, -a 5650", goflags.FileNormalizedStringSliceOptions),
flagSet.StringSliceVarP(&options.Ip, "ip", "i", nil, "target ip to lookup, example: -i 100.19.12.21, -i 2a10:ad40:: ", goflags.FileNormalizedStringSliceOptions),
flagSet.StringSliceVarP(&options.Domain, "domain", "d", nil, "target domain to lookup, example: -d google.com, -d facebook.com", goflags.FileNormalizedStringSliceOptions),
flagSet.StringSliceVar(&options.Org, "org", nil, "target organization to lookup, example: -org GOOGLE", goflags.StringSliceOptions),
Expand Down
18 changes: 18 additions & 0 deletions runner/options_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package runner

import (
"testing"

"github.com/stretchr/testify/require"
)

func TestValidateASNInput(t *testing.T) {
for _, asn := range []string{"AS13335", "as13335", "13335"} {
options := &Options{Asn: []string{asn}}
require.NoError(t, options.validateOptions(), asn)
}
for _, asn := range []string{"ASX", "google", "AS"} {
options := &Options{Asn: []string{asn}}
require.Error(t, options.validateOptions(), asn)
}
}
Loading