返回 social-analyzer
special-scan.js
根目录 / modules / special-scan.js
1 import helper from './helper.js'
2 import async from 'async'
3 import {Builder,By,Key} from 'selenium-webdriver'
4
5 async function find_username_special (req) {
6 const time = new Date()
7 const functions = []
8 helper.websites_entries.forEach((site) => {
9 if ('status' in site) {
10 if (site.status === 'bad') {
11 return Promise.resolve()
12 }
13 }
14 if (site.selected === 'true') {
15 site.detections.forEach((detection) => {
16 if (detection.type === 'special') {
17 if (detection.function === 'special_facebook_1') {
18 functions.push(find_username_site_special_facebook_1.bind(null, req.body.uuid, req.body.string, site))
19 } else if (detection.function === 'special_gmail_1') {
20 functions.push(find_username_site_special_gmail_1.bind(null, req.body.uuid, req.body.string, site))
21 } else if (detection.function === 'special_google_1') {
22 functions.push(find_username_site_special_google_1.bind(null, req.body.uuid, req.body.string, site))
23 }
24 }
25 })
26 }
27 })
28 const results = await async.parallelLimit(functions, 5)
29 helper.verbose && console.log(`Total time ${new Date() - time}`)
30 return results.filter(item => item !== undefined)
31 }
32
33 async function find_username_site_special_facebook_1 (uuid, username, site) {
34 return new Promise(async (resolve, reject) => {
35 helper.log_to_file_queue(uuid, '[Checking] ' + helper.get_site_from_url(site.url))
36 const driver = new Builder()
37 .forBrowser('firefox')
38 .setFirefoxOptions(new firefox.Options().headless().windowSize({
39 width: 640,
40 height: 480
41 }))
42 .build()
43
44 try {
45 const timeouts = {
46 implicit: 0,
47 pageLoad: 10000,
48 script: 10000
49 }
50
51 let source = ''
52 const temp_profile = Object.assign({}, helper.profile_template)
53 const link = 'https://mbasic.facebook.com/login/identify/?ctx=recoveqr'
54 await driver.manage().setTimeouts(timeouts)
55 await driver.get(link)
56 await driver.findElement(By.id('identify_search_text_input')).sendKeys(username)
57 await driver.findElement(By.id('did_submit')).click()
58 source = await driver.getPageSource()
59 await driver.quit()
60 if (source.includes('Try Entering Your Password')) {
61 temp_profile.found += 1
62 }
63 if (temp_profile.found > 0) {
64 temp_profile.text = 'unavailable'
65 temp_profile.title = 'unavailable'
66 temp_profile.rate = '%' + ((temp_profile.found / 1) * 100).toFixed(2)
67 temp_profile.link = site.url.replace('{username}', username)
68 temp_profile.type = site.type
69 resolve(temp_profile)
70 } else {
71 resolve(undefined)
72 }
73 } catch (err) {
74 if (driver !== undefined) {
75 try {
76 await driver.quit()
77 } catch (err) {
78 helper.verbose && console.log('Driver Session Issue')
79 }
80 }
81 resolve(undefined)
82 }
83 })
84 }
85
86 async function find_username_site_special_gmail_1 (uuid, username, site) {
87 return new Promise(async (resolve, reject) => {
88 helper.log_to_file_queue(uuid, '[Checking] ' + helper.get_site_from_url(site.url))
89 const driver = new Builder()
90 .forBrowser('firefox')
91 .setFirefoxOptions(new firefox.Options().headless().windowSize({
92 width: 640,
93 height: 480
94 }))
95 .build()
96
97 try {
98 const timeouts = {
99 implicit: 0,
100 pageLoad: 10000,
101 script: 10000
102 }
103
104 const temp_profile = Object.assign({}, helper.profile_template)
105 const link = 'https://accounts.google.com/signup/v2/webcreateaccount?service=mail&continue=https%3A%2F%2Fmail.google.com%2Fmail%2F%3Fpc%3Dtopnav-about-n-en&flowName=GlifWebSignIn&flowEntry=SignUp'
106 await driver.manage().setTimeouts(timeouts)
107 await driver.get(link)
108 await driver.findElement(By.id('username')).sendKeys(username)
109 await driver.findElement(By.id('selectioni1')).click()
110 const text_only = await driver.findElement(By.tagName('body')).getText()
111 await driver.quit()
112 if (text_only.includes('That username is taken') && !text_only.includes('your username must be between') && !text_only.includes('You can use letters')) {
113 temp_profile.found += 1
114 }
115 if (temp_profile.found > 0) {
116 temp_profile.text = username + '@gmail.com'
117 temp_profile.title = 'unavailable'
118 temp_profile.rate = '%' + ((temp_profile.found / 1) * 100).toFixed(2)
119 temp_profile.link = 'https://google.com'
120 temp_profile.type = site.type
121 resolve(temp_profile)
122 } else {
123 resolve(undefined)
124 }
125 } catch (err) {
126 if (driver !== undefined) {
127 try {
128 await driver.quit()
129 } catch (err) {
130 helper.verbose && console.log('Driver Session Issue')
131 }
132 }
133 resolve(undefined)
134 }
135 })
136 }
137
138 async function find_username_site_special_google_1 (uuid, username, site) {
139 return new Promise(async (resolve, reject) => {
140 helper.log_to_file_queue(uuid, '[Checking] ' + helper.get_site_from_url(site.url))
141 const driver = new Builder()
142 .forBrowser('firefox')
143 .setFirefoxOptions(new firefox.Options().headless().windowSize({
144 width: 640,
145 height: 480
146 }))
147 .build()
148
149 try {
150 const timeouts = {
151 implicit: 0,
152 pageLoad: 10000,
153 script: 10000
154 }
155
156 const temp_profile = Object.assign({}, helper.profile_template)
157 const link = 'https://accounts.google.com/signin/v2/identifier?continue=https%3A%2F%2Fmail.google.com%2Fmail%2F&service=mail&sacu=1&rip=1&flowName=GlifWebSignIn&flowEntry=ServiceLogin'
158 await driver.manage().setTimeouts(timeouts)
159 await driver.get(link)
160 await driver.findElement(By.id('identifierId')).sendKeys(username)
161 await driver.findElement(By.xpath("//button[contains(.,'Next')]")).click()
162 const text_only = await driver.findElement(By.tagName('body')).getText()
163 await driver.quit()
164 if (text_only.includes("Couldn't sign you in") && !text_only.includes("Couldn't find your")) {
165 temp_profile.found += 1
166 }
167 if (temp_profile.found > 0) {
168 temp_profile.text = username + '@gmail.com'
169 temp_profile.title = 'unavailable'
170 temp_profile.rate = '%' + ((temp_profile.found / 1) * 100).toFixed(2)
171 temp_profile.link = 'https://google.com'
172 temp_profile.type = site.type
173 resolve(temp_profile)
174 } else {
175 resolve(undefined)
176 }
177 } catch (err) {
178 if (driver !== undefined) {
179 try {
180 await driver.quit()
181 } catch (err) {
182 helper.verbose && console.log('Driver Session Issue')
183 }
184 }
185 resolve(undefined)
186 }
187 })
188 }
189
190 export default{
191 find_username_special
192 }
193
193 lines JAVASCRIPT