wmi is in progress
This commit is contained in:
parent
14ddc4feba
commit
dc0d6a2608
32
.vscode/launch.json
vendored
Normal file
32
.vscode/launch.json
vendored
Normal file
|
@ -0,0 +1,32 @@
|
|||
{
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Debug",
|
||||
"type": "go",
|
||||
"request": "launch",
|
||||
"mode": "debug",
|
||||
"remotePath": "",
|
||||
"port": 2345,
|
||||
"host": "127.0.0.1",
|
||||
"program": "${workspaceRoot}/main.go",
|
||||
"env": {},
|
||||
"args": [],
|
||||
"showLog": true
|
||||
},
|
||||
{
|
||||
"name": "File Debug",
|
||||
"type": "go",
|
||||
"request": "launch",
|
||||
"mode": "debug",
|
||||
"remotePath": "",
|
||||
"port": 2345,
|
||||
"host": "127.0.0.1",
|
||||
"program": "${fileDirname}",
|
||||
"env": {},
|
||||
"args": [],
|
||||
"showLog": true
|
||||
}
|
||||
|
||||
]
|
||||
}
|
14
.vscode/settings.json
vendored
Normal file
14
.vscode/settings.json
vendored
Normal file
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"editor.tabSize": 2,
|
||||
"editor.insertSpaces": true,
|
||||
"editor.formatOnSave": true,
|
||||
"editor.formatOnPaste": true,
|
||||
"editor.autoClosingBrackets": true,
|
||||
"editor.trimAutoWhitespace": true,
|
||||
"files.trimTrailingWhitespace": true,
|
||||
"files.trimFinalNewlines": true,
|
||||
"go.testFlags": [
|
||||
"-v",
|
||||
],
|
||||
"go.testTimeout": "60s"
|
||||
}
|
25
wmi/wmi.go
25
wmi/wmi.go
|
@ -19,16 +19,21 @@ const (
|
|||
|
||||
type WMIMatcher struct {
|
||||
osm.Matchers
|
||||
meta osm.Metadata
|
||||
}
|
||||
|
||||
func (w *WMIMatcher) Key() string {
|
||||
return "WMI"
|
||||
}
|
||||
|
||||
func (w *WMIMatcher) String() string {
|
||||
func (w *WMIMatcher) Name() string {
|
||||
return "WMI"
|
||||
}
|
||||
|
||||
func (w *WMIMatcher) Meta() osm.Metadata {
|
||||
return w.meta
|
||||
}
|
||||
|
||||
func (w *WMIMatcher) IsPrePacket() bool {
|
||||
return false
|
||||
}
|
||||
|
@ -41,10 +46,10 @@ func (w *WMIMatcher) IsError(info osm.MatchInfo, index int, packet *osm.Packet)
|
|||
return false
|
||||
}
|
||||
|
||||
func (w *WMIMatcher) Match(info osm.MatchInfo, index int, packet *osm.Packet) bool {
|
||||
func (w *WMIMatcher) Match(info osm.MatchInfo, index int, packet *osm.Packet) error {
|
||||
|
||||
if packet == nil {
|
||||
return false
|
||||
return osm.NoPacketReceivedError()
|
||||
}
|
||||
|
||||
buf := new(bytes.Buffer)
|
||||
|
@ -57,28 +62,28 @@ func (w *WMIMatcher) Match(info osm.MatchInfo, index int, packet *osm.Packet) bo
|
|||
switch index {
|
||||
case 0:
|
||||
if wmiRecv.Call_id != WMI_CALL_ID_1 {
|
||||
return false
|
||||
return osm.NotMatchedError()
|
||||
}
|
||||
|
||||
if wmiRecv.Ptype != PDU_BIND_ACK {
|
||||
return false
|
||||
return osm.NotMatchedError()
|
||||
}
|
||||
|
||||
return true
|
||||
return nil
|
||||
case 1:
|
||||
|
||||
if wmiRecv.Call_id != WMI_CALL_ID_2 {
|
||||
return false
|
||||
return osm.NotMatchedError()
|
||||
}
|
||||
|
||||
if wmiRecv.Ptype != PDU_RESP {
|
||||
return false
|
||||
return osm.NotMatchedError()
|
||||
}
|
||||
|
||||
return true
|
||||
return nil
|
||||
}
|
||||
|
||||
return false
|
||||
return osm.NotMatchedError()
|
||||
}
|
||||
|
||||
func NewMatcher() osm.Matcher {
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package wmi
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net"
|
||||
"testing"
|
||||
|
||||
|
@ -10,40 +9,30 @@ import (
|
|||
|
||||
func TestWMI(t *testing.T) {
|
||||
|
||||
lm := NewMatcher()
|
||||
m := NewMatcher()
|
||||
|
||||
//port := types.NewPort("135", types.NewHost("192.168.1.1"), types.TYPE_TCP)
|
||||
//scanInfo := scaninfo.NewServiceScanInfo(port)
|
||||
//var ipport string
|
||||
//ipport = port.Host.Ip + ":" + string(port.Port)
|
||||
conn, err := net.Dial("tcp", "192.168.1.203:135")
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
//fmt.Println(ipport)
|
||||
client, _ := net.Dial("tcp", "192.168.1.106:135")
|
||||
|
||||
defer client.Close()
|
||||
|
||||
fmt.Println(lm.PacketCount())
|
||||
|
||||
for ii := 0; ii < lm.PacketCount(); ii++ {
|
||||
|
||||
pack := lm.Packet(ii)
|
||||
|
||||
fmt.Println(pack)
|
||||
|
||||
client.Write(pack.Buffer)
|
||||
defer conn.Close()
|
||||
|
||||
for i := 0; i < m.PacketCount(); i++ {
|
||||
_, err := conn.Write(m.Packet(i).Buffer)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
bytes := make([]byte, 1024)
|
||||
n, _ := conn.Read(bytes)
|
||||
p := osm.NewPacket(bytes, n)
|
||||
|
||||
read, _ := client.Read(bytes)
|
||||
|
||||
//fmt.Println(bytes)
|
||||
|
||||
b := lm.Match(nil, ii, osm.NewPacket(bytes, read))
|
||||
|
||||
if b {
|
||||
fmt.Println("Good")
|
||||
if err := m.Match(nil, i, p); err != nil {
|
||||
t.Error(err)
|
||||
return
|
||||
}
|
||||
|
||||
}
|
||||
t.Log(m.Name())
|
||||
t.Log(m.Meta())
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user