Skip to content

Commit

Permalink
fix not-sniping issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Kqzz committed Sep 19, 2023
1 parent 7a660f6 commit 53648b6
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 58 deletions.
2 changes: 1 addition & 1 deletion claimer/claimer.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ func (s *Claim) runClaim() {
s.Proxies = []string{""}
}

time.Sleep(time.Until(s.DropRange.End))
time.Sleep(time.Until(s.DropRange.Start))

go requestGenerator(workChan, killChan, gcs, s.Username, mc.MsPr, s.DropRange.End, s.Proxies, -1)
go requestGenerator(workChan, killChan, mss, s.Username, mc.Ms, s.DropRange.End, s.Proxies, -1)
Expand Down
25 changes: 15 additions & 10 deletions cmd/cli/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ func isFlagPassed(names ...string) bool {
func main() {

var startUsername string
flag.StringVar(&startUsername, "username", "", "username(s) to snipe")
flag.StringVar(&startUsername, "u", "", "username(s) to snipe")
flag.StringVar(&startUsername, "username", "", "username to snipe")
flag.StringVar(&startUsername, "u", "", "username to snipe")

flag.Parse()

Expand All @@ -58,16 +58,13 @@ func main() {

log.Log("", log.GetHeader())

var username string
accounts, err := getAccounts("gc.txt", "gp.txt", "ms.txt")

if !isFlagPassed("u", "username") {
username = log.Input("target username(s)")
} else {
username = startUsername
if err != nil {
log.Log("err", "fatal: %v", err)
continue
}

dropRange := log.GetDropRange()

proxies, err := parser.ReadLines("proxies.txt")

if err != nil {
Expand All @@ -76,7 +73,15 @@ func main() {

err = nil

accounts, err := getAccounts("gc.txt", "gp.txt", "ms.txt")
var username string

if !isFlagPassed("u", "username") {
username = log.Input("target username")
} else {
username = startUsername
}

dropRange := log.GetDropRange()

err = claimer.ClaimWithinRange(username, dropRange, accounts, proxies)

Expand Down
96 changes: 49 additions & 47 deletions mc/msa_ouath_device_flow.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import (
)

/*
Credit to emma (implied. on discord) for the entire oauth flow!
Client ID is 648b1790-3c45-4745-bd7b-d9e828433655, applet name is mc Library Authentication
Flow is as follows:
Expand Down Expand Up @@ -63,6 +65,53 @@ const client_id = "648b1790-3c45-4745-bd7b-d9e828433655"

// types in msa.go are used here as well.

func (account *MCaccount) OauthFlow() error {
jar, err := cookiejar.New(nil)
if err != nil {
return err
}

tr := &http.Transport{
TLSClientConfig: &tls.Config{
Renegotiation: tls.RenegotiateOnceAsClient,
InsecureSkipVerify: true},
}

client := &http.Client{
Jar: jar,
Transport: tr,
}

reqParams := fmt.Sprintf("client_id=%s&scope=XboxLive.signin", client_id)

req, _ := http.NewRequest("POST", "https://login.microsoftonline.com/consumers/oauth2/v2.0/devicecode", bytes.NewBuffer([]byte(reqParams)))

req.Header.Set("Content-Type", "application/x-www-form-urlencoded")

resp, err := client.Do(req)
if err != nil {
return err
}
defer resp.Body.Close()
respbytes, err := io.ReadAll(resp.Body)
if resp.StatusCode != 200 {
return errors.New("non-200 status on devicecode post")
}

if err != nil {
return err
}

var respObj msDeviceInitResponse
err = json.Unmarshal(respbytes, &respObj)
if err != nil {
return err
}
fmt.Printf("[*] %v", respObj.Message)

return pollEndpoint(account, respObj.DeviceCode, respObj.Interval)
}

func authWithToken(account *MCaccount, access_token_from_ms string) error {
jar, err := cookiejar.New(nil)
if err != nil {
Expand Down Expand Up @@ -228,53 +277,6 @@ func authWithToken(account *MCaccount, access_token_from_ms string) error {
return nil
}

func (account *MCaccount) InitAuthFlow() error {
jar, err := cookiejar.New(nil)
if err != nil {
return err
}

tr := &http.Transport{
TLSClientConfig: &tls.Config{
Renegotiation: tls.RenegotiateOnceAsClient,
InsecureSkipVerify: true},
}

client := &http.Client{
Jar: jar,
Transport: tr,
}

reqParams := fmt.Sprintf("client_id=%s&scope=XboxLive.signin", client_id)

req, _ := http.NewRequest("POST", "https://login.microsoftonline.com/consumers/oauth2/v2.0/devicecode", bytes.NewBuffer([]byte(reqParams)))

req.Header.Set("Content-Type", "application/x-www-form-urlencoded")

resp, err := client.Do(req)
if err != nil {
return err
}
defer resp.Body.Close()
respbytes, err := io.ReadAll(resp.Body)
if resp.StatusCode != 200 {
return errors.New("non-200 status on devicecode post")
}

if err != nil {
return err
}

var respObj msDeviceInitResponse
err = json.Unmarshal(respbytes, &respObj)
if err != nil {
return err
}
fmt.Printf("auth for mc account: %s\n", respObj.Message)

return pollEndpoint(account, respObj.DeviceCode, respObj.Interval)
}

func pollEndpoint(account *MCaccount, device_code string, interval int) error {

sleepDuration := time.Second * time.Duration(interval)
Expand Down

0 comments on commit 53648b6

Please sign in to comment.