Skip to content

Instantly share code, notes, and snippets.

@g4rcez
Created July 25, 2017 04:51
Show Gist options
  • Save g4rcez/24b7eb54f6f24774a21f80caec6ca376 to your computer and use it in GitHub Desktop.
Save g4rcez/24b7eb54f6f24774a21f80caec6ca376 to your computer and use it in GitHub Desktop.
SiteWatcher - Script para buscar diretórios e subsites de um site específico
#!/usr/bin/python3
import sys
import os
import platform
class OS():
sistema = platform.system()
hostname = platform.node()
def basename(stdin):
return Stdin.array2String(stdin).split('/')[-1]
class Stdin():
def getOptAndValue(stdin, parametros):
try:
for flag in stdin:
if flag in parametros:
return stdin[stdin.index(flag) + 1]
except:
return None
def getOpt(stdin, parametros):
try:
for flag in stdin:
if flag in parametros:
return True
except:
return False
try:
import requests
except:
print("Deseja instalar a biblioteca requests? [Y/n]")
vaiInstalar = input()
if vaiInstalar in ('Y', 'y', 's', 'S'):
os.system("sudo pip3 install requests")
else:
exit()
def returnIntoFile(site, path, mode, referer='http://www.xuxa.com/'):
arqhash = open("/tmp/sitewatcher", 'w')
loghash = []
arq = open(path, 'r')
texto = arq.readlines()
tmp = site
header = {
'user-agent': 'AppleWebKit/537.36 (KHTML, like Gecko)',
'referer': referer
}
for linha in texto:
if mode == "sub":
print("SubMode")
site = site.replace("www.", "")
tmp = "http://"+linha.replace("\n", "")+"."+site
tmp = tmp.strip()
else:
tmp = "http://" + site + linha.replace("\n", "")
tmp = tmp.strip()
try:
req = requests.get(tmp, headers=header)
if req.status_code == 200:
print('\n' + "[\033[32m+Online+\033[00m] => " + tmp, end='')
var = "[Online] => " + tmp
loghash.append(var)
loghash.append('\n')
except:
pass
arq.close()
arqhash.writelines(loghash)
arqhash.close()
namescript = sys.argv[0]
stdin = sys.argv[1:]
try:
namescript = namescript.split('/')[1]
except:
pass
site = ''
arquivo = ''
if Stdin.getOpt(stdin, '-t'):
site = Stdin.getOptAndValue(stdin, '-t')
elif Stdin.getOpt(stdin, '--target'):
site = Stdin.getOptAndValue(stdin, '--target')
else:
site = input('Por favor, informe um site para a análise: ')
if Stdin.getOpt(stdin, '-f'):
arquivo = Stdin.getOptAndValue(stdin, '-f')
elif Stdin.getOpt(stdin, '--file'):
arquivo = Stdin.getOptAndValue(stdin, '--file')
else:
arquivo = input("Por favor, informe um arquivo com sua wordlist: ")
try:
site = site.strip()
print("Scan no site: " + site)
site = site.replace("http://", "")
site = site.replace("https://", "")
if Stdin.getOpt(stdin, "-r"):
Stdin.getOptAndValue(Stdin, '-r')
elif Stdin.getOpt(stdin, "--referer"):
Stdin.getOptAndValue(Stdin, '--referer')
else:
if Stdin.getOpt(stdin, "--sub") or Stdin.getOpt(stdin, "-s"):
returnIntoFile(site, arquivo, "sub")
else:
returnIntoFile(site, arquivo, "dir")
except:
print("Não foi possível estabelecer uma conexão com: " + site)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment