Dirb | Enumeração de diretórios | Solyd One
- Dirb | Enumeração de diretórios | Solyd One
info
Quando o site possui parâmetros como ?page=index.html, podemos testar se caminhos como ../../../..... etc/passwd estão acessíveis. Olhar documentação sobre LFI e RFI
Obter diretórios
- Ele possui scripts com as wordslist pré prontas, mas podemos adicionar a nossa lista
dirb <url_site>
Brute force de diretórios
import sys
import requests
def brute(url, wordlist):
for word in wordlist:
try:
url_final = "{}/{}".format(url, word.strip())
response = requests.get(url_final)
code = response.status_code
if code != 404:
print("{} -- {}".format(url_final, code))
except KeyboardInterrupt:
sys.exit(0)
except Exception as error:
print(error)
pass
if __name__ == "__main__":
url = sys.argv[1]
wordlist = sys.argv[2]
with open(wordlist, "r") as file:
wordlist = file.readlines()
brute(url, wordlist)
Web Crawler | Script
import sys
import requests
from bs4 import BeautifulSoup
TO_CRAWL = []
CRAWLED = set()
def request(url):
header = {"User-Agent": "Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0"}
try:
response = requests.get(url, headers=header)
return response.text
except KeyboardInterrupt:
sys.exit(0)
except:
pass
def get_links(html):
links = []
try:
soup = BeautifulSoup(html, "html.parser")
tags_a = soup.find_all("a", href=True)
for tag in tags_a:
link = tag["href"]
if link.startswith("http"):
links.append(link)
return links
except:
pass
def crawl():
while 1:
if TO_CRAWL:
url = TO_CRAWL.pop()
html = request(url)
if html:
links = get_links(html)
if links:
for link in links:
if link not in CRAWLED and link not in TO_CRAWL:
TO_CRAWL.append(link)
print("Crawling {}".format(url))
CRAWLED.add(url)
else:
CRAWLED.add(url)
else:
print("Done")
break
if __name__ == "__main__":
url = sys.argv[1]
TO_CRAWL.append(url)
crawl()
Email Crawler | Script
import sys
import re
import requests
from bs4 import BeautifulSoup
TO_CRAWL = []
CRAWLED = set()
EMAILS = []
def request(url):
header = {"User-Agent": "Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0"}
try:
response = requests.get(url, headers=header)
return response.text
except KeyboardInterrupt:
sys.exit(0)
except:
pass
def get_links(html):
links = []
try:
soup = BeautifulSoup(html, "html.parser")
tags_a = soup.find_all("a", href=True)
for tag in tags_a:
link = tag["href"]
if link.startswith("http"):
links.append(link)
return links
except:
pass
def get_emails(html):
emails = re.findall(r"\w[\w\.]+\w@\w[\w\.]+\w", html)
return emails
def crawl():
while 1:
if TO_CRAWL:
url = TO_CRAWL.pop()
html = request(url)
if html:
links = get_links(html)
if links:
for link in links:
if link not in CRAWLED and link not in TO_CRAWL:
TO_CRAWL.append(link)
emails = get_emails(html)
for email in emails:
if email not in EMAILS:
print(email)
EMAILS.append(email)
CRAWLED.add(url)
else:
CRAWLED.add(url)
else:
print("Done")
break
if __name__ == "__main__":
url = sys.argv[1]
TO_CRAWL.append(url)
crawl()