Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# ksp-submission
This repository is created for Karnataka State Police Hackathon 2023 - submission collection.
## Team Information
### Team Name -
### Team Name - Runtime Terror
### Problem Statement -
Solution for Crowdsourcing of data
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
6 changes: 6 additions & 0 deletions SolutionToCrowdSourcingData/flask/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from webapp import create_app

app = create_app()

if __name__ == '__main__':
app.run(debug=True)
7 changes: 7 additions & 0 deletions SolutionToCrowdSourcingData/flask/webapp/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from flask import Flask

def create_app():
app = Flask(__name__)
from .views import views
app.register_blueprint(views, url_prefix='/')
return app
Binary file not shown.
Binary file not shown.
13 changes: 13 additions & 0 deletions SolutionToCrowdSourcingData/flask/webapp/templates/end.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Thank You</title>
</head>
<body>
<h1><b>Thank You</b>></h1>
</h1>
</body>
</html>
44 changes: 44 additions & 0 deletions SolutionToCrowdSourcingData/flask/webapp/templates/input.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Crowd Sourcing</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.3.1/dist/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<style>
.form-div{
margin: 50px;
}
</style>
</head>
<body>
<div class="form-div">
<form method="POST">
<div class="form-group">
<label for="name">Name</label>
<input type="text" class="form-control" name ="name" id="name" aria-describedby="emailHelp" placeholder="Enter name">
</div>
<br/>
<div class="form-group">
<label for="email-addr">Email address</label>
<input type="email" class="form-control" name ="email-addr" id="email-addr" aria-describedby="emailHelp" placeholder="Enter email">
</div>
<br/>
<div class="form-group">
<label for="social-handle">Social Handle</label>
<input type="text" class="form-control" name="social-handle" id="social-handle" aria-describedby="emailHelp" placeholder="Enter social handle">
</div>
<br/>
<div class="form-group">
<label for="phone-number">Phone Number</label>
<input type="number" minlength="10" maxlength="10" class="form-control" name="phone-number" id="phone-number" aria-describedby="emailHelp" placeholder="Enter phone number">
</div>
<button type="submit" class="btn btn-primary">Submit</button>
</form>
</div>
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.14.7/dist/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@4.3.1/dist/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
</body>
</html>
32 changes: 32 additions & 0 deletions SolutionToCrowdSourcingData/flask/webapp/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
from flask import Blueprint, render_template, request, flash, redirect, url_for
views = Blueprint('views', __name__)

# import sys
# sys.path.append('../../scraper')
# import os
# os.path.dirname()
# from scraper import htmlCreate

# from scraper.htmlCreate import createHtml
# from ..scraper import htmlCreate

@views.route('/', methods=['GET', 'POST'])
def home():
if request.method == 'POST':
try:
name = request.form.get('name')
email = request.form.get('email-addr')
social = request.form.get('social-handle')
phone = request.form.get('phone-number')
print(name,email,social,phone)
# htmlCreate.downloader(socials
return redirect(url_for('views.end'))
except:
print("Error Occurred")
else:
pass
return render_template("input.html")

@views.route('/tata')
def end():
return render_template('end.html')
7 changes: 7 additions & 0 deletions SolutionToCrowdSourcingData/scraper/Blackbird_usecase.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import os
def scrapeBlackBird(username):
try:
os.system("python blackbird.py -u "+username)
return 0
except:
return -1
1 change: 1 addition & 0 deletions SolutionToCrowdSourcingData/scraper/Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
web: gunicorn webserver:app
Empty file.
187 changes: 187 additions & 0 deletions SolutionToCrowdSourcingData/scraper/blackbird.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,187 @@
import argparse
import asyncio
import json
import os
import random
import subprocess
import sys
import time
import warnings
from datetime import datetime

import aiohttp
from bs4 import BeautifulSoup
from colorama import Fore, init

file = open('data.json')
searchData = json.load(file)
currentOs = sys.platform
path = os.path.dirname(__file__)
warnings.filterwarnings('ignore')

useragents = open('useragents.txt').read().splitlines()
proxy = None


async def findUsername(username, interfaceType):
start_time = time.time()
timeout = aiohttp.ClientTimeout(total=20)

print(f"{Fore.LIGHTYELLOW_EX}[!] Searching '{username}' across {len(searchData['sites'])} social networks\033[0m")

async with aiohttp.ClientSession(timeout=timeout) as session:
tasks = []
for u in searchData["sites"]:
task = asyncio.ensure_future(makeRequest(session, u, username, interfaceType))
tasks.append(task)

results = await asyncio.gather(*tasks)
now = datetime.now().strftime("%m/%d/%Y %H:%M:%S")
executionTime = round(time.time() - start_time, 1)
userJson = {"search-params": {"username": username, "sites-number": len(searchData['sites']), "date": now, "execution-time": executionTime}, "sites": []}
for x in results:
userJson["sites"].append(x)
pathSave = os.path.join(path, 'results', username + '.json')
userFile = open(pathSave, 'w')
json.dump(userJson, userFile, indent=4, sort_keys=True)

print(f"{Fore.LIGHTYELLOW_EX}[!] Search complete in {executionTime} seconds\033[0m")
print(f"{Fore.LIGHTYELLOW_EX}[!] Results saved to {username}.json\033[0m")
return userJson


async def makeRequest(session, u, username, interfaceType):
url = u["url"].format(username=username)
jsonBody = None
useragent = random.choice(useragents)
headers = {
"User-Agent": useragent
}
metadata = []
if 'headers' in u:
headers.update(eval(u['headers']))
if 'json' in u:
jsonBody = u['json'].format(username=username)
jsonBody = json.loads(jsonBody)
try:
async with session.request(u["method"], url, json=jsonBody,proxy=proxy, headers=headers, ssl=False) as response:
responseContent = await response.text()
if 'content-type' in response.headers and "application/json" in response.headers["Content-Type"]:
jsonData = await response.json()
else:
soup = BeautifulSoup(responseContent, 'html.parser')

if eval(u["valid"]):
print(f'{Fore.LIGHTGREEN_EX}[+]\033[0m - #{u["id"]} {Fore.BLUE}{u["app"]}\033[0m {Fore.LIGHTGREEN_EX}account found\033[0m - {Fore.YELLOW}{url}\033[0m [{response.status} {response.reason}]\033[0m')
if 'metadata' in u:
metadata = []
for d in u["metadata"]:
try:
value = eval(d['value']).strip('\t\r\n')
print(f" |--{d['key']}: {value}")
metadata.append({"type": d["type"], "key": d['key'], "value": value})
except Exception as e:
pass
return ({"id": u["id"], "app": u['app'], "url": url, "response-status": f"{response.status} {response.reason}", "status": "FOUND", "error-message": None, "metadata": metadata})
else:
if interfaceType == 'CLI':
if showAll:
print(f'[-]\033[0m - #{u["id"]} {Fore.BLUE}{u["app"]}\033[0m account not found - {Fore.YELLOW}{url}\033[0m [{response.status} {response.reason}]\033[0m')
return ({"id": u["id"], "app": u['app'], "url": url, "response-status": f"{response.status} {response.reason}", "status": "NOT FOUND", "error-message": None, "metadata": metadata})
except Exception as e:
if interfaceType == 'CLI':
if showAll:
print(f'{Fore.RED}[X]\033[0m - #{u["id"]} {Fore.BLUE}{u["app"]}\033[0m error on request ({repr(e)})- {Fore.YELLOW}{url}\033[0m')
return ({"id": u["id"], "app": u['app'], "url": url, "response-status": None, "status": "ERROR", "error-message": repr(e), "metadata": metadata})


def list_sites():
for i, u in enumerate(searchData["sites"], 1):
print(f'{i}. {u["app"]}')


def read_results(file):
try:
pathRead = os.path.join(path, 'results', file)
f = open(pathRead, 'r')
jsonD = json.load(f)
print(f'Loaded results file: {file}')
print(f"Username: {jsonD['search-params']['username']}")
print(f"Number of sites: {jsonD['search-params']['sites-number']}")
print(f"Date: {jsonD['search-params']['date']}")
print('-------------------------------------------------')
for u in jsonD['sites']:
if u['status'] == "FOUND":
print(f'{Fore.LIGHTGREEN_EX}[+]\033[0m - {Fore.BLUE}{u["app"]}\033[0m {Fore.LIGHTGREEN_EX}account found\033[0m - {Fore.YELLOW}{u["url"]}\033[0m [{u["response-status"]}]\033[0m')
if u["metadata"]:
for d in u["metadata"]:
print(f" |--{d['key']}: {d['value']}")
elif u['status'] == "ERROR":
print(f'{Fore.RED}[X]\033[0m - {Fore.BLUE}{u["app"]}\033[0m error on request ({u["error-message"]}) - {Fore.YELLOW}{u["url"]}\033[0m')
elif u['status'] == "NOT FOUND":
print(f'{Fore.WHITE}[-]\033[0m - {Fore.BLUE}{u["app"]}\033[0m account not found - {Fore.YELLOW}{u["url"]}\033[0m [{u["response-status"]}]\033[0m')

