Fix crash #174 by duplicating curl handle

Wrap libcurl to bypass lack of covariance support
This commit is contained in:
Brendan Le Glaunec
2018-03-13 10:24:25 +01:00
committed by Brendan LE GLAUNEC
parent 6392dcd9a0
commit bcc8099f91
4 changed files with 25 additions and 4 deletions
+6 -2
View File
@@ -32,6 +32,8 @@ func routeAttack(c Curler, camera Stream, route string, timeout time.Duration, e
c.Setopt(curl.OPT_WRITEFUNCTION, doNotWrite)
}
// Do not use signals (would break multithreading)
c.Setopt(curl.OPT_NOSIGNAL, 1)
// Do not send a body in the describe request
c.Setopt(curl.OPT_NOBODY, 1)
// Send a request to the URL of the camera we want to attack
@@ -82,6 +84,8 @@ func credAttack(c Curler, camera Stream, username string, password string, timeo
c.Setopt(curl.OPT_WRITEFUNCTION, doNotWrite)
}
// Do not use signals (would break multithreading)
c.Setopt(curl.OPT_NOSIGNAL, 1)
// Do not send a body in the describe request
c.Setopt(curl.OPT_NOBODY, 1)
// Send a request to the URL of the camera we want to attack
@@ -117,7 +121,7 @@ func credAttack(c Curler, camera Stream, username string, password string, timeo
func attackCameraCredentials(c Curler, target Stream, credentials Credentials, resultsChan chan<- Stream, timeout time.Duration, log bool) {
for _, username := range credentials.Usernames {
for _, password := range credentials.Passwords {
ok := credAttack(c, target, username, password, timeout, log)
ok := credAttack(c.Duphandle(), target, username, password, timeout, log)
if ok {
target.CredentialsFound = true
target.Username = username
@@ -133,7 +137,7 @@ func attackCameraCredentials(c Curler, target Stream, credentials Credentials, r
func attackCameraRoute(c Curler, target Stream, routes Routes, resultsChan chan<- Stream, timeout time.Duration, log bool) {
for _, route := range routes {
ok := routeAttack(c, target, route, timeout, log)
ok := routeAttack(c.Duphandle(), target, route, timeout, log)
if ok {
target.RouteFound = true
target.Route = route