diff --git a/main.go b/main.go index 784c0d8..1e165c1 100644 --- a/main.go +++ b/main.go @@ -34,7 +34,7 @@ import ( ) func main() { - version := "1.8.12" + version := "1.8.13" CaptchaServices = []string{"capmonster.cloud", "anti-captcha.com", "2captcha.com", "rucaptcha.com", "deathbycaptcha.com", "anycaptcha.com", "azcaptcha.com", "solvecaptcha.com"} rand.Seed(time.Now().UTC().UnixNano()) color.Blue(logo + " v" + version + "\n") @@ -297,7 +297,7 @@ func Options() { // Setting information to windows titlebar by github.com/foxzsz go func() { for { - cmd := exec.Command("cmd", "/C", "title", fmt.Sprintf(`DMDGO [%d sent, %v failed, %d locked, %d avg. dms, %d tokens left]`, len(session), len(failed), len(dead), len(session)/len(instances), len(instances)-len(dead))) + cmd := exec.Command("cmd", "/C", "title", fmt.Sprintf(`DMDGO [%d sent, %v failed, %d locked, %v avg. dms, %d tokens left]`, len(session), len(failed), len(dead), len(session)/len(instances), len(instances)-len(dead))) _ = cmd.Run() } }() diff --git a/utilities/captcha.go b/utilities/captcha.go index 0ffca2b..90ae484 100644 --- a/utilities/captcha.go +++ b/utilities/captcha.go @@ -1,6 +1,7 @@ package utilities import ( + "bytes" "encoding/json" "fmt" "io/ioutil" @@ -9,16 +10,12 @@ import ( "strconv" "strings" "time" - - "github.com/fatih/color" ) func (in *Instance) SolveCaptcha(sitekey string, cookie string, rqData string, rqToken string, url string) (string, error) { switch true { case Contains([]string{"capmonster.cloud", "anti-captcha.com", "anycaptcha.com"}, in.Config.CaptchaSettings.CaptchaAPI): - return in.SolveCaptchaCapmonster(sitekey, cookie, rqData, url) - case in.Config.CaptchaSettings.CaptchaAPI == "deathbycaptcha.com": - return in.SolveCaptchaDeathByCaptcha(sitekey, url) + return in.Capmonster(sitekey, url, rqData, cookie) case Contains([]string{"2captcha.com", "rucaptcha.com"}, in.Config.CaptchaSettings.CaptchaAPI): return in.twoCaptcha(sitekey, rqData, url) default: @@ -26,236 +23,9 @@ func (in *Instance) SolveCaptcha(sitekey string, cookie string, rqData string, r } } -// Function to use a captcha solving service and return a solved captcha key -func (in *Instance) SolveCaptchaCapmonster(sitekey string, cookies string, rqdata string, url string) (string, error) { - var jsonx Pload - if !in.Config.ProxySettings.ProxyForCaptcha || in.Config.CaptchaSettings.CaptchaAPI == "anycaptcha.com" { - jsonx = Pload{ - ClientKey: in.Config.CaptchaSettings.ClientKey, - Task: Task{ - Type: "HCaptchaTaskProxyless", - WebsiteURL: url, - WebsiteKey: sitekey, - UserAgent: UserAgent, - Cookies: cookies, - Data: rqdata, - Invisible: true, - }, - } - } else { - var address string - var port int - var username string - var password string - var err error - // Proxies with user-pass AUTH - if strings.Contains(in.Proxy, "@") { - proxyParts := strings.Split(in.Proxy, "@") - username, password, address = strings.Split(proxyParts[0], ":")[0], strings.Split(proxyParts[0], ":")[1], strings.Split(proxyParts[1], ":")[0] - port, err = strconv.Atoi(strings.Split(proxyParts[1], ":")[1]) - if err != nil { - return "", fmt.Errorf("could not parse proxy port %v", err) - } - } else { - // IP AUTH proxies - address = strings.Split(in.Proxy, ":")[0] - port, err = strconv.Atoi(strings.Split(in.Proxy, ":")[1]) - if err != nil { - return "", fmt.Errorf("could not parse proxy port %v", err) - } - } - jsonx = Pload{ - ClientKey: in.Config.CaptchaSettings.ClientKey, - Task: Task{ - Type: "HCaptchaTask", - WebsiteURL: url, - WebsiteKey: sitekey, - UserAgent: UserAgent, - ProxyType: in.Config.ProxySettings.ProxyProtocol, - ProxyAddress: address, - ProxyPort: port, - ProxyLogin: username, - ProxyPassword: password, - Cookies: cookies, - Data: rqdata, - Invisible: true, - }, - } - } - - bytes, err := json.Marshal(jsonx) - if err != nil { - return "", fmt.Errorf("error marshalling json [%v]", err) - - } - // Almost all solving services have similar API, so we can use the same function and replace the domain. - resp, err := http.Post("https://api."+in.Config.CaptchaSettings.CaptchaAPI+"/createTask", "application/json", strings.NewReader(string(bytes))) - if err != nil { - return "", fmt.Errorf("error creating the request for captcha [%v]", err) - } - defer resp.Body.Close() - // Get taskID from response body - body, err := ioutil.ReadAll(resp.Body) - if err != nil { - return "", fmt.Errorf("error reading the response body [%v]", err) - } - var response Resp - err = json.Unmarshal(body, &response) - if err != nil { - return "", fmt.Errorf("error unmarshalling the response body [%v]", err) - } - switch response.ErrorID { - case 0: - // Poling server for the solved captcha - jsonx = Pload{ - ClientKey: in.Config.CaptchaSettings.ClientKey, - TaskID: response.TaskID, - } - y, err := json.Marshal(jsonx) - if err != nil { - return "", fmt.Errorf("error marshalling json [%v]", err) - } - // Anti Captcha documentation prescribes to use a delay of 5 seconds before requesting the captcha and 3 seconds delays after that. - time.Sleep(5 * time.Second) - p := 0 - for { - if p > 100 { - // Max retries - break - } - resp, err := http.Post("https://api."+in.Config.CaptchaSettings.CaptchaAPI+"/getTaskResult", "application/json", strings.NewReader(string(y))) - if err != nil { - return "", fmt.Errorf("error creating the request for captcha [%v]", err) - } - defer resp.Body.Close() - body, err := ioutil.ReadAll(resp.Body) - if err != nil { - return "", fmt.Errorf("error reading the response body [%v]", err) - } - var response Resp - err = json.Unmarshal(body, &response) - if err != nil { - return "", fmt.Errorf("error unmarshalling the response body [%v]", err) - } - if response.Status == "ready" { - return response.Solution.Ans, nil - - } else if response.Status == "processing" { - p++ // Incrementing the counter - time.Sleep(3 * time.Second) - continue - } - if response.ErrorID != 0 { - return "", fmt.Errorf("ErrorID: %s, ErrorCode: %s, ErrorDescription: %s", response.ErrorID, response.ErrorCode, response.ErrorDesc) - } - - } - return "", fmt.Errorf("max captcha retries reached [%v]", err) - case 1: - return "", fmt.Errorf("No captcha API key or Incorrect Captcha API key (Can happen if you've specified a different service but using a different service's key)") - case 2: - color.Red("No Available Captcha Workers - Increase your Maximum Bid in your Captcha API settings. Also try reducing the number of threads. Sleeping 10 seconds") - time.Sleep(10 * time.Second) - return "", fmt.Errorf("no captcha workers were available, retrying") - case 3: - return "", fmt.Errorf("the size of the captcha you are uploading is less than 100 bytes.") - case 4: - return "", fmt.Errorf("the size of the captcha you are uploading is greater than 500,000 bytes.") - - case 10: - return "", fmt.Errorf("you have zero or negative captcha API balance") - case 11: - return "", fmt.Errorf("captcha was unsolvable.") - default: - return "", fmt.Errorf("unknown error [%v]", response.ErrorID) - } -} - -type Pload struct { - ClientKey string `json:"clientKey"` - Task Task `json:"task"` - ErrorID int `json:"ErrorId"` - TaskID int `json:"taskId"` -} - -type Task struct { - Type string `json:"type,omitempty"` - WebsiteURL string `json:"websiteURL,omitempty"` - WebsiteKey string `json:"websiteKey,omitempty"` - ProxyType string `json:"proxyType,omitempty"` - ProxyAddress string `json:"proxyAddress,omitempty"` - ProxyPort int `json:"proxyPort,omitempty"` - ProxyLogin string `json:"proxyLogin,omitempty"` - Data string `json:"data,omitempty"` - ProxyPassword string `json:"proxyPassword,omitempty"` - UserAgent string `json:"userAgent,omitempty"` - Cookies string `json:"cookies,omitempty` - Invisible bool `json:"isInvisible,omitempty` -} - -type Resp struct { - TaskID int `json:"taskID"` - ErrorID int `json:"ErrorId"` - Status string `json:"status"` - Solution Sol `json:"solution"` - ErrorCode string `json:"errorCode"` - ErrorDesc string `json:"errorDescription"` -} - -type Sol struct { - Ans string `json:"gRecaptchaResponse"` -} - -// Incomplete -func (in *Instance) SolveCaptchaDeathByCaptcha(sitekey, url string) (string, error) { - // Authentication can be a user:pass combination or with a 2fa key. - var username string - var password string - var authtoken string - var proxy string - var proxytype string - - if strings.Contains(in.Config.CaptchaSettings.ClientKey, ":") { - credentials := strings.Split(in.Config.CaptchaSettings.ClientKey, ":") - username, password = credentials[0], credentials[1] - } else { - authtoken = in.Config.CaptchaSettings.ClientKey - } - captchaPostEndpoint := "http://api.dbcapi.me/api/captcha" - - fmt.Println(authtoken) - payload := fmt.Sprintf( - `{ - "username": "%s", - "password": "%s", - "type": 7, - "token_params": { - "proxy": "%s", - "proxytype": "%s", - "pageurl": "%s", - "sitekey": "%s" - } - }`, username, password, proxy, proxytype, url, sitekey) - fmt.Println(payload) - req, err := http.NewRequest(http.MethodPost, captchaPostEndpoint, strings.NewReader(payload)) - if err != nil { - return "", fmt.Errorf("error creating request [%v]", err) - } - resp, err := http.DefaultClient.Do(req) - if err != nil { - return "", fmt.Errorf("error sending request [%v]", err) - } - defer resp.Body.Close() - body, err := ioutil.ReadAll(resp.Body) - if err != nil { - return "", fmt.Errorf("error reading response [%v]", err) - } - fmt.Println(string(body)) - fmt.Println(resp.StatusCode) - - return "", nil - -} +/* + 2Captcha/RuCaptcha +*/ type twoCaptchaSubmitResponse struct { Status int `json:"status"` @@ -370,3 +140,148 @@ func (in *Instance) twoCaptcha(sitekey, rqdata, site string) (string, error) { } return solvedKey, nil } + +/* + Capmonster +*/ + +type CapmonsterPayload struct { + ClientKey string `json:"clientKey,omitempty"` + Task Task `json:"task,omitempty"` + TaskId int `json:"taskId,omitempty"` +} + +type Task struct { + CaptchaType string `json:"type,omitempty"` + WebsiteURL string `json:"websiteURL,omitempty"` + WebsiteKey string `json:"websiteKey,omitempty"` + IsInvisible bool `json:"isInvisible,omitempty"` + Data string `json:"data,omitempty"` + ProxyType string `json:"proxyType,omitempty"` + ProxyAddress string `json:"proxyAddress,omitempty"` + ProxyPort int `json:"proxyPort,omitempty"` + ProxyLogin string `json:"proxyLogin,omitempty"` + ProxyPassword string `json:"proxyPassword,omitempty"` + UserAgent string `json:"userAgent,omitempty"` + Cookies string `json:"cookies,omitempty"` +} + +type CapmonsterSubmitResponse struct { + ErrorID int `json:"errorId,omitempty"` + TaskID int `json:"taskId,omitempty"` +} + +type CapmonsterOutResponse struct { + ErrorID int `json:"errorId,omitempty"` + ErrorCode string `json:"errorCode,omitempty"` + Status string `json:"status,omitempty"` + Solution Solution `json:"solution"` +} + +type Solution struct { + CaptchaResponse string `json:"gRecaptchaResponse,omitempty"` +} + +func (in *Instance) Capmonster(sitekey, website, rqdata, cookies string) (string, error) { + var solvedKey string + inEndpoint, outEndpoint := fmt.Sprintf("https://api.%s/createTask", in.Config.CaptchaSettings.CaptchaAPI), fmt.Sprintf("https://api.%s/getTaskResult", in.Config.CaptchaSettings.CaptchaAPI) + var submitCaptcha CapmonsterPayload + if in.Config.CaptchaSettings.ClientKey == "" { + return solvedKey, fmt.Errorf("no client key provided in config") + } else { + submitCaptcha.ClientKey = in.Config.CaptchaSettings.ClientKey + } + if in.Config.ProxySettings.ProxyForCaptcha && in.Proxy != "" { + submitCaptcha.Task.CaptchaType = "HCaptchaTask" + proxyURL, err := url.Parse(in.Proxy) + if err != nil { + return solvedKey, fmt.Errorf("error while parsing proxy url %v", err) + } + submitCaptcha.Task.ProxyType = in.Config.ProxySettings.ProxyProtocol + submitCaptcha.Task.ProxyAddress = proxyURL.Hostname() + submitCaptcha.Task.ProxyPort, err = strconv.Atoi(proxyURL.Port()) + if err != nil { + return solvedKey, fmt.Errorf("error while parsing proxy port %v", err) + } + submitCaptcha.Task.ProxyLogin = proxyURL.User.Username() + pwd, setPwd := proxyURL.User.Password() + if setPwd { + submitCaptcha.Task.ProxyPassword = pwd + } + } else { + submitCaptcha.Task.CaptchaType = "HCaptchaTaskProxyless" + } + submitCaptcha.Task.WebsiteURL, submitCaptcha.Task.WebsiteKey, submitCaptcha.Task.Data, submitCaptcha.Task.Cookies, submitCaptcha.Task.IsInvisible, submitCaptcha.Task.UserAgent = website, sitekey, rqdata, cookies, true, UserAgent + payload, err := json.Marshal(submitCaptcha) + if err != nil { + return solvedKey, fmt.Errorf("error while marshalling payload %v", err) + } + req, err := http.NewRequest(http.MethodPost, inEndpoint, strings.NewReader(string(payload))) + if err != nil { + return solvedKey, fmt.Errorf("error creating request [%v]", err) + } + req.Header.Set("Content-Type", "application/json") + resp, err := http.DefaultClient.Do(req) + if err != nil { + return solvedKey, fmt.Errorf("error sending request [%v]", err) + } + defer resp.Body.Close() + body, err := ioutil.ReadAll(resp.Body) + if err != nil { + return solvedKey, fmt.Errorf("error reading response [%v]", err) + } + var inResponse CapmonsterSubmitResponse + err = json.Unmarshal(body, &inResponse) + if err != nil { + return solvedKey, fmt.Errorf("error unmarshalling response [%v]", err) + } + if inResponse.ErrorID != 0 { + return solvedKey, fmt.Errorf("error %v %v", inResponse.ErrorID, string(body)) + } + var retrieveCaptcha CapmonsterPayload + retrieveCaptcha.ClientKey = in.Config.CaptchaSettings.ClientKey + retrieveCaptcha.TaskId = inResponse.TaskID + payload, err = json.Marshal(retrieveCaptcha) + if err != nil { + return solvedKey, fmt.Errorf("error while marshalling payload %v", err) + } + req, err = http.NewRequest(http.MethodPost, outEndpoint, bytes.NewBuffer(payload)) + if err != nil { + return solvedKey, fmt.Errorf("error creating request [%v]", err) + } + req.Header.Set("Content-Type", "application/json") + t := time.Now() + for i := 0; i < 120; i++ { + if time.Since(t).Seconds() >= float64(in.Config.CaptchaSettings.Timeout) { + return solvedKey, fmt.Errorf("timedout - increase timeout in config to wait longer") + } + resp, err = http.DefaultClient.Do(req) + if err != nil { + return solvedKey, fmt.Errorf("error sending request [%v]", err) + } + defer resp.Body.Close() + body, err = ioutil.ReadAll(resp.Body) + if err != nil { + return solvedKey, fmt.Errorf("error reading response [%v]", err) + } + var outResponse CapmonsterOutResponse + err = json.Unmarshal(body, &outResponse) + if err != nil { + return solvedKey, fmt.Errorf("error unmarshalling response [%v]", err) + } + if outResponse.ErrorID != 0 { + return solvedKey, fmt.Errorf("error %v %v", outResponse.ErrorID, string(body)) + } + if outResponse.Status == "ready" { + solvedKey = outResponse.Solution.CaptchaResponse + break + } else if outResponse.Status == "processing" { + time.Sleep(5 * time.Second) + continue + } else { + return solvedKey, fmt.Errorf("error invalid status %v %v", outResponse.ErrorID, string(body)) + } + + } + return solvedKey, nil +} diff --git a/utilities/direct_messages.go b/utilities/direct_messages.go index c6222d1..6465117 100644 --- a/utilities/direct_messages.go +++ b/utilities/direct_messages.go @@ -13,6 +13,8 @@ import ( "io/ioutil" "math" + //"regexp" + // "io/ioutil" "math/rand" "net/http" @@ -54,7 +56,6 @@ func (in *Instance) GetCookieString() (string, error) { for _, cookie := range resp.Cookies() { cookies += fmt.Sprintf(`%s=%s; `, cookie.Name, cookie.Value) } - cookies += "locale=en-US" // CfRay := resp.Header.Get("cf-ray") // if strings.Contains(CfRay, "-BOM") { // CfRay = strings.ReplaceAll(CfRay, "-BOM", "") @@ -75,21 +76,20 @@ func (in *Instance) GetCookieString() (string, error) { // if err != nil { // return cookies + "locale:en-US", nil // } - // fmt.Println(finalCookies) + // finalCookies += "; locale:en-US" // return finalCookies, nil // } - + cookies += "locale:en-US" 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) - res := RandomResult() payload := fmt.Sprintf( ` { "m":"%s", - "results":["%s","%s"], + "results":["859fe3e432b90450c6ddf8fae54c9a58","460d5f1e93f296a48e3f6745675f27e2"], "timing":%v, "fp": { @@ -107,7 +107,7 @@ func (in *Instance) GetCfBm(m, r, cookies string) (string, error) { } } } - `, m, res[0], res[1], 60+rand.Intn(60), + `, m, 60+rand.Intn(60), ) req, err := http.NewRequest("POST", site, strings.NewReader(payload)) if err != nil { @@ -127,7 +127,6 @@ func (in *Instance) GetCfBm(m, r, cookies string) (string, error) { if len(resp.Cookies()) == 0 { return cookies, nil } - cookies = cookies + "; " for _, cookie := range resp.Cookies() { cookies = cookies + cookie.Name + "=" + cookie.Value } @@ -250,7 +249,6 @@ func (in *Instance) SendMessage(channelSnowflake string, memberid string) (http. } url := "https://discord.com/api/v9/channels/" + channelSnowflake + "/messages" - req, err := http.NewRequest("POST", url, strings.NewReader(string(body))) if err != nil { @@ -260,15 +258,15 @@ func (in *Instance) SendMessage(channelSnowflake string, memberid string) (http. if err != nil { return http.Response{}, fmt.Errorf("error while getting cookie %v", err) } - + dur := typingSpeed(x, in.Config.SuspicionAvoidance.TypingVariation, in.Config.SuspicionAvoidance.TypingSpeed, in.Config.SuspicionAvoidance.TypingBase) if dur != 0 { - iterations := int((int64(dur)/int64(time.Second*10))) + 1 + iterations := int((int64(dur) / int64(time.Second*10))) + 1 for i := 0; i < iterations; i++ { if err := in.typing(channelSnowflake, cookie); err != nil { - continue + continue } - s := time.Second * 10 + s := time.Second * 10 if i == iterations-1 { s = dur % time.Second * 10 } @@ -587,4 +585,4 @@ func typingSpeed(msg string, TypingVariation, TypingSpeed, TypingBase int) time. d += rand.Intn(TypingVariation) } return time.Duration(d) * time.Millisecond -} \ No newline at end of file +} diff --git a/utilities/headers.go b/utilities/headers.go index 0c8d26a..f21ab15 100644 --- a/utilities/headers.go +++ b/utilities/headers.go @@ -5,9 +5,9 @@ import ( "net/http" ) -const UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:98.0) Gecko/20100101 Firefox/98.0" +const UserAgent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) discord/0.0.61 Chrome/91.0.4472.164 Electron/13.6.6 Safari/537.36" const XTrack = "eyJvcyI6IldpbmRvd3MiLCJicm93c2VyIjoiRmlyZWZveCIsImRldmljZSI6IiIsInN5c3RlbV9sb2NhbGUiOiJlbi1VUyIsImJyb3dzZXJfdXNlcl9hZ2VudCI6Ik1vemlsbGEvNS4wIChXaW5kb3dzIE5UIDEwLjA7IFdpbjY0OyB4NjQ7IHJ2Ojk3LjApIEdlY2tvLzIwMTAwMTAxIEZpcmVmb3gvOTcuMCIsImJyb3dzZXJfdmVyc2lvbiI6Ijk3LjAiLCJvc192ZXJzaW9uIjoiMTAiLCJyZWZlcnJlciI6IiIsInJlZmVycmluZ19kb21haW4iOiIiLCJyZWZlcnJlcl9jdXJyZW50IjoiIiwicmVmZXJyaW5nX2RvbWFpbl9jdXJyZW50IjoiIiwicmVsZWFzZV9jaGFubmVsIjoic3RhYmxlIiwiY2xpZW50X2J1aWxkX251bWJlciI6OTk5OSwiY2xpZW50X2V2ZW50X3NvdXJjZSI6bnVsbH0=" -const XSuper = "eyJvcyI6IldpbmRvd3MiLCJicm93c2VyIjoiRmlyZWZveCIsImRldmljZSI6IiIsInN5c3RlbV9sb2NhbGUiOiJlbi1VUyIsImJyb3dzZXJfdXNlcl9hZ2VudCI6Ik1vemlsbGEvNS4wIChXaW5kb3dzIE5UIDEwLjA7IFdpbjY0OyB4NjQ7IHJ2Ojk4LjApIEdlY2tvLzIwMTAwMTAxIEZpcmVmb3gvOTguMCIsImJyb3dzZXJfdmVyc2lvbiI6Ijk4LjAiLCJvc192ZXJzaW9uIjoiMTAiLCJyZWZlcnJlciI6IiIsInJlZmVycmluZ19kb21haW4iOiIiLCJyZWZlcnJlcl9jdXJyZW50IjoiIiwicmVmZXJyaW5nX2RvbWFpbl9jdXJyZW50IjoiIiwicmVsZWFzZV9jaGFubmVsIjoic3RhYmxlIiwiY2xpZW50X2J1aWxkX251bWJlciI6MTIxNzE5LCJjbGllbnRfZXZlbnRfc291cmNlIjpudWxsfQ==" +const XSuper = "eyJvcyI6Ik1hYyBPUyBYIiwiYnJvd3NlciI6IkRpc2NvcmQgQ2xpZW50IiwicmVsZWFzZV9jaGFubmVsIjoicHRiIiwiY2xpZW50X3ZlcnNpb24iOiIwLjAuNjEiLCJvc192ZXJzaW9uIjoiMjEuMy4wIiwib3NfYXJjaCI6ImFybTY0Iiwic3lzdGVtX2xvY2FsZSI6ImVuLVVTIiwiY2xpZW50X2J1aWxkX251bWJlciI6MTIzODMzLCJjbGllbnRfZXZlbnRfc291cmNlIjpudWxsfQ==" func (in *Instance) cookieHeaders(req *http.Request) *http.Request { for k, v := range map[string]string{