Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
G
gost
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nanahira
gost
Commits
7cbfd5f4
Commit
7cbfd5f4
authored
Oct 29, 2017
by
rui.zheng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
change SNI obfuscation
parent
4599d81c
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
40 additions
and
24 deletions
+40
-24
http.go
http.go
+3
-6
sni.go
sni.go
+24
-15
vendor/github.com/ginuerzh/tls-dissector/extension.go
vendor/github.com/ginuerzh/tls-dissector/extension.go
+10
-0
vendor/vendor.json
vendor/vendor.json
+3
-3
No files found.
http.go
View file @
7cbfd5f4
...
@@ -135,12 +135,9 @@ func (h *httpHandler) Handle(conn net.Conn) {
...
@@ -135,12 +135,9 @@ func (h *httpHandler) Handle(conn net.Conn) {
}
}
// try to get the actual host.
// try to get the actual host.
if
req
.
Host
!=
""
{
if
v
:=
req
.
Header
.
Get
(
"Gost-Target"
);
v
!=
""
{
if
index
:=
strings
.
IndexByte
(
req
.
Host
,
'.'
);
index
>
0
{
if
host
,
err
:=
decodeServerName
(
v
);
err
==
nil
{
// try to decode the prefix
req
.
Host
=
host
if
name
,
err
:=
decodeServerName
(
req
.
Host
[
:
index
]);
err
==
nil
{
req
.
Host
=
name
}
}
}
}
}
...
...
sni.go
View file @
7cbfd5f4
...
@@ -146,7 +146,6 @@ func (c *sniClientConn) obfuscate(p []byte) ([]byte, error) {
...
@@ -146,7 +146,6 @@ func (c *sniClientConn) obfuscate(p []byte) ([]byte, error) {
return
b
,
nil
return
b
,
nil
}
}
// TODO: HTTP obfuscate
buf
:=
&
bytes
.
Buffer
{}
buf
:=
&
bytes
.
Buffer
{}
br
:=
bufio
.
NewReader
(
bytes
.
NewReader
(
p
))
br
:=
bufio
.
NewReader
(
bytes
.
NewReader
(
p
))
for
{
for
{
...
@@ -171,12 +170,12 @@ func (c *sniClientConn) obfuscate(p []byte) ([]byte, error) {
...
@@ -171,12 +170,12 @@ func (c *sniClientConn) obfuscate(p []byte) ([]byte, error) {
if
strings
.
HasPrefix
(
s
,
"Host"
)
{
if
strings
.
HasPrefix
(
s
,
"Host"
)
{
s
=
strings
.
TrimSpace
(
strings
.
TrimSuffix
(
strings
.
TrimPrefix
(
s
,
"Host:"
),
"
\r\n
"
))
s
=
strings
.
TrimSpace
(
strings
.
TrimSuffix
(
strings
.
TrimPrefix
(
s
,
"Host:"
),
"
\r\n
"
))
name
:=
encodeServerName
(
s
)
+
"."
+
c
.
host
host
:=
encodeServerName
(
s
)
if
Debug
{
if
Debug
{
log
.
Logf
(
"[sni] obfuscate: %s -> %s"
,
s
,
name
)
log
.
Logf
(
"[sni] obfuscate: %s -> %s"
,
s
,
c
.
host
)
}
}
buf
.
WriteString
(
"Host: "
+
name
+
"
\r\n
"
)
buf
.
WriteString
(
"Host: "
+
c
.
host
+
"
\r\n
"
)
buf
.
WriteString
(
"Gost-Target: "
+
host
+
"
\r\n
"
)
// drain the remain bytes.
// drain the remain bytes.
io
.
Copy
(
buf
,
br
)
io
.
Copy
(
buf
,
br
)
break
break
...
@@ -196,21 +195,31 @@ func readClientHelloRecord(r io.Reader, host string, isClient bool) ([]byte, str
...
@@ -196,21 +195,31 @@ func readClientHelloRecord(r io.Reader, host string, isClient bool) ([]byte, str
if
err
:=
clientHello
.
Decode
(
record
.
Opaque
);
err
!=
nil
{
if
err
:=
clientHello
.
Decode
(
record
.
Opaque
);
err
!=
nil
{
return
nil
,
""
,
err
return
nil
,
""
,
err
}
}
if
!
isClient
{
var
extensions
[]
dissector
.
Extension
for
_
,
ext
:=
range
clientHello
.
Extensions
{
if
ext
.
Type
()
==
0xFFFE
{
if
host
,
err
=
decodeServerName
(
string
(
ext
.
Bytes
()[
4
:
]));
err
==
nil
{
continue
}
}
extensions
=
append
(
extensions
,
ext
)
}
clientHello
.
Extensions
=
extensions
}
for
_
,
ext
:=
range
clientHello
.
Extensions
{
for
_
,
ext
:=
range
clientHello
.
Extensions
{
if
ext
.
Type
()
==
dissector
.
ExtServerName
{
if
ext
.
Type
()
==
dissector
.
ExtServerName
{
snExtension
:=
ext
.
(
*
dissector
.
ServerNameExtension
)
snExtension
:=
ext
.
(
*
dissector
.
ServerNameExtension
)
serverName
:=
snExtension
.
Name
if
isClient
{
if
isClient
{
snExtension
.
Name
=
encodeServerName
(
serverName
)
+
"."
+
host
clientHello
.
Extensions
=
append
(
clientHello
.
Extensions
,
}
else
{
dissector
.
NewExtension
(
0xFFFE
,
[]
byte
(
encodeServerName
(
snExtension
.
Name
))))
if
index
:=
strings
.
IndexByte
(
serverName
,
'.'
);
index
>
0
{
}
// try to decode the prefix
if
host
!=
""
{
if
name
,
err
:=
decodeServerName
(
serverName
[
:
index
]);
err
==
nil
{
snExtension
.
Name
=
host
snExtension
.
Name
=
name
}
}
}
}
host
=
snExtension
.
Name
break
break
}
}
}
}
...
...
vendor/github.com/ginuerzh/tls-dissector/extension.go
View file @
7cbfd5f4
...
@@ -46,6 +46,16 @@ type unknownExtension struct {
...
@@ -46,6 +46,16 @@ type unknownExtension struct {
raw
[]
byte
raw
[]
byte
}
}
func
NewExtension
(
t
uint16
,
data
[]
byte
)
Extension
{
ext
:=
&
unknownExtension
{
raw
:
make
([]
byte
,
2
+
2
+
len
(
data
)),
}
binary
.
BigEndian
.
PutUint16
(
ext
.
raw
[
:
2
],
t
)
binary
.
BigEndian
.
PutUint16
(
ext
.
raw
[
2
:
4
],
uint16
(
len
(
data
)))
copy
(
ext
.
raw
[
4
:
],
data
)
return
ext
}
func
(
ext
*
unknownExtension
)
Type
()
uint16
{
func
(
ext
*
unknownExtension
)
Type
()
uint16
{
return
binary
.
BigEndian
.
Uint16
(
ext
.
raw
)
return
binary
.
BigEndian
.
Uint16
(
ext
.
raw
)
}
}
...
...
vendor/vendor.json
View file @
7cbfd5f4
...
@@ -99,10 +99,10 @@
...
@@ -99,10 +99,10 @@
"revisionTime"
:
"2017-02-05T06:52:49Z"
"revisionTime"
:
"2017-02-05T06:52:49Z"
},
},
{
{
"checksumSHA1"
:
"
qBQox+0NNTwkyw+a4eMiuMjDxjY
="
,
"checksumSHA1"
:
"
ZefD404me5Nm13S6NTsfJ57UApI
="
,
"path"
:
"github.com/ginuerzh/tls-dissector"
,
"path"
:
"github.com/ginuerzh/tls-dissector"
,
"revision"
:
"
7daf6e2af3aed2de50b3662683f6434297949d2a
"
,
"revision"
:
"
ede94e83b36efefb6d06e5a29d28e2211b8bd6a9
"
,
"revisionTime"
:
"2017-10-2
5T09:37:20
Z"
"revisionTime"
:
"2017-10-2
9T12:10:54
Z"
},
},
{
{
"checksumSHA1"
:
"fBx0fqiyrl26gkGo14J9pJ8zB2Y="
,
"checksumSHA1"
:
"fBx0fqiyrl26gkGo14J9pJ8zB2Y="
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment