projectdiscovery / asnmap

Go CLI and Library for quickly mapping organization network ranges using ASN information.
MIT License
763 stars 69 forks source link

[FTL] unexpected end of JSON input #124

Closed gprime31 closed 1 year ago

gprime31 commented 1 year ago

2023-05-20_20-51

So upgrading from an earlier version works fine ( git pull ) but fresh install (git clone or go install) results in this error: [FTL] unexpected end of JSON input missing bracket or something?

MetzinAround commented 1 year ago

Did you do the recent install with PDTM or another method?

MetzinAround commented 1 year ago

Just realized you answered that.

could you try installing with PDTM and see if that still causes the error?

gprime31 commented 1 year ago

2023-05-22_11-04

gprime31 commented 1 year ago

2023-05-22_11-05 Digital ocean droplet.

gprime31 commented 1 year ago

2023-05-22_13-20 ok very strange, it works but some throw the error... same with asn numbers.

gprime31 commented 1 year ago

tested on: OS: Ubuntu 20.04.6 LTS x86_64 and OS: Debian GNU/Linux 11 (bullseye) aarch64 have the error.

Linux Arch AMD-64 and Mint 21.1 AMD-64 work fine, no problems. is there something that comes with those distros by default that the others are missing?

HackTheBridge commented 1 year ago

I'm also getting this error for all options :/ I just checked pdtm and is up to date. Worked fine for me a few weeks ago. I'm using MacOS.

projectdiscovery $ asnmap -a AS43996

   ___   _____  __
  / _ | / __/ |/ /_ _  ___ ____
 / __ |_\ \/    /  ' \/ _  / _ \
/_/ |_/___/_/|_/_/_/_/\_,_/ .__/
                         /_/

        projectdiscovery.io

[INF] Current asnmap version v1.0.4 (latest)
[FTL] unexpected end of JSON input
Mzack9999 commented 1 year ago

@gprime31 @HackTheBridge Thanks for reporting this bug - It seems like the final endpoint https://api.asnmap.sh/api/v1/asnmap?ip=xxx is returning for some reason an empty answer. I suspect it might be related to TLS configuration/certificates. I'll post an update as soon as we find the root cause. Thanks for your patience!

ehsandeep commented 1 year ago

Build test are failing as well with same error

--- FAIL: TestGetASNFromIP (0.49s)
    --- FAIL: TestGetASNFromIP/found (0.27s)
        client_test.go:25: 
                Error Trace:    /home/runner/work/asnmap/asnmap/libs/client_test.go:25
                Error:          Expected nil, but got: &json.SyntaxError{msg:"unexpected end of JSON input", Offset:0}
                Test:           TestGetASNFromIP/found
    --- FAIL: TestGetASNFromIP/not_found (0.22s)
        client_test.go:25: 
                Error Trace:    /home/runner/work/asnmap/asnmap/libs/client_test.go:25
                Error:          Expected nil, but got: &json.SyntaxError{msg:"unexpected end of JSON input", Offset:0}
                Test:           TestGetASNFromIP/not_found
--- FAIL: TestGetASNFromOrg (0.67s)
    --- FAIL: TestGetASNFromOrg/not_found (0.23s)
        client_test.go:130: 
                Error Trace:    /home/runner/work/asnmap/asnmap/libs/client_test.go:130
                Error:          Expected nil, but got: &json.SyntaxError{msg:"unexpected end of JSON input", Offset:0}
                Test:           TestGetASNFromOrg/not_found
[INF] google.com resolve to [142.251.2[11](https://github.com/projectdiscovery/asnmap/actions/runs/5087766935/jobs/9143446381?pr=125#step:6:12).238 2607:f8b0:400a:800::200e]
[INF] google.com resolve to [142.251.211.238 2607:f8b0:400a:800::200e]
[INF] somerandomdomainnamethatisfake.com resolve to []
FAIL
FAIL    github.com/projectdiscovery/asnmap/libs 2.098s
--- FAIL: TestProcessForDomainInput (0.25s)
    --- FAIL: TestProcessForDomainInput/Domain (0.25s)
        runner_test.go:[13](https://github.com/projectdiscovery/asnmap/actions/runs/5087766935/jobs/9143446381?pr=125#step:6:14)1: 
                Error Trace:    /home/runner/work/asnmap/asnmap/runner/runner_test.go:131
                Error:          Expected nil, but got: &json.SyntaxError{msg:"unexpected end of JSON input", Offset:0}
                Test:           TestProcessForDomainInput/Domain
tarunKoyalwar commented 1 year ago
echo AS134029 | ./asnmap                                                      1 ↵

   ___   _____  __              
  / _ | / __/ |/ /_ _  ___ ____ 
 / __ |_\ \/    /  ' \/ _  / _ \
/_/ |_/___/_/|_/_/_/_/\_,_/ .__/
                         /_/ 

        projectdiscovery.io

[INF] Current asnmap version v1.0.4 (latest)
HTTP/1.1 502 Bad Gateway
Cf-Cache-Status: BYPASS
Cf-Ray: 7d0043e5de651bdc-BOM
Connection: keep-alive
Date: Wed, 31 May 2023 15:31:41 GMT
Nel: {"success_fraction":0,"report_to":"cf-nel","max_age":604800}
Report-To: {"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v3?s=CpnpIaf4YwqhMT4LzAaBRG1DJWhRFNFkCf9FTe3OhHROombJRTZXCOBn6NrYBQN6mo%2BwqBCdSmTDXN%2F6%2BNjGmhP1DemI3aNW%2Fbu8nucuc5qwxdsAT4yf5f0Xv3DexAKqL30SVm5SdJ3B37w%3D"}],"group":"cf-nel","max_age":604800}
Server: cloudflare
Vary: Accept-Encoding
Content-Length: 0

got response: 
[FTL] unexpected end of JSON input
tarunKoyalwar commented 1 year ago

@ehsandeep seems to be resolved now . not able to reproduce it

$ echo AS134029 | ./asnmap    

   ___   _____  __              
  / _ | / __/ |/ /_ _  ___ ____ 
 / __ |_\ \/    /  ' \/ _  / _ \
/_/ |_/___/_/|_/_/_/_/\_,_/ .__/
                         /_/ 

        projectdiscovery.io

[INF] Current asnmap version v1.0.4 (latest)
HTTP/1.1 200 OK
Transfer-Encoding: chunked
Cache-Control: max-age=14400
Cf-Cache-Status: EXPIRED
Cf-Ray: 7dde3bd699fef488-BOM
Connection: keep-alive
Content-Type: application/json; charset=utf-8
Date: Tue, 27 Jun 2023 14:03:29 GMT
Last-Modified: Mon, 26 Jun 2023 21:57:52 GMT
Nel: {"success_fraction":0,"report_to":"cf-nel","max_age":604800}
Report-To: {"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v3?s=%2BsAqYrbFnPkkIQxY1r6dL8ywrkmmNIltlZAKUvVV4eRPrmqyTs5o%2FusFONKUPP8Vi63D1ruqeNd5jACuZjab4csjarvT7CZyFbw0pPGVKRbNlL0vHnk05ATgSg0tG06d7bvFEDe0qt4tvNo%3D"}],"group":"cf-nel","max_age":604800}
Server: cloudflare
Strict-Transport-Security: max-age=15724800; includeSubDomains
Vary: Accept-Encoding

11d
[{"FirstIp":"103.57.226.0","LastIp":"103.57.226.255","ASN":134029,"Country":"IN","Org":"UIDAI-AS-IN Unique Identification Authority of India"},{"FirstIp":"103.58.114.0","LastIp":"103.58.114.255","ASN":134029,"Country":"IN","Org":"UIDAI-AS-IN Unique Identification Authority of India"}]
0

got response: [{"FirstIp":"103.57.226.0","LastIp":"103.57.226.255","ASN":134029,"Country":"IN","Org":"UIDAI-AS-IN Unique Identification Authority of India"},{"FirstIp":"103.58.114.0","LastIp":"103.58.114.255","ASN":134029,"Country":"IN","Org":"UIDAI-AS-IN Unique Identification Authority of India"}]
103.57.226.0/24
103.58.114.0/24
srand2 commented 1 year ago

Hey I just updated to latest version 1.0.4 and I'm receiving the error described here:

└─▪  echo AS197568 | asnmap

   ___   _____  __
  / _ | / __/ |/ /_ _  ___ ____
 / __ |_\ \/    /  ' \/ _  / _ \
/_/ |_/___/_/|_/_/_/_/\_,_/ .__/
                         /_/

                projectdiscovery.io

[INF] Current asnmap version v1.0.4 (latest)
[FTL] unexpected end of JSON input