Skip to content

Instantly share code, notes, and snippets.

@snovvcrash snovvcrash/s0c14lch3ck.py
Last active Jul 1, 2019

Embed
What would you like to do?
Username checker for social media accounts and email addresses
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
'''
One-liner demos:
curl -s https://gist.githubusercontent.com/snovvcrash/86bcbf65cbc89bf496fd19afcf19f6f5/raw/0fa599810a8c308d0f2feb1f0b62e0837bed39ea/s0c14lch3ck.py | python3 - <USERNAME> <YOUR_EMAIL>
wget -qO- https://gist.githubusercontent.com/snovvcrash/86bcbf65cbc89bf496fd19afcf19f6f5/raw/0fa599810a8c308d0f2feb1f0b62e0837bed39ea/s0c14lch3ck.py | python3 - <USERNAME> <YOUR_EMAIL>
'''
__author__ = 'Sam Freeside (@snovvcrash)'
__version__ = '0.1'
import socket
import smtplib
import sys
import re
from urllib.request import Request, urlopen
from urllib.error import HTTPError, URLError
from collections import OrderedDict
try:
import dns.resolver
except ImportError:
print('Install dnspython3: sudo -H python3 -m pip install dnspython3')
sys.exit()
VERSION_FORMATTED = f'\033[0m\033[1;37m{{\033[0;35mv{__version__}\033[1;37m}}\033[0m'
AUTHOR_FORMATTED = f'\033[0m\033[0;37mby {__author__}\033[0m'
BANNER = '''\033[0;35m\
___ _ __ _ _ ____ _
___| | ___ / | /. | | | ___ | |_ <__ / ___ | |__
<_-<| / |/ | '| |/_ .|| |/ | '| . | <_ \\/ | '| / /
/__/`___'\\_|_.|_| |_| |_|\\_|_.|_|_|<___/\\_|_.|_\\_\\
%s
%s\
''' % (VERSION_FORMATTED, AUTHOR_FORMATTED)
username = 'username'
COLORS = {
'red': '\033[%s;31m',
'green': '\033[%s;32m',
'yellow': '\033[%s;33m',
'reset': '\033[0m'
}
SITES = OrderedDict({
'vk': f'https://vk.com',
'twitter': f'https://twitter.com',
'telegram': f'https://telegram.me',
'livejournal': f'https://{username}.livejournal.com',
'reddit': f'https://www.reddit.com/user',
'lastfm': f'https://www.last.fm/user',
'askfm': f'https://ask.fm',
'github': f'https://github.com',
'keybase': f'https://keybase.io',
'instagram': f'https://instagram.com',
'steam': f'https://steamcommunity.com/id'
})
DOMAINS = OrderedDict({
'gmail': 'gmail.com',
'yandex': 'yandex.ru',
'mail': 'mail.ru',
'protonmail-com': 'protonmail.com',
'protonmail-ch': 'protonmail.ch'
})
HEADERS = {
'User-Agent': f's0cialchecker v{__version__}'
}
NOT_FOUND_STRINGS = ['not found', 'not be found']
def colored(msg, color, mode=0):
return f'{COLORS[color] % mode}{msg}{COLORS["reset"]}'
def check_social(username):
print('[*] Social media check...')
for i, site in enumerate(SITES.values()):
if username not in site:
url = f'{site}/{username}'
else:
url = site
req = Request(url, headers=HEADERS)
try:
resp = urlopen(req, timeout=5.0)
except (HTTPError, URLError, socket.timeout) as e:
color, mode = 'red' if '404' in str(e) else 'yellow', 0
else:
resp_body = resp.read().decode('utf-8').lower()
if any(not_found in resp_body for not_found in NOT_FOUND_STRINGS):
color, mode = 'red', 0
else:
color, mode = 'green', 1
if i == len(SITES) - 1:
print(f'|__ {colored(url, color=color, mode=mode)}\n')
else:
print(f'| {colored(url, color=color, mode=mode)}')
def check_email(username, your_email):
regex_username = re.compile(r'^[_a-z0-9-]+(\.[_a-z0-9-]+)*$')
regex_adress = re.compile(r'^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,})$')
if regex_username.match(username) is None or regex_adress.match(your_email) is None:
return
print('[*] Email check...')
server = smtplib.SMTP()
server.set_debuglevel(0)
for i, domain in enumerate(DOMAINS.values()):
address = f'{username}@{domain}'
records = dns.resolver.query(domain, 'MX')
mx_record = records[0].exchange
mx_record = str(mx_record)
try:
server.connect(mx_record)
server.helo(server.local_hostname)
server.mail(your_email)
code, message = server.rcpt(str(address))
except Exception as e:
color, mode = 'yellow', 0
else:
if code == 250:
color, mode = 'green', 1
else:
color, mode = 'red', 0
try:
server.quit()
except:
pass
if i == len(DOMAINS) - 1:
print(f'|__ {colored(address, color=color, mode=mode)}\n')
else:
print(f'| {colored(address, color=color, mode=mode)}')
if __name__ == '__main__':
print(f'{BANNER}\n')
if len(sys.argv) < 3:
print(f'Usage: python3 {sys.argv[0]} <USERNAME> <YOUR_EMAIL>')
sys.exit()
username = sys.argv[1]
your_email = sys.argv[2]
print(f'[*] Username: {username}\n')
check_social(username)
check_email(username, your_email)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.