Created
October 18, 2017 09:35
-
-
Save JamesTheHacker/ecc3bee6416acfa19b67198d9f1e65a5 to your computer and use it in GitHub Desktop.
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
const cheerio = require('cheerio'); | |
const google = require('google'); | |
const request = require('superagent'); | |
const util = require('util'); | |
const misconfiguredCORS = require('./plugins/misconfiguredCORS'); | |
google.resultsPerPage = 100; | |
const g = util.promisify(google); | |
async function fetchURLsFromGoogle(q) { | |
const { links } = await g(q); | |
return links | |
.filter(link => link.link) | |
.map(link => link.link); | |
} | |
function* createGenerator(urls, plugin, ...args) { | |
let currIndex = 0; | |
while(true) { | |
if(currIndex >= urls.length) | |
return { done: true }; | |
yield plugin(urls[currIndex++], ...args); | |
} | |
} | |
async function main(q) { | |
const urls = await fetchURLsFromGoogle(q); | |
const headers = await createGenerator(urls, misconfiguredCORS, 'lol.com'); | |
const results = await Promise.all(headers); | |
return results.filter(result=>result); | |
} | |
main(process.argv[2]) | |
.then(results=>console.log(results)) | |
.then(() => process.exit()) // Required otherwise shit hangs | |
.catch(err => console.error(err)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment