init
This commit is contained in:
8
.idea/.gitignore
generated
vendored
Normal file
8
.idea/.gitignore
generated
vendored
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
# Default ignored files
|
||||||
|
/shelf/
|
||||||
|
/workspace.xml
|
||||||
|
# Editor-based HTTP Client requests
|
||||||
|
/httpRequests/
|
||||||
|
# Datasource local storage ignored files
|
||||||
|
/dataSources/
|
||||||
|
/dataSources.local.xml
|
9
.idea/airBaltic.iml
generated
Normal file
9
.idea/airBaltic.iml
generated
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module type="WEB_MODULE" version="4">
|
||||||
|
<component name="Go" enabled="true" />
|
||||||
|
<component name="NewModuleRootManager">
|
||||||
|
<content url="file://$MODULE_DIR$" />
|
||||||
|
<orderEntry type="inheritedJdk" />
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
</component>
|
||||||
|
</module>
|
8
.idea/modules.xml
generated
Normal file
8
.idea/modules.xml
generated
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectModuleManager">
|
||||||
|
<modules>
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/.idea/airBaltic.iml" filepath="$PROJECT_DIR$/.idea/airBaltic.iml" />
|
||||||
|
</modules>
|
||||||
|
</component>
|
||||||
|
</project>
|
6
.idea/vcs.xml
generated
Normal file
6
.idea/vcs.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
157
main.go
Normal file
157
main.go
Normal file
@@ -0,0 +1,157 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"flag"
|
||||||
|
"io"
|
||||||
|
"log"
|
||||||
|
"math/rand"
|
||||||
|
"net/http"
|
||||||
|
"net/http/cookiejar"
|
||||||
|
"net/url"
|
||||||
|
"regexp"
|
||||||
|
"strconv"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Function to create a new HTTP client with a fresh cookie jar
|
||||||
|
func newClient() *http.Client {
|
||||||
|
jar, err := cookiejar.New(nil)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal("Error creating cookie jar:", err)
|
||||||
|
}
|
||||||
|
return &http.Client{Jar: jar}
|
||||||
|
}
|
||||||
|
|
||||||
|
func sendVoteRequest(voteNonce, data string, client *http.Client, city string, userAgent string, verbose bool) {
|
||||||
|
const requestUrl = "https://vote.airbaltic.com/wp-admin/admin-ajax.php"
|
||||||
|
|
||||||
|
formData := url.Values{
|
||||||
|
"action": {"vote_for_city"},
|
||||||
|
"livery_uuid": {city},
|
||||||
|
"vote_nonce": {voteNonce},
|
||||||
|
"data": {data},
|
||||||
|
}
|
||||||
|
|
||||||
|
req, err := http.NewRequest("POST", requestUrl, bytes.NewBufferString(formData.Encode()))
|
||||||
|
if err != nil {
|
||||||
|
log.Println("Error creating request:", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
req.Header.Set("User-Agent", userAgent)
|
||||||
|
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
|
||||||
|
|
||||||
|
resp, err := client.Do(req)
|
||||||
|
if err != nil {
|
||||||
|
log.Println("Error sending request:", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
defer func(Body io.ReadCloser) {
|
||||||
|
err := Body.Close()
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal("Error closing response body:", err)
|
||||||
|
}
|
||||||
|
}(resp.Body)
|
||||||
|
|
||||||
|
body, err := io.ReadAll(resp.Body)
|
||||||
|
if err != nil {
|
||||||
|
log.Println("Error reading response:", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if resp.StatusCode != http.StatusOK || !bytes.Contains(body, []byte(`"success":true`)) {
|
||||||
|
log.Printf("Unexpected response: %s\n", body)
|
||||||
|
} else if verbose {
|
||||||
|
println("Voted for " + city + " with nonce: " + voteNonce + " and data " + data + " with userAgent: " + userAgent)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func getNonceAndData(client *http.Client, userAgent string) (string, string) {
|
||||||
|
const requestUrl = "https://vote.airbaltic.com"
|
||||||
|
|
||||||
|
req, err := http.NewRequest("GET", requestUrl, nil)
|
||||||
|
if err != nil {
|
||||||
|
log.Println("Error creating request:", err)
|
||||||
|
return "", ""
|
||||||
|
}
|
||||||
|
req.Header.Set("User-Agent", userAgent)
|
||||||
|
|
||||||
|
res, err := client.Do(req)
|
||||||
|
if err != nil {
|
||||||
|
log.Println("Error sending GET request:", err)
|
||||||
|
return "", ""
|
||||||
|
}
|
||||||
|
defer func(Body io.ReadCloser) {
|
||||||
|
err := Body.Close()
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal("Error closing response body:", err)
|
||||||
|
}
|
||||||
|
}(res.Body)
|
||||||
|
|
||||||
|
body, err := io.ReadAll(res.Body)
|
||||||
|
if err != nil {
|
||||||
|
log.Println("Error reading response body:", err)
|
||||||
|
return "", ""
|
||||||
|
}
|
||||||
|
|
||||||
|
re := regexp.MustCompile(`vote_nonce:\s*'(?P<vote_nonce>.*?)',\s*data:\s*'(?P<data>.*?)'`)
|
||||||
|
match := re.FindStringSubmatch(string(body))
|
||||||
|
|
||||||
|
if len(match) > 0 {
|
||||||
|
return match[re.SubexpIndex("vote_nonce")], match[re.SubexpIndex("data")]
|
||||||
|
}
|
||||||
|
log.Println("No vote_nonce or data found in response")
|
||||||
|
return "", ""
|
||||||
|
}
|
||||||
|
|
||||||
|
func doVote(city string, userAgent string, verbose bool) {
|
||||||
|
|
||||||
|
client := newClient() // Create a new client for each pair of requests
|
||||||
|
if verbose {
|
||||||
|
println("Getting nonce and data")
|
||||||
|
}
|
||||||
|
voteNonce, data := getNonceAndData(client, userAgent)
|
||||||
|
if voteNonce != "" && data != "" {
|
||||||
|
if verbose {
|
||||||
|
println("For this vote the nonce is : " + voteNonce + "\n and the data is: " + data)
|
||||||
|
}
|
||||||
|
sendVoteRequest(voteNonce, data, client, city, userAgent, verbose)
|
||||||
|
} else {
|
||||||
|
log.Println("Failed to retrieve nonce or data")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func getUserAgent(userAgents []string) string {
|
||||||
|
return userAgents[rand.Intn(len(userAgents))]
|
||||||
|
}
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
var requestsPerMinute int
|
||||||
|
var verbose bool
|
||||||
|
flag.IntVar(&requestsPerMinute, "rq", 60, "the count of requests per minute")
|
||||||
|
cityTemp := flag.Int("cty", 307, "the city to vote for")
|
||||||
|
flag.BoolVar(&verbose, "v", false, "report a lot of stuff to terminal")
|
||||||
|
userAgents := []string{
|
||||||
|
"Mozilla/5.0 (X11; Linux x86_64; rv:129.0) Gecko/20100101 Firefox/129.0",
|
||||||
|
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.5 Safari/605.1.1",
|
||||||
|
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.3",
|
||||||
|
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.3",
|
||||||
|
"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) SamsungBrowser/25.0 Chrome/121.0.0.0 Safari/537.3",
|
||||||
|
}
|
||||||
|
flag.Parse()
|
||||||
|
city := strconv.Itoa(*cityTemp)
|
||||||
|
|
||||||
|
sleepDuration := time.Minute / time.Duration(requestsPerMinute)
|
||||||
|
println("Voting for " + city + " " + strconv.Itoa(requestsPerMinute) + " times per minute")
|
||||||
|
if verbose {
|
||||||
|
println("Verbose output on")
|
||||||
|
}
|
||||||
|
for {
|
||||||
|
go doVote(city, getUserAgent(userAgents), verbose)
|
||||||
|
if verbose {
|
||||||
|
println("Sleeping for: " + sleepDuration.String())
|
||||||
|
}
|
||||||
|
time.Sleep(sleepDuration) // Adjust the sleep duration as needed
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user