Advertisement
Guest User

recaptchabox autoit

a guest
Jun 19th, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.00 KB | None | 0 0
  1. #include <WinAPI.au3>
  2. #include <GUIConstantsEx.au3>
  3. #include <IE.au3>
  4. #include <WindowsConstants.au3>
  5.  
  6. MsgBox(0,'Result',RecaptchaBox("woobox.com/wijcoc/hesk5h?embed=1"))
  7.  
  8. #cs
  9. Hàm RecaptchaBox($url,$theme,$bgcolor,$lang)
  10. ------------- param -------------
  11. $url: địa chỉ trang có recaptcha vd: https://www.google.com/recaptcha/api2/demo
  12. $theme: dark hoặc light, mặc định là light
  13. $bgcolor: cái này tích hợp vào gui mới cần
  14. $lang: ngôn ngữ mặc định là Việt Nam
  15. -------------- return -------------
  16. Trả về gcaptcha-response dùng để request
  17. #ce
  18. Func RecaptchaBox($url,$theme='light',$bgcolor='#FFFFFF',$lang='vi')
  19. Local $oIE = _IECreateEmbedded()
  20. $gui = GUICreate("Recaptcha box", 330, 94,(@DesktopWidth - 640) / 2, (@DesktopHeight - 580) / 2)
  21. $ojb = GUICtrlCreateObj($oIE, 0, 0, 330, 510)
  22. GUICtrlSetResizing(-1, 544/2)
  23. GUISetBkColor(0xFFFFFF)
  24. _IENavigate($oIE, $url)
  25. $DataSiteKey = StringRegExp(_IEBodyReadHTML($oIE),'https:.*?k=(.*?)&amp',1); regex sida
  26. If @error Then
  27. GUIDelete()
  28. Return 'error: can not find recaptcha in site'
  29. endif
  30. $oIE.document.parentwindow.execScript("document.write('<body></body>');var iDiv = document.createElement('div');iDiv.id = 'recaptchaa';document.getElementsByTagName('body')[0].appendChild(iDiv);var jq = document.createElement('script');jq.src = 'https://www.google.com/recaptcha/api.js';document.getElementsByTagName('head')[0].appendChild(jq);")
  31. $oIE.document.parentwindow.execScript("captcha = grecaptcha.render(document.getElementById('recaptchaa'), {'sitekey' : '"& $DataSiteKey[0] &"','theme':'"&$theme&"','hl' : '"&$lang&"'});")
  32. $oIE.document.parentwindow.execScript("document.body.style.background = '"& $bgcolor &"';")
  33. $RecaptchaResponse = $oIE.document.parentwindow.eval('grecaptcha.getResponse(captcha);')
  34. GUISetState(@SW_SHOW) ;Show GUI
  35. Do
  36. Sleep(10)
  37. Until MemoryReadPixel(268, 49, $gui) = '0x4F8EF5' ; chờ load captcha trên Gui
  38. Do
  39. Sleep(10)
  40. Until MemoryReadPixel(26, 113, $gui) <> '0xFFFFFF' ;nếu click
  41. WinMove($gui,'',Default,Default,Default,540)
  42.  
  43. While $oIE.document.parentwindow.eval('grecaptcha.getResponse(captcha);') = '' ;loop cho tới khi giải captcha thành công
  44. Local $iMsg = GUIGetMsg()
  45. Switch $iMsg
  46. Case $GUI_EVENT_CLOSE
  47. ExitLoop
  48. EndSwitch
  49. Sleep(100)
  50. WEnd
  51.  
  52. $RecaptchaResponse = $oIE.document.parentwindow.eval('grecaptcha.getResponse(captcha);')
  53. If $RecaptchaResponse <> '' Then
  54. WinMove($gui,'',Default,Default,Default,94+30)
  55. GUIDelete()
  56. Return $RecaptchaResponse
  57. endif
  58. GUIDelete()
  59. Return False
  60. EndFunc
  61.  
  62. Func MemoryReadPixel($x, $y, $handle)
  63. Local $hDC
  64. Local $iColor
  65. Local $sColor
  66.  
  67. $hDC = _WinAPI_GetWindowDC($handle)
  68. $iColor = DllCall("gdi32.dll", "int", "GetPixel", "int", $hDC, "int", $x, "int", $y)
  69. $sColor = Hex($iColor[0], 6)
  70. _WinAPI_ReleaseDC($handle, $hDC)
  71.  
  72. Return "0x" & StringRight($sColor, 2) & StringMid($sColor, 3, 2) & StringLeft($sColor, 2)
  73. EndFunc ;==>MemoryReadPixel
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement