Skip to content

Commit

Permalink
Add fixes for changes to the captcha process
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronthebaron committed Jun 7, 2024
1 parent a157c1e commit 6c82206
Show file tree
Hide file tree
Showing 2 changed files with 107 additions and 0 deletions.
102 changes: 102 additions & 0 deletions pkg/provider/googleapps/example/captcha.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
<!doctype html>
<html lang="en" dir="ltr">
<head>
<title>Sign in - Google Accounts</title>
</head>
<body>
<div class="BDEI9 LZgQXe">
<div class="Ha17qf" data-auto-init="Card">
<div class="Or16q">
<div data-view-id="hm18Ec" data-locale="en" data-allow-sign-up-types="true"><c-wiz jsrenderer="OTcFib" jsshadow jsdata="deferred-i2" data-p="%.@.]" data-node-index="2;0" jsmodel="hc6Ubd" c-wiz>
<div class="gEc4r"><img src="//ssl.gstatic.com/images/branding/googlelogo/2x/googlelogo_color_74x24dp.png" class="TrZEUc" alt="Google" width="74" height="24"></div>
<div class="EQIoSc" jsname="bN97Pc">
<div jsname="paFcre">
<div class="aMfydd" jsname="tJHJj">
<h1 class="Tn0LBd" jsname="r4nke">Sign in</h1>
<p class="a2CQh" jsname="VdSJob">Use your Google Account</p>
</div>
</div>
<form action="/v3/signin/identifier?continue=https://accounts.google.com/o/saml2/initsso?idpid%3DXXXXXX%26spid%3DYYYYYY%26forceauthn%3Dfalse%26hl%3Den%26loc%3DUS&amp;dsh=XXXXXXXXX:YYYYYYYYY&amp;faa=1&amp;flowEntry=ServiceLogin&amp;flowName=WebLiteSignIn&amp;followup=https://accounts.google.com/o/saml2/initsso?idpid%3DXXXXXX%26spid%3DYYYYYY%26forceauthn%3Dfalse%26hl%3Den%26loc%3DUS&amp;hl=en&amp;ifkv=ABCDEFGHIJKLMNOPQRSTUVWXYZ?hl%3Den?hl%3Den" method="POST" novalidate>
<div class="iEhbme" jsname="rEuO1b">
<section class="aN1Vld ">
<div class="yOnVIb" jsname="MZArnb">
<div class="Fu5aXd" jsname="dWPKW">
<div class="Flfooc">
<div class="TRuRhd YKooDc">
<div class="fjpXlc">
<label class="dXXNOd">
<input class="xyezD" jsname="Ufn6O" type="email" name="identifier" id="identifierId" value="test-id1@example.com" autofocus autocapitalize="none" autocomplete="username" dir="ltr"/>
<div class="nWPx2e">
<div class="YhhY8"></div>
<div class="CCQ94b">Email or phone</div>
<div class="tNASEf"></div>
</div>
</label>
</div>
</div>
</div>
<div class="F3wxlc" jsname="h9d3hd"></div>
<div class="NHVGlc" jsname="JIbuQc"></div>
</div>
<p class="vOZun" jsname="OZNMeb" aria-live="assertive"></p>
<p class="vOZun"><a href="/signin/usernamerecovery?continue=https://accounts.google.com/o/saml2/initsso?idpid%3DXXXXXX%26spid%3DYYYYYY%26forceauthn%3Dfalse%26hl%3Den%26loc%3DUS&amp;dsh=XXXXXXXXX:YYYYYYYYY&amp;faa=1&amp;flowEntry=ServiceLogin&amp;flowName=WebLiteSignIn&amp;followup=https://accounts.google.com/o/saml2/initsso?idpid%3DXXXXXX%26spid%3DYYYYYY%26forceauthn%3Dfalse%26hl%3Den%26loc%3DUS&amp;hl=en&amp;ifkv=ABCDEFGHIJKLMNOPQRSTUVWXYZ?hl%3Den?hl%3Den" jsname="Cuz2Ue">Forgot email?</a></p>
<input type="password" name="hiddenPassword" class="hJIRO" tabindex="-1" aria-hidden="true" spellcheck="false" jsname="RHeR4d">
<div class="ZWssT" data-auto-init="CaptchaInput" jsname="Si5T8b">
<img jsname="O9Milc" alt="CAPTCHA image of text used to distinguish humans from robots" src="/Captcha?v=2&ctoken=super_long_captcha_string" id="captchaimg" class="TrZEUc">
<button class="vopC4e TrZEUc" jsname="A1U4Sb" id="playCaptchaButton" tabindex="0" type="button" aria-label="Listen and type the numbers you hear"><svg aria-hidden="true" class="hZUije JVMrYb" fill="currentColor" focusable="false" width="18px" height="18px" viewBox="0 0 24 24" xmlns="https://www.w3.org/2000/svg"><path d="M3 9v6h4l5 5V4L7 9H3zm13.5 3c0-1.8-1-3.3-2.5-4v8c1.5-.7 2.5-2.2 2.5-4zM14 3.2v2.1c2.9.9 5 3.5 5 6.7s-2.1 5.9-5 6.7v2.1c4-.9 7-4.5 7-8.8s-3-7.9-7-8.8z"></path></svg></button>
<audio jsname="CakGX" src="/Captcha?v=2&ctoken=super_long_captcha_string&kind=audio" type="audio/wav" id="captchaAudio"></audio>
<div class="Fu5aXd Jj6Lae" jsname="jKg4ed">
<div class="Flfooc">
<div class="TRuRhd YKooDc">
<div class="fjpXlc">
<label class="dXXNOd">
<input class="xyezD" jsname="Ufn6O" type="text" name="ca" dir="ltr" aria-invalid="true"/>
<div class="nWPx2e">
<div class="YhhY8"></div>
<div class="CCQ94b">Type the text you hear or see</div>
<div class="tNASEf"></div>
</div>
</label>
</div>
</div>
</div>
<div class="F3wxlc" jsname="h9d3hd">
<div class="EllNBf" aria-hidden="true"><svg aria-hidden="true" class="hZUije SnjiRb" fill="currentColor" focusable="false" width="16px" height="16px" viewBox="0 0 24 24" xmlns="https://www.w3.org/2000/svg"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 15h-2v-2h2v2zm0-4h-2V7h2v6z"></path></svg></div>
<div jsname="B34EJ">
<span jsslot>Please enter the characters you see in the image above</span>
</div>
</div>
<div class="NHVGlc" jsname="JIbuQc"></div>
</div>
<input jsname="SBlSod" type="hidden" name="ct" value="super_long_captcha_string" id="ct">
</div>
<input type="hidden" name="usi" value="XXXXXXXXX:YYYYYYYYY">
<input type="hidden" name="domain" value="">
<input type="hidden" name="region" value="US">
<span jsname="xdJtEf">
<input type="hidden" name="bgresponse" value="js_disabled" id="bgresponse" style="display:none">
</span>
<span jsname="ZVfTqd"></span>
</div>
</section>
</div>
<span jsslot>
<div class="D4rY0b">
<p class="vOZun">Not your computer? Use a private browsing window to sign in. <a href="https://support.google.com/accounts?p=signin_privatebrowsing&amp;hl=en" jsname="JFyozc" target="_blank">Learn more about using Guest mode</a></p>
</div>
</span>
<div class="i2knIc" jsname="DH6Rkf">
<div class="wg0fFb" jsname="DhK0U">
<div class="RhTxBf" jsname="k77Iif"><button name="action" class="JnOM6e TrZEUc rDisVe" value="1" jsname="Njthtb" id="identifierNext">Next</button></div>
<div class="tmMcIf" jsname="QkNstf"><a href="/lifecycle/flows/signup?continue=https://accounts.google.com/o/saml2/initsso?idpid%3DXXXXXX%26spid%3DYYYYYY%26forceauthn%3Dfalse%26hl%3Den%26loc%3DUS&amp;dsh=XXXXXXXXX:YYYYYYYYY&amp;faa=1&amp;flowEntry=SignUp&amp;flowName=GlifWebSignIn&amp;followup=https://accounts.google.com/o/saml2/initsso?idpid%3DXXXXXX%26spid%3DYYYYYY%26forceauthn%3Dfalse%26hl%3Den%26loc%3DUS&amp;hl=en&amp;ifkv=ABCDEFGHIJKLMNOPQRSTUVWXYZ?hl%3Den?hl%3Den" class="JnOM6e TrZEUc kTeh9 KXbQ4b">Create account</a></div>
</div>
</div>
<input type="hidden" name="at" value="VVVVVVVVVVV:ZZZZZZZZZZZZZZZZ">
</form>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
5 changes: 5 additions & 0 deletions pkg/provider/googleapps/googleapps.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ func (kc *Client) Authenticate(loginDetails *creds.LoginDetails) (string, error)
captchaInputIds := []string{
"logincaptcha",
"identifier-captcha-input",
"captchaimg",
}

var captchaFound *goquery.Selection
Expand All @@ -103,6 +104,10 @@ func (kc *Client) Authenticate(loginDetails *creds.LoginDetails) (string, error)

for captchaFound != nil && captchaFound.Length() > 0 {
captchaImgDiv := responseDoc.Find(".captcha-img")
if captchaImgDiv != nil {
captchaImgDiv = responseDoc.Find("div[data-auto-init='CaptchaInput']")
captchaInputId = "ca"
}
captchaPictureSrc, found := goquery.NewDocumentFromNode(captchaImgDiv.Children().Nodes[0]).Attr("src")

if !found {
Expand Down

0 comments on commit 6c82206

Please sign in to comment.