except Exception as e:
print(f'{Fore.RED}[X] Error reading file [{repr(e)}]')


if __name__ == '__main__':
init()

print(Fore.RED + """
▄▄▄▄ ██▓ ▄▄▄ ▄████▄ ██ ▄█▀ ▄▄▄▄ ██▓ ██▀███ ▓█████▄
▓█████▄ ▓██▒ ▒████▄ ▒██▀ ▀█ ██▄█▒ ▓█████▄ ▓██▒▓██ ▒ ██▒▒██▀ ██▌
▒██▒ ▄██▒██░ ▒██ ▀█▄ ▒▓█ ▄ ▓███▄░ ▒██▒ ▄██▒██▒▓██ ░▄█ ▒░██ █▌
▒██░█▀ ▒██░ ░██▄▄▄▄██ ▒▓▓▄ ▄██▒▓██ █▄ ▒██░█▀ ░██░▒██▀▀█▄ ░▓█▄ ▌
░▓█ ▀█▓░██████▒▓█ ▓██▒▒ ▓███▀ ░▒██▒ █▄░▓█ ▀█▓░██░░██▓ ▒██▒░▒████▓
░▒▓███▀▒░ ▒░▓ ░▒▒ ▓▒█░░ ░▒ ▒ ░▒ ▒▒ ▓▒░▒▓███▀▒░▓ ░ ▒▓ ░▒▓░ ▒▒▓ ▒
▒░▒ ░ ░ ░ ▒ ░ ▒ ▒▒ ░ ░ ▒ ░ ░▒ ▒░▒░▒ ░ ▒ ░ ░▒ ░ ▒░ ░ ▒ ▒
░ ░ ░ ░ ░ ▒ ░ ░ ░░ ░ ░ ░ ▒ ░ ░░ ░ ░ ░ ░
░ ░ ░ ░ ░░ ░ ░ ░ ░ ░ ░ ░
░ ░ ░ ░

Made with ❤️️ by """ + Fore.BLUE + "p1ngul1n0\n")

parser = argparse.ArgumentParser(description='An OSINT tool to search for accounts by username in social networks.')
parser.add_argument('-u', action='store', dest='username',
required=False,
help='The target username.')
parser.add_argument('--list-sites', action='store_true', dest='list',
required=False,
help='List all sites currently supported.')
parser.add_argument('-f', action='store', dest='file',
required=False,
help='Read results file.')
parser.add_argument('--web', action='store_true', dest='web',
required=False,
help='Run webserver.')
parser.add_argument('--proxy', action='store', dest='proxy',
required=False,
help='Proxy to send requests through.E.g: --proxy http://127.0.0.1:8080 ')
parser.add_argument('--show-all', action='store_true', dest='showAll',
required=False,
help='Show all results.')
arguments = parser.parse_args()

if arguments.proxy:
proxy = arguments.proxy
showAll = False
if arguments.showAll:
showAll = arguments.showAll

if arguments.web:
print('[!] Started WebServer on http://127.0.0.1:9797/')
command = subprocess.run((sys.executable, "webserver.py"))
command.check_returncode()

if arguments.username:
try:
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
except:
pass
interfaceType = 'CLI'
asyncio.run(findUsername(arguments.username, interfaceType))
elif arguments.list:
list_sites()
elif arguments.file:
read_results(arguments.file)
4 changes: 4 additions & 0 deletions SolutionToCrowdSourcingData/scraper/callermodule.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from Blackbird_usecase import scrapeBlackBird
import filter_black_bird
#scrapeBlackBird("elonmusk")
filter_black_bird.filter_BB("elonmusk")
Loading