From 32a43dee7e8bb81fb2906aca5eb9019ae6cba4a1 Mon Sep 17 00:00:00 2001 From: Vanshaj <79518089+V4NSH4J@users.noreply.github.com> Date: Tue, 19 Jul 2022 05:12:44 +0530 Subject: [PATCH] DMDGO v1.10.14 Added CFBM, but I think it flags so it's disabled by default. --- config.yml | 18 +-- instance/config.go | 1 + instance/direct_messages.go | 254 ++++++++++++++++++++++++------------ instance/headers.go | 64 ++------- instance/types.go | 21 +++ main.go | 2 +- 6 files changed, 215 insertions(+), 145 deletions(-) diff --git a/config.yml b/config.yml index 2099a58..37cad1f 100644 --- a/config.yml +++ b/config.yml @@ -1,6 +1,6 @@ direct_message_settings: - individual_delay: 110 + individual_delay: 120 rate_limit_delay: 300 offset: 100 max_dms_per_token: 0 @@ -20,8 +20,8 @@ direct_message_settings: delay_between_multiple_messages: 10 proxy_settings: - proxy_from_file: false - proxy_for_captcha: false + proxy_from_file: true + proxy_for_captcha: true use_proxy_for_gateway: false proxy_protocol: "http" timeout: 60 @@ -34,23 +34,25 @@ scraper_settings: captcha_settings: captcha_api_key: "" - captcha_api: "capmonster.cloud" + captcha_api: "invisifox.com" max_captcha_wait: 120 max_captcha_retry_dm: 0 max_captcha_retry_invite: 3 other_settings: disable_keep_alives: false - mode: 0 constant_cookies: false - censor_token: false + censor_token: true logs: false gateway_status: 4 + cfbm: false + x_super_properties: "" + useragent: "" suspicion_avoidance: - random_individual_delay: 0 + random_individual_delay: 60 random_rate_limit_delay: 0 - random_delay_before_dm: 0 + random_delay_before_dm: 10 typing: false typing_variation: 250 typing_speed: 450 diff --git a/instance/config.go b/instance/config.go index 867e439..6b24686 100644 --- a/instance/config.go +++ b/instance/config.go @@ -87,6 +87,7 @@ type OtherSettings struct { Useragent string `yaml:"useragent"` ChromeHeaders bool `yaml:"chrome_headers"` ChromeVersion string `yaml:"chrome_version"` + Cfbm bool `yaml:"cfbm"` } type SuspicionAvoidance struct { diff --git a/instance/direct_messages.go b/instance/direct_messages.go index d396cd0..4f0c5a6 100644 --- a/instance/direct_messages.go +++ b/instance/direct_messages.go @@ -14,102 +14,192 @@ import ( "math" "math/rand" "net/http" + "regexp" "strings" "time" "github.com/V4NSH4J/discord-mass-dm-GO/utilities" ) -// Cookies are required for legitimate looking requests, a GET request to instance.com has these required cookies in it's response along with the website HTML -// We can use this to get the cookies & arrange them in a string +func cookieToString(cookies []*http.Cookie, cookieString string) string { + for i := 0; i < len(cookies); i++ { + if i == len(cookies)-1 { + cookieString += fmt.Sprintf(`%s=%s`, cookies[i].Name, cookies[i].Value) + } else { + cookieString += fmt.Sprintf(`%s=%s; `, cookies[i].Name, cookies[i].Value) + } + } + if !strings.Contains(cookieString, "locale=en-US; ") { + cookieString += "; locale=en-US " + } + return cookieString +} func (in *Instance) GetCookieString() (string, error) { if in.Config.OtherSettings.ConstantCookies && in.Cookie != "" { return in.Cookie, nil } - if in.Config.OtherSettings.Mode != 2 { - url := "https://discord.com" - - req, err := http.NewRequest("GET", url, nil) - - if err != nil { - utilities.LogErr("[%v] Error while making request to get cookies %v", time.Now().Format("15:04:05"), err) - return "", fmt.Errorf("error while making request to get cookie %v", err) - } - req = in.cookieHeaders(req) - resp, err := in.Client.Do(req) - if err != nil { - utilities.LogErr("[%v] Error while getting response from cookies request %v", time.Now().Format("15:04:05"), err) - return "", fmt.Errorf("error while getting response from cookie request %v", err) - } - defer resp.Body.Close() - - if resp.Cookies() == nil { - utilities.LogErr("[%v] Error while getting cookies from response %v", time.Now().Format("15:04:05"), err) - return "", fmt.Errorf("there are no cookies in response") - } - cookies := "" - for _, cookie := range resp.Cookies() { - cookies += fmt.Sprintf(`%s=%s; `, cookie.Name, cookie.Value) - } - // CfRay := resp.Header.Get("cf-ray") - // if strings.Contains(CfRay, "-BOM") { - // CfRay = strings.ReplaceAll(CfRay, "-BOM", "") - // } - - // if CfRay != "" { - // body, err := ioutil.ReadAll(resp.Body) - // if err != nil { - // utilities.LogErr("[%v] Error while reading response body %v", time.Now().Format("15:04:05"), err) - // return cookies + "locale:en-US", nil - // } - // m := regexp.MustCompile(`m:'(.+)'`) - // match := m.FindStringSubmatch(string(body)) - // if match == nil { - // return cookies + "locale:en-US", nil - // } - // finalCookies, err := in.GetCfBm(match[1], CfRay, cookies) - // if err != nil { - // return cookies + "locale:en-US", nil - // } - // finalCookies += "; locale:en-US" - // return finalCookies, nil - // } - cookies += fmt.Sprintf("locale:%s", "en-US") - if in.Config.OtherSettings.ConstantCookies { - in.Cookie = cookies - } - return cookies, nil - } else { - site := "https://discord.com/ios/125.0/manifest.json" - req, err := http.NewRequest("GET", site, nil) - if err != nil { - return "", fmt.Errorf("error while making request to get cookie %v", err) - } - req = in.cookieHeaders(req) - resp, err := in.Client.Do(req) - if err != nil { - return "", fmt.Errorf("error while getting response from cookie request %v", err) - } - defer resp.Body.Close() - if resp.Cookies() == nil { - return "", fmt.Errorf("there are no cookies in response") - } - cookies := "" - for i, cookie := range resp.Cookies() { - if i != len(resp.Cookies())-1 { - cookies += fmt.Sprintf(`%s=%s; `, cookie.Name, cookie.Value) - } else { - cookies += fmt.Sprintf(`%s=%s`, cookie.Name, cookie.Value) - } - } - if in.Config.OtherSettings.ConstantCookies { - in.Cookie = cookies - } - return cookies, nil + cookies := []*http.Cookie{} + link := "https://discord.com" + req, err := http.NewRequest("GET", link, nil) + if err != nil { + return "", fmt.Errorf("error while making request to get cookies %v", err) + } + req = in.cookieHeaders(req) + resp, err := in.Client.Do(req) + if err != nil { + return "", fmt.Errorf("error while getting response from cookies request %v", err) + } + defer resp.Body.Close() + if resp.Cookies() == nil { + utilities.LogErr("[%v] Error while getting cookies from response %v", time.Now().Format("15:04:05"), err) + return "", fmt.Errorf("there are no cookies in response") + } + if len(resp.Cookies()) == 0 { + return "", fmt.Errorf("there are no cookies in response") + } + cookies = append(cookies, resp.Cookies()...) + if !in.Config.OtherSettings.Cfbm { + return cookieToString(cookies, ""), nil + } + CfRay := strings.ReplaceAll(resp.Header.Get("cf-ray"), "-BOM", "") + if CfRay == "" { + return cookieToString(cookies, ""), fmt.Errorf("cf-ray is empty") + } + body, err := ioutil.ReadAll(resp.Body) + if err != nil { + return "", fmt.Errorf("error while reading response body %v", err) + } + reg := regexp.MustCompile(`m:'(.+)'`) + match := reg.FindStringSubmatch(string(body)) + if match == nil { + return cookieToString(cookies, ""), fmt.Errorf("m is empty") + } + if len(match) < 2 { + return cookieToString(cookies, ""), fmt.Errorf("no match found for m value") + } + m := match[1] + link = fmt.Sprintf(`https://discord.com/cdn-cgi/bm/cv/result?req_id=%s`, CfRay) + var cfBmPayload CfBm + cfBmPayload.M = m + cfBmPayload.Results = []string{"0e2f525de9f4846b6502d7590065c5ce", "26bc87cb622bfa30b61add57c4874bd8"} + cfBmPayload.Timing = rand.Intn(100) + 50 + cfBmPayload.Fp.ID = 3 + cfBmPayload.Fp.E.Ch = false + cfBmPayload.Fp.E.R = []int{1920, 1080} + cfBmPayload.Fp.E.Ar = []int{rand.Intn(810) + 810, rand.Intn(540) + 540} + cfBmPayload.Fp.E.Cd = []int{16, 32, 64, 128, 256}[rand.Intn(5)] + cfBmPayload.Fp.E.Pr = 1920 / 1080 + bytes, err := json.Marshal(cfBmPayload) + if err != nil { + return "", fmt.Errorf("error while marshalling cf-bm payload %v", err) + } + req, err = http.NewRequest("POST", link, strings.NewReader(string(bytes))) + if err != nil { + return cookieToString(cookies, ""), fmt.Errorf("error while making request to get cookies %v", err) } + req = in.cfBmHeaders(req, cookieToString(cookies, "")) + resp, err = in.Client.Do(req) + if err != nil { + return cookieToString(cookies, ""), fmt.Errorf("error while getting response from cookies request %v", err) + } + defer resp.Body.Close() + if resp.Cookies() == nil { + return cookieToString(cookies, ""), fmt.Errorf("there are no cookies in response") + } + cookies = append(cookies, resp.Cookies()...) + return cookieToString(cookies, "locale=en-US; "), nil } + +// func (in *Instance) GetCookieString() (string, error) { +// if in.Config.OtherSettings.ConstantCookies && in.Cookie != "" { +// return in.Cookie, nil +// } +// if in.Config.OtherSettings.Mode != 2 { +// url := "https://discord.com" + +// req, err := http.NewRequest("GET", url, nil) + +// if err != nil { +// utilities.LogErr("[%v] Error while making request to get cookies %v", time.Now().Format("15:04:05"), err) +// return "", fmt.Errorf("error while making request to get cookie %v", err) +// } +// req = in.cookieHeaders(req) +// resp, err := in.Client.Do(req) +// if err != nil { +// utilities.LogErr("[%v] Error while getting response from cookies request %v", time.Now().Format("15:04:05"), err) +// return "", fmt.Errorf("error while getting response from cookie request %v", err) +// } +// defer resp.Body.Close() + +// if resp.Cookies() == nil { +// utilities.LogErr("[%v] Error while getting cookies from response %v", time.Now().Format("15:04:05"), err) +// return "", fmt.Errorf("there are no cookies in response") +// } +// cookies := "" +// for _, cookie := range resp.Cookies() { +// cookies += fmt.Sprintf(`%s=%s; `, cookie.Name, cookie.Value) +// } +// // CfRay := resp.Header.Get("cf-ray") +// // if strings.Contains(CfRay, "-BOM") { +// // CfRay = strings.ReplaceAll(CfRay, "-BOM", "") +// // } + +// // if CfRay != "" { +// // body, err := ioutil.ReadAll(resp.Body) +// // if err != nil { +// // utilities.LogErr("[%v] Error while reading response body %v", time.Now().Format("15:04:05"), err) +// // return cookies + "locale:en-US", nil +// // } +// // m := regexp.MustCompile(`m:'(.+)'`) +// // match := m.FindStringSubmatch(string(body)) +// // if match == nil { +// // return cookies + "locale:en-US", nil +// // } +// // finalCookies, err := in.GetCfBm(match[1], CfRay, cookies) +// // if err != nil { +// // return cookies + "locale:en-US", nil +// // } +// // finalCookies += "; locale:en-US" +// // return finalCookies, nil +// // } +// cookies += fmt.Sprintf("locale:%s", "en-US") +// if in.Config.OtherSettings.ConstantCookies { +// in.Cookie = cookies +// } +// return cookies, nil +// } else { +// site := "https://discord.com/ios/125.0/manifest.json" +// req, err := http.NewRequest("GET", site, nil) +// if err != nil { +// return "", fmt.Errorf("error while making request to get cookie %v", err) +// } +// req = in.cookieHeaders(req) +// resp, err := in.Client.Do(req) +// if err != nil { +// return "", fmt.Errorf("error while getting response from cookie request %v", err) +// } +// defer resp.Body.Close() +// if resp.Cookies() == nil { +// return "", fmt.Errorf("there are no cookies in response") +// } +// cookies := "" +// for i, cookie := range resp.Cookies() { +// if i != len(resp.Cookies())-1 { +// cookies += fmt.Sprintf(`%s=%s; `, cookie.Name, cookie.Value) +// } else { +// cookies += fmt.Sprintf(`%s=%s`, cookie.Name, cookie.Value) +// } +// } +// if in.Config.OtherSettings.ConstantCookies { +// in.Cookie = cookies +// } +// return cookies, nil +// } + +// } + func (in *Instance) GetCfBm(m, r, cookies string) (string, error) { site := fmt.Sprintf(`https://discord.com/cdn-cgi/bm/cv/result?req_id=%s`, r) payload := fmt.Sprintf( diff --git a/instance/headers.go b/instance/headers.go index b1a6516..5ce656d 100644 --- a/instance/headers.go +++ b/instance/headers.go @@ -26,15 +26,11 @@ func (in *Instance) cookieHeaders(req *http.Request) *http.Request { "accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9", "accept-encoding": "gzip, deflate, br", "accept-language": "en-US,en;q=0.9", - "sec-ch-ua": `".Not/A)Brand";v="99", "Google Chrome";v="103", "Chromium";v="103"`, "sec-ch-ua-mobile": "?0", - "sec-ch-ua-platform": `"Windows"`, "sec-fetch-dest": "document", "sec-fetch-mode": "navigate", "sec-fetch-site": "none", "sec-fetch-user": "?1", - "Pragma": "no-cache", - "Cache-Control": "no-cache", "upgrade-insecure-requests": "1", "user-agent": in.UserAgent, } { @@ -47,19 +43,15 @@ func (in *Instance) cookieHeaders(req *http.Request) *http.Request { func (in *Instance) cfBmHeaders(req *http.Request, cookie string) *http.Request { for k, v := range map[string]string{ - "accept": "*/*", - "accept-language": "en-US,en;q=0.9", - "content-type": "application/json", - "cookie": cookie, - "origin": "https://discord.com", - "referer": "https://discord.com/", - "sec-ch-ua": `".Not/A)Brand";v="99", "Google Chrome";v="103", "Chromium";v="103"`, - "sec-ch-ua-mobile": "?0", - "sec-ch-ua-platform": `"Windows"`, - "sec-fetch-dest": "empty", - "sec-fetch-mode": "cors", - "sec-fetch-site": "same-origin", - "user-agent": in.UserAgent, + "accept": "*/*", + "accept-language": "en-US,en;q=0.9", + "content-type": "application/json", + "cookie": cookie, + "origin": "https://discord.com", + "referer": "https://discord.com/", + "sec-fetch-mode": "cors", + "sec-fetch-site": "same-origin", + "user-agent": in.UserAgent, } { req.Header.Set(k, v) } @@ -92,9 +84,6 @@ func (in *Instance) inviteHeaders(req *http.Request, cookie, xcontext string) *h "cookie": cookie, "origin": "https://discord.com", "referer": "https://discord.com/channels/@me", - "sec-ch-ua": `".Not/A)Brand";v="99", "Google Chrome";v="103", "Chromium";v="103"`, - "sec-ch-ua-mobile": "?0", - "sec-ch-ua-platform": `"Windows"`, "sec-fetch-dest": "empty", "sec-fetch-mode": "cors", "sec-fetch-site": "same-origin", @@ -103,8 +92,6 @@ func (in *Instance) inviteHeaders(req *http.Request, cookie, xcontext string) *h "x-debug-options": "bugReporterEnabled", "x-discord-locale": "en-US", "x-super-properties": in.XSuper, - "Pragma": "no-cache", - "Cache-Control": "no-cache", } { req.Header.Set(k, v) } @@ -135,9 +122,6 @@ func (in *Instance) xContextPropertiesHeaders(req *http.Request, cookie string) "authorization": in.Token, "cookie": cookie, "referer": "https://discord.com/channels/@me", - "sec-ch-ua": `".Not/A)Brand";v="99", "Google Chrome";v="103", "Chromium";v="103"`, - "sec-ch-ua-mobile": "?0", - "sec-ch-ua-platform": `"Windows"`, "sec-fetch-dest": "empty", "sec-fetch-mode": "cors", "sec-fetch-site": "same-origin", @@ -145,8 +129,6 @@ func (in *Instance) xContextPropertiesHeaders(req *http.Request, cookie string) "x-debug-options": "bugReporterEnabled", "x-discord-locale": "en-US", "x-super-properties": in.XSuper, - "Pragma": "no-cache", - "Cache-Control": "no-cache", } { req.Header.Set(k, v) } @@ -182,9 +164,6 @@ func (in *Instance) OpenChannelHeaders(req *http.Request, cookie string) *http.R "cookie": cookie, "origin": "https://discord.com", "referer": "https://discord.com/channels/@me", - "sec-ch-ua": `".Not/A)Brand";v="99", "Google Chrome";v="103", "Chromium";v="103"`, - "sec-ch-ua-mobile": "?0", - "sec-ch-ua-platform": `"Windows"`, "sec-fetch-dest": "empty", "sec-fetch-mode": "cors", "sec-fetch-site": "same-origin", @@ -193,8 +172,6 @@ func (in *Instance) OpenChannelHeaders(req *http.Request, cookie string) *http.R "x-debug-options": "bugReporterEnabled", "x-discord-locale": "en-US", "x-super-properties": in.XSuper, - "Pragma": "no-cache", - "Cache-Control": "no-cache", } { req.Header.Set(k, v) } @@ -228,9 +205,6 @@ func (in *Instance) SendMessageHeaders(req *http.Request, cookie, recipient stri "cookie": cookie, "origin": "https://discord.com", "referer": fmt.Sprintf("https://discord.com/channels/@me/%s", recipient), - "sec-ch-ua": `".Not/A)Brand";v="99", "Google Chrome";v="103", "Chromium";v="103"`, - "sec-ch-ua-mobile": "?0", - "sec-ch-ua-platform": `"Windows"`, "sec-fetch-dest": "empty", "sec-fetch-mode": "cors", "sec-fetch-site": "same-origin", @@ -239,8 +213,6 @@ func (in *Instance) SendMessageHeaders(req *http.Request, cookie, recipient stri "x-debug-options": "bugReporterEnabled", "x-discord-locale": "en-US", "x-super-properties": in.XSuper, - "Pragma": "no-cache", - "Cache-Control": "no-cache", } { req.Header.Set(k, v) } @@ -264,17 +236,13 @@ func (in *Instance) TypingHeaders(req *http.Request, cookie, snowflake string) * } } else { for k, v := range map[string]string{ - "accept": "*/*", - + "accept": "*/*", "accept-language": "en-US,en;q=0.9", "authorization": in.Token, "content-type": "application/json", "cookie": cookie, "origin": "https://discord.com", "referer": fmt.Sprintf("https://discord.com/channels/@me/%s", snowflake), - "sec-ch-ua": `".Not/A)Brand";v="99", "Google Chrome";v="103", "Chromium";v="103"`, - "sec-ch-ua-mobile": "?0", - "sec-ch-ua-platform": `"Windows"`, "sec-fetch-dest": "empty", "sec-fetch-mode": "cors", "sec-fetch-site": "same-origin", @@ -283,8 +251,6 @@ func (in *Instance) TypingHeaders(req *http.Request, cookie, snowflake string) * "x-debug-options": "bugReporterEnabled", "x-discord-locale": "en-US", "x-super-properties": in.XSuper, - "Pragma": "no-cache", - "Cache-Control": "no-cache", } { req.Header.Set(k, v) } @@ -317,9 +283,6 @@ func (in *Instance) AtMeHeaders(req *http.Request, cookie string) *http.Request "content-type": "application/json", "cookie": cookie, "origin": "https://discord.com", - "sec-ch-ua": `".Not/A)Brand";v="99", "Google Chrome";v="103", "Chromium";v="103"`, - "sec-ch-ua-mobile": "?0", - "sec-ch-ua-platform": `"Windows"`, "sec-fetch-dest": "empty", "sec-fetch-mode": "cors", "sec-fetch-site": "same-origin", @@ -328,8 +291,6 @@ func (in *Instance) AtMeHeaders(req *http.Request, cookie string) *http.Request "x-debug-options": "bugReporterEnabled", "x-discord-locale": "en-US", "x-super-properties": in.XSuper, - "Pragma": "no-cache", - "Cache-Control": "no-cache", } { req.Header.Set(k, v) } @@ -378,9 +339,6 @@ func (in *Instance) UserInfoHeaders(req *http.Request, cookie string) *http.Requ "content-type": "application/json", "cookie": cookie, "origin": "https://discord.com", - "sec-ch-ua": `".Not/A)Brand";v="99", "Google Chrome";v="103", "Chromium";v="103"`, - "sec-ch-ua-mobile": "?0", - "sec-ch-ua-platform": `"Windows"`, "sec-fetch-dest": "empty", "sec-fetch-mode": "cors", "sec-fetch-site": "same-origin", @@ -389,8 +347,6 @@ func (in *Instance) UserInfoHeaders(req *http.Request, cookie string) *http.Requ "x-debug-options": "bugReporterEnabled", "x-discord-locale": "en-US", "x-super-properties": in.XSuper, - "Pragma": "no-cache", - "Cache-Control": "no-cache", } { req.Header.Set(k, v) } diff --git a/instance/types.go b/instance/types.go index ec53691..6fa134a 100644 --- a/instance/types.go +++ b/instance/types.go @@ -285,3 +285,24 @@ type PresenceChange struct { Status string `json:"status"` Afk bool `json:"afk"` } + +type CfBm struct { + M string `json:"m"` + Results []string `json:"results"` + Timing int `json:"timing"` // Time taken + Fp struct { // Fingerprint + ID int `json:"id"` // ID + E struct { // Engine + R []int `json:"r"` // Screen Width, Screen Height (Total) + Ar []int `json:"ar"` // Available screen Width, Available screen Height + Pr float64 `json:"pr"` // Pixel ratio + Cd int `json:"cd"` // Color depth + Wb bool `json:"wb"` + Wp bool `json:"wp"` + Wn bool `json:"wn"` + Ch bool `json:"ch"` // Chrome browser + Ws bool `json:"ws"` + Wd bool `json:"wd"` + } `json:"e"` + } `json:"fp"` +} diff --git a/main.go b/main.go index 2364137..35579d8 100644 --- a/main.go +++ b/main.go @@ -17,7 +17,7 @@ import ( ) func main() { - version := "1.10.13" + version := "1.10.14" rand.Seed(time.Now().UTC().UnixNano()) color.Blue.Printf(logo + " v" + version + "\n") color.Green.Printf("Made by https://github.com/V4NSH4J\nStar repository on github for updates!\n")