social-scanner
v0.1.5
Published
A node utility to scan various social networks against username.
Downloads
5
Readme
Installation
You can install it via npm or yarn.
npm install social-scanner
yarn add social-scanner
Looking for the cli?
You can use it from the command line installing the globally the cli repository.
npm install -g social-scanner-cli
yarn global add social-scanner-cli
How it works?
The script can be used as a module and take specific options in order:
socialScanner(username, options, callback)
By default it will perform an HTTP request for each rule existing in the project against the given username, if the page exists (return 200 status code) and depending by rule, if different response content assertions succeeds is treated as positive.
const socialScanner = require('../lib/index');
socialScanner('codekraft-studio', {}, (err, response) => {
if (err) {
console.log('Error:', JSON.stringify(err, null, 2));
return;
}
console.log('Response:', JSON.stringify(response, null, 2));
});
You can also capture the output in different formats. By default is BASE64, but you can use PNG or many more using the captureOptions object to pass options directly to webpage-capture which is the one you is in charge of web screenshots.
// outputType: 'base64|png|pdf'
socialScanner('codekraft-studio', {
capture: true,
captureOptions: {
outputType: 'base64',
onlySuccess: true,
outputType: 'file'
}
}, (err, response) => {
// some code
});
To specify a custom path for the files you must pass it to outputDir option like so:
socialScanner('codekraft-studio', {
capture: true,
outputDir: '/home/user/Desktop'
});
Options
This is the options object to customize the HTTP request behavior, is passed directly to request
- requestOptions: A object of options passed to request
The default values used by the script are:
strictSSL: false,
followRedirect: true,
followAllRedirects: false,
maxRedirects: 2,
timeout: 3000
Filters
These are the options object properties dedicated to filter the rules to test against the given input.
- restrict: A list (or array) of social networks to scan
- restrictCategories: An array of restrict rule categories
By default no restrictions will be made and all the rules will be tested.
Output
- onlySuccess: Returns only results that matched the search
- capture: Take screenshot of the resulting page(s)
- outputDir: The output directory where place the screenshots
- captureOptions: A object of options passed directly to webpage-capture
- crop: If the screnshot should be cropped or not
- onlySuccess: Returns only results that matched the search
- outputType: Change the output format for the capture result
onlySuccess: false,
capture: false,
captureOptions: {
outputType: 'base64',
onlySuccess: false,
crop: true
}
This are the default properties used by the script are listed below, for the full options list refer to webpage-capture github page. Please note this, if the option on the child package has the same name in this package please don't use the option in the child because it's needed in this package to customize the operations.
Examples
The code is very simple to use, the best way is just try it with your username to see in which services is already taken and where is you or not, if you find some response incongruences, for example the response say it's a match but obviously is not, please be kind and open a new issue following this format.
Scan a username against all rules
Scan a username against various social networks, without taking screenshots.
socialScanner(username, {}, (err, response) => { });
Scan a username against all rules taking screenshots to string (base64)
Scan a username against various social networks, taking screenshots.
socialScanner(username, {
capture: true,
onlySuccess: true
}, (err, response) => { });
Scan a username against all rules taking screenshots to file (png)
Scan a username against various social networks, taking screenshots to file in the default PNG format, the files will be placed in a output subfolder called as the username for example, with my username, the output will be stored in: ./output/b4dnewz
.
socialScanner(username, {
onlySuccess: true,
capture: true,
captureOptions: {
outputType: 'file'
}
}, (err, response) => { });
Filter the list of rules to scan by rule name
Scan username against some restricted social networks, the rules are filtered by rule name, you can see the full list in the rules page.
socialScanner(username, {
restrict: ['facebook', 'github']
}, (err, response) => { });
Filter the list of rules to scan by rule category
Scan username against some restricted social categories, the rules are filtered by their category, if you use the cli tool there is a command to list all the categories, otherwise look at the rules page or try to guess them, they are english words so pretty prevedible, for example: tech, design, ...
.
socialScanner(username, {
restrictCategories: ['community']
}, (err, response) => { });
Adding rules
So you want to add a rule or a set of rules to the tool? Maybe you have tried it with your username and you haven't find listed your favorite social network or web service. There is a solution for this, simply open a new issue asking what service you want to add and it will be integrated as soon as possible in the next releases.
What I need to know?
For example you want to integrate you favourite social network which is called example.com
and you know the profile pages for that website are under the path: example.com/profile/<my-username>
, you also know this website doesn't allow some kind of characters for usernames, because during the registration process you have tried many different wrong usernames.
How to integrate?
Now you can open a new issue following the template and describing as much as you can the website you want to add or you can fork the repository and add the rule yourself, take a look at the rules file than add your new rule object and submit a pull request.
License
The social-scanner is released under the MIT License by b4dnewz.
Contributing
- Fork it ( https://github.com/b4dnewz/social-scanner/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Write and run the tests (
npm run test
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request