Skip to content

Commit 1927951

Browse files
committed
add experimental jax3 support
1 parent fab5ff4 commit 1927951

File tree

197 files changed

+27240
-1466
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

197 files changed

+27240
-1466
lines changed

Gopkg.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

event/conn.go

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/*
2+
* Honeytrap
3+
* Copyright (C) 2016-2017 DutchSec (https://dutchsec.com/)
4+
*
5+
* This program is free software; you can redistribute it and/or modify it under
6+
* the terms of the GNU Affero General Public License version 3 as published by the
7+
* Free Software Foundation.
8+
*
9+
* This program is distributed in the hope that it will be useful, but WITHOUT
10+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11+
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
12+
* details.
13+
*
14+
* You should have received a copy of the GNU Affero General Public License
15+
* version 3 along with this program in the file "LICENSE". If not, see
16+
* <http://www.gnu.org/licenses/agpl-3.0.txt>.
17+
*
18+
* See https://honeytrap.io/ for more details. All requests should be sent to
19+
* licensing@honeytrap.io
20+
*
21+
* The interactive user interfaces in modified source and object code versions
22+
* of this program must display Appropriate Legal Notices, as required under
23+
* Section 5 of the GNU Affero General Public License version 3.
24+
*
25+
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
26+
* these Appropriate Legal Notices must retain the display of the "Powered by
27+
* Honeytrap" logo and retain the original copyright notice. If the display of the
28+
* logo is not reasonably feasible for technical reasons, the Appropriate Legal Notices
29+
* must display the words "Powered by Honeytrap" and retain the original copyright notice.
30+
*/
31+
package event
32+
33+
import (
34+
"net"
35+
)
36+
37+
type Conn struct {
38+
net.Conn
39+
40+
options []Option
41+
}
42+
43+
func (ec *Conn) Options() Option {
44+
return NewWith(ec.options...)
45+
}
46+
47+
func WithConn(conn net.Conn, options ...Option) *Conn {
48+
if innerConn, ok := conn.(*Conn); ok {
49+
innerConn.options = append(innerConn.options, options...)
50+
return innerConn
51+
}
52+
53+
return &Conn{
54+
Conn: conn,
55+
options: options,
56+
}
57+
}

event/event_linux_amd64.go

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,3 @@
2929
* must display the words "Powered by Honeytrap" and retain the original copyright notice.
3030
*/
3131
package event
32-
33-
import (
34-
"net"
35-
36-
"github.com/google/netstack/tcpip/adapters/gonet"
37-
)
38-
39-
func Conn(conn net.Conn) Option {
40-
return func(m Event) {
41-
if gc, ok := conn.(*gonet.Conn); !ok {
42-
} else if irs, err := gc.IRS(); err != nil {
43-
} else {
44-
m.Store("irs", irs)
45-
}
46-
}
47-
}

event/event_other.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,3 @@
3131
* must display the words "Powered by Honeytrap" and retain the original copyright notice.
3232
*/
3333
package event
34-
35-
import "net"
36-
37-
func Conn(conn net.Conn) Option {
38-
return func(m Event) {
39-
}
40-
}

event/map.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ func New(opts ...Option) Event {
6363
e.sm.Store("date", time.Now())
6464

6565
for _, opt := range opts {
66+
if opt == nil {
67+
continue
68+
}
69+
6670
opt(e)
6771
}
6872

listener/netstack/netstack_linux_amd64.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ import (
4040
"github.com/fatih/color"
4141
"github.com/vishvananda/netlink"
4242

43+
"github.com/honeytrap/honeytrap/event"
4344
"github.com/honeytrap/honeytrap/listener"
4445
"github.com/honeytrap/honeytrap/pushers"
4546

@@ -317,6 +318,13 @@ func (l *netstackListener) Start(ctx context.Context) error {
317318
continue
318319
}
319320

321+
if gc, ok := conn.(*gonet.Conn); !ok {
322+
} else if irs, err := gc.IRS(); err != nil {
323+
} else {
324+
conn = event.WithConn(conn, event.Custom("irs", irs))
325+
326+
}
327+
320328
l.ch <- conn
321329
}
322330
} else if ua, ok := address.(*net.UDPAddr); ok {

services/http.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ import (
4343

4444
"github.com/honeytrap/honeytrap/event"
4545
"github.com/honeytrap/honeytrap/pushers"
46+
"github.com/rs/xid"
4647
)
4748

4849
var (
@@ -119,6 +120,8 @@ func Cookies(cookies []*http.Cookie) event.Option {
119120
}
120121

121122
func (s *httpService) Handle(ctx context.Context, conn net.Conn) error {
123+
id := xid.New()
124+
122125
for {
123126
br := bufio.NewReader(conn)
124127

@@ -143,13 +146,20 @@ func (s *httpService) Handle(ctx context.Context, conn net.Conn) error {
143146

144147
io.Copy(ioutil.Discard, req.Body)
145148

149+
var connOptions event.Option = nil
150+
151+
if ec, ok := conn.(*event.Conn); ok {
152+
connOptions = ec.Options()
153+
}
154+
146155
s.c.Send(event.New(
147156
EventOptions,
157+
connOptions,
148158
event.Category("http"),
149159
event.Type("request"),
150-
event.Conn(conn),
151160
event.SourceAddr(conn.RemoteAddr()),
152161
event.DestinationAddr(conn.LocalAddr()),
162+
event.Custom("http.sessionid", id.String()),
153163
event.Custom("http.method", req.Method),
154164
event.Custom("http.proto", req.Proto),
155165
event.Custom("http.host", req.Host),

services/https.go

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ import (
3434
"context"
3535
"crypto/rand"
3636
"crypto/rsa"
37-
"crypto/tls"
3837
"crypto/x509"
3938
"crypto/x509/pkix"
4039
"fmt"
@@ -43,6 +42,9 @@ import (
4342
"sync"
4443
"time"
4544

45+
"github.com/honeytrap/honeytrap/event"
46+
tls "github.com/honeytrap/honeytrap/services/jax3/crypto/tls"
47+
4648
"github.com/honeytrap/honeytrap/pushers"
4749
)
4850

@@ -143,14 +145,35 @@ func (s *httpsService) getCertificate(hello *tls.ClientHelloInfo) (*tls.Certific
143145
}
144146

145147
func (s *httpsService) Handle(ctx context.Context, conn net.Conn) error {
148+
jax3Digest := ""
149+
serverName := ""
150+
146151
tlsConn := tls.Server(conn, &tls.Config{
147-
Certificates: []tls.Certificate{},
148-
GetCertificate: s.getCertificate,
152+
Certificates: []tls.Certificate{},
153+
GetCertificate: func(hello *tls.ClientHelloInfo) (*tls.Certificate, error) {
154+
jax3Digest = hello.JAX3Digest()
155+
serverName = hello.ServerName
156+
return s.getCertificate(hello)
157+
},
149158
})
150159

151160
if err := tlsConn.Handshake(); err != nil {
161+
s.c.Send(event.New(
162+
EventOptions,
163+
event.Category("https"),
164+
event.Type("handshake-failed"),
165+
event.SourceAddr(conn.RemoteAddr()),
166+
event.DestinationAddr(conn.LocalAddr()),
167+
event.Custom("https.jax3-digest", jax3Digest),
168+
event.Custom("https.server-name", serverName),
169+
))
170+
152171
return err
153172
}
154173

155-
return s.httpService.Handle(ctx, tlsConn)
174+
return s.httpService.Handle(ctx, event.WithConn(
175+
tlsConn,
176+
event.Custom("https.jax3-digest", jax3Digest),
177+
event.Custom("https.server-name", serverName),
178+
))
156179
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright 2016 The Go Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style
3+
// license that can be found in the LICENSE file.
4+
5+
// +build amd64,!gccgo,!appengine
6+
7+
#include "textflag.h"
8+
9+
// func hasAESNI() bool
10+
TEXT ·hasAESNI(SB),NOSPLIT,$0
11+
XORQ AX, AX
12+
INCL AX
13+
CPUID
14+
SHRQ $25, CX
15+
ANDQ $1, CX
16+
MOVB CX, ret+0(FP)
17+
RET
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// Copyright 2016 The Go Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style
3+
// license that can be found in the LICENSE file.
4+
5+
// +build s390x,!gccgo,!appengine
6+
7+
#include "textflag.h"
8+
9+
// func hasHWSupport() bool
10+
TEXT ·hasHWSupport(SB),NOSPLIT,$16-1
11+
XOR R0, R0 // set function code to 0 (query)
12+
LA mask-16(SP), R1 // 16-byte stack variable for mask
13+
MOVD $(0x38<<40), R3 // mask for bits 18-20 (big endian)
14+
15+
// check for KM AES functions
16+
WORD $0xB92E0024 // cipher message (KM)
17+
MOVD mask-16(SP), R2
18+
AND R3, R2
19+
CMPBNE R2, R3, notfound
20+
21+
// check for KMC AES functions
22+
WORD $0xB92F0024 // cipher message with chaining (KMC)
23+
MOVD mask-16(SP), R2
24+
AND R3, R2
25+
CMPBNE R2, R3, notfound
26+
27+
// check for KMCTR AES functions
28+
WORD $0xB92D4024 // cipher message with counter (KMCTR)
29+
MOVD mask-16(SP), R2
30+
AND R3, R2
31+
CMPBNE R2, R3, notfound
32+
33+
// check for KIMD GHASH function
34+
WORD $0xB93E0024 // compute intermediate message digest (KIMD)
35+
MOVD mask-8(SP), R2 // bits 64-127
36+
MOVD $(1<<62), R5
37+
AND R5, R2
38+
CMPBNE R2, R5, notfound
39+
40+
MOVB $1, ret+0(FP)
41+
RET
42+
notfound:
43+
MOVB $0, ret+0(FP)
44+
RET

0 commit comments

Comments
 (0)