Skip to content

Commit 7c00227

Browse files
committed
Hello world
1 parent a395bbf commit 7c00227

File tree

4 files changed

+77
-0
lines changed

4 files changed

+77
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
RealiTLScanner

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Reality - Tls - Scanner
2+
3+
Build
4+
```
5+
go build
6+
```
7+
8+
Usage
9+
10+
Recommend to run this tool locally. It may cause VPS to be flagged if you run scanner in the cloud.
11+
```
12+
./RealiTLScanner -addr www.microsoft.com
13+
./RealiTLScanner -addr 20.81.111.85
14+
``

go.mod

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module github.com/xtls/RealiTLScanner
2+
3+
go 1.19

main.go

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
package main
2+
3+
import (
4+
"crypto/tls"
5+
"flag"
6+
"fmt"
7+
"net"
8+
"time"
9+
)
10+
11+
func main() {
12+
addrPtr := flag.String("addr", "127.0.0.1", "Destination to start scan")
13+
portPtr := flag.String("port", "443", "Port to scan")
14+
flag.Parse()
15+
fmt.Println("Reality Tls Scanner running: ", *addrPtr, ":", *portPtr)
16+
s := Scanner {
17+
addr: *addrPtr,
18+
port: *portPtr,
19+
timeout: 10 * time.Second,
20+
numberOfThread: 1,
21+
}
22+
s.Run()
23+
}
24+
25+
type Scanner struct {
26+
addr string
27+
port string
28+
timeout time.Duration
29+
numberOfThread int
30+
}
31+
32+
func (s Scanner) Run() {
33+
conn, err := net.DialTimeout("tcp", s.addr+":"+s.port, s.timeout)
34+
if err != nil {
35+
fmt.Println("Dial failed: ", err)
36+
return
37+
}
38+
line := "" + conn.RemoteAddr().String() + " \t----- "
39+
conn.SetDeadline(time.Now().Add(s.timeout))
40+
c := tls.Client(conn, &tls.Config {
41+
InsecureSkipVerify: true,
42+
NextProtos: []string{"h2", "http/1.1"},
43+
})
44+
err = c.Handshake()
45+
if err != nil {
46+
fmt.Println("", line, "TLS handshake failed: ", err)
47+
return
48+
}
49+
defer c.Close()
50+
state := c.ConnectionState()
51+
fmt.Println("", line, "Found TLS v", TlsDic[state.Version], "\tALPN", state.NegotiatedProtocol, "\t", state.PeerCertificates[0].Subject)
52+
}
53+
54+
var TlsDic = map[uint16]string{
55+
0x0301: "1.0",
56+
0x0302: "1.1",
57+
0x0303: "1.2",
58+
0x0304: "1.3",
59+
}

0 commit comments

Comments
 (0)