From 2efeb48d535525f6fe502a4b6ad81ef0eba849cf Mon Sep 17 00:00:00 2001 From: Jordan Doyle Date: Tue, 24 Nov 2015 22:49:37 +0000 Subject: [PATCH] Initial commit --- LICENSE.md | 22 ++++++++++++++++++++++ README.md | 17 +++++++++++++++++ common.js | 31 +++++++++++++++++++++++++++++++ package.json | 20 ++++++++++++++++++++ reaper.js | 94 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 184 insertions(+) create mode 100644 LICENSE.md create mode 100644 README.md create mode 100644 common.js create mode 100644 package.json create mode 100644 reaper.js diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..be24f10 --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,22 @@ +The MIT License +=============== + +Copyright (c) 2015 Jordan Doyle + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..5239cb3 --- /dev/null +++ b/README.md @@ -0,0 +1,17 @@ +# reaper + +[![License](https://poser.pugx.org/laravel/framework/license.svg)](http://github.com/jordandoyle/reaper) + +[League of Legends](http://leagueoflegends.com) mass summoner name checker. Supply a region and a list and the script will check the list for available summoner names. Common uses are finding quick variations of your name or finding rare (or "OG") names for selling. An API Key is required to do use this script, they are available for free from [Riot Games](https://developer.riotgames.com/), the API key is set in **reaper.js**. + +This script includes a built-in rate limiter and a very basic web server for checking the status of the script remotely available on port **8090**. + +The syntax of reaper is very simple: + + node reaper.js [server (na/euw/lan/etc)] [username file] (output file) + +For example: + + node reaper.js euw username_list.txt output.txt + +Will check the list username_list.txt for available summoner names on Europe West and output what it finds to output.txt diff --git a/common.js b/common.js new file mode 100644 index 0000000..ce13c84 --- /dev/null +++ b/common.js @@ -0,0 +1,31 @@ +console.error = function(msg) +{ + console.log("[".white + "!".red + "] ".white + msg.white); +}; + +console.info = function(msg) +{ + console.log("[".white + "-".green + "] ".white + msg.white); +}; + +console.warn = function(msg) +{ + console.log("[".white + "~".blue + "] ".white + msg.white); +}; + +exports.shuffle = function(array) +{ + var currentIndex = array.length; + var temporaryValue; + var randomIndex; + + while(currentIndex !== 0) + { + randomIndex = Math.floor(Math.random() * currentIndex); + currentIndex -= 1; + + temporaryValue = array[currentIndex]; + array[currentIndex] = array[randomIndex]; + array[randomIndex] = temporaryValue; + } +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..8594b15 --- /dev/null +++ b/package.json @@ -0,0 +1,20 @@ +{ + "name": "reaper", + "description": "League of Legends available name scraper", + "version": "1.0.2", + "author": "Jordan Doyle ", + "main": "reaper.js", + "repository": { + "type": "git", + "url": "git://github.com/JordanDoyle/reaper.git" + }, + "bugs": { + "url": "https://github.com/JordanDoyle/reaper/issues" + }, + "dependencies": { + "chunk": "~0.0.2", + "colors": "~1.1.2", + "limiter": "~1.0.5" + }, + "license": "MIT" +} \ No newline at end of file diff --git a/reaper.js b/reaper.js new file mode 100644 index 0000000..495a5a0 --- /dev/null +++ b/reaper.js @@ -0,0 +1,94 @@ +var common = require('./common'); + +var colors = require('colors'); +var chunk = require('chunk'); +var args = process.argv.slice(2); + +var fs = require('fs'); +var http = require('http'); +var https = require("https"); + +if(args.length < 2 || args.length > 3) +{ + console.error("Invalid syntax. Valid syntax: " + process.argv[0] + " " + process.argv[1] + " [server] [username input] (username output)"); +} + +var apiKey = ""; + +var server = args[0]; +var input = args[1]; +var output = args[2]; + +var RateLimiter = require('limiter').RateLimiter; +var limiter = new RateLimiter(1, 'second'); + +var namesChecked = 0; +var namesFound = 0; + +// basic http server for logging +http.createServer(function(req, res) +{ + res.writeHead(200, { 'Content-Type': 'text/plain' }); + res.end('Names Checked: ' + namesChecked + '\nNames Found: ' + namesFound); +}).listen(8090); + +var names = fs.readFileSync(input).toString().split('\n'); + +// shuffle the list of names passed in +common.shuffle(names); + +// check names in chunks of 40 +chunk(names, 40).forEach(function(chunked) +{ + limiter.removeTokens(1, function(err, remainingRequests) + { + namesChecked += 40; + + var users = chunked.join(',').replace(/[-]/g, ' ').replace(/[\r\n'.]/g, ''); + + // make a secure request to the specified server + https.get('https://' + server + '.api.pvp.net/api/lol/' + server + '/v1.4/summoner/by-name/' + users + '?api_key=' + apiKey, function(res) + { + // riot returns a 404 if none of the names are registered + if(res.statusCode === 404) { + chunked.forEach(function(name) + { + namesFound++; + console.info(name.replace(/[-]/g, ' ').replace(/[\r\n'.]/g, '') + " is available!"); + + if(output != undefined) + fs.appendFile(output, name + '\n'); + }); + } else if(res.statusCode === 200) { + var body = ''; + res.setEncoding('utf8'); + + res.on('data', function(d) { + body += d; + }); + + res.on('end', function() + { + var obj = JSON.parse(body); + + chunked.forEach(function(name) + { + name = name.replace(/[-]/g, ' ').replace(/[\r\n'.]/g, '').trim(); + + if(name.length < 3) + return; + + if(obj[name] == undefined) + { + if(output != undefined) + fs.appendFile(output, name + '\r\n'); + + console.info(name + " is available!"); + namesFound++; + } + }); + }); + } + }); + }); +}); -- libgit2 1.7.2