#NEWLINE# def main( ) : #NEWLINE# #INDENT# global PROCESSES , LOGFILE , OUTPUTFILE , INPUTFILE #NEWLINE# parser = argparse . ArgumentParser ( description = "Check domains' nameservers for public AXFR" ) #NEWLINE# parser . add_argument ( '-i' , '--inputfile' , type = str , nargs = '?' , default = sys . stdin , help = 'Inputfile to read domains from. Default: stdin' ) #NEWLINE# parser . add_argument ( '-o' , '--outputfile' , type = str , nargs = '?' , default = sys . stdout , help = 'Outputfile to write zonedata to. Default: stdout' ) #NEWLINE# parser . add_argument ( '-l' , '--logfile' , type = str , nargs = '?' , default = sys . stderr , help = 'Logfile to use. Default: stderr' ) #NEWLINE# parser . add_argument ( '-p' , '--processes' , type = int , nargs = '?' , default = 20 , help = 'Processes to use. Default: 20' ) #NEWLINE# parser . add_argument ( '-d' , '--domain' , type = str , nargs = '?' , help = 'Domain to check. Ignored if -i is used.' ) #NEWLINE# args = parser . parse_args ( ) #NEWLINE# if ( args . processes <= 0 ) : #NEWLINE# #INDENT# print ( 'Number of processes must be greater than zero.' ) #NEWLINE# sys . exit ( 1 ) #NEWLINE# #UNINDENT# PROCESSES = args . processes #NEWLINE# if ( not ( str ( type ( args . inputfile ) ) == "<class '_io.TextIOWrapper'>" ) ) : #NEWLINE# #INDENT# if ( not os . path . isfile ( args . inputfile ) ) : #NEWLINE# #INDENT# print ( 'Inputfile does not exist.' ) #NEWLINE# sys . exit ( 1 ) #NEWLINE# #UNINDENT# domains = open ( args . inputfile , 'r' ) . readlines ( ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( not ( args . domain is None ) ) : #NEWLINE# #INDENT# domains = [ args . domain ] #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# domains = args . inputfile . readlines ( ) #NEWLINE# #UNINDENT# #UNINDENT# if ( not ( str ( type ( args . outputfile ) ) == "<class '_io.TextIOWrapper'>" ) ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# OUTPUTFILE = open ( args . outputfile , 'w' ) #NEWLINE# #UNINDENT# except : #NEWLINE# #INDENT# print ( 'Outputfile cannot be created.' ) #NEWLINE# sys . exit ( 1 ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# OUTPUTFILE = args . outputfile #NEWLINE# #UNINDENT# if ( not ( str ( type ( args . logfile ) ) == "<class '_io.TextIOWrapper'>" ) ) : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# LOGFILE = open ( PROCESSES . logfile , 'w' ) #NEWLINE# #UNINDENT# except : #NEWLINE# #INDENT# print ( 'Logfile cannot be created.' ) #NEWLINE# sys . exit ( 1 ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# LOGFILE = args . logfile #NEWLINE# #UNINDENT# pool = Pool ( processes = PROCESSES ) #NEWLINE# pool . map ( checkaxfr , domains )