Merge branch 'ptalmeida-master'

pull/143/head
Yahya SayadArbabi 5 years ago
commit cd50d34e2e

@ -0,0 +1,25 @@
group: travis_latest
language: python
cache: pip
matrix:
allow_failures:
- python: nightly
include:
- python: 3.6
- python: 3.7
dist: xenial # required for Python >= 3.7 (travis-ci/travis-ci#9069)
- python: nightly
dist: xenial
install:
- pip install -r requirements.txt
- pip install flake8
before_script:
# stop the build if there are Python syntax errors or undefined names
- flake8 . --count --select=E901,E999,F821,F822,F823 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
- flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
script:
- python3 -m unittest tests.all --buffer --verbose
notifications:
on_success: change
on_failure: change # `always` will be the setting once code changes slow down

@ -1,8 +1,10 @@
# Sherlock
> Find usernames across [social networks](https://github.com/theyahya/sherlock/blob/master/sites.md)
# Sherlock [![Build Status](https://travis-ci.com/TheYahya/sherlock.svg?branch=master)](https://travis-ci.com/TheYahya/sherlock)
> Find usernames across [social networks](https://github.com/theyahya/sherlock/blob/master/sites.md)
<p align="center">
<img src="./screenshot/preview.png">
<a href="https://asciinema.org/a/IMRMmbAxFGUgd2SJN0rkAfaPb">
<img src="https://asciinema.org/a/IMRMmbAxFGUgd2SJN0rkAfaPb.svg">
</a>
</p>
## Installation
@ -28,9 +30,10 @@ $ pip3 install -r requirements.txt
$ python3 sherlock.py --help
usage: sherlock.py [-h] [--version] [--verbose] [--quiet] [--tor]
[--unique-tor] [--csv] [--site SITE_NAME]
[--proxy PROXY_URL]
USERNAMES [USERNAMES ...]
Sherlock: Find Usernames Across Social Networks (Version 0.2.0)
Sherlock: Find Usernames Across Social Networks (Version 0.4.0)
positional arguments:
USERNAMES One or more usernames to check with social networks.
@ -49,6 +52,9 @@ optional arguments:
--csv Create Comma-Separated Values (CSV) File.
--site SITE_NAME Limit analysis to just the listed sites. Add multiple
options to specify more than one site.
--proxy PROXY_URL, -p PROXY_URL
Make requests over a proxy. e.g.
socks5://127.0.0.1:1080
```
For example, run ```python3 sherlock.py user123```, and all of the accounts
@ -77,6 +83,29 @@ Or you can simply use "Docker Hub" to run `sherlock`:
docker run theyahya/sherlock user123
```
## Tests
If you are contributing to Sherlock, then Thank You!
Before creating a pull request with new development, please run the tests
to ensure that all is well. It would also be a good idea to run the tests
before starting development to distinguish problems between your
environment and the Sherlock software.
The following is an example of the command line to run all the tests for
Sherlock. This invocation hides the progress text that Sherlock normally
outputs, and instead shows the verbose output of the tests.
```
$ python3 -m unittest tests.all --buffer --verbose
```
Note that the tests are very much a work in progress. Significant work is
required to get full test coverage. But, the current tests are working
properly, and will be expanded as time goes by.
## Original creator of Sherlock
Siddharth Dushantha ([sdushantha](https://github.com/sdushantha))
## License
MIT © [Yahya SayadArbabi](https://theyahya.com)

File diff suppressed because it is too large Load Diff

@ -10,22 +10,34 @@ networks.
import csv
import json
import os
import sys
import platform
import re
import sys
from argparse import ArgumentParser, RawDescriptionHelpFormatter
from concurrent.futures import ThreadPoolExecutor
from time import time
import requests
from argparse import ArgumentParser, RawDescriptionHelpFormatter
from concurrent.futures import ThreadPoolExecutor
from colorama import Fore, Style, init
from requests_futures.sessions import FuturesSession
from torrequest import TorRequest
module_name = "Sherlock: Find Usernames Across Social Networks"
__version__ = "0.2.7"
__version__ = "0.4.1"
amount = 0
BANNER = r'''
."""-.
/ \
____ _ _ _ | _..--'-.
/ ___|| |__ ___ _ __| | ___ ___| |__ >.`__.-""\;"`
\___ \| '_ \ / _ \ '__| |/ _ \ / __| |/ / / /( ^\
___) | | | | __/ | | | (_) | (__| < '-`) =|-.
|____/|_| |_|\___|_| |_|\___/ \___|_|\_\ /`--.'--' \ .-.
.'`-._ `.\ | J /
/ `--.| \__/'''[1:]
# TODO: fix tumblr
@ -208,13 +220,27 @@ def sherlock(username, site_data, verbose=False, tor=False, unique_tor=False, pr
if net_info["errorType"] == 'status_code':
request_method = session.head
if net_info["errorType"] == "response_url":
#Site forwards request to a different URL if username not
#found. Disallow the redirect so we can capture the
#http status from the original URL request.
allow_redirects = False
else:
#Allow whatever redirect that the site wants to do.
#The final result of the request will be what is available.
allow_redirects = True
# This future starts running the request in a new thread, doesn't block the main thread
if proxy != None:
proxies = {"http": proxy, "https": proxy}
future = request_method(
url=url, headers=headers, proxies=proxies)
future = request_method(url=url, headers=headers,
proxies=proxies,
allow_redirects=allow_redirects
)
else:
future = request_method(url=url, headers=headers)
future = request_method(url=url, headers=headers,
allow_redirects=allow_redirects
)
# Store future in data for access later
net_info["request_future"] = future
@ -290,9 +316,13 @@ def sherlock(username, site_data, verbose=False, tor=False, unique_tor=False, pr
exists = "no"
elif error_type == "response_url":
error = net_info.get("errorUrl")
# Checks if the redirect url is the same as the one defined in data.json
if not error in r.url:
# For this detection method, we have turned off the redirect.
# So, there is no need to check the response URL: it will always
# match the request. Instead, we will ensure that the response
# code indicates that the request was successful (i.e. no 404, or
# forward to some odd redirect).
if (r.status_code >= 200) and (r.status_code < 300):
#
print_found(social_network, url, response_time, verbose)
write_to_file(url, f)
exists = "yes"
@ -326,6 +356,7 @@ def sherlock(username, site_data, verbose=False, tor=False, unique_tor=False, pr
Fore.WHITE + "{}").format(fname))
final_score(amount, f)
f.close()
return results_total
@ -379,17 +410,7 @@ def main():
args = parser.parse_args()
# Banner
print(Fore.WHITE + Style.BRIGHT +
""" .\"\"\"-.
/ \\
____ _ _ _ | _..--'-.
/ ___|| |__ ___ _ __| | ___ ___| |__ >.`__.-\"\"\;\"`
\___ \| '_ \ / _ \ '__| |/ _ \ / __| |/ / / /( ^\\
___) | | | | __/ | | | (_) | (__| < '-`) =|-.
|____/|_| |_|\___|_| |_|\___/ \___|_|\_\ /`--.'--' \ .-.
.'`-._ `.\ | J /
/ `--.| \__/""")
print(Fore.WHITE + Style.BRIGHT + BANNER)
# Argument check
# TODO regex check on args.proxy

@ -3,15 +3,21 @@
This module generates the listing of supported sites.
"""
import json
from collections import OrderedDict
with open("data.json", "r", encoding="utf-8") as data_file:
data = json.load(data_file)
sorted_json_data = json.dumps(data, indent=2, sort_keys=True)
with open("data.json", "w") as data_file:
data_file.write(sorted_json_data)
with open("sites.md", "w") as site_file:
site_file.write(f'## List Of Supported Sites ({len(data)} Sites In Total!)\n')
index = 1
for social_network in data:
for social_network in OrderedDict(sorted(data.items())):
url_main = data.get(social_network).get("urlMain")
site_file.write(f'{index}. [{social_network}]({url_main})\n')
index = index + 1

@ -1,134 +1,134 @@
## List Of Supported Sites (133 Sites In Total!)
1. [Instagram](https://www.instagram.com/)
2. [Twitter](https://www.twitter.com/)
3. [Facebook](https://www.facebook.com/)
4. [YouTube](https://www.youtube.com/)
5. [Blogger](https://www.blogger.com/)
6. [Google Plus](https://plus.google.com/)
7. [Reddit](https://www.reddit.com/)
8. [Pinterest](https://www.pinterest.com/)
9. [GitHub](https://www.github.com/)
10. [Steam](https://steamcommunity.com/)
11. [Vimeo](https://vimeo.com/)
12. [SoundCloud](https://soundcloud.com/)
13. [Disqus](https://disqus.com/)
14. [Medium](https://medium.com/)
15. [DeviantART](https://deviantart.com)
16. [VK](https://vk.com/)
17. [About.me](https://about.me/)
18. [Imgur](https://imgur.com/)
19. [9GAG](https://9gag.com/)
20. [Flipboard](https://flipboard.com/)
21. [SlideShare](https://slideshare.net/)
22. [Fotolog](https://fotolog.com/)
23. [Spotify](https://open.spotify.com/)
24. [MixCloud](https://www.mixcloud.com/)
25. [Scribd](https://www.scribd.com/)
26. [Patreon](https://www.patreon.com/)
27. [BitBucket](https://bitbucket.org/)
28. [Roblox](https://www.roblox.com/)
29. [Gravatar](http://en.gravatar.com/)
30. [iMGSRC.RU](https://imgsrc.ru/)
1. [500px](https://500px.com/)
2. [9GAG](https://9gag.com/)
3. [About.me](https://about.me/)
4. [Academia.edu](https://www.academia.edu/)
5. [AngelList](https://angel.co/)
6. [Aptoide](https://en.aptoide.com/)
7. [AskFM](https://ask.fm/)
8. [BLIP.fm](https://blip.fm/)
9. [Badoo](https://badoo.com/)
10. [Bandcamp](https://www.bandcamp.com/)
11. [Basecamp](https://basecamp.com/)
12. [Behance](https://www.behance.net/)
13. [BitBucket](https://bitbucket.org/)
14. [BlackPlanet](http://blackplanet.com/)
15. [Blogger](https://www.blogger.com/)
16. [BuzzFeed](https://buzzfeed.com/)
17. [Canva](https://www.canva.com/)
18. [Carbonmade](https://carbonmade.com/)
19. [CashMe](https://cash.me/)
20. [Cloob](https://www.cloob.com/)
21. [Codecademy](https://www.codecademy.com/)
22. [Codementor](https://www.codementor.io/)
23. [Codepen](https://codepen.io/)
24. [Coderwall](https://coderwall.com/)
25. [ColourLovers](https://www.colourlovers.com/)
26. [Contently](https://contently.com/)
27. [Coroflot](https://coroflot.com/)
28. [CreativeMarket](https://creativemarket.com/)
29. [Crevado](https://crevado.com/)
30. [Crunchyroll](https://www.crunchyroll.com/)
31. [DailyMotion](https://www.dailymotion.com/)
32. [Etsy](https://www.etsy.com/)
33. [CashMe](https://cash.me/)
34. [Behance](https://www.behance.net/)
35. [GoodReads](https://www.goodreads.com/)
36. [Instructables](https://www.instructables.com/)
37. [Keybase](https://keybase.io/)
38. [Kongregate](https://www.kongregate.com/)
39. [LiveJournal](https://www.livejournal.com/)
40. [VSCO](https://vsco.co/)
41. [AngelList](https://angel.co/)
42. [last.fm](https://last.fm/)
43. [Dribbble](https://dribbble.com/)
44. [Codecademy](https://www.codecademy.com/)
45. [Pastebin](https://pastebin.com/)
46. [Foursquare](https://foursquare.com/)
47. [Gumroad](https://www.gumroad.com/)
48. [Newgrounds](https://newgrounds.com)
49. [Wattpad](https://www.wattpad.com/)
50. [Canva](https://www.canva.com/)
51. [Trakt](https://www.trakt.tv/)
52. [500px](https://500px.com/)
53. [BuzzFeed](https://buzzfeed.com/)
54. [TripAdvisor](https://tripadvisor.com/)
55. [Contently](https://contently.com/)
56. [Houzz](https://houzz.com/)
57. [BLIP.fm](https://blip.fm/)
58. [HackerNews](https://news.ycombinator.com/)
59. [Codementor](https://www.codementor.io/)
60. [ReverbNation](https://www.reverbnation.com/)
61. [Designspiration](https://www.designspiration.net/)
62. [Bandcamp](https://www.bandcamp.com/)
63. [ColourLovers](https://www.colourlovers.com/)
64. [IFTTT](https://www.ifttt.com/)
65. [Ebay](https://www.ebay.com/)
66. [Slack](https://slack.com)
67. [Trip](https://www.trip.skyscanner.com/)
68. [Ello](https://ello.co/)
69. [HackerOne](https://hackerone.com/)
70. [Tinder](https://tinder.com/)
71. [We Heart It](https://weheartit.com/)
72. [Flickr](https://www.flickr.com/)
73. [WordPress](https://wordpress.com)
74. [Unsplash](https://unsplash.com/)
75. [Pexels](https://www.pexels.com/)
76. [devRant](https://devrant.com/)
77. [MyAnimeList](https://myanimelist.net/)
78. [ImageShack](https://imageshack.us/)
79. [Badoo](https://badoo.com/)
80. [MeetMe](https://www.meetme.com/)
81. [Quora](https://www.quora.com/)
82. [Pixabay](https://pixabay.com/)
83. [Giphy](https://giphy.com/)
84. [Taringa](https://taringa.net/)
85. [SourceForge](https://sourceforge.net/)
86. [Codepen](https://codepen.io/)
87. [Launchpad](https://launchpad.net/)
88. [Photobucket](https://photobucket.com/)
89. [Wix](https://wix.com/)
90. [Crevado](https://crevado.com/)
91. [Carbonmade](https://carbonmade.com/)
92. [Coroflot](https://coroflot.com/)
93. [Jimdo](https://jimdosite.com/)
94. [Repl.it](https://repl.it/)
95. [Issuu](https://issuu.com/)
96. [YouPic](https://youpic.com/)
97. [House-Mixes.com](https://www.house-mixes.com/)
98. [Letterboxd](https://letterboxd.com/)
99. [Coderwall](https://coderwall.com/)
100. [Zhihu](https://www.zhihu.com/)
101. [Gitee](https://gitee.com/)
102. [Academia.edu](https://www.academia.edu/)
103. [BlackPlanet](http://blackplanet.com/)
104. [Cloob](https://www.cloob.com/)
105. [Crunchyroll](https://www.crunchyroll.com/)
106. [Rajce.net](https://www.rajce.idnes.cz/)
107. [VirusTotal](https://www.virustotal.com/)
108. [WebNode](https://www.webnode.cz/)
109. [Aptoide](https://en.aptoide.com/)
110. [GitLab](https://gitlab.com/)
111. [NameMC (Minecraft.net skins)](https://namemc.com/)
112. [Plug.DJ](https://plug.dj/)
113. [Wikipedia](https://www.wikipedia.org/)
114. [Mastodon](https://mstdn.io/)
115. [Telegram](https://t.me/)
116. [TradingView](https://www.tradingview.com/)
117. [Kaggle](https://www.kaggle.com/)
118. [Itch.io](https://itch.io/)
119. [Basecamp](https://basecamp.com/)
120. [ProductHunt](https://www.producthunt.com/)
121. [Younow](https://www.younow.com/)
122. [Smashcast](https://www.smashcast.tv/)
123. [AskFM](https://ask.fm/)
124. [KanoWorld](https://world.kano.me/)
125. [EyeEm](https://www.eyeem.com/)
126. [Wikia](http://www.wikia.com/)
127. [CreativeMarket](https://creativemarket.com/)
128. [Venmo](https://venmo.com/)
129. [HubPages](https://hubpages.com/)
130. [StreamMe](https://www.stream.me/)
131. [Kik](http://kik.me/)
132. [Star Citizen](https://robertsspaceindustries.com/)
133. [EVE Online](https://eveonline.com)
32. [Designspiration](https://www.designspiration.net/)
33. [DeviantART](https://deviantart.com)
34. [Disqus](https://disqus.com/)
35. [Dribbble](https://dribbble.com/)
36. [EVE Online](https://eveonline.com)
37. [Ebay](https://www.ebay.com/)
38. [Ello](https://ello.co/)
39. [Etsy](https://www.etsy.com/)
40. [EyeEm](https://www.eyeem.com/)
41. [Facebook](https://www.facebook.com/)
42. [Flickr](https://www.flickr.com/)
43. [Flipboard](https://flipboard.com/)
44. [Fotolog](https://fotolog.com/)
45. [Foursquare](https://foursquare.com/)
46. [Giphy](https://giphy.com/)
47. [GitHub](https://www.github.com/)
48. [GitLab](https://gitlab.com/)
49. [Gitee](https://gitee.com/)
50. [GoodReads](https://www.goodreads.com/)
51. [Google Plus](https://plus.google.com/)
52. [Gravatar](http://en.gravatar.com/)
53. [Gumroad](https://www.gumroad.com/)
54. [HackerNews](https://news.ycombinator.com/)
55. [HackerOne](https://hackerone.com/)
56. [House-Mixes.com](https://www.house-mixes.com/)
57. [Houzz](https://houzz.com/)
58. [HubPages](https://hubpages.com/)
59. [IFTTT](https://www.ifttt.com/)
60. [ImageShack](https://imageshack.us/)
61. [Imgur](https://imgur.com/)
62. [Instagram](https://www.instagram.com/)
63. [Instructables](https://www.instructables.com/)
64. [Issuu](https://issuu.com/)
65. [Itch.io](https://itch.io/)
66. [Jimdo](https://jimdosite.com/)
67. [Kaggle](https://www.kaggle.com/)
68. [KanoWorld](https://world.kano.me/)
69. [Keybase](https://keybase.io/)
70. [Kik](http://kik.me/)
71. [Kongregate](https://www.kongregate.com/)
72. [Launchpad](https://launchpad.net/)
73. [Letterboxd](https://letterboxd.com/)
74. [LiveJournal](https://www.livejournal.com/)
75. [Mastodon](https://mstdn.io/)
76. [Medium](https://medium.com/)
77. [MeetMe](https://www.meetme.com/)
78. [MixCloud](https://www.mixcloud.com/)
79. [MyAnimeList](https://myanimelist.net/)
80. [NameMC (Minecraft.net skins)](https://namemc.com/)
81. [Newgrounds](https://newgrounds.com)
82. [Pastebin](https://pastebin.com/)
83. [Patreon](https://www.patreon.com/)
84. [Pexels](https://www.pexels.com/)
85. [Photobucket](https://photobucket.com/)
86. [Pinterest](https://www.pinterest.com/)
87. [Pixabay](https://pixabay.com/)
88. [Plug.DJ](https://plug.dj/)
89. [ProductHunt](https://www.producthunt.com/)
90. [Quora](https://www.quora.com/)
91. [Rajce.net](https://www.rajce.idnes.cz/)
92. [Reddit](https://www.reddit.com/)
93. [Repl.it](https://repl.it/)
94. [ReverbNation](https://www.reverbnation.com/)
95. [Roblox](https://www.roblox.com/)
96. [Scribd](https://www.scribd.com/)
97. [Slack](https://slack.com)
98. [SlideShare](https://slideshare.net/)
99. [Smashcast](https://www.smashcast.tv/)
100. [SoundCloud](https://soundcloud.com/)
101. [SourceForge](https://sourceforge.net/)
102. [Spotify](https://open.spotify.com/)
103. [Star Citizen](https://robertsspaceindustries.com/)
104. [Steam](https://steamcommunity.com/)
105. [StreamMe](https://www.stream.me/)
106. [Taringa](https://taringa.net/)
107. [Telegram](https://t.me/)
108. [Tinder](https://tinder.com/)
109. [TradingView](https://www.tradingview.com/)
110. [Trakt](https://www.trakt.tv/)
111. [Trip](https://www.trip.skyscanner.com/)
112. [TripAdvisor](https://tripadvisor.com/)
113. [Twitter](https://www.twitter.com/)
114. [Unsplash](https://unsplash.com/)
115. [VK](https://vk.com/)
116. [VSCO](https://vsco.co/)
117. [Venmo](https://venmo.com/)
118. [Vimeo](https://vimeo.com/)
119. [VirusTotal](https://www.virustotal.com/)
120. [Wattpad](https://www.wattpad.com/)
121. [We Heart It](https://weheartit.com/)
122. [WebNode](https://www.webnode.cz/)
123. [Wikia](http://www.wikia.com/)
124. [Wikipedia](https://www.wikipedia.org/)
125. [Wix](https://wix.com/)
126. [WordPress](https://wordpress.com)
127. [YouPic](https://youpic.com/)
128. [YouTube](https://www.youtube.com/)
129. [Younow](https://www.younow.com/)
130. [Zhihu](https://www.zhihu.com/)
131. [devRant](https://devrant.com/)
132. [iMGSRC.RU](https://imgsrc.ru/)
133. [last.fm](https://last.fm/)

@ -0,0 +1,4 @@
"""Sherlock Tests
This package contains various submodules used to run tests.
"""

@ -0,0 +1,142 @@
"""Sherlock Tests
This module contains various tests.
"""
from tests.base import SherlockBaseTest
import unittest
class SherlockDetectTests(SherlockBaseTest):
def test_detect_true(self):
"""Test Username Existence Detection.
This test ensures that the mechanism of ensuring that a Username
exists works properly.
Keyword Arguments:
self -- This object.
Return Value:
N/A.
Will trigger an assert if Usernames which are known to exist are
not detected.
"""
self.username_check(['jack'], ['Twitter'], exist_check=True)
self.username_check(['dfox'], ['devRant'], exist_check=True)
self.username_check(['blue'], ['Pinterest'], exist_check=True)
self.username_check(['kevin'], ['Instagram'], exist_check=True)
self.username_check(['zuck'], ['Facebook'], exist_check=True)
return
def test_detect_false_via_message(self):
"""Test Username Does Not Exist (Via Message).
This test ensures that the "message" detection mechanism of
ensuring that a Username does *not* exist works properly.
Keyword Arguments:
self -- This object.
Return Value:
N/A.
Will trigger an assert if detection mechanism did not work as expected.
"""
self.username_check(['jackkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk'],
['Instagram'],
exist_check=False
)
return
def test_detect_false_via_status_code(self):
"""Test Username Does Not Exist (Via Status Code).
This test ensures that the "status code" detection mechanism of
ensuring that a Username does *not* exist works properly.
Keyword Arguments:
self -- This object.
Return Value:
N/A.
Will trigger an assert if detection mechanism did not work as expected.
"""
self.username_check(['jackkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk'],
['Facebook'],
exist_check=False
)
return
def test_detect_false_via_response_url(self):
"""Test Username Does Not Exist (Via Response URL).
This test ensures that the "response URL" detection mechanism of
ensuring that a Username does *not* exist works properly.
Keyword Arguments:
self -- This object.
Return Value:
N/A.
Will trigger an assert if detection mechanism did not work as expected.
"""
self.username_check(['jackkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk'],
['Pinterest'],
exist_check=False
)
return
class SherlockSiteCoverageTests(SherlockBaseTest):
def test_coverage_false_via_response_url(self):
"""Test Username Does Not Exist Site Coverage (Via Response URL).
This test checks all sites with the "response URL" detection mechanism
to ensure that a Username that does not exist is reported that way.
Keyword Arguments:
self -- This object.
Return Value:
N/A.
Will trigger an assert if detection mechanism did not work as expected.
"""
self.username_check(['noonewouldeverusethis7'],
["Pinterest", "iMGSRC.RU", "Pastebin",
"WordPress", "devRant", "ImageShack", "MeetMe"
],
exist_check=False
)
return
def test_coverage_true_via_response_url(self):
"""Test Username Does Exist Site Coverage (Via Response URL).
This test checks all sites with the "response URL" detection mechanism
to ensure that a Username that does exist is reported that way.
Keyword Arguments:
self -- This object.
Return Value:
N/A.
Will trigger an assert if detection mechanism did not work as expected.
"""
self.username_check(['blue'],
["Pinterest", "iMGSRC.RU", "Pastebin",
"WordPress", "devRant", "ImageShack", "MeetMe"
],
exist_check=True
)
return

@ -0,0 +1,107 @@
"""Sherlock Base Tests
This module contains various utilities for running tests.
"""
import json
import os
import os.path
import unittest
import sherlock
import warnings
class SherlockBaseTest(unittest.TestCase):
def setUp(self):
"""Sherlock Base Test Setup.
Does common setup tasks for base Sherlock tests.
Keyword Arguments:
self -- This object.
Return Value:
N/A.
"""
#This ignores the ResourceWarning from an unclosed SSLSocket.
#TODO: Figure out how to fix the code so this is not needed.
warnings.simplefilter("ignore", ResourceWarning)
# Load the data file with all site information.
data_file_path = os.path.join(os.path.dirname(os.path.realpath(sherlock.__file__)), "data.json")
with open(data_file_path, "r", encoding="utf-8") as raw:
self.site_data_all = json.load(raw)
self.verbose=False
self.tor=False
self.unique_tor=False
return
def site_data_filter(self, site_list):
"""Filter Site Data.
Keyword Arguments:
self -- This object.
site_list -- List of strings corresponding to sites which
should be filtered.
Return Value:
Dictionary containing sub-set of site data specified by 'site_list'.
"""
# Create new dictionary that has filtered site data based on input.
# Note that any site specified which is not understood will generate
# an error.
site_data = {}
for site in site_list:
with self.subTest(f"Checking test vector Site '{site}' "
f"exists in total site data."
):
site_data[site] = self.site_data_all[site]
return site_data
def username_check(self, username_list, site_list, exist_check=True):
"""Username Exist Check.
Keyword Arguments:
self -- This object.
username_list -- List of strings corresponding to usernames
which should exist on *all* of the sites.
site_list -- List of strings corresponding to sites which
should be filtered.
exist_check -- Boolean which indicates if this should be
a check for Username existence,
or non-existence.
Return Value:
N/A.
Will trigger an assert if Username does not have the expected
existence state.
"""
#Filter all site data down to just what is needed for this test.
site_data = self.site_data_filter(site_list)
if exist_check:
check_type_text = "exists"
exist_result_desired = "yes"
else:
check_type_text = "does not exist"
exist_result_desired = "no"
for username in username_list:
results = sherlock.sherlock(username,
site_data,
verbose=self.verbose,
tor=self.tor,
unique_tor=self.unique_tor
)
for site, result in results.items():
with self.subTest(f"Checking Username '{username}' "
f"{check_type_text} on Site '{site}'"
):
self.assertEqual(result['exists'], exist_result_desired)
return
Loading…
Cancel
Save