Skip to content

Commit

Permalink
Add LoginFailNotify
Browse files Browse the repository at this point in the history
Tidy Code
  • Loading branch information
patyhank committed Mar 18, 2023
1 parent 7bb3dbf commit 4bffa20
Show file tree
Hide file tree
Showing 7 changed files with 261 additions and 33 deletions.
16 changes: 13 additions & 3 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,29 @@ jobs:
env:
GOOS: windows
GOARCH: amd64
run: go build -o auth-server.exe .
run: go build -o auth-server.exe . && go build -o ./LoginNotify/LoginNotify.exe ./LoginNotify
- name: Build Linux
env:
GOOS: linux
GOARCH: amd64
run: go build -o auth-server .
run: go build -o auth-server . && go build -o ./LoginNotify/LoginNotify ./LoginNotify
- name: Upload a Windows Build Artifact
uses: actions/[email protected]
with:
name: linux-build
name: linux-build.zip
path: auth-server
- name: Upload a Windows Build Artifact
uses: actions/[email protected]
with:
name: linux-build-notify.zip
path: LoginNotify/LoginNotify
- name: Upload a Linux Build Artifact
uses: actions/[email protected]
with:
name: windows-build
path: auth-server.exe
- name: Upload a Windows Build Artifact
uses: actions/[email protected]
with:
name: windows-build
path: LoginNotify/LoginNotify.exe
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
accounts.txt
accounts.txt
.exe
4 changes: 2 additions & 2 deletions GMMAuth/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"errors"
"fmt"
"github.com/dlclark/regexp2"
"io/ioutil"
"io"
"net/http"
"net/url"
"os"
Expand Down Expand Up @@ -98,7 +98,7 @@ func AuthMSLogin(cid, username, password string) (string, error) {
cookies = append(cookies, strings.SplitN(s, ";", 2)[0])
}
cookieStr := strings.Join(cookies, "; ")
body, _ := ioutil.ReadAll(result.Body)
body, _ := io.ReadAll(result.Body)
mppft := ppft.FindStringSubmatch(string(body))
mUrlPost, err := urlPost.FindStringMatch(string(body))
if mppft == nil || err != nil || mUrlPost == nil {
Expand Down
126 changes: 126 additions & 0 deletions LoginNotify/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
package main

import (
"fmt"
"github.com/dlclark/regexp2"
"github.com/pion/mdns"
"github.com/zserge/lorca"
"golang.org/x/net/ipv4"
"io"
"log"
"net"
"net/http"
"net/url"
"regexp"
"strings"
"sync"
)

var emailMap = sync.Map{}

func main() {
addr, err := net.ResolveUDPAddr("udp", mdns.DefaultAddress)
if err != nil {
panic(err)
}

l, err := net.ListenUDP("udp4", addr)
if err != nil {
panic(err)
}

_, err = mdns.Server(ipv4.NewPacketConn(l), &mdns.Config{
LocalNames: []string{"auth-server.local"},
})
if err != nil {
panic(err)
}
http.HandleFunc("/failedLogin", failedLogin)
log.Fatal(http.ListenAndServe(":37585", nil))
}

func failedLogin(w http.ResponseWriter, r *http.Request) {
message, _ := io.ReadAll(r.Body)
sp := strings.SplitN(string(message), "|", 2)
if len(sp) != 2 {
w.WriteHeader(200)
return
}
if _, ok := emailMap.Load(sp[0]); ok {
return
}
emailMap.Store(sp[0], 0)
go func() {
client := http.DefaultClient
ppft := regexp.MustCompile("sFTTag:[ ]?'.*value=\"(.*)\"/>'")
urlPost := regexp2.MustCompile("urlPost:[ ]?'(.+?(?='))", 0)
loginEndpoint := fmt.Sprintf("https://login.live.com/oauth20_authorize.srf?redirect_uri=https://login.live.com/oauth20_desktop.srf&scope=service::user.auth.xboxlive.com::MBI_SSL&display=touch&response_type=code&locale=en&client_id=%v", "000000004C12AE6F")

req, _ := http.NewRequest("GET", loginEndpoint, nil)
result, err := client.Do(req)
if err != nil {
fmt.Println(err)
return
}
if result.StatusCode != 200 {
fmt.Println(err)
return
}
cookie := result.Header.Values("set-cookie")
var cookies []string
for _, s := range cookie {
cookies = append(cookies, strings.SplitN(s, ";", 2)[0])
}
cookieStr := strings.Join(cookies, "; ")
body, _ := io.ReadAll(result.Body)
mppft := ppft.FindStringSubmatch(string(body))
mUrlPost, err := urlPost.FindStringMatch(string(body))
if mppft == nil || err != nil || mUrlPost == nil {
return
}
mapp := map[string]string{
"login": sp[0],
"loginfmt": sp[1],
"passwd": sp[1],
"PPFT": mppft[1],
"PPSX": "PassportR",
"type": "11",
"NewUser": "1",
"LoginOptions": "1",
"i13": "1",
"CookieDisclosure": "0",
"ps": "2",
"ctx": "2",
"i19": "25774",
}
values := url.Values{}

for s, s2 := range mapp {
values.Add(s, s2)
}
req, _ = http.NewRequest("POST", mUrlPost.GroupByNumber(1).String(), strings.NewReader(values.Encode()))

req.Header.Add("Cookie", cookieStr)
req.Header.Add("Pragma", "no-cache")
//req.Header.Add("Accept-Encoding", "gzip, deflate, compress")
req.Header.Add("Accept-Language", "zh-TW, zh;q=0.9")
req.Header.Add("User-Agent", "XboxReplay; XboxLiveAuth/4.0")
req.Header.Add("Accept", "*/*")
req.Header.Add("Content-Type", "application/x-www-form-urlencoded")

res, err := client.Do(req)
resBody, err := io.ReadAll(res.Body)
if len(resBody) == 0 {
return
}

ui, err := lorca.New("", "", 640, 320, "--window-position=0,0")
if err != nil {
return
}
ui.Load("data:text/html," + url.PathEscape(string(resBody)))
defer ui.Close()
<-ui.Done()
emailMap.Delete(sp[0])
}()
}
12 changes: 10 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@ module auth-server
go 1.18

require (
github.com/dlclark/regexp2 v1.4.0 // indirect
github.com/gorilla/mux v1.8.0 // indirect
github.com/dlclark/regexp2 v1.4.0
github.com/gorilla/mux v1.8.0
github.com/pion/mdns v0.0.7
github.com/zserge/lorca v0.1.10
golang.org/x/net v0.5.0
)

require (
github.com/pion/logging v0.2.2 // indirect
golang.org/x/sys v0.6.0 // indirect
)
56 changes: 56 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,4 +1,60 @@
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dlclark/regexp2 v1.4.0 h1:F1rxgk7p4uKjwIQxBs9oAXe5CqrXlCduYEJvrF4u93E=
github.com/dlclark/regexp2 v1.4.0/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55kozfMjCc=
github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI=
github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So=
github.com/pion/logging v0.2.2 h1:M9+AIj/+pxNsDfAT64+MAVgJO0rsyLnoJKCqf//DoeY=
github.com/pion/logging v0.2.2/go.mod h1:k0/tDVsRCX2Mb2ZEmTqNa7CWsQPc+YYCB7Q+5pahoms=
github.com/pion/mdns v0.0.7 h1:P0UB4Sr6xDWEox0kTVxF0LmQihtCbSAdW0H2nEgkA3U=
github.com/pion/mdns v0.0.7/go.mod h1:4iP2UbeFhLI/vWju/bw6ZfwjJzk0z8DNValjGxR/dD8=
github.com/pion/transport/v2 v2.0.0 h1:bsMYyqHCbkvHwj+eNCFBuxtlKndKfyGI2vaQmM3fIE4=
github.com/pion/transport/v2 v2.0.0/go.mod h1:HS2MEBJTwD+1ZI2eSXSvHJx/HnzQqRy2/LXxt6eVMHc=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
github.com/zserge/lorca v0.1.10 h1:f/xBJ3D3ipcVRCcvN8XqZnpoKcOXV8I4vwqlFyw7ruc=
github.com/zserge/lorca v0.1.10/go.mod h1:bVmnIbIRlOcoV285KIRSe4bUABKi7R7384Ycuum6e4A=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200222125558-5a598a2470a0/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco=
golang.org/x/net v0.5.0 h1:GyT4nK/YDHSqa1c4753ouYCDajOYKTja9Xb/OHtgvSw=
golang.org/x/net v0.5.0/go.mod h1:DivGGAXEgPSlEBzxGzZI+ZLohi+xUj054jfeKui00ws=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.4.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.4.0/go.mod h1:9P2UbLfCdcvo3p/nzKvsmas4TnlujnuoV9hGgYzW1lQ=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/text v0.6.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
Loading

0 comments on commit 4bffa20

Please sign in to comment.