🤬
  • ■ ■ ■ ■ ■ ■
    monitor.py
     1 +import subprocess
     2 +import pyfiglet
     3 +from optparse import OptionParser
     4 +from discordwebhook import Discord
     5 +import os
     6 +import time
     7 + 
     8 + 
     9 +parser = OptionParser()
     10 + 
     11 +print(pyfiglet.figlet_format("Subdomain Monitor",font='digital'))
     12 + 
     13 +parser.add_option('-d',dest='domain',help='Enter domain name')
     14 +parser.add_option('-w',dest='webhook',help='Enter webhook url')
     15 +parser.add_option('-t',dest='time',help='Time duration')
     16 +val,args = parser.parse_args()
     17 +domain = val.domain
     18 +webhook = val.webhook
     19 +second = val.time
     20 + 
     21 +def send_notification(message):
     22 + return Discord(url=webhook).post(content=message)
     23 + 
     24 +def exec(cmd):
     25 + subprocess.call(cmd,shell=True)
     26 + 
     27 +def amass(output='.amass'):
     28 + exec(f'amass enum -d {domain} -o {output}')
     29 + 
     30 +def subfinder(output='.subfinder'):
     31 + exec(f'subfinder -d {domain} -o {output}')
     32 + 
     33 +def sort(output='.sorted',compare=['.subfinder','.amass']):
     34 + exec(f'cat {compare[0]} {compare[1]} | sort -u > {output}')
     35 + 
     36 +def compare(file1,file2):
     37 + arr = []
     38 + with open(file1,'r') as data1:
     39 + old_subdomains = data1.read().split()
     40 + with open(file2,'r') as data:
     41 + new_subdomains = data.read().split()
     42 + print(old_subdomains)
     43 + print(new_subdomains)
     44 + switch = True
     45 + for subdomain in new_subdomains:
     46 + if subdomain not in old_subdomains:
     47 + arr.append(subdomain)
     48 + with open(file1,'a') as data1:
     49 + #print('Awesome')
     50 + #send_notificaton(f'Got a new subdomain: {subdomain}')
     51 + data1.write(f"{subdomain}\n")
     52 + 
     53 + send_notification(f'[+] Got a new subdomain: {subdomain}')
     54 + for subdomain in arr:
     55 + send_notification(f'Subdomain: {subdomain}')
     56 + 
     57 +def cmd():
     58 + amass()
     59 + subfinder()
     60 + sort()
     61 + 
     62 +#compare('old.txt','new.txt')
     63 + 
     64 + 
     65 +if __name__ == "__main__":
     66 + while True:
     67 + if '.sorted_new' in os.listdir():
     68 + cmd()
     69 + compare('.sorted_new','.sorted')
     70 + time.sleep(int(second))
     71 + else:
     72 + amass()
     73 + #subfinder()
     74 + sort('.sorted_new')
     75 + time.sleep(1)
     76 + 
Please wait...
Page is in error, reload to recover