deobfuscator

package module
v0.0.0-...-2423afb Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 28, 2023 License: MIT Imports: 18 Imported by: 0

README

Akamai V2 Deobfuscator

This project aims to reverse Akamai script obfuscation.

Use

Deob script :

import (
	http "github.com/Noooste/fhttp"
	"github.com/Noooste/go-utils"
	"log"
	"os"
	"regexp"
)

func main() {
	var response, _ = http.Get("https://www.nike.com/h8r6ElR8B4Q6OG-YC53dZdAB1hU/7wacrNpthiat/RX44Qw/dT1rJV/RfAxY")
	script := string(utils.GetResponseBody(response))

	windowName := regexp.MustCompile(`(\w+)=window`).FindStringSubmatch(script)[1]

	var err error
	var v *Virtual
	script, v, err = runMainFunction(script, true)
	if err != nil {
		log.Fatalf("Error: %s", err)
	}

	v.deobedScript = script

	if err = v.deob(false); err != nil {
		log.Fatalf("Error: %s", err)
	}

	script = CleanFinalScript(v.deobedScript, windowName, true)

	_ = os.WriteFile("output.js", []byte(script), 0644)
}

Get script ID and DeviceData key order (only on dynamic scripts) :

import (
	"github.com/Noooste/akamai-v2-deobfuscator"
	"github.com/Noooste/go-utils"
	"log"
	"time"
)

func main() {
	var response, _ = http.Get("https://www.ihg.com/pjYhi/LLw3p/IAq-/-m5-/tv/X9YYbpGSaJS9/MngDAQ/dVogXDE/wRFA")
	script := utils.GetResponseBody(response)

	var id, order = deobfuscator.GetScriptInformation(script)
	now := time.Since(start)

	log.Println("script id : ", id)
	log.Println("device data order :", order)
}

Get rotate function :

import (
	"github.com/Noooste/akamai-v2-deobfuscator"
	http "github.com/Noooste/fhttp"
	"github.com/Noooste/go-utils"
	"github.com/ditashi/jsbeautifier-go/jsbeautifier"
	"log"
	"os"
	"runtime/debug"
)


func main() {
	defer func() {
		if r := recover(); r != nil {
			log.Print(r)
			debug.PrintStack()
		}
	}()

	var response, _ = http.Get("https://www.nike.com/h8r6ElR8B4Q6OG-YC53dZdAB1hU/7wacrNpthiat/RX44Qw/dT1rJV/RfAxY")
	script := utils.GetResponseBody(response)

	rf, _, _, _ := deobfuscator.GetRotateFunction(script)

	beautified, _ := jsbeautifier.Beautify(&rf, jsbeautifier.DefaultOptions())
	os.WriteFile("rotate_function.js", []byte(beautified), 0644)
}

Documentation

Index

Constants

View Source
const INFINITE = 0xffffffff

Variables

View Source
var SavePath = "./test"
View Source
var Verbose bool
View Source
var VerboseTime time.Time

Functions

func CleanFinalScript

func CleanFinalScript(script string, windowName string, doBeautify bool) string

func CleanScriptAndRun

func CleanScriptAndRun(script []byte) ([]byte, *goja.Runtime)

func GetDevice

func GetDevice(script []byte, runInVm func(string) (goja.Value, error)) []any

func GetId

func GetId(script []byte, runInVm func(string) (goja.Value, error)) string

func GetSavedFunction

func GetSavedFunction(hash string) string

func GetScriptInformation

func GetScriptInformation(script []byte) (string, []any)

func RunInVm

func RunInVm(script string) (*goja.Runtime, error)

func SaveFunction

func SaveFunction(hash, script string)

Types

type Error

type Error struct {
	Err    string
	Solved bool
}

func GetRotateFunction

func GetRotateFunction(script []byte) (function string, hash string, err error, errors []Error)

func ParseRotateFunction

func ParseRotateFunction(script []byte, runInVm func(string) (goja.Value, error)) (string, string, error, []Error)

type RotateFunction

type RotateFunction struct {
	DeviceDataOrder []string
	ScriptId        string

	LastCall time.Time
	// contains filtered or unexported fields
}

func (*RotateFunction) GetResult

func (rf *RotateFunction) GetResult(startTimestamp int, deviceData, mouseMoveData string, totVel, deltaTimestamp int) (string, error)

func (*RotateFunction) GetScriptId

func (rf *RotateFunction) GetScriptId() string

type Virtual

type Virtual struct {
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL