Skip to content

Commit

Permalink
发布第一个包版本
Browse files Browse the repository at this point in the history
  • Loading branch information
Amzza0x00 committed Nov 18, 2022
1 parent 1112816 commit d5e19aa
Show file tree
Hide file tree
Showing 22 changed files with 83 additions and 91 deletions.
20 changes: 10 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,19 @@ setup:
mkdir -p build/windows

build-linux:
${BUILD_ENV} GOARCH=amd64 GOOS=linux go build ${LDFLAGS} -o build/linux/${PSEXEC}-linux-amd64 cmd/psexec.go;
${BUILD_ENV} GOARCH=386 GOOS=linux go build ${LDFLAGS} -o build/linux/${PSEXEC}-linux-x86 cmd/psexec.go;
${BUILD_ENV} GOARCH=amd64 GOOS=linux go build ${LDFLAGS} -o build/linux/${OXIDFIND}-linux-amd64 cmd/oxidfind.go;
${BUILD_ENV} GOARCH=386 GOOS=linux go build ${LDFLAGS} -o build/linux/${OXIDFIND}-linux-x86 cmd/oxidfind.go;
${BUILD_ENV} GOARCH=amd64 GOOS=linux go build ${LDFLAGS} -o build/linux/${PSEXEC}-linux-amd64 cmd/psexec/psexec.go;
${BUILD_ENV} GOARCH=386 GOOS=linux go build ${LDFLAGS} -o build/linux/${PSEXEC}-linux-x86 cmd/psexec/psexec.go;
${BUILD_ENV} GOARCH=amd64 GOOS=linux go build ${LDFLAGS} -o build/linux/${OXIDFIND}-linux-amd64 cmd/oxidfind/oxidfind.go;
${BUILD_ENV} GOARCH=386 GOOS=linux go build ${LDFLAGS} -o build/linux/${OXIDFIND}-linux-x86 cmd/oxidfind/oxidfind.go;

build-osx:
${BUILD_ENV} GOARCH=amd64 GOOS=darwin go build ${LDFLAGS} -o build/osx/${PSEXEC}-darwin-amd64 cmd/psexec.go;
${BUILD_ENV} GOARCH=amd64 GOOS=darwin go build ${LDFLAGS} -o build/osx/${OXIDFIND}-darwin-amd64 cmd/oxidfind.go;
${BUILD_ENV} GOARCH=amd64 GOOS=darwin go build ${LDFLAGS} -o build/osx/${PSEXEC}-darwin-amd64 cmd/psexec/psexec.go;
${BUILD_ENV} GOARCH=amd64 GOOS=darwin go build ${LDFLAGS} -o build/osx/${OXIDFIND}-darwin-amd64 cmd/oxidfind/oxidfind.go;


build-windows:
${BUILD_ENV} GOARCH=amd64 GOOS=windows go build ${LDFLAGS} -o build/windows/${PSEXEC}-windows-amd64.exe cmd/psexec.go;
${BUILD_ENV} GOARCH=386 GOOS=windows go build ${LDFLAGS} -o build/windows/${PSEXEC}-windows-x86.exe cmd/psexec.go;
${BUILD_ENV} GOARCH=amd64 GOOS=windows go build ${LDFLAGS} -o build/windows/${OXIDFIND}-windows-amd64.exe cmd/oxidfind.go;
${BUILD_ENV} GOARCH=386 GOOS=windows go build ${LDFLAGS} -o build/windows/${OXIDFIND}-windows-x86.exe cmd/oxidfind.go;
${BUILD_ENV} GOARCH=amd64 GOOS=windows go build ${LDFLAGS} -o build/windows/${PSEXEC}-windows-amd64.exe cmd/psexec/psexec.go;
${BUILD_ENV} GOARCH=386 GOOS=windows go build ${LDFLAGS} -o build/windows/${PSEXEC}-windows-x86.exe cmd/psexec/psexec.go;
${BUILD_ENV} GOARCH=amd64 GOOS=windows go build ${LDFLAGS} -o build/windows/${OXIDFIND}-windows-amd64.exe cmd/oxidfind/oxidfind.go;
${BUILD_ENV} GOARCH=386 GOOS=windows go build ${LDFLAGS} -o build/windows/${OXIDFIND}-windows-x86.exe cmd/oxidfind/oxidfind.go;

8 changes: 4 additions & 4 deletions cmd/oxidfind.go → cmd/oxidfind/oxidfind.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ package main
import (
"flag"
"fmt"
"go-impacket/pkg"
"go-impacket/pkg/common"
DCERPCv5 "go-impacket/pkg/dcerpc/v5"
"go-impacket/pkg/util"
"github.com/Amzza0x00/go-impacket/pkg"
"github.com/Amzza0x00/go-impacket/pkg/common"
DCERPCv5 "github.com/Amzza0x00/go-impacket/pkg/dcerpc/v5"
"github.com/Amzza0x00/go-impacket/pkg/util"
"log"
"os"
"sync"
Expand Down
10 changes: 5 additions & 5 deletions cmd/psexec.go → cmd/psexec/psexec.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ package main
import (
"flag"
"fmt"
"go-impacket/pkg"
"go-impacket/pkg/common"
DCERPCv5 "go-impacket/pkg/dcerpc/v5"
"go-impacket/pkg/smb/smb2"
"go-impacket/pkg/util"
"github.com/Amzza0x00/go-impacket/pkg"
"github.com/Amzza0x00/go-impacket/pkg/common"
DCERPCv5 "github.com/Amzza0x00/go-impacket/pkg/dcerpc/v5"
"github.com/Amzza0x00/go-impacket/pkg/smb/smb2"
"github.com/Amzza0x00/go-impacket/pkg/util"
"log"
"os"
)
Expand Down
9 changes: 3 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
module go-impacket
module github.com/Amzza0x00/go-impacket

go 1.16
go 1.19

require (
golang.org/x/crypto v0.0.0-20220817201139-bc19a97f63c8
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1
)
require golang.org/x/crypto v0.0.0-20220817201139-bc19a97f63c8
8 changes: 0 additions & 8 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,10 +1,2 @@
golang.org/x/crypto v0.0.0-20220817201139-bc19a97f63c8 h1:GIAS/yBem/gq2MUqgNIzUHW7cJMmx3TGZOrnyYaNQ6c=
golang.org/x/crypto v0.0.0-20220817201139-bc19a97f63c8/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1 h1:SrN+KX8Art/Sf4HNj6Zcz06G7VEz+7w9tdXTPOZ7+l4=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
2 changes: 1 addition & 1 deletion pkg/common/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"encoding/binary"
"encoding/hex"
"errors"
"go-impacket/pkg/encoder"
"github.com/Amzza0x00/go-impacket/pkg/encoder"
"io"
"log"
"net"
Expand Down
8 changes: 2 additions & 6 deletions pkg/dcerpc/v5/iobjectexproter.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package v5
import (
"bytes"
"encoding/hex"
"go-impacket/pkg/encoder"
"go-impacket/pkg/ms"
"github.com/Amzza0x00/go-impacket/pkg/encoder"
"github.com/Amzza0x00/go-impacket/pkg/ms"
)

// 此文件提供IObjectExporter rpc接口
Expand Down Expand Up @@ -88,10 +88,6 @@ func NewServerAlive2Response() ServerAlive2ResponseStruct {
return ServerAlive2ResponseStruct{}
}

//type TcpClient struct {
// TCPClient
//}

func (c *TCPClient) ServerAlive2Request(callId uint32) (address []string, err error) {
err = c.MSRPCBind(ms.IID_IObjectExporter, ms.IID_IObjectExporter_VERSION)
if err != nil {
Expand Down
10 changes: 5 additions & 5 deletions pkg/dcerpc/v5/msservice.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import (
"encoding/hex"
"errors"
"fmt"
"go-impacket/pkg/dcerpc"
"go-impacket/pkg/encoder"
"go-impacket/pkg/ms"
"go-impacket/pkg/smb/smb2"
"go-impacket/pkg/util"
"github.com/Amzza0x00/go-impacket/pkg/dcerpc"
"github.com/Amzza0x00/go-impacket/pkg/encoder"
"github.com/Amzza0x00/go-impacket/pkg/ms"
"github.com/Amzza0x00/go-impacket/pkg/smb/smb2"
"github.com/Amzza0x00/go-impacket/pkg/util"
"strings"
)

Expand Down
8 changes: 4 additions & 4 deletions pkg/dcerpc/v5/rpcrt.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ package v5
import (
"encoding/hex"
"errors"
"go-impacket/pkg/encoder"
"go-impacket/pkg/ms"
"go-impacket/pkg/smb/smb2"
"go-impacket/pkg/util"
"github.com/Amzza0x00/go-impacket/pkg/encoder"
"github.com/Amzza0x00/go-impacket/pkg/ms"
"github.com/Amzza0x00/go-impacket/pkg/smb/smb2"
"github.com/Amzza0x00/go-impacket/pkg/util"
)

// 此文件提供ms-rpce封装
Expand Down
18 changes: 10 additions & 8 deletions pkg/dcerpc/v5/scmr.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package v5

import (
"go-impacket/pkg/encoder"
"go-impacket/pkg/util"
"github.com/Amzza0x00/go-impacket/pkg/encoder"
"github.com/Amzza0x00/go-impacket/pkg/util"
)

// 此文件提供访问windows服务管理封装
Expand Down Expand Up @@ -108,17 +108,19 @@ const (
)

// OpenSCManagerW请求
//DWORD ROpenSCManagerW(
// DWORD ROpenSCManagerW(
//
// [in, string, unique, range(0, SC_MAX_COMPUTER_NAME_LENGTH)] SVCCTL_HANDLEW lpMachineName,
// [in, string, unique, range(0, SC_MAX_NAME_LENGTH)] wchar_t* lpDatabaseName,
// [in] DWORD dwDesiredAccess,
// [out] LPSC_RPC_HANDLE lpScHandle
// );
//lpMachineName:一种 SVCCTL_HANDLEW(第 2.2.3 节)数据类型,它定义指向以空字符结尾的 UNICODE 字符串的指针,该字符串指定服务器的机器名称。
//lpDatabaseName:指向以空结尾的 UNICODE 字符串的指针,该字符串指定要打开的 SCM 数据库的名称。该参数必须设置为 NULL、“ServicesActive”或“ServicesFailed”。
//dwDesiredAccess:一个值,指定对数据库的访问。这必须是第 3.1.4 节中指定的值之一。
//客户端还必须具有 SC_MANAGER_CONNECT 访问权限。
//lpScHandle:一种 LPSC_RPC_HANDLE 数据类型,用于定义新打开的 SCM 数据库的句柄。
//
// lpMachineName:一种 SVCCTL_HANDLEW(第 2.2.3 节)数据类型,它定义指向以空字符结尾的 UNICODE 字符串的指针,该字符串指定服务器的机器名称。
// lpDatabaseName:指向以空结尾的 UNICODE 字符串的指针,该字符串指定要打开的 SCM 数据库的名称。该参数必须设置为 NULL、“ServicesActive”或“ServicesFailed”。
// dwDesiredAccess:一个值,指定对数据库的访问。这必须是第 3.1.4 节中指定的值之一。
// 客户端还必须具有 SC_MANAGER_CONNECT 访问权限。
// lpScHandle:一种 LPSC_RPC_HANDLE 数据类型,用于定义新打开的 SCM 数据库的句柄。
func NewOpenSCManagerWRequest() MSRPCRequestHeaderStruct {
header := NewMSRPCHeader()
//header.CallId = 2
Expand Down
4 changes: 2 additions & 2 deletions pkg/dcerpc/v5/transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package v5

import (
"fmt"
"go-impacket/pkg/common"
"go-impacket/pkg/smb/smb2"
"github.com/Amzza0x00/go-impacket/pkg/common"
"github.com/Amzza0x00/go-impacket/pkg/smb/smb2"
"net"
)

Expand Down
4 changes: 2 additions & 2 deletions pkg/gss/gssapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ package gss

import (
"encoding/asn1"
"go-impacket/pkg/encoder"
"go-impacket/pkg/ntlm"
"github.com/Amzza0x00/go-impacket/pkg/encoder"
"github.com/Amzza0x00/go-impacket/pkg/ntlm"
"strconv"
"strings"
)
Expand Down
17 changes: 11 additions & 6 deletions pkg/ntlm/nlmp.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"encoding/hex"
"errors"
"fmt"
"go-impacket/pkg/encoder"
"github.com/Amzza0x00/go-impacket/pkg/encoder"
"golang.org/x/crypto/md4"
"hash"
"strings"
Expand Down Expand Up @@ -119,13 +119,18 @@ func LMOWFv2(password, user, userDomain string) []byte {

// 计算ntlmv2响应
// Set temp to ConcatenationOf(Responserversion, HiResponserversion,
// Z(6), Time, ClientChallenge, Z(4), ServerName, Z(4))
//
// Z(6), Time, ClientChallenge, Z(4), ServerName, Z(4))
//
// Set NTProofStr to HMAC_MD5(ResponseKeyNT,
// ConcatenationOf(CHALLENGE_MESSAGE.ServerChallenge,temp))
//
// ConcatenationOf(CHALLENGE_MESSAGE.ServerChallenge,temp))
//
// Set NtChallengeResponse to ConcatenationOf(NTProofStr, temp)
// Set LmChallengeResponse to ConcatenationOf(HMAC_MD5(ResponseKeyLM,
// ConcatenationOf(CHALLENGE_MESSAGE.ServerChallenge, ClientChallenge)),
// ClientChallenge )
//
// ConcatenationOf(CHALLENGE_MESSAGE.ServerChallenge, ClientChallenge)),
// ClientChallenge )
func ComputeNTLMv2Response(h hash.Hash, clientChallenge, serverChallenge, timestamp, serverName []byte) (NTChallengeResponse, LMChallengeResponse, SessionBaseKey []byte) {
temp := []byte{1, 1}
temp = append(temp, 0, 0, 0, 0, 0, 0)
Expand Down Expand Up @@ -238,7 +243,7 @@ type Challenge struct {
}

// https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-nlmp/5e550938-91d4-459f-b67d-75d70009e3f3
//ntlm v2认证结构
// ntlm v2认证结构
type NTLMv2Authentication struct {
Header
LmChallengeResponseLen uint16 `smb:"len:LmChallengeResponse"`
Expand Down
2 changes: 1 addition & 1 deletion pkg/ntlm/ntlmssp.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"crypto/md5"
"crypto/rand"
"encoding/binary"
"go-impacket/pkg/encoder"
"github.com/Amzza0x00/go-impacket/pkg/encoder"
"hash"
"time"
)
Expand Down
6 changes: 3 additions & 3 deletions pkg/smb/smb2/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ package smb2
import (
"encoding/hex"
"errors"
"go-impacket/pkg/encoder"
"go-impacket/pkg/ms"
"go-impacket/pkg/smb"
"github.com/Amzza0x00/go-impacket/pkg/encoder"
"github.com/Amzza0x00/go-impacket/pkg/ms"
"github.com/Amzza0x00/go-impacket/pkg/smb"
)

// 此文件用于smb2创建文件请求
Expand Down
4 changes: 2 additions & 2 deletions pkg/smb/smb2/loctl.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ package smb2

import (
"encoding/hex"
"go-impacket/pkg/encoder"
"go-impacket/pkg/smb"
"github.com/Amzza0x00/go-impacket/pkg/encoder"
"github.com/Amzza0x00/go-impacket/pkg/smb"
)

// loctl/fsctl封装
Expand Down
6 changes: 3 additions & 3 deletions pkg/smb/smb2/read.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ package smb2
import (
"encoding/hex"
"errors"
"go-impacket/pkg/encoder"
"go-impacket/pkg/ms"
"go-impacket/pkg/smb"
"github.com/Amzza0x00/go-impacket/pkg/encoder"
"github.com/Amzza0x00/go-impacket/pkg/ms"
"github.com/Amzza0x00/go-impacket/pkg/smb"
)

// 此文件用于smb2读数据请求
Expand Down
12 changes: 6 additions & 6 deletions pkg/smb/smb2/smb.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import (
"encoding/hex"
"errors"
"fmt"
"go-impacket/pkg/common"
"go-impacket/pkg/encoder"
"go-impacket/pkg/gss"
"go-impacket/pkg/ms"
"go-impacket/pkg/ntlm"
"go-impacket/pkg/smb"
"github.com/Amzza0x00/go-impacket/pkg/common"
"github.com/Amzza0x00/go-impacket/pkg/encoder"
"github.com/Amzza0x00/go-impacket/pkg/gss"
"github.com/Amzza0x00/go-impacket/pkg/ms"
"github.com/Amzza0x00/go-impacket/pkg/ntlm"
"github.com/Amzza0x00/go-impacket/pkg/smb"
"net"
)

Expand Down
6 changes: 3 additions & 3 deletions pkg/smb/smb2/tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import (
"encoding/hex"
"errors"
"fmt"
"go-impacket/pkg/encoder"
"go-impacket/pkg/ms"
"go-impacket/pkg/smb"
"github.com/Amzza0x00/go-impacket/pkg/encoder"
"github.com/Amzza0x00/go-impacket/pkg/ms"
"github.com/Amzza0x00/go-impacket/pkg/smb"
)

// 此文件用于目录树连接/断开
Expand Down
6 changes: 3 additions & 3 deletions pkg/smb/smb2/write.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ package smb2
import (
"encoding/hex"
"errors"
"go-impacket/pkg/encoder"
"go-impacket/pkg/ms"
"go-impacket/pkg/smb"
"github.com/Amzza0x00/go-impacket/pkg/encoder"
"github.com/Amzza0x00/go-impacket/pkg/ms"
"github.com/Amzza0x00/go-impacket/pkg/smb"
"os"
)

Expand Down
4 changes: 2 additions & 2 deletions pkg/smb/smbpacket.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package smb

import (
"go-impacket/pkg/gss"
"github.com/Amzza0x00/go-impacket/pkg/gss"
)

// 此文件定义SMB协议头
Expand Down Expand Up @@ -62,7 +62,7 @@ type SMB2PacketStruct struct {
}

// https://docs.microsoft.com/en-us/openspecs/windows_protocols/ms-smb2/e14db7ff-763a-4263-8b10-0c3944f52fc5
//SMB 修订号
// SMB 修订号
const (
SMB2_0_2_Dialect = 0x0202
SMB2_1_Dialect = 0x0210
Expand Down
2 changes: 1 addition & 1 deletion pkg/version.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package pkg

const (
VERSION = "0.2.1"
VERSION = "0.2.2"
BANNER = "Go-Impacket v" + VERSION + "-dev"
)

0 comments on commit d5e19aa

Please sign in to comment.