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

jarm: update jarm to not fail on handshake failure #328

Merged
merged 1 commit into from
Sep 30, 2021

Conversation

aspacewalz
Copy link
Contributor

This PR removes the error handling for a JARM probe response. The reason is that a handshake failure should still be processed the same as any other response. Currently a handshake failure results in the ZeroHash value being returned. This does not match the salesforce jarm module which should be treated as the correct implementation.

After this change, the salesforce and zgrab2 modules will both return the same fingerprint for services that return a handshake failure to one of the probes.

How to Test

go test ./...

Notes & Caveats

This PR is being created to bring the zgrab2 JARM module in line with the behavior of the salesforce jarm tool.

Comment on lines 123 to +124

// ret, err = zgrab2.ReadAvailable(conn)
ret, err = zgrab2.ReadAvailableWithOptions(conn, 1484, 500*time.Millisecond, 0, 1484)
if err != io.EOF && err != nil {
rawhashes = append(rawhashes, "")
conn.Close()
continue
}
ret, _ = zgrab2.ReadAvailableWithOptions(conn, 1484, 500*time.Millisecond, 0, 1484)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It appears to be the case that error responses from the target should still be processed by ParseServerHello which contains logic for handling the various failure responses appropriately.

@@ -142,12 +130,11 @@ func (scanner *Scanner) Scan(target zgrab2.ScanTarget) (zgrab2.ScanStatus, inter
continue
}

rawhashes = append(rawhashes, string(ans))
rawhashes = append(rawhashes, ans)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ans is already a string. no need to cast.

@@ -120,20 +114,14 @@ func (scanner *Scanner) Scan(target zgrab2.ScanTarget) (zgrab2.ScanStatus, inter
return zgrab2.TryGetScanStatus(err), nil, err
}

_, err = conn.Write([]byte(data))
_, err = conn.Write(jarm.BuildProbe(probe))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

data was already a byte slice and was also only used in this function call.

Comment on lines 147 to +148
}
if err != nil {
return ret, err
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this block err is ALWAYS nil so i removed it.

Copy link
Member

@codyprime codyprime left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code cleanup changes look good.

Tested against a known problem host, verified the changes after matched the salesforce jarm tool fingerprint.

@codyprime codyprime merged commit 00fe9ca into zmap:master Sep 30, 2021
@aspacewalz aspacewalz deleted the aspacewalz/jarm-fix branch September 30, 2021 19:41
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.

2 participants