Skip to content

Instantly share code, notes, and snippets.

@danilovazb
Last active August 29, 2015 14:18
Show Gist options
  • Save danilovazb/1e985bd48e1dae90ba8f to your computer and use it in GitHub Desktop.
Save danilovazb/1e985bd48e1dae90ba8f to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import threading
import time
import urllib2,sys,json,requests,re
import pycurl
import subprocess
from bs4 import BeautifulSoup
from itertools import islice
from datetime import datetime
from optparse import OptionParser
# Máximo de conexões/threads simultâneas
MAX_CONEXOES = 100
# Função para imprimir uma linha por vez via lock
print_lock = threading.Lock()
def mostrar_msg(msg):
print_lock.acquire()
print msg
print_lock.release()
# Função para cada thread
def fuzzear(diretorio,site):
diretorios = []
url = "http://%s/%s" % (site,diretorio)
#print "\033[1;32m[+]\033[0m Consultando diretorio: %s" % diretorio
user_agent = {'User-Agent': 'Mozilla/5.0 (Windows; U; Windows NT 5.1; hu-HU; rv:1.7.8) Gecko/20050511 Firefox/1.0.4'}
#payload = {'cChave': 'ZTViYjBkZTA3YzJmMWI3ZDFhZGU2MGQ2MGQzYjM4NmJfQ0FVVU5JOQ%3D%3D', 'cAction': '', 'cLogin': 'SEU_RA_AQUI', 'cdiretorio': diretorio}
try:
response2 = requests.get(url)
#html = response2.text
#print response2.text
if response2.status_code == 200:
print "\n\033[1;31m[+]\033[0m Diretorio encontrado: \033[1;31m%s\033[0m" % url
else:
lol = "dsd"
except Exception as ex:
lol = "iejf"
def main():
# Thread principal
parser=OptionParser("python fuzz.py -s www.site.com -w wordlist.txt")
parser.add_option('-s',dest='site',type='string',help='passa o site como parametro para realizar o fuzzing, passar o site sem \"http://\", apenas o site da seguinte forma: www.site.com.br')
parser.add_option('-w',dest='wordlist',type='string',help='arquivo com diretorios para realizar o fuzzing')
(option,args)=parser.parse_args()
if(option.site==None) | (option.wordlist==None):
print parser.usage
exit(0)
else:
site=option.site
wordlist=option.wordlist
lista_threads = []
arquivo_diretorio = wordlist
p = subprocess.Popen(['wc', '-l', wordlist], stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
result, err = p.communicate()
total_linhas = result.split(" ")[0]
lin = 0
with open(arquivo_diretorio, 'rb') as arquivo:
for linha in arquivo:
porcent = lin*100/int(total_linhas)
lin += 1
sys.stdout.write("\r%d%%" % porcent)
sys.stdout.flush()
diretorio = linha.strip()
while threading.active_count() > MAX_CONEXOES:
#mostrar_msg("Esperando 1s...")
time.sleep(1)
thread = threading.Thread(target=fuzzear, args=(diretorio,site))
lista_threads.append(thread)
try:
thread.start()
except Exception as ex:
lol = "iejf"
# Esperando pelas threads abertas terminarem
#mostrar_msg("Esperando threads abertas terminarem...")
for thread in lista_threads:
thread.join()
if __name__=='__main__':
try:
main()
except Exception as ex:
lol = "iejf"
@arthurbarros
Copy link

troca o open por io.open

import io
with io.open(...):
     pass 

@danilovazb
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment