test

package module
v0.0.0-...-0437d3f Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2022 License: MIT Imports: 14 Imported by: 0

README ¶

Hi there 👋, my names Liza :3.

I originally was not going to release this src, but seeing as i have no reason to keep it to myself ive decided to publically release it.

What this cannot do:

  • Execute JS

Example:

// Currently proxys do not work, at the same time the other struct entrys for the ReqConfig is experimental, i also am unsure if CONNECT works.
// If you are confused with the code, or wanna suggest anything MAKE a pull request or post a issue message.

package main

import (
	"fmt"

	"github.com/6uf/lzhttp"
)

func main() {
	Client := lzhttp.Client{
		Config: lzhttp.GetDefaultConfig(),
	}

	Client.Config.Headers["x-testheader-id"] = "application123"
	Client.Config.Headers["authorization"] = "bearer VERYSECRETTOKEN"
	// Client.Config.Headers["content-type"] = "application/json" | post req etc.

	// Supports multiple methods of requests, the reqs are all handled under one function.
	res, _ := Client.DefaultRequest(lzhttp.MethodGet, "https://example.com/", lzhttp.ReqConfig{ // "GET"
		SaveCookies: true,
	})

	// Client.TransformCookies("https://example.com/") Gets the cached cookies from the previous request.
	// Client.GetCookie("__cf_bm", "https://example.com/") Singles out a cookie and returns only that value.

	fmt.Println(res.Status, string(res.Data), res.Headers) // res.Data = []byte
	res, _ = Client.DefaultRequest(lzhttp.MethodPost, "https://example.post/api/v2/test", lzhttp.ReqConfig{ // "POST"
		Data:        []byte(`{"hello":"world"}`),
		Cookies:     Client.TransformCookies("https://example.com/"),
		SaveCookies: false,
		// ...
	})

	fmt.Println(res.Status, string(res.Data), res.Headers)
}

Documentation ¶

Index ¶

Constants ¶

View Source
const (
	MethodGet     = "GET"
	MethodPost    = "POST"
	MethodPut     = "PUT"
	MethodOptions = "OPTIONS"
	MethodDelete  = "DELETE"
	MethodConnect = "CONNECT"
)

Variables ¶

This section is empty.

Functions ¶

func CheckAddr ¶

func CheckAddr(url *url.URL) string

Takes in the url and returns the host + port of the url.

e.g. "www.google.com:443"

func Contains ¶

func Contains(Value []hpack.HeaderField, Data hpack.HeaderField) bool

Helper function that checks if a Cookie or other form of header is already Applied in your list of headers.

func TurnCookieHeader ¶

func TurnCookieHeader(Cookies []string) string

func UserAgent ¶

func UserAgent() string

Returns a user agent based on your OS

Types ¶

type Client ¶

type Client struct {
	Config  Config
	Ja3     string
	Cookies map[string][]hpack.HeaderField // Used to store the data of websites cookies
	Client  Website
}

func (*Client) CheckQuery ¶

func (Data *Client) CheckQuery() *Client

Checks if there are params in your url and adds it to your path.

e.g. "/api/name?code=12343&scope=1234"

func (*Client) ConnectProxy ¶

func (Data *Client) ConnectProxy(config ReqConfig) error

func (*Client) DefaultRequest ¶

func (Data *Client) DefaultRequest(method, addr string, config ReqConfig) (Res Response, err error)

Handles conns and sending of requests, GO doesnt allow multiple reqs to be sent through the framer.

func (*Client) DefaultSpec ¶

func (Data *Client) DefaultSpec() *tls.ClientHelloSpec

func (*Client) DeleteHeader ¶

func (Data *Client) DeleteHeader(headernames ...string)

func (*Client) FindData ¶

func (Datas *Client) FindData(req ReqConfig) (Config Response, err error)

Find data is called after the requests are performed, it looks the frames of the framer and returns its data, any errors and also headers / status codes.

func (*Client) FormHeaderBytes ¶

func (Data *Client) FormHeaderBytes(headers []string) []byte

Form header bytes takes the []string of headers and turns it into []byte data this is so it can be compatiable for the http2 headers.

func (*Client) GenerateConn ¶

func (Data *Client) GenerateConn(config ReqConfig) error

Generate conn performs a conn to the url you supply. Makes all the config options and sets JA3 if given a value. TODO: Add proxy support.

func (*Client) GenerateSpec ¶

func (Data *Client) GenerateSpec(config ReqConfig) *tls.ClientHelloSpec

func (*Client) GetCookie ¶

func (Data *Client) GetCookie(cookie_name, url string) string

gets a selected cookie based on the cookie_name variable

e.g. "__vf_bm" > "__vf_bm=awdawd223reqfqh32rqrf32qr" (example value)

func (*Client) GetHeaders ¶

func (Data *Client) GetHeaders(method string) (headers []string)

Loops over the Config headers and applies them to the Client []string variable. Method for example "GET".

func (*Client) GrabUrl ¶

func (Data *Client) GrabUrl(addr, method string) *Client

Determines if the url is a IP address or not. This also checks if theres a path present, default to "/" if none.

e.g. "Data.Client.url.Host = addr" > 127.0.0.2
e.g. "https://website.com" > "https://website.com/"

func (*Client) JA3 ¶

func (Data *Client) JA3() (targetPointFormats []byte, suites []uint16, targetCurves []tls.CurveID)

func (*Client) SendHeaders ¶

func (Data *Client) SendHeaders(headers []string, endStream bool)

Writes the headers to the http2 framer. this function also encodes the headers into a []byte Endstream is also called in this function, only use true values when performing GET requests.

func (*Client) SendSettings ¶

func (Data *Client) SendSettings(method string)

This function writes the settings, windows update, prio frames gets the headers AND sends them.

func (*Client) Send_Prio_Frames ¶

func (Data *Client) Send_Prio_Frames()

func (*Client) TransformCookies ¶

func (Data *Client) TransformCookies(url string) string

This is a helper function that gets all the cookies from a cached url and returns them in a format that works with the cookie: header.

func (*Client) Windows_Update ¶

func (Data *Client) Windows_Update()

Writes the window update frame to the http2 framer.

e.g. "Data.Client.Conn.WriteWindowUpdate(0, 15663105)"

func (*Client) WriteSettings ¶

func (Data *Client) WriteSettings()

Write settings writes the default chrome settings to the framer

e.g. "ID: http2.SettingHeaderTableSize, Val: 65536"
e.g. "ID: http2.SettingMaxConcurrentStreams, Val: 1000"
e.g. "ID: http2.SettingInitialWindowSize, Val: 6291456"
e.g. "ID: http2.SettingMaxHeaderListSize, Val: 262144,"

type Config ¶

type Config struct {
	HeaderOrder       []string
	Headers           map[string]string
	Protocols         []string
	CapitalizeHeaders bool
	Debug             bool
}

func GetDefaultConfig ¶

func GetDefaultConfig() Config

This returns the default config variables. header order, chrome like headers and protocols.

type ProxyAuth ¶

type ProxyAuth struct {
	IP, Port, User, Password string
}

type ReqConfig ¶

type ReqConfig struct {
	Data                     []byte
	Cookies                  string
	Ciphersuites             []uint16
	Certificates             []tls.Certificate
	CurvePreferences         []tls.CurveID
	Renegotiation            tls.RenegotiationSupport
	ClientAuth               tls.ClientAuthType
	InsecureSkipVerify       bool
	Proxy                    *ProxyAuth
	SaveCookies              bool
	PreferServerCipherSuites bool
	RootCAs                  *x509.CertPool
	ClientCAs                *x509.CertPool
}

type Response ¶

type Response struct {
	Data    []byte
	Status  string
	Headers []hpack.HeaderField
}

type Website ¶

type Website struct {
	Conn *http2.Framer
	// contains filtered or unexported fields
}

func (*Website) DataSend ¶

func (Data *Website) DataSend(body []byte)

Sends data through the framer

Jump to

Keyboard shortcuts

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