-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
105 lines (87 loc) · 2.2 KB
/
main.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
package main
import (
"errors"
"fmt"
"github.com/PuerkitoBio/goquery"
"github.com/davecgh/go-spew/spew"
"net/http"
"regexp"
"strconv"
"stuff/client"
)
func main() {
fmt.Printf("hello, world\n")
numWorkers := 1000
done := make(chan bool, numWorkers)
for i:=0; i<numWorkers; i++ {
go func(do chan bool) {
sendErr := sendMailToInnung("BennyBot", "[email protected]", "automated xD")
if sendErr != nil {
_, _ = spew.Print("!")
do <- false
} else {
_, _ = spew.Print(".")
do <- true
}
}(done)
}
k := 0
for i:=0; i<numWorkers; i++ {
if <- done {
k++
}
}
spew.Dump(strconv.Itoa(k) + " out of " + strconv.Itoa(numWorkers) + " succeeded.")
}
func sendMailToInnung(name, email, message string) error {
res, err := http.Get("http://shk-schwaben.de/index.php/kontakt.html")
if err != nil {
return err
}
defer res.Body.Close()
if res.StatusCode != 200 {
return errors.New(fmt.Sprintf("status code error: %d %s", res.StatusCode, res.Status))
}
// Load the HTML document
doc, err := goquery.NewDocumentFromReader(res.Body)
if err != nil {
return err
}
sel := doc.Find(".captcha_text").First()
secret := sel.Text()
re := regexp.MustCompile("[0-9]+")
nums := re.FindAllString(secret, -1)
sum := 0
for _,n := range nums {
n2, _ := strconv.Atoi(n)
sum += n2
}
//spew.Dump(secret, nums, sum)
sel2 := doc.Find("#ctrl_5").First()
captchaName, _ := sel2.Attr("name")
//spew.Dump("Name: ", captchaName)
sesId := ""
for _,c := range res.Cookies() {
if c.Name == "PHPSESSID" {
sesId = c.Value
}
}
//spew.Dump("SesId: ", sesId)
cooks := []*http.Cookie{{Name: "PHPSESSID", Value: sesId}}
header := map[string]string{
"Content-Type": "application/x-www-form-urlencoded",
"Referer": "http://shk-schwaben.de/index.php/kontakt.html",
}
cli := client.SimpleClient{BaseUrl: "http://shk-schwaben.de", Headers: header}
bodyPs := map[string]string{
"FORM_SUBMIT": "auto_KontaktFormular",
"MAX_FILE_SIZE": "2048000",
"Ihr_Name": "Ich2",
"Ihre_E-Mail": "[email protected]",
"Nachricht": "Hi",
captchaName: strconv.Itoa(sum),
}
var back []byte
mailErr := cli.Call5("POST", "/index.php/kontakt-danke.html", map[string]string{}, bodyPs, cooks, &back)
return mailErr
}