Skip to content

Commit

Permalink
add giop protocol
Browse files Browse the repository at this point in the history
  • Loading branch information
zhzyker committed Jun 6, 2022
1 parent edcf125 commit 7a9b25c
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
6 changes: 6 additions & 0 deletions internal/protocol/identify.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,12 @@ func JudgeTcp(result map[string]interface{}, Args map[string]interface{}) bool {
return true
}
}
if protocol == "giop" || runAll {
if judge.TcpGIOP(result, Args) {
printSuccess("TCP/GIOP", result)
return true
}
}

status := result["status"].(string)
if status == "open" && runAll {
Expand Down
41 changes: 41 additions & 0 deletions internal/protocol/judge/tcp_giop.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package judge

import (
"encoding/hex"
"github.com/zhzyker/dismap/internal/parse"
"github.com/zhzyker/dismap/internal/proxy"
"github.com/zhzyker/dismap/pkg/logger"
"strings"
)

func TcpGIOP(result map[string]interface{}, Args map[string]interface{}) bool {
timeout := Args["FlagTimeout"].(int)
host := result["host"].(string)
port := result["port"].(int)

conn, err := proxy.ConnProxyTcp(host, port, timeout)
if logger.DebugError(err) {
return false
}

msg := "\x47\x49\x4f\x50\x01\x02\x00\x03\x00\x00\x00\x17\x00\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\x0b\x4e\x61\x6d\x65\x53\x65\x72\x76\x69\x63\x65"
_, err = conn.Write([]byte(msg))
if logger.DebugError(err) {
return false
}

reply := make([]byte, 256)
_, _ = conn.Read(reply)
if conn != nil {
_ = conn.Close()
}

if strings.Contains(hex.EncodeToString(reply[0:4]), "47494f50") == false {
return false
}

result["protocol"] = "giop"
result["banner.string"] = parse.ByteToStringParse2(reply[0:4])
result["banner.byte"] = reply
return true
}

0 comments on commit 7a9b25c

Please sign in to comment.