-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
register goja func to check udp port #5397
register goja func to check udp port #5397
Conversation
Before:Tempalte: id: tftp-detect
info:
name: TFTP Service - Detection
author: pussycat0x
severity: info
description: |
Detect TFTP Service.
metadata:
verified: true
max-request: 1
shodan-query: "port:69"
tags: js,tftp,udp,network
javascript:
- pre-condition: |
isPortOpen(Host,Port);
code: |
let packet = bytes.NewBuffer();
let message = "1.txt"
let data = message;
packet.WriteString(data)
let c = require("nuclei/net");
let conn = c.Open('udp', `${Host}:${Port}`);
conn.SendHex(packet.Hex());
let resp = conn.RecvString(256);
resp;
args:
Host: "{{Host}}"
Port: 69
matchers:
- type: word
words:
- "Unknown transfer ID"
# digest: 4a0a00473045022100c512c1a23c479681469c4b6a1e1e7a5740dfee043f58cb2a1d79767822cbb32802203dfa42884afa515fb2ac6dd0e0075422bc1f3ece618c6538164c8b9b09062e46:922c64590222798bb761d5b6d8e72950 ✗ go run . -t port-detect.yaml -u 201.194.192.183 -v -debug
__ _
____ __ _______/ /__ (_)
/ __ \/ / / / ___/ / _ \/ /
/ / / / /_/ / /__/ / __/ /
/_/ /_/\__,_/\___/_/\___/_/ v3.3.0-dev
projectdiscovery.io
[VER] Started metrics server at localhost:9092
[INF] Current nuclei version: v3.3.0-dev (development)
[INF] Current nuclei-templates version: v9.9.1 (latest)
[WRN] Scan results upload to cloud is disabled.
[INF] New templates added in latest release: 75
[INF] Templates loaded for current scan: 1
[INF] Executing 1 signed templates from projectdiscovery/nuclei-templates
[INF] Targets loaded for current scan: 1
[DBG] [tftp-detect] Executing Precondition for request
[DBG] [tftp-detect] Javascript Code:
isPortOpen(Host, Port);
[WRN] [tftp-detect] Could not execute request for 201.194.192.183: [tftp-detect:RUNTIME] could not execute pre-condition: dial tcp 201.194.192.183:69: connect: connection refused
[INF] No results found. Better luck next time! AfterTempalte: id: tftp-detect
info:
name: TFTP Service - Detection
author: pussycat0x
severity: info
description: |
Detect TFTP Service.
metadata:
verified: true
max-request: 1
shodan-query: "port:69"
tags: js,tftp,udp,network
javascript:
- pre-condition: |
isUDPPortOpen(Host,Port);
code: |
let packet = bytes.NewBuffer();
let message = "1.txt"
let data = message;
packet.WriteString(data)
let c = require("nuclei/net");
let conn = c.Open('udp', `${Host}:${Port}`);
conn.SendHex(packet.Hex());
let resp = conn.RecvString(256);
resp;
args:
Host: "{{Host}}"
Port: 69
matchers:
- type: word
words:
- "Unknown transfer ID"
# digest: 4a0a00473045022100c512c1a23c479681469c4b6a1e1e7a5740dfee043f58cb2a1d79767822cbb32802203dfa42884afa515fb2ac6dd0e0075422bc1f3ece618c6538164c8b9b09062e46:922c64590222798bb761d5b6d8e72950 ✗ ./nuclei -t test.yaml -u 201.194.192.183 -v -debug
__ _
____ __ _______/ /__ (_)
/ __ \/ / / / ___/ / _ \/ /
/ / / / /_/ / /__/ / __/ /
/_/ /_/\__,_/\___/_/\___/_/ v3.3.0-dev
projectdiscovery.io
[VER] Started metrics server at localhost:9092
[INF] Current nuclei version: v3.3.0-dev (development)
[INF] Current nuclei-templates version: v9.9.1 (latest)
[WRN] Scan results upload to cloud is disabled.
[INF] New templates added in latest release: 75
[INF] Templates loaded for current scan: 1
[WRN] Loading 1 unsigned templates for scan. Use with caution.
[INF] Targets loaded for current scan: 1
[DBG] [tftp-detect] Executing Precondition for request
[DBG] [tftp-detect] Javascript Code:
isUDPPortOpen(Host, Port);
[DBG] [tftp-detect] Precondition for request was satisfied
[VER] [tftp-detect] Sent Javascript request to 201.194.192.183:69
[DBG] [tftp-detect] Dumped Javascript request for 201.194.192.183:69:
Variables:
1. Host => 201.194.192.183
2. Port => 69 address=201.194.192.183:69
[DBG] [tftp-detect] Javascript Code:
let packet = bytes.NewBuffer();
let message = "1.txt"
let data = message;
packet.WriteString(data)
let c = require("nuclei/net");
let conn = c.Open('udp', `${Host}:${Port}`);
conn.SendHex(packet.Hex());
let resp = conn.RecvString(256);
resp;
[DBG] [tftp-detect] Dumped Javascript response for 201.194.192.183:69:
1. error => [:RUNTIME] failed to read .... 4.192.183:69: i/o timeout
2. success => false address=201.194.192.183:69
[WRN] [tftp-detect] Could not execute request for 201.194.192.183: [:RUNTIME] failed to read 256 bytes <- read udp 192.168.1.3:56995->201.194.192.183:69: i/o timeout
[INF] No results found. Better luck next time! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
implementation lgtm !
./nuclei -u 201.194.192.183 -t a.yaml -debug
__ _
____ __ _______/ /__ (_)
/ __ \/ / / / ___/ / _ \/ /
/ / / / /_/ / /__/ / __/ /
/_/ /_/\__,_/\___/_/\___/_/ v3.3.0-dev
projectdiscovery.io
[INF] Current nuclei version: v3.3.0-dev (development)
[INF] Current nuclei-templates version: v9.9.1 (latest)
[WRN] Scan results upload to cloud is disabled.
[INF] New templates added in latest release: 75
[INF] Templates loaded for current scan: 1
[WRN] Loading 1 unsigned templates for scan. Use with caution.
[INF] Targets loaded for current scan: 1
[DBG] [tftp-detect] Executing Precondition for request
[DBG] [tftp-detect] Javascript Code:
isPortOpenWithNetwork(Host, Port, Network);
[DBG] [tftp-detect] Precondition for request was satisfied
[DBG] [tftp-detect] Dumped Javascript request for 201.194.192.183:69:
Variables:
1. Host => 201.194.192.183
2. Network => udp
3. Port => 69 address=201.194.192.183:69
[DBG] [tftp-detect] Javascript Code:
let packet = bytes.NewBuffer();
let message = "1.txt"
let data = message;
packet.WriteString(data)
let c = require("nuclei/net");
let conn = c.Open('udp', `${Host}:${Port}`);
conn.SendHex(packet.Hex());
let resp = conn.RecvString(256);
resp;
[DBG] [tftp-detect] Dumped Javascript response for 201.194.192.183:69:
1. response => Illegal TFTP operation.
2. success => true address=201.194.192.183:69
[INF] No results found. Better luck next time!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tagging @ehsandeep @princechaddha since this involves change/design with templates
instead of
isPortOpenWithNetwork(Host,Port,Network);
i propose
isUDPPortOpen(Host,Port)
we already have isPortOpen()
which default to tcp and since there is only one alternative value isUDPPortOpen
seems simple compared to adding new argument for network selection
|
Proposed changes
Checklist