Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Commit

Permalink
Merge pull request #18 from Implex-ltd/temp
Browse files Browse the repository at this point in the history
GoEngine Testing, Fixs
  • Loading branch information
0xF7A4C6 authored Aug 13, 2023
2 parents ccbe17e + 9b52157 commit bcc33b9
Show file tree
Hide file tree
Showing 15 changed files with 20,209 additions and 164,066 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,7 @@ assets/scrapped
scripts/datasetBuilder/output
scripts/datasetBuilder/input/scrapper
scripts/datasetBuilder/input/unlabeled

*.png
*.jpg
*.jpeg
65 changes: 60 additions & 5 deletions cmd/GoEngine/cmd/engine/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@ package main

import (
"engine/internal/browser"
"fmt"
"log"
"os"
"strings"
"sync"
"time"

"github.com/gofiber/fiber/v2"
"github.com/playwright-community/playwright-go"
"github.com/zenthangplus/goccm"
)

Expand Down Expand Up @@ -42,7 +45,7 @@ func initBrowser() {
go func() {
defer c.Done()

client, err := browser.NewInstance(true)
client, err := browser.NewInstance(true, false)
if err != nil {
log.Println(err)
return
Expand Down Expand Up @@ -116,22 +119,74 @@ func engine() {
}
}

func debug() {
log.Println("ctrl+c to exit.")
func crawl(url string, headless bool) {
var name string
var head string

if headless {
head = "headless"
} else {
head = "headfull"
}

if strings.Contains(url, "browserleaks") {
name = strings.Split(url, "browserleaks.com/")[1]
} else {
name = strings.ReplaceAll(strings.ReplaceAll(strings.ReplaceAll(strings.Split(url, "://")[1], ".", ""), "/", ""), ":", "")
}

client, err := browser.NewInstance(true)
client, err := browser.NewInstance(true, headless)
if err != nil {
log.Println(err)
return
}

defer client.CloseInstance()
client.Page.Goto(url)

log.Println("Loaded", url)
defer log.Println("Done", url)

time.Sleep(5 * time.Second)
client.Page.Screenshot(playwright.PageScreenshotOptions{
FullPage: playwright.Bool(true),
Path: playwright.String(fmt.Sprintf("./img/%s/%s.png", head, name)),
})

client.Page.Goto("https://abrahamjuliot.github.io/creepjs/")
select {}
}

func debug() {
log.Println("ctrl+c to exit.")

gotos := []string{
"https://browserleaks.com/webrtc",
"https://browserleaks.com/canvas",
"https://browserleaks.com/webgl",
"https://browserleaks.com/tls",
"https://browserleaks.com/javascript",
"https://browserleaks.com/fonts",
"https://browserleaks.com/ip",
"https://bot.sannysoft.com/",
"https://abrahamjuliot.github.io/creepjs/",
}

c := goccm.New(len(gotos))

for _, page := range gotos {
c.Wait()

go func(url string) {
defer c.Done()
go crawl(url, false)
crawl(url, true)
}(page)
}

c.WaitAllDone()
log.Println("Done.")
}

func main() {
switch os.Args[1] {
case "debug":
Expand Down
1,523 changes: 1,421 additions & 102 deletions cmd/GoEngine/cmd/engine/scripts/spoof.js

Large diffs are not rendered by default.

26 changes: 14 additions & 12 deletions cmd/GoEngine/internal/browser/browser.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,27 +10,27 @@ import (

var (
THREAD_HSW = 100
BASE_EXT_PATH = `C:\Users\arm\Desktop\GoEngine\cmd\engine\`
ARGS = []string{
"--user-agent=5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36",
}
)

func NewInstance(spoof bool) (*Instance, error) {
func NewInstance(spoof, headless bool) (*Instance, error) {
pw, err := playwright.Run()
if err != nil {
return nil, err
}

browser, err := pw.Chromium.Launch(playwright.BrowserTypeLaunchOptions{
Headless: playwright.Bool(false),
Args: []string{

},
Headless: playwright.Bool(headless),
Args: ARGS,
})
if err != nil {
return nil, err
}

context, err := browser.NewContext(playwright.BrowserNewContextOptions{
Locale: playwright.String("fr-FR"),
Locale: playwright.String("en"),
TimezoneId: playwright.String("Europe/Paris"),
Screen: &playwright.ScreenSize{
Width: playwright.Int(1920),
Expand Down Expand Up @@ -60,9 +60,11 @@ func NewInstance(spoof bool) (*Instance, error) {
}

if spoof {
page.AddInitScript(playwright.PageAddInitScriptOptions{
if err := page.AddInitScript(playwright.PageAddInitScriptOptions{
Path: playwright.String("./scripts/spoof.js"),
})
}); err != nil {
return nil, err
}
}

return &Instance{
Expand Down Expand Up @@ -141,7 +143,7 @@ func (I *Instance) TriggerCaptcha() error {
return err
}

time.Sleep(time.Second*2)
time.Sleep(time.Second * 2)

if err := bl.Click(playwright.ElementHandleClickOptions{
Timeout: playwright.Float(3000),
Expand All @@ -158,7 +160,7 @@ func (I *Instance) TriggerCaptcha() error {
select {
case <-ticker.C:
for _, frame := range I.Page.Frames() {
r, err := frame.Evaluate(`typeof hsw !== 'undefined'`)
r, err := frame.Evaluate(`typeof hsw !== "undefined"`)
if err != nil {
continue
}
Expand All @@ -181,7 +183,7 @@ func (I *Instance) Hsw(jwt string) (string, error) {
<-I.Manager
}()

answer, err := I.Frame.Evaluate(fmt.Sprintf("const getParameter=WebGLRenderingContext.getParameter,a=setInterval(()=>{if(document.body){clearInterval(a);var e=document.createElement(`script`);e.type=`text/javascript`,e.text='WebGLRenderingContext.prototype.getParameter = function(parameter) {if (parameter === 37445) { return `Intel Open Source Technology Center`; };if (parameter === 37446) { return `Mesa DRI Intel(R) Ivybridge Mobile ` }; return getParameter(parameter);}',document.body.appendChild(e)}},1);const canvas=document.createElement(`canvas`);canvas.width=220,canvas.height=30;const ctx=canvas.getContext(`2d`);for(let x=0;x<canvas.width;x++)for(let y=0;y<canvas.height;y++){let a=Math.floor(256*Math.random()),t=Math.floor(256*Math.random()),o=Math.floor(256*Math.random());ctx.fillStyle=`rgb(${a},${t},${o})`,ctx.fillRect(x,y,1,1)}const randomDataURL=canvas.toDataURL(`image/png`),originalToDataURL=HTMLCanvasElement.prototype.toDataURL;HTMLCanvasElement.prototype.toDataURL=function(a){return`image/png`===a&&220===this.width&&30===this.height?randomDataURL:originalToDataURL.apply(this,arguments)};hsw(`%s`)", jwt))
answer, err := I.Frame.Evaluate(fmt.Sprintf("hsw(`%s`)", jwt)) // const getParameter=WebGLRenderingContext.getParameter,a=setInterval(()=>{if(document.body){clearInterval(a);var e=document.createElement(`script`);e.type=`text/javascript`,e.text='WebGLRenderingContext.prototype.getParameter = function(parameter) {if (parameter === 37445) { return `Intel Open Source Technology Center`; };if (parameter === 37446) { return `Mesa DRI Intel(R) Ivybridge Mobile ` }; return getParameter(parameter);}',document.body.appendChild(e)}},1);const canvas=document.createElement(`canvas`);canvas.width=220,canvas.height=30;const ctx=canvas.getContext(`2d`);for(let x=0;x<canvas.width;x++)for(let y=0;y<canvas.height;y++){let a=Math.floor(256*Math.random()),t=Math.floor(256*Math.random()),o=Math.floor(256*Math.random());ctx.fillStyle=`rgb(${a},${t},${o})`,ctx.fillRect(x,y,1,1)}const randomDataURL=canvas.toDataURL(`image/png`),originalToDataURL=HTMLCanvasElement.prototype.toDataURL;HTMLCanvasElement.prototype.toDataURL=function(a){return`image/png`===a&&220===this.width&&30===this.height?randomDataURL:originalToDataURL.apply(this,arguments)};
if err != nil {
return "", err
}
Expand Down
Loading

0 comments on commit bcc33b9

Please sign in to comment.