Skip to content
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

js: generate matcher-status event #5450

Merged
merged 5 commits into from
Jul 26, 2024
Merged

js: generate matcher-status event #5450

merged 5 commits into from
Jul 26, 2024

Conversation

tarunKoyalwar
Copy link
Member

@tarunKoyalwar tarunKoyalwar commented Jul 26, 2024

Proposed Changes

due to inconsistency earlier javascript protocol pre-condition (false) status did not create failed event even if matcher-status is set to true , this is now resolved by creating a failed matcher-status event if pre-condition errored out or return false

Before

$  nuclei -u scanme.sh:1234 -t a.yaml -ms -v

                     __     _
   ____  __  _______/ /__  (_)
  / __ \/ / / / ___/ / _ \/ /
 / / / / /_/ / /__/ /  __/ /
/_/ /_/\__,_/\___/_/\___/_/   v3.3.0

		projectdiscovery.io

[VER] Started metrics server at localhost:9092
[INF] Current nuclei version: v3.3.0 (latest)
[INF] Current nuclei-templates version: v9.9.2 (latest)
[WRN] Scan results upload to cloud is disabled.
[INF] New templates added in latest release: 67
[INF] Templates loaded for current scan: 1
[WRN] Loading 1 unsigned templates for scan. Use with caution.
[INF] Targets loaded for current scan: 1
[WRN] [ssh-server-enumeration] Could not execute request for scanme.sh:1234: [ssh-server-enumeration:RUNTIME] could not execute pre-condition: dial tcp [2400:6180:0:d0::91:1001]:1234: connect: connection refused
[INF] No results found. Better luck next time!

After

$ ./nuclei -u scanme.sh:1234 -t a.yaml -ms -v

                     __     _
   ____  __  _______/ /__  (_)
  / __ \/ / / / ___/ / _ \/ /
 / / / / /_/ / /__/ /  __/ /
/_/ /_/\__,_/\___/_/\___/_/   v3.3.0

		projectdiscovery.io

[VER] Started metrics server at localhost:9092
[INF] Current nuclei version: v3.3.0 (latest)
[INF] Current nuclei-templates version: v9.9.2 (latest)
[WRN] Scan results upload to cloud is disabled.
[INF] New templates added in latest release: 67
[INF] Templates loaded for current scan: 1
[WRN] Loading 1 unsigned templates for scan. Use with caution.
[INF] Targets loaded for current scan: 1
[WRN] [ssh-server-enumeration] Could not execute request for scanme.sh:1234: dial tcp [2400:6180:0:d0::91:1001]:1234: connect: connection refused
[ssh-server-enumeration] [failed] [javascript] [info] scanme.sh:1234

Template

id: ssh-server-enumeration

info:
  name: Detect SSH on port 22.
  author: Justin Bacco
  severity: info
  metadata:
    max-request: 2
    shodan-query: port:22
  tags: enum,js,ssh,network

javascript:
  - pre-condition: |
      isPortOpen(Host,Port)
    code: |
      var m = require("nuclei/ssh");
      var c = m.SSHClient();
      var response = c.ConnectSSHInfoMode(Host, Port);
      Export(response);

    args:
      Host: "{{Host}}"
      Port: 22

    matchers:
      - type: dsl
        dsl:
          - "success == true"

@tarunKoyalwar tarunKoyalwar self-assigned this Jul 26, 2024
@tarunKoyalwar tarunKoyalwar marked this pull request as ready for review July 26, 2024 11:51
pkg/js/compiler/compiler.go Show resolved Hide resolved
pkg/js/compiler/compiler.go Show resolved Hide resolved
pkg/js/global/scripts.go Show resolved Hide resolved
@ehsandeep ehsandeep merged commit 2418319 into dev Jul 26, 2024
12 checks passed
@ehsandeep ehsandeep deleted the issue-5449-missing-ms branch July 26, 2024 21:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

pre-condition does not create matcher-status event
3 participants