-
Notifications
You must be signed in to change notification settings - Fork 171
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7ad1adc
commit 18ceaf5
Showing
12 changed files
with
423 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
//go:build integration | ||
// +build integration | ||
|
||
package main | ||
|
||
import ( | ||
//"fmt" | ||
"log" | ||
// "net/http" | ||
// "net/url" | ||
// "strings" | ||
// "io/ioutil" | ||
// "strconv" | ||
|
||
cycletls "github.com/Danny-Dasilva/CycleTLS/cycletls" | ||
) | ||
|
||
|
||
func main() { | ||
client := cycletls.Init() | ||
formData := cycletls.FormData{ | ||
Fields: []cycletls.FormField{ | ||
{Name: "CustTel", Value: "A"}, | ||
{Name: "CustTel", Value: "1111111111"}, | ||
{Name: "Size", Value: "small"}, | ||
{Name: "Delivery", Value: "11:15"}, | ||
{Name: "Comments", Value: "example test paragraph"}, | ||
}, | ||
} | ||
resp, err := client.Do("https://httpbin.org/post", cycletls.Options{ | ||
Body: "", | ||
Ja3: "771,4865-4867-4866-49195-49199-52393-52392-49196-49200-49162-49161-49171-49172-51-57-47-53-10,0-23-65281-10-11-35-16-5-51-43-13-45-28-21,29-23-24-25-256-257,0", | ||
UserAgent: "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:87.0) Gecko/20100101 Firefox/87.0", | ||
Headers: map[string]string{"Content-Type": "application/x-www-form-urlencoded"}, | ||
Form: formData, | ||
}, "POST") | ||
if err != nil { | ||
log.Print("Request Failed: " + err.Error()) | ||
} | ||
|
||
log.Println(resp) | ||
// Create the form data | ||
// data := url.Values{} | ||
// data.Add("key2", "value2") | ||
// for _, field := range formData.Fields { | ||
// data.Set(field.Name, field.Value) | ||
// } | ||
|
||
// // Encode the form data | ||
// encodedData := data.Encode() | ||
|
||
|
||
// // Create the HTTP request | ||
// req, err := http.NewRequest("POST", "https://httpbin.org/post", strings.NewReader(encodedData)) | ||
// if err != nil { | ||
// // handle error | ||
// } | ||
// req.Header.Set("Content-Type", "application/x-www-form-urlencoded") | ||
// req.Header.Add("Content-Length", strconv.Itoa(len(data.Encode()))) | ||
// // Send the request | ||
// client := &http.Client{} | ||
// resp, err := client.Do(req) | ||
// if err != nil { | ||
// // handle error | ||
// } | ||
|
||
// defer resp.Body.Close() | ||
|
||
// log.Println(resp) | ||
// body, err := ioutil.ReadAll(resp.Body) | ||
// if err != nil { | ||
// panic(err) | ||
// } | ||
|
||
// log.Println(string(body)) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
//go:build integration | ||
// +build integration | ||
|
||
package cycletls_test | ||
|
||
import ( | ||
//"fmt" | ||
"log" | ||
"testing" | ||
"net/http" | ||
"net/url" | ||
"strings" | ||
"io/ioutil" | ||
cycletls "github.com/Danny-Dasilva/CycleTLS/cycletls" | ||
) | ||
|
||
|
||
func TestDefaultHeaderOrder(t *testing.T) { | ||
// client := cycletls.Init() | ||
formData := cycletls.FormData{ | ||
Fields: []cycletls.FormField{ | ||
{Name: "CustTel", Value: "A"}, | ||
{Name: "CustTel", Value: "1111111111"}, | ||
{Name: "Size", Value: "small"}, | ||
{Name: "Toppings", Value: "cheese&delivery"}, | ||
{Name: "Delivery", Value: "11:15"}, | ||
{Name: "Comments", Value: "example test paragraph"}, | ||
}, | ||
} | ||
// resp, err := client.Do("https://httpbin.org/forms/post", cycletls.Options{ | ||
// Body: "", | ||
// Ja3: "771,4865-4867-4866-49195-49199-52393-52392-49196-49200-49162-49161-49171-49172-51-57-47-53-10,0-23-65281-10-11-35-16-5-51-43-13-45-28-21,29-23-24-25-256-257,0", | ||
// UserAgent: "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:87.0) Gecko/20100101 Firefox/87.0", | ||
// Form: formData, | ||
// }, "POST") | ||
// if err != nil { | ||
// log.Print("Request Failed: " + err.Error()) | ||
// } | ||
|
||
// Create the form data | ||
|
||
data := url.Values{} | ||
|
||
for _, field := range formData.Fields { | ||
data.Set(field.Name, field.Value) | ||
} | ||
|
||
// Encode the form data | ||
encodedData := data.Encode() | ||
|
||
// Create the HTTP request | ||
req, err := http.NewRequest("POST", "https://httpbin.org/forms/post", strings.NewReader(encodedData)) | ||
if err != nil { | ||
// handle error | ||
} | ||
req.Header.Set("Content-Type", "application/x-www-form-urlencoded") | ||
|
||
// Send the request | ||
client := &http.Client{} | ||
resp, err := client.Do(req) | ||
if err != nil { | ||
// handle error | ||
} | ||
log.Println(resp) | ||
|
||
defer resp.Body.Close() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package main | ||
|
||
import ( | ||
"./cycletls" | ||
"log" | ||
"runtime" | ||
"time" | ||
// "net/http" | ||
) | ||
|
||
func main() { | ||
runtime.GOMAXPROCS(runtime.NumCPU()) | ||
|
||
start := time.Now() | ||
defer func() { | ||
log.Println("Execution Time: ", time.Since(start)) | ||
}() | ||
client := cycletls.Init() | ||
response, err := client.Do("https://www.google.com", cycletls.Options{ | ||
Body: "", | ||
Ja3: "771,4865-4866-4867-49195-49199-49196-49200-52393-52392-49171-49172-156-157-47-53,0-23-65281-10-11-35-16-5-13-18-51-45-43-27,29-23-24,0", | ||
UserAgent: "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.54 Safari/537.36", | ||
}, "GET") | ||
if err != nil { | ||
log.Print("Request Failed: " + err.Error()) | ||
} | ||
log.Println(response.Status,) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package main | ||
|
||
import ( | ||
"./cycletls" | ||
"log" | ||
"runtime" | ||
"time" | ||
// "net/http" | ||
) | ||
|
||
func main() { | ||
runtime.GOMAXPROCS(runtime.NumCPU()) | ||
|
||
start := time.Now() | ||
defer func() { | ||
log.Println("Execution Time: ", time.Since(start)) | ||
}() | ||
client := cycletls.Init() | ||
response, err := client.Do("https://www.google.com", cycletls.Options{ | ||
Body: "", | ||
Ja3: "771,4865-4866-4867-49195-49199-49196-49200-52393-52392-49171-49172-156-157-47-53,0-23-65281-10-11-35-16-5-13-18-51-45-43-27-17513,29-23-24,0", //something invalid | ||
UserAgent: "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.54 Safari/537.36", | ||
}, "GET") | ||
if err != nil { | ||
log.Print("Request Failed: " + err.Error()) | ||
} | ||
log.Println(response.Body,) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
const fs = require('fs'); | ||
|
||
const filePath = './test.go'; | ||
|
||
fs.readFile(filePath, (err, data) => { | ||
if (err) { | ||
// handle error | ||
return; | ||
} | ||
|
||
// encode the file contents as a base64 string | ||
const base64Data = Buffer.from(data).toString('base64'); | ||
console.log(base64Data); | ||
}); | ||
|
||
console.log(fs.readFileSync(filePath, { encoding: 'base64' })) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import requests | ||
files = {'foo': 'bar'} | ||
|
||
print(requests.Request('POST', 'http://httpbin.org/post', files=files).prepare().body.decode('utf8')) | ||
print(requests.Request('POST', 'http://httpbin.org/post', files=files).prepare().body.decode('utf8')) |
Oops, something went wrong.