From c62177354797848a572b76ac5a157d0bd63f3d7d Mon Sep 17 00:00:00 2001 From: 1759537337 Date: Fri, 27 Sep 2024 17:13:14 +0800 Subject: [PATCH 1/6] New Protocol: Socks5 --- modules/mqtt.go | 7 - modules/mqtt/scanner.go | 321 ------------------------------ modules/socks5.go | 7 + modules/socks5/scanner.go | 255 ++++++++++++++++++++++++ zgrab2_schemas/zgrab2/__init__.py | 2 +- zgrab2_schemas/zgrab2/mqtt.py | 22 -- zgrab2_schemas/zgrab2/socks5.py | 31 +++ 7 files changed, 294 insertions(+), 351 deletions(-) delete mode 100644 modules/mqtt.go delete mode 100644 modules/mqtt/scanner.go create mode 100644 modules/socks5.go create mode 100644 modules/socks5/scanner.go delete mode 100644 zgrab2_schemas/zgrab2/mqtt.py create mode 100644 zgrab2_schemas/zgrab2/socks5.py diff --git a/modules/mqtt.go b/modules/mqtt.go deleted file mode 100644 index 4b009137..00000000 --- a/modules/mqtt.go +++ /dev/null @@ -1,7 +0,0 @@ -package modules - -import "github.com/zmap/zgrab2/modules/mqtt" - -func init() { - mqtt.RegisterModule() -} diff --git a/modules/mqtt/scanner.go b/modules/mqtt/scanner.go deleted file mode 100644 index 1c23a962..00000000 --- a/modules/mqtt/scanner.go +++ /dev/null @@ -1,321 +0,0 @@ -package mqtt - -import ( - "encoding/binary" - "fmt" - "io" - "net" - - log "github.com/sirupsen/logrus" - "github.com/zmap/zgrab2" -) - -// ScanResults is the output of the scan. -type ScanResults struct { - SessionPresent bool `json:"session_present,omitempty"` - ConnectReturnCode byte `json:"connect_return_code,omitempty"` - Response string `json:"response,omitempty"` - TLSLog *zgrab2.TLSLog `json:"tls,omitempty"` -} - -// Flags are the MQTT-specific command-line flags. -type Flags struct { - zgrab2.BaseFlags - zgrab2.TLSFlags - - Verbose bool `long:"verbose" description:"More verbose logging, include debug fields in the scan results"` - V5 bool `long:"v5" description:"Scanning MQTT v5.0. Otherwise scanning MQTT v3.1.1"` - UseTLS bool `long:"tls" description:"Use TLS for the MQTT connection"` -} - -// Module implements the zgrab2.Module interface. -type Module struct { -} - -// Scanner implements the zgrab2.Scanner interface, and holds the state -// for a single scan. -type Scanner struct { - config *Flags -} - -// Connection holds the state for a single connection to the MQTT server. -type Connection struct { - conn net.Conn - config *Flags - results ScanResults -} - -// RegisterModule registers the MQTT zgrab2 module. -func RegisterModule() { - var module Module - _, err := zgrab2.AddCommand("mqtt", "MQTT", module.Description(), 1883, &module) - if err != nil { - log.Fatal(err) - } -} - -// NewFlags returns the default flags object to be filled in with the -// command-line arguments. -func (m *Module) NewFlags() interface{} { - return new(Flags) -} - -// NewScanner returns a new Scanner instance. -func (m *Module) NewScanner() zgrab2.Scanner { - return new(Scanner) -} - -// Description returns an overview of this module. -func (m *Module) Description() string { - return "Perform an MQTT scan" -} - -// Validate flags -func (f *Flags) Validate(args []string) error { - return nil -} - -// Help returns this module's help string. -func (f *Flags) Help() string { - return "" -} - -// Protocol returns the protocol identifier for the scanner. -func (s *Scanner) Protocol() string { - return "mqtt" -} - -// Init initializes the Scanner instance with the flags from the command line. -func (s *Scanner) Init(flags zgrab2.ScanFlags) error { - f, _ := flags.(*Flags) - s.config = f - return nil -} - -// InitPerSender does nothing in this module. -func (s *Scanner) InitPerSender(senderID int) error { - return nil -} - -// GetName returns the configured name for the Scanner. -func (s *Scanner) GetName() string { - return s.config.Name -} - -// GetTrigger returns the Trigger defined in the Flags. -func (scanner *Scanner) GetTrigger() string { - return scanner.config.Trigger -} - -// SendMQTTConnectPacket constructs and sends an MQTT CONNECT packet to the server. -func (mqtt *Connection) SendMQTTConnectPacket(v5 bool) error { - var packet []byte - if v5 { - packet = []byte{ - // Fixed Header - 0x10, // Control Packet Type (CONNECT) and flags - 0x17, // Remaining Length (23 bytes) - - // Variable Header - 0x00, 0x04, 'M', 'Q', 'T', 'T', // Protocol Name - 0x05, // Protocol Level (MQTT v5.0) - 0x02, // Connect Flags (Clean Start) - 0x00, 0x3C, // Keep Alive (60 seconds) - - // Properties - 0x00, // Properties Length (0) - - // Payload - 0x00, 0x0A, 'M', 'Q', 'T', 'T', 'C', 'l', 'i', 'e', 'n', 't', // Client Identifier - } - } else { - packet = []byte{ - // Fixed Header - 0x10, // Control Packet Type (CONNECT) and flags - 0x16, // Remaining Length (22 bytes) - - // Variable Header - 0x00, 0x04, 'M', 'Q', 'T', 'T', // Protocol Name - 0x04, // Protocol Level (MQTT v3.1.1) - 0x02, // Connect Flags (Clean Start) - 0x00, 0x3C, // Keep Alive (60 seconds) - - // Payload - 0x00, 0x0A, 'M', 'Q', 'T', 'T', 'C', 'l', 'i', 'e', 'n', 't', // Client Identifier - } - } - _, err := mqtt.conn.Write(packet) - return err -} - -// ReadMQTTv3Packet reads and parses the CONNACK packet from the server. -func (mqtt *Connection) ReadMQTTv3Packet() error { - response := make([]byte, 4) - _, err := mqtt.conn.Read(response) - if err != nil { - return err - } - - mqtt.results.Response = fmt.Sprintf("%X", response) - - // DISCONNECT packet - if ((response[0] & 0xF0) == 0xE0) && (response[1] == 0x00) { - return nil - } - - // Check if the response is a valid CONNACK packet - if response[0] != 0x20 || response[1] != 0x02 { - return fmt.Errorf("invalid CONNACK packet") - } - - mqtt.results.SessionPresent = (response[2] & 0x01) == 0x01 - mqtt.results.ConnectReturnCode = response[3] - - return nil -} - -// ReadMQTTv5Packet reads and parses the CONNACK or DISCONNECT packet from the server for MQTT v5.0. -func (mqtt *Connection) ReadMQTTv5Packet() error { - // Read the first byte to determine the packet type - firstByte := make([]byte, 1) - _, err := io.ReadFull(mqtt.conn, firstByte) - if err != nil { - return err - } - - packetType := firstByte[0] >> 4 - - // Read the remaining length - remainingLengthBytes, err := readVariableByteInteger(mqtt.conn) - if err != nil { - return err - } - - // Convert remaining length bytes to integer - remainingLength, _ := binary.Uvarint(remainingLengthBytes) - - // Allocate the packet buffer with the correct size - packet := make([]byte, 1+len(remainingLengthBytes)+int(remainingLength)) - packet[0] = firstByte[0] - copy(packet[1:], remainingLengthBytes) - - // Read the rest of the packet - _, err = io.ReadFull(mqtt.conn, packet[1+len(remainingLengthBytes):]) - if err != nil { - return err - } - - // Store the original response - mqtt.results.Response = fmt.Sprintf("%X", packet) - - // Process the packet based on its type - switch packetType { - case 2: // CONNACK - return mqtt.processConnAck(packet) - case 14: // DISCONNECT - return mqtt.processDisconnect(packet) - default: - return fmt.Errorf("unexpected packet type: %d", packetType) - } -} - -func (mqtt *Connection) processConnAck(packet []byte) error { - if len(packet) < 4 { - return fmt.Errorf("invalid CONNACK packet length") - } - - mqtt.results.SessionPresent = (packet[2] & 0x01) == 0x01 - mqtt.results.ConnectReturnCode = packet[3] - - // Process properties if present - if len(packet) > 4 { - propertiesLength, n := binary.Uvarint(packet[4:]) - propertiesStart := 4 + n - propertiesEnd := propertiesStart + int(propertiesLength) - - if propertiesEnd > len(packet) { - return fmt.Errorf("invalid properties length in CONNACK") - } - } - - return nil -} - -func (mqtt *Connection) processDisconnect(packet []byte) error { - if len(packet) < 2 { - return fmt.Errorf("invalid DISCONNECT packet length") - } - - // Process properties if present - if len(packet) > 3 { - propertiesLength, n := binary.Uvarint(packet[3:]) - propertiesStart := 3 + n - propertiesEnd := propertiesStart + int(propertiesLength) - - if propertiesEnd > len(packet) { - return fmt.Errorf("invalid properties length in DISCONNECT") - } - } - - return nil -} - -func readVariableByteInteger(r io.Reader) ([]byte, error) { - var result []byte - for i := 0; i < 4; i++ { - b := make([]byte, 1) - _, err := r.Read(b) - if err != nil { - return nil, err - } - result = append(result, b[0]) - if b[0]&0x80 == 0 { - break - } - } - if len(result) == 4 && result[3]&0x80 != 0 { - return nil, fmt.Errorf("invalid variable byte integer") - } - return result, nil -} - -// Scan performs the configured scan on the MQTT server. -func (s *Scanner) Scan(t zgrab2.ScanTarget) (status zgrab2.ScanStatus, result interface{}, thrown error) { - conn, err := t.Open(&s.config.BaseFlags) - if err != nil { - return zgrab2.TryGetScanStatus(err), nil, fmt.Errorf("error opening connection: %w", err) - } - defer conn.Close() - - mqtt := Connection{conn: conn, config: s.config} - - if s.config.UseTLS { - tlsConn, err := s.config.TLSFlags.GetTLSConnection(conn) - if err != nil { - return zgrab2.TryGetScanStatus(err), nil, fmt.Errorf("error getting TLS connection: %w", err) - } - mqtt.results.TLSLog = tlsConn.GetLog() - - if err := tlsConn.Handshake(); err != nil { - return zgrab2.TryGetScanStatus(err), &mqtt.results, fmt.Errorf("error during TLS handshake: %w", err) - } - - mqtt.conn = tlsConn - } - - if err := mqtt.SendMQTTConnectPacket(s.config.V5); err != nil { - return zgrab2.TryGetScanStatus(err), nil, fmt.Errorf("error sending CONNECT packet: %w", err) - } - - if s.config.V5 { - err = mqtt.ReadMQTTv5Packet() - } else { - err = mqtt.ReadMQTTv3Packet() - } - - if err != nil { - return zgrab2.TryGetScanStatus(err), &mqtt.results, fmt.Errorf("error reading CONNACK packet: %w", err) - } - - return zgrab2.SCAN_SUCCESS, &mqtt.results, nil -} diff --git a/modules/socks5.go b/modules/socks5.go new file mode 100644 index 00000000..629e05ce --- /dev/null +++ b/modules/socks5.go @@ -0,0 +1,7 @@ +package modules + +import "github.com/zmap/zgrab2/modules/socks5" + +func init() { + socks5.RegisterModule() +} diff --git a/modules/socks5/scanner.go b/modules/socks5/scanner.go new file mode 100644 index 00000000..258712cc --- /dev/null +++ b/modules/socks5/scanner.go @@ -0,0 +1,255 @@ +// Package socks5 contains the zgrab2 Module implementation for SOCKS5. +package socks5 + +import ( + "fmt" + "net" + + log "github.com/sirupsen/logrus" + "github.com/zmap/zgrab2" +) + +// ScanResults is the output of the scan. +type ScanResults struct { + Version string `json:"version,omitempty"` + MethodSelection string `json:"method_selection,omitempty"` + ConnectionResponse string `json:"connection_response,omitempty"` + ConnectionResponseExplanation map[string]string `json:"connection_response_explanation,omitempty"` +} + +// Flags are the SOCKS5-specific command-line flags. +type Flags struct { + zgrab2.BaseFlags + Verbose bool `long:"verbose" description:"More verbose logging, include debug fields in the scan results"` +} + +// Module implements the zgrab2.Module interface. +type Module struct { +} + +// Scanner implements the zgrab2.Scanner interface, and holds the state +// for a single scan. +type Scanner struct { + config *Flags +} + +// Connection holds the state for a single connection to the SOCKS5 server. +type Connection struct { + buffer [10000]byte + config *Flags + results ScanResults + conn net.Conn +} + +// RegisterModule registers the socks5 zgrab2 module. +func RegisterModule() { + var module Module + _, err := zgrab2.AddCommand("socks5", "SOCKS5", module.Description(), 1080, &module) + if err != nil { + log.Fatal(err) + } +} + +// NewFlags returns the default flags object to be filled in with the +// command-line arguments. +func (m *Module) NewFlags() interface{} { + return new(Flags) +} + +// NewScanner returns a new Scanner instance. +func (m *Module) NewScanner() zgrab2.Scanner { + return new(Scanner) +} + +// Description returns an overview of this module. +func (m *Module) Description() string { + return "Perform a SOCKS5 scan" +} + +// Validate flags +func (f *Flags) Validate(args []string) (err error) { + return +} + +// Help returns this module's help string. +func (f *Flags) Help() string { + return "" +} + +// Protocol returns the protocol identifier for the scanner. +func (s *Scanner) Protocol() string { + return "socks5" +} + +// Init initializes the Scanner instance with the flags from the command line. +func (s *Scanner) Init(flags zgrab2.ScanFlags) error { + f, _ := flags.(*Flags) + s.config = f + return nil +} + +// InitPerSender does nothing in this module. +func (s *Scanner) InitPerSender(senderID int) error { + return nil +} + +// GetName returns the configured name for the Scanner. +func (s *Scanner) GetName() string { + return s.config.Name +} + +// GetTrigger returns the Trigger defined in the Flags. +func (scanner *Scanner) GetTrigger() string { + return scanner.config.Trigger +} + +// readResponse reads a response from the SOCKS5 server. +func (conn *Connection) readResponse(expectedLength int) ([]byte, error) { + resp := make([]byte, expectedLength) + _, err := conn.conn.Read(resp) + if err != nil { + return nil, err + } + return resp, nil +} + +// sendCommand sends a command to the SOCKS5 server. +func (conn *Connection) sendCommand(cmd []byte) error { + _, err := conn.conn.Write(cmd) + return err +} + +// explainResponse converts the raw response into a human-readable explanation. +func explainResponse(resp []byte) map[string]string { + if len(resp) < 10 { + return map[string]string{"error": "response too short"} + } + + return map[string]string{ + "Version": fmt.Sprintf("0x%02x (SOCKS Version 5)", resp[0]), + "Reply": fmt.Sprintf("0x%02x (%s)", resp[1], getReplyDescription(resp[1])), + "Reserved": fmt.Sprintf("0x%02x", resp[2]), + "Address Type": fmt.Sprintf("0x%02x (%s)", resp[3], getAddressTypeDescription(resp[3])), + "Bound Address": fmt.Sprintf("%d.%d.%d.%d", resp[4], resp[5], resp[6], resp[7]), + "Bound Port": fmt.Sprintf("%d", int(resp[8])<<8|int(resp[9])), + } +} + +func getReplyDescription(code byte) string { + switch code { + case 0x00: + return "succeeded" + case 0x01: + return "general SOCKS server failure" + case 0x02: + return "connection not allowed by ruleset" + case 0x03: + return "network unreachable" + case 0x04: + return "host unreachable" + case 0x05: + return "connection refused" + case 0x06: + return "TTL expired" + case 0x07: + return "command not supported" + case 0x08: + return "address type not supported" + default: + return "unassigned" + } +} + +func getAddressTypeDescription(code byte) string { + switch code { + case 0x01: + return "IPv4 address" + case 0x03: + return "Domain name" + case 0x04: + return "IPv6 address" + default: + return "unknown" + } +} + +// PerformHandshake performs the SOCKS5 handshake. +func (conn *Connection) PerformHandshake() (bool, error) { + // Send version identifier/method selection message + verMethodSel := []byte{0x05, 0x01, 0x00} // VER = 0x05, NMETHODS = 1, METHODS = 0x00 (NO AUTHENTICATION REQUIRED) + err := conn.sendCommand(verMethodSel) + if err != nil { + return false, fmt.Errorf("error sending version identifier/method selection: %w", err) + } + conn.results.Version = "0x05" + + // Read method selection response + methodSelResp, err := conn.readResponse(2) + if err != nil { + return false, fmt.Errorf("error reading method selection response: %w", err) + } + conn.results.MethodSelection = fmt.Sprintf("%x", methodSelResp) + + if methodSelResp[1] == 0xFF { + return true, fmt.Errorf("no acceptable authentication methods") + } + + return false, nil +} + +// PerformConnectionRequest sends a connection request to the SOCKS5 server. +func (conn *Connection) PerformConnectionRequest() error { + // Send a connection request + req := []byte{0x05, 0x01, 0x00, 0x01, 0xA6, 0x6F, 0x04, 0x64, 0x00, 0x50} // VER = 0x05, CMD = CONNECT, RSV = 0x00, ATYP = IPv4, DST.ADDR = 166.111.4.100, DST.PORT = 80 + err := conn.sendCommand(req) + if err != nil { + return fmt.Errorf("error sending connection request: %w", err) + } + + // Read connection response + resp, err := conn.readResponse(10) + if err != nil { + return fmt.Errorf("error reading connection response: %w", err) + } + conn.results.ConnectionResponse = fmt.Sprintf("%x", resp) + conn.results.ConnectionResponseExplanation = explainResponse(resp) + + if resp[1] != 0x00 { + return fmt.Errorf("connection request failed with response: %x", resp) + } + + return nil +} + +// Scan performs the configured scan on the SOCKS5 server. +func (s *Scanner) Scan(t zgrab2.ScanTarget) (status zgrab2.ScanStatus, result interface{}, thrown error) { + var err error + var have_auth bool + conn, err := t.Open(&s.config.BaseFlags) + if err != nil { + return zgrab2.TryGetScanStatus(err), nil, fmt.Errorf("error opening connection: %w", err) + } + cn := conn + defer func() { + cn.Close() + }() + + results := ScanResults{} + socks5Conn := Connection{conn: cn, config: s.config, results: results} + + have_auth, err = socks5Conn.PerformHandshake() + if err != nil { + if have_auth { + return zgrab2.SCAN_SUCCESS, &socks5Conn.results, nil + } else { + return zgrab2.TryGetScanStatus(err), &socks5Conn.results, fmt.Errorf("error during handshake: %w", err) + } + } + + err = socks5Conn.PerformConnectionRequest() + if err != nil { + return zgrab2.TryGetScanStatus(err), &socks5Conn.results, fmt.Errorf("error during connection request: %w", err) + } + + return zgrab2.SCAN_SUCCESS, &socks5Conn.results, nil +} \ No newline at end of file diff --git a/zgrab2_schemas/zgrab2/__init__.py b/zgrab2_schemas/zgrab2/__init__.py index c7a0e205..d2eab36c 100644 --- a/zgrab2_schemas/zgrab2/__init__.py +++ b/zgrab2_schemas/zgrab2/__init__.py @@ -22,4 +22,4 @@ from . import ipp from . import banner from . import amqp091 -from . import mqtt +from . import socks5 diff --git a/zgrab2_schemas/zgrab2/mqtt.py b/zgrab2_schemas/zgrab2/mqtt.py deleted file mode 100644 index 0c0be42b..00000000 --- a/zgrab2_schemas/zgrab2/mqtt.py +++ /dev/null @@ -1,22 +0,0 @@ -# zschema sub-schema for zgrab2's MQTT module -# Registers zgrab2-mqtt globally, and mqtt with the main zgrab2 schema. -from zschema.leaves import * -from zschema.compounds import * -import zschema.registry - -from . import zgrab2 - -# Schema for ScanResults struct -mqtt_scan_response = SubRecord({ - "session_present": Boolean(), - "connect_return_code": Byte(), - "response": String(), - "tls": zgrab2.tls_log, -}) - -mqtt_scan = SubRecord({ - "result": mqtt_scan_response, -}, extends=zgrab2.base_scan_response) - -zschema.registry.register_schema("zgrab2-mqtt", mqtt_scan) -zgrab2.register_scan_response_type("mqtt", mqtt_scan) \ No newline at end of file diff --git a/zgrab2_schemas/zgrab2/socks5.py b/zgrab2_schemas/zgrab2/socks5.py new file mode 100644 index 00000000..e2bf917c --- /dev/null +++ b/zgrab2_schemas/zgrab2/socks5.py @@ -0,0 +1,31 @@ +# zschema sub-schema for zgrab2's MQTT module +# Registers zgrab2-mqtt globally, and mqtt with the main zgrab2 schema. +from zschema.leaves import * +from zschema.compounds import * +import zschema.registry + +from . import zgrab2 + +# Schema for ScanResults struct +socks5_response_explanation = SubRecord({ + "Version": String(), + "Reply": String(), + "Reserved": String(), + "Address Type": String(), + "Bound Address": String(), + "Bound Port": String(), +}) + +socks5_scan_response = SubRecord({ + "version": String(), + "method_selection": String(), + "connection_response": String(), + "connection_response_explanation": socks5_response_explanation, +}) + +socks5_scan = SubRecord({ + "result": socks5_scan_response, +}, extends=zgrab2.base_scan_response) + +zschema.registry.register_schema("zgrab2-socks5", socks5_scan) +zgrab2.register_scan_response_type("socks5", socks5_scan) \ No newline at end of file From 0250159fa114da1defe43381825e39b9d2ba5536 Mon Sep 17 00:00:00 2001 From: 1759537337 Date: Sat, 28 Sep 2024 17:03:40 +0800 Subject: [PATCH 2/6] Add Socks5 integration_test --- integration_tests/socks5/3proxy.cfg | 12 ++++++++++++ integration_tests/socks5/cleanup.sh | 9 +++++++++ integration_tests/socks5/setup.sh | 26 ++++++++++++++++++++++++++ integration_tests/socks5/test.sh | 23 +++++++++++++++++++++++ 4 files changed, 70 insertions(+) create mode 100644 integration_tests/socks5/3proxy.cfg create mode 100644 integration_tests/socks5/cleanup.sh create mode 100644 integration_tests/socks5/setup.sh create mode 100644 integration_tests/socks5/test.sh diff --git a/integration_tests/socks5/3proxy.cfg b/integration_tests/socks5/3proxy.cfg new file mode 100644 index 00000000..e2970a62 --- /dev/null +++ b/integration_tests/socks5/3proxy.cfg @@ -0,0 +1,12 @@ +internal 0.0.0.0 +external 0.0.0.0 + +maxconn 10 + +auth none + +socks -p1080 + +allow * + +flush \ No newline at end of file diff --git a/integration_tests/socks5/cleanup.sh b/integration_tests/socks5/cleanup.sh new file mode 100644 index 00000000..7e039ded --- /dev/null +++ b/integration_tests/socks5/cleanup.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +set +e + +echo "socks5/cleanup: Tests cleanup for socks5" + +CONTAINER_NAME=zgrab_socks5 + +docker stop $CONTAINER_NAME diff --git a/integration_tests/socks5/setup.sh b/integration_tests/socks5/setup.sh new file mode 100644 index 00000000..c391d756 --- /dev/null +++ b/integration_tests/socks5/setup.sh @@ -0,0 +1,26 @@ +#!/usr/bin/env bash + +echo "socks5/setup: Tests setup for socks5" + +CONTAINER_TAG="3proxy/3proxy" +CONTAINER_NAME="zgrab_socks5" + +# If the container is already running, use it. +if docker ps --filter "name=$CONTAINER_NAME" | grep -q $CONTAINER_NAME; then + echo "socks5/setup: Container $CONTAINER_NAME already running -- nothing to setup" + exit 0 +fi + +DOCKER_RUN_FLAGS="--rm --name $CONTAINER_NAME -e "PROXY_USER=user" -e "PROXY_PASS=password" -v ./3proxy.cfg:/etc/3proxy/3proxy.cfg -td" + +# If it is not running, try launching it -- on success, use that. +echo "socks5/setup: Trying to launch $CONTAINER_NAME..." +if ! docker run $DOCKER_RUN_FLAGS $CONTAINER_TAG; then + echo "failed" + # echo "socks5/setup: Building docker image $CONTAINER_TAG..." + # # If it fails, build it from ./container/Dockerfile + # docker build -t $CONTAINER_TAG ./container + # # Try again + # echo "socks5/setup: Launching $CONTAINER_NAME..." + # docker run $DOCKER_RUN_FLAGS $CONTAINER_TAG +fi diff --git a/integration_tests/socks5/test.sh b/integration_tests/socks5/test.sh new file mode 100644 index 00000000..52df6eeb --- /dev/null +++ b/integration_tests/socks5/test.sh @@ -0,0 +1,23 @@ +#!/usr/bin/env bash + +set -e +MODULE_DIR=$(dirname $0) +ZGRAB_ROOT=$(git rev-parse --show-toplevel) +ZGRAB_OUTPUT=$ZGRAB_ROOT/zgrab-output + +mkdir -p $ZGRAB_OUTPUT/socks5 + +CONTAINER_NAME=zgrab_socks5 + +OUTPUT_FILE=$ZGRAB_OUTPUT/socks5/socks5.json + +echo "socks5/test: Tests runner for socks5" +# TODO FIXME: Add any necessary flags or additional tests +CONTAINER_NAME=$CONTAINER_NAME $ZGRAB_ROOT/docker-runner/docker-run.sh socks5 > $OUTPUT_FILE + +# Dump the docker logs +echo "socks5/test: BEGIN docker logs from $CONTAINER_NAME [{(" +docker logs --tail all $CONTAINER_NAME +echo ")}] END docker logs from $CONTAINER_NAME" + +# TODO: If there are any other relevant log files, dump those to stdout here. From 28dace6b495a26f1df41e82eaed2ecb181ded98d Mon Sep 17 00:00:00 2001 From: 1759537337 Date: Sun, 29 Sep 2024 17:11:42 +0800 Subject: [PATCH 3/6] delete mqtt --- integration_tests/mqtt/cleanup.sh | 9 ----- integration_tests/mqtt/mosquitto.conf | 6 ---- integration_tests/mqtt/multiple.ini | 23 ------------- integration_tests/mqtt/server.crt | 20 ----------- integration_tests/mqtt/server.csr | 16 --------- integration_tests/mqtt/server.key | 28 ---------------- integration_tests/mqtt/server.pem | 48 --------------------------- integration_tests/mqtt/setup.sh | 27 --------------- integration_tests/mqtt/test.sh | 27 --------------- zgrab2_schemas/zgrab2/socks5.py | 4 +-- 10 files changed, 2 insertions(+), 206 deletions(-) delete mode 100755 integration_tests/mqtt/cleanup.sh delete mode 100644 integration_tests/mqtt/mosquitto.conf delete mode 100644 integration_tests/mqtt/multiple.ini delete mode 100644 integration_tests/mqtt/server.crt delete mode 100644 integration_tests/mqtt/server.csr delete mode 100644 integration_tests/mqtt/server.key delete mode 100644 integration_tests/mqtt/server.pem delete mode 100755 integration_tests/mqtt/setup.sh delete mode 100755 integration_tests/mqtt/test.sh diff --git a/integration_tests/mqtt/cleanup.sh b/integration_tests/mqtt/cleanup.sh deleted file mode 100755 index b926199d..00000000 --- a/integration_tests/mqtt/cleanup.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/usr/bin/env bash - -set +e - -echo "mqtt/cleanup: Tests cleanup for mqtt" - -CONTAINER_NAME=zgrab_mqtt - -docker stop $CONTAINER_NAME diff --git a/integration_tests/mqtt/mosquitto.conf b/integration_tests/mqtt/mosquitto.conf deleted file mode 100644 index c0efbf2f..00000000 --- a/integration_tests/mqtt/mosquitto.conf +++ /dev/null @@ -1,6 +0,0 @@ -listener 1883 0.0.0.0 - -listener 8883 0.0.0.0 -protocol mqtt -certfile /mosquitto/server.pem -keyfile /mosquitto/server.key \ No newline at end of file diff --git a/integration_tests/mqtt/multiple.ini b/integration_tests/mqtt/multiple.ini deleted file mode 100644 index 74f05023..00000000 --- a/integration_tests/mqtt/multiple.ini +++ /dev/null @@ -1,23 +0,0 @@ -[mqtt] -name="mqtt-tls" -trigger="mqtt-tls" -port=8883 -tls=true - -[mqtt] -name="mqtt-tls-v5" -trigger="mqtt-tls-v5" -port=8883 -tls=true -v5=true - -[mqtt] -name="mqtt" -trigger="mqtt" -port=1883 - -[mqtt] -name="mqtt-v5" -trigger="mqtt-v5" -port=1883 -v5=true \ No newline at end of file diff --git a/integration_tests/mqtt/server.crt b/integration_tests/mqtt/server.crt deleted file mode 100644 index 1a7c0ff2..00000000 --- a/integration_tests/mqtt/server.crt +++ /dev/null @@ -1,20 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIDOzCCAiOgAwIBAgIUS+JTI5jiO1C0AgqSuFgB1P9wS8swDQYJKoZIhvcNAQEL -BQAwRTELMAkGA1UEBhMCQVUxEzARBgNVBAgMClNvbWUtU3RhdGUxITAfBgNVBAoM -GEludGVybmV0IFdpZGdpdHMgUHR5IEx0ZDAgFw0yNDA5MjUwMzIwNTNaGA8yMDUy -MDIxMDAzMjA1M1owRTELMAkGA1UEBhMCQVUxEzARBgNVBAgMClNvbWUtU3RhdGUx -ITAfBgNVBAoMGEludGVybmV0IFdpZGdpdHMgUHR5IEx0ZDCCASIwDQYJKoZIhvcN -AQEBBQADggEPADCCAQoCggEBAKO/vB4nZjhbXcSMuIpl65aCK6zI6EtX2m5CrnJh -fRChp9MJV3OesPV93rcM2Vd+grf8qTw77TLcglYcSuHvBHfVbHaCnBx0z5ogYozR -EiuNV/hxTgfJdhQVN5WwGvRJe0pb7RaLtz4PF8rHJlTitQw37uGmOsW4bBZU1F6B -Nz/Os9BPLBBBnQvHUQmmp/aGJBga0mRRW3VFFOt7XgLJR2PR9jCTQZstleudSddj -SRemVvfm0zcsIO4IPsCKdkUMh4+eW3H0cc2oFggIDz72+uUYnyxtOx1vv7RzVETJ -BwMG/VDnfNZ5lozTKhlKZhVyVijy3ObMax8pLXixJcKrqc0CAwEAAaMhMB8wHQYD -VR0OBBYEFP6DHoFBdNVmHwc6LZnLwcDcKnvzMA0GCSqGSIb3DQEBCwUAA4IBAQA9 -VRDbEAFWmqKq+LPRqGmjiqGE0rTOsoKSDWn0Zsre31H2vsXy8BUW69rjhwMXEONl -5ybZCHnU8GLawFzrVQJnuV77XhIDuJhIz81guy0K872YcrNuhlIS7ahxXJszwgPe -Tp313rJKUA44DIuF18WjWjwQL8bU80xiJJcyuR2mViOFgcfIABmSzvvMx8nHxp7W -C9woea6TMamq7GQmIky9ZVy7OcfOSCygK0TU6Y2qNcIuKl4xtvY07msGFLifXp6s -A9A4aS610tqPNInh5zokI2m/y7nvCq7BA9n+5HvMKJcxW2G+AU7R7IFJctsPL07g -1MDuvzVplpxKk3tkj8Ou ------END CERTIFICATE----- diff --git a/integration_tests/mqtt/server.csr b/integration_tests/mqtt/server.csr deleted file mode 100644 index e1fb5146..00000000 --- a/integration_tests/mqtt/server.csr +++ /dev/null @@ -1,16 +0,0 @@ ------BEGIN CERTIFICATE REQUEST----- -MIICijCCAXICAQAwRTELMAkGA1UEBhMCQVUxEzARBgNVBAgMClNvbWUtU3RhdGUx -ITAfBgNVBAoMGEludGVybmV0IFdpZGdpdHMgUHR5IEx0ZDCCASIwDQYJKoZIhvcN -AQEBBQADggEPADCCAQoCggEBAKO/vB4nZjhbXcSMuIpl65aCK6zI6EtX2m5CrnJh -fRChp9MJV3OesPV93rcM2Vd+grf8qTw77TLcglYcSuHvBHfVbHaCnBx0z5ogYozR -EiuNV/hxTgfJdhQVN5WwGvRJe0pb7RaLtz4PF8rHJlTitQw37uGmOsW4bBZU1F6B -Nz/Os9BPLBBBnQvHUQmmp/aGJBga0mRRW3VFFOt7XgLJR2PR9jCTQZstleudSddj -SRemVvfm0zcsIO4IPsCKdkUMh4+eW3H0cc2oFggIDz72+uUYnyxtOx1vv7RzVETJ -BwMG/VDnfNZ5lozTKhlKZhVyVijy3ObMax8pLXixJcKrqc0CAwEAAaAAMA0GCSqG -SIb3DQEBCwUAA4IBAQCPropLZOaRaCD+iSGS304DRO6ysO8D2UW9T8CKqcbI6mOp -b8Wx2ENXXxuhSIpF3xe+yqpPOQmxph+lYnlewqVFWKRY91xIX07iMQ4bQHXKiWTs -IUQYRDbiLPq4sLgKdUdD41SoLhRBLGySX0/27hBlMQ0dZz92jTLOAYL06oqdtcJE -q/v3HVKlGiPkPiuFljbxBwI142ceFAWCctTb7N+6a0W/HioZPhKXLfGMcEHyNCQ7 -XwMQW5DSp4S7J4FseDkxLIxcbYYCxpi3jHFx+eYPerZ5TobE6QZHQeWLj8mcrNwu -mrL6CFlKde7F+xmb3e/tPfUTE+NxNdWzPGTjov2h ------END CERTIFICATE REQUEST----- diff --git a/integration_tests/mqtt/server.key b/integration_tests/mqtt/server.key deleted file mode 100644 index a82fc343..00000000 --- a/integration_tests/mqtt/server.key +++ /dev/null @@ -1,28 +0,0 @@ ------BEGIN PRIVATE KEY----- -MIIEvQIBADANBgkqhkiG9w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ba7SaRbd0LWOLY -2TZ89XD3xQKBgHukKlb6pFAyZR4Favsd0QTNxbC//g55dW2/JZHXCkaQvsCa1wkh -JMKxYoTs5SDOk2j7vdDgV+zPxHHjXUv6Di5l+zabM9ZCe9srAOXGau65mdRhEKwE -CRSWjKcYNc96tqXBywHAR0+qX1XYnYPVXlAYxfmAa07qxI0FcuGonibxAoGBAILv -rtKEE8tgdcROYnyy+92Fn6YEwohGDtAcMenxRqQnIj6NRfBYD5Gy0AU5WmarrZ4K -iu68Ycca+rjp+xu70aWroM2QnJkkySHeU82Wa3afygV5JedEbn9kXX0qgQTiHrKC -Wo4vfgRl7iobr4uvKKJn8h1qV9F09WZTqaxDMNU9AoGACTw9ZiKtrW+5jS1ucLdl -49gE6QPH3+JnQPqazguLF9OoCOyw69lHdzu/S77Yag4W5M+N8dBCRNF/lOfCbtJc -eIeSFMdJOq97GlsK6QompySHlKlq13u17Jot0x82VPJt1vUuGTrS8qrM5QDKWxZw -skYVITHcfYVzVgxC9JIIKGg= ------END PRIVATE KEY----- diff --git a/integration_tests/mqtt/server.pem b/integration_tests/mqtt/server.pem deleted file mode 100644 index 97774dfb..00000000 --- a/integration_tests/mqtt/server.pem +++ /dev/null @@ -1,48 +0,0 @@ ------BEGIN PRIVATE KEY----- -MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCjv7weJ2Y4W13E -jLiKZeuWgiusyOhLV9puQq5yYX0QoafTCVdznrD1fd63DNlXfoK3/Kk8O+0y3IJW -HErh7wR31Wx2gpwcdM+aIGKM0RIrjVf4cU4HyXYUFTeVsBr0SXtKW+0Wi7c+DxfK -xyZU4rUMN+7hpjrFuGwWVNRegTc/zrPQTywQQZ0Lx1EJpqf2hiQYGtJkUVt1RRTr -e14CyUdj0fYwk0GbLZXrnUnXY0kXplb35tM3LCDuCD7AinZFDIePnltx9HHNqBYI -CA8+9vrlGJ8sbTsdb7+0c1REyQcDBv1Q53zWeZaM0yoZSmYVclYo8tzmz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FzrVQJnuV77XhIDuJhIz81guy0K872YcrNuhlIS7ahxXJszwgPe -Tp313rJKUA44DIuF18WjWjwQL8bU80xiJJcyuR2mViOFgcfIABmSzvvMx8nHxp7W -C9woea6TMamq7GQmIky9ZVy7OcfOSCygK0TU6Y2qNcIuKl4xtvY07msGFLifXp6s -A9A4aS610tqPNInh5zokI2m/y7nvCq7BA9n+5HvMKJcxW2G+AU7R7IFJctsPL07g -1MDuvzVplpxKk3tkj8Ou ------END CERTIFICATE----- diff --git a/integration_tests/mqtt/setup.sh b/integration_tests/mqtt/setup.sh deleted file mode 100755 index 46284641..00000000 --- a/integration_tests/mqtt/setup.sh +++ /dev/null @@ -1,27 +0,0 @@ -#!/usr/bin/env bash - -echo "mqtt/setup: Tests setup for mqtt" - -CONTAINER_TAG="eclipse-mosquitto" -CONTAINER_NAME="zgrab_mqtt" - -# If the container is already running, use it. -if docker ps --filter "name=$CONTAINER_NAME" | grep -q $CONTAINER_NAME; then - echo "mqtt/setup: Container $CONTAINER_NAME already running -- nothing to setup" - exit 0 -fi - -DOCKER_RUN_FLAGS="--rm --name $CONTAINER_NAME -td -v ./mosquitto.conf:/mosquitto/config/mosquitto.conf -v ./server.pem:/mosquitto/server.pem -v ./server.key:/mosquitto/server.key" - -# If it is not running, try launching it -- on success, use that. -echo "mqtt/setup: Trying to launch $CONTAINER_NAME..." -if ! docker run $DOCKER_RUN_FLAGS $CONTAINER_TAG; then - echo "eclipse-mosquitto launch fail" - - #echo "mqtt/setup: Building docker image $CONTAINER_TAG..." - # If it fails, build it from ./container/Dockerfile - #docker build -t $CONTAINER_TAG ./container - # Try again - #echo "mqtt/setup: Launching $CONTAINER_NAME..." - #docker run $DOCKER_RUN_FLAGS $CONTAINER_TAG -fi diff --git a/integration_tests/mqtt/test.sh b/integration_tests/mqtt/test.sh deleted file mode 100755 index 8f2ae805..00000000 --- a/integration_tests/mqtt/test.sh +++ /dev/null @@ -1,27 +0,0 @@ -#!/usr/bin/env bash - -set -e -MODULE_DIR=$(dirname $0) -ZGRAB_ROOT=$(git rev-parse --show-toplevel) -ZGRAB_OUTPUT=$ZGRAB_ROOT/zgrab-output - -mkdir -p $ZGRAB_OUTPUT/mqtt - -CONTAINER_NAME=zgrab_mqtt - -OUTPUT_FILE=$ZGRAB_OUTPUT/mqtt/mqtt.json - -echo "mqtt/test: Tests runner for mqtt" -# TODO FIXME: Add any necessary flags or additional tests -echo -e ",target,mqtt -,target,mqtt-tls -,target,mqtt-v5 -,target,mqtt-tls-v5" | docker run --rm -i -v ./multiple.ini:/multiple.ini --link $CONTAINER_NAME:target zgrab2_runner multiple -c /multiple.ini> $OUTPUT_FILE -#CONTAINER_NAME=$CONTAINER_NAME $ZGRAB_ROOT/docker-runner/docker-run.sh mqtt --v5 >> $OUTPUT_FILE - -# Dump the docker logs -echo "mqtt/test: BEGIN docker logs from $CONTAINER_NAME [{(" -docker logs --tail all $CONTAINER_NAME -echo ")}] END docker logs from $CONTAINER_NAME" - -# TODO: If there are any other relevant log files, dump those to stdout here. diff --git a/zgrab2_schemas/zgrab2/socks5.py b/zgrab2_schemas/zgrab2/socks5.py index e2bf917c..d9475014 100644 --- a/zgrab2_schemas/zgrab2/socks5.py +++ b/zgrab2_schemas/zgrab2/socks5.py @@ -1,5 +1,5 @@ -# zschema sub-schema for zgrab2's MQTT module -# Registers zgrab2-mqtt globally, and mqtt with the main zgrab2 schema. +# zschema sub-schema for zgrab2's Socks5 module +# Registers zgrab2-socks5 globally, and socks5 with the main zgrab2 schema. from zschema.leaves import * from zschema.compounds import * import zschema.registry From d844a6ec63f6801b98c7b6ba41039e4bb6507596 Mon Sep 17 00:00:00 2001 From: phillip-stephens Date: Wed, 22 Jan 2025 16:12:38 -0800 Subject: [PATCH 4/6] lint --- modules/socks5/scanner.go | 2 +- zgrab2_schemas/zgrab2/socks5.py | 43 +++++++++++++++++++-------------- 2 files changed, 26 insertions(+), 19 deletions(-) diff --git a/modules/socks5/scanner.go b/modules/socks5/scanner.go index 258712cc..0cdef7a3 100644 --- a/modules/socks5/scanner.go +++ b/modules/socks5/scanner.go @@ -252,4 +252,4 @@ func (s *Scanner) Scan(t zgrab2.ScanTarget) (status zgrab2.ScanStatus, result in } return zgrab2.SCAN_SUCCESS, &socks5Conn.results, nil -} \ No newline at end of file +} diff --git a/zgrab2_schemas/zgrab2/socks5.py b/zgrab2_schemas/zgrab2/socks5.py index d9475014..c41975c4 100644 --- a/zgrab2_schemas/zgrab2/socks5.py +++ b/zgrab2_schemas/zgrab2/socks5.py @@ -7,25 +7,32 @@ from . import zgrab2 # Schema for ScanResults struct -socks5_response_explanation = SubRecord({ - "Version": String(), - "Reply": String(), - "Reserved": String(), - "Address Type": String(), - "Bound Address": String(), - "Bound Port": String(), -}) +socks5_response_explanation = SubRecord( + { + "Version": String(), + "Reply": String(), + "Reserved": String(), + "Address Type": String(), + "Bound Address": String(), + "Bound Port": String(), + } +) -socks5_scan_response = SubRecord({ - "version": String(), - "method_selection": String(), - "connection_response": String(), - "connection_response_explanation": socks5_response_explanation, -}) +socks5_scan_response = SubRecord( + { + "version": String(), + "method_selection": String(), + "connection_response": String(), + "connection_response_explanation": socks5_response_explanation, + } +) -socks5_scan = SubRecord({ - "result": socks5_scan_response, -}, extends=zgrab2.base_scan_response) +socks5_scan = SubRecord( + { + "result": socks5_scan_response, + }, + extends=zgrab2.base_scan_response, +) zschema.registry.register_schema("zgrab2-socks5", socks5_scan) -zgrab2.register_scan_response_type("socks5", socks5_scan) \ No newline at end of file +zgrab2.register_scan_response_type("socks5", socks5_scan) From f8bc6390faeb97523edae2f37a16151a2988239a Mon Sep 17 00:00:00 2001 From: phillip-stephens Date: Wed, 22 Jan 2025 16:27:03 -0800 Subject: [PATCH 5/6] socks5: made integration test shell scripts executable --- integration_tests/socks5/cleanup.sh | 0 integration_tests/socks5/setup.sh | 0 integration_tests/socks5/test.sh | 0 3 files changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 integration_tests/socks5/cleanup.sh mode change 100644 => 100755 integration_tests/socks5/setup.sh mode change 100644 => 100755 integration_tests/socks5/test.sh diff --git a/integration_tests/socks5/cleanup.sh b/integration_tests/socks5/cleanup.sh old mode 100644 new mode 100755 diff --git a/integration_tests/socks5/setup.sh b/integration_tests/socks5/setup.sh old mode 100644 new mode 100755 diff --git a/integration_tests/socks5/test.sh b/integration_tests/socks5/test.sh old mode 100644 new mode 100755 From 0f52ac4df27f75e6c4746224031b181e5ef96a11 Mon Sep 17 00:00:00 2001 From: 1759537337 <128583732+xiangguisss@users.noreply.github.com> Date: Mon, 27 Jan 2025 19:21:57 +0800 Subject: [PATCH 6/6] Update socks5 --- modules/socks5/scanner.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/socks5/scanner.go b/modules/socks5/scanner.go index 0cdef7a3..885fa3a6 100644 --- a/modules/socks5/scanner.go +++ b/modules/socks5/scanner.go @@ -214,7 +214,7 @@ func (conn *Connection) PerformConnectionRequest() error { conn.results.ConnectionResponse = fmt.Sprintf("%x", resp) conn.results.ConnectionResponseExplanation = explainResponse(resp) - if resp[1] != 0x00 { + if resp[1] > 0x80 { return fmt.Errorf("connection request failed with response: %x", resp) }