-
Notifications
You must be signed in to change notification settings - Fork 316
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,6 @@ import ( | |
_ "fmt" | ||
jarm "github.com/RumbleDiscovery/jarm-go" | ||
"github.com/zmap/zgrab2" | ||
"io" | ||
"log" | ||
"net" | ||
"strings" | ||
|
@@ -103,13 +102,8 @@ func (scanner *Scanner) Scan(target zgrab2.ScanTarget) (zgrab2.ScanStatus, inter | |
// Stores raw hashes returned from parsing each protocols Hello message | ||
rawhashes := []string{} | ||
|
||
// Stores final module results | ||
r := Results{} | ||
|
||
// Loop through each Probe type | ||
for _, probe := range jarm.GetProbes(target.Host(), int(scanner.GetPort())) { | ||
data := jarm.BuildProbe(probe) | ||
|
||
var ( | ||
conn net.Conn | ||
err error | ||
|
@@ -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)) | ||
if err != nil { | ||
rawhashes = append(rawhashes, "") | ||
conn.Close() | ||
continue | ||
} | ||
|
||
// 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) | ||
Comment on lines
123
to
+124
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
|
||
ans, err := jarm.ParseServerHello(ret, probe) | ||
if err != nil { | ||
|
@@ -142,12 +130,11 @@ func (scanner *Scanner) Scan(target zgrab2.ScanTarget) (zgrab2.ScanStatus, inter | |
continue | ||
} | ||
|
||
rawhashes = append(rawhashes, string(ans)) | ||
rawhashes = append(rawhashes, ans) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
conn.Close() | ||
|
||
} | ||
|
||
fprint := jarm.RawHashToFuzzyHash(strings.Join(rawhashes, ",")) | ||
r.Fingerprint = string(fprint) | ||
return zgrab2.SCAN_SUCCESS, &r, nil | ||
return zgrab2.SCAN_SUCCESS, &Results{ | ||
Fingerprint: jarm.RawHashToFuzzyHash(strings.Join(rawhashes, ",")), | ||
}, nil | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -145,9 +145,7 @@ func ReadAvailableWithOptions(conn net.Conn, bufferSize int, readTimeout time.Du | |
} | ||
return ret, err | ||
} | ||
if err != nil { | ||
return ret, err | ||
} | ||
|
||
Comment on lines
147
to
+148
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In this block |
||
if n >= maxReadSize { | ||
return ret, err | ||
} | ||
|
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.
data was already a byte slice and was also only used in this function call.