Skip to content

Instantly share code, notes, and snippets.

@Li4n0
Last active June 17, 2021 12:41
Show Gist options
  • Save Li4n0/21aa0bec2d626114a729ca2677efb05a to your computer and use it in GitHub Desktop.
Save Li4n0/21aa0bec2d626114a729ca2677efb05a to your computer and use it in GitHub Desktop.
Use Golang's SSE client connect to RevSuit
package client
import (
"crypto/tls"
"log"
"time"
"net"
"net/http"
"github.com/r3labs/sse"
"gopkg.in/cenkalti/backoff.v1"
)
func Listen() {
client := sse.NewClient("http://127.0.0.1:10000/revsuit/api/events")
client.Connection.Transport = &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: true}
}
// Set token.
client.Headers = map[string]string{"Token": "your token"}
//Set reconnection policy.
reconnectStrategy := backoff.NewExponentialBackOff()
reconnectStrategy.MaxElapsedTime = time.Minute
client.ReconnectStrategy = reconnectStrategy
//Listening channel.
err := client.Subscribe("messages", func(event *sse.Event) {
log.Println(string(event.Data))
// Look up this flag in your local database of recorded requests
//to find which request attack was successful for the scanner.
searchRequest(event.Data)
})
if err != nil {
log.Fatal("Disconnect from reverse platform, please check network or reverse connection platform's status.")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment