<s> import urllib2 , re , sys <EOL> from urlparse import urlparse <EOL> from threading import Thread <EOL> USER_AGENT = '<STR_LIT>' <EOL> DEPTH = <NUM_LIT:1> <EOL> LFI_DEPTH = <NUM_LIT:8> <EOL> def Verify ( url ) : <EOL> try : <EOL> resp = get ( url ) <EOL> if re . findall ( "<STR_LIT>" , resp ) : <EOL> print "<STR_LIT>" + url <EOL> sys . exit ( <NUM_LIT:0> ) <EOL> except : <EOL> sys . exit ( <NUM_LIT:0> ) <EOL> def LFIFuzzer ( url , lfi_depth ) : <EOL> path_formats = [ "<STR_LIT>" , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ] <EOL> FUZZ_URLS = [ ] <EOL> for path in path_formats : <EOL> for d in range ( <NUM_LIT:0> , lfi_depth ) : <EOL> FUZZ_URLS . append ( url + path + "<STR_LIT>" ) <EOL> path += path <EOL> for x in FUZZ_URLS : <EOL> t = Thread ( target = Verify , args = ( x , ) ) <EOL> t . start ( ) <EOL> def rreplace ( s , old , new , occurrence ) : <EOL> li = s . rsplit ( old , occurrence ) <EOL> return new . join ( li ) <EOL> def get ( url ) : <EOL> try : <EOL> req = urllib2 . Request ( url ) <EOL> req . add_header ( '<STR_LIT>' , USER_AGENT ) <EOL> resp = urllib2 . urlopen ( req ) <EOL> return unicode ( resp . read ( ) , "<STR_LIT:utf-8>" , errors = "<STR_LIT:replace>" ) <EOL> except urllib2 . HTTPError , error : <EOL> print "<STR_LIT>" + str ( error ) <EOL> sys . exit ( <NUM_LIT:0> ) <EOL> except urllib2 . URLError , error : <EOL> sys . exit ( <NUM_LIT:0> ) <EOL> def Parse ( url ) : <EOL> try : <EOL> parse_url = urlparse ( url ) <EOL> base_url = '<STR_LIT>' . format ( uri = parse_url ) <EOL> html = get ( url ) <EOL> link_re = re . compile ( r'<STR_LIT>' ) <EOL> allurls = link_re . findall ( html ) <EOL> allurls = list ( set ( allurls ) ) <EOL> f_urls = [ ] <EOL> f_urls . append ( base_url ) <EOL> for ul in allurls : <EOL> tmp_ul = '<STR_LIT>' <EOL> dblslah = False <EOL> if ul . startswith ( "<STR_LIT>" ) : <EOL> dblslah = True <EOL> if ( urlparse ( url ) . hostname ) in ( urlparse ( ul ) . hostname ) : <EOL> tmp_ul = "<STR_LIT>" + ul <EOL> elif ul . startswith ( "<STR_LIT:/>" ) and dblslah == False : <EOL> tmp_ul = base_url + ul <EOL> elif ul . startswith ( "<STR_LIT:http>" ) : <EOL> if ( urlparse ( url ) . hostname ) in ( urlparse ( ul ) . hostname ) : <EOL> tmp_ul = ul <EOL> if tmp_ul not in f_urls : <EOL> f_urls . append ( tmp_ul ) <EOL> f_urls = list ( set ( f_urls ) ) <EOL> final_urls = [ ] <EOL> for u in f_urls : <EOL> tmp_dbl_slash = u . replace ( "<STR_LIT>" , "<STR_LIT>" , <NUM_LIT:1> ) <EOL> if ( "<STR_LIT>" ) not in tmp_dbl_slash : <EOL> if tmp_dbl_slash . endswith ( '<STR_LIT:/>' ) : <EOL> if tmp_dbl_slash not in final_urls : <EOL> final_urls . append ( tmp_dbl_slash . replace ( "<STR_LIT>" , "<STR_LIT>" , <NUM_LIT:1> ) ) <EOL> tmp_dbl_slash = rreplace ( tmp_dbl_slash , '<STR_LIT:/>' , '<STR_LIT>' , <NUM_LIT:1> ) <EOL> sep_count = tmp_dbl_slash . count ( "<STR_LIT:/>" ) <EOL> while ( sep_count > <NUM_LIT:0> ) : <EOL> x = tmp_dbl_slash . split ( '<STR_LIT:/>' ) [ - <NUM_LIT:1> ] <EOL> tmp_dbl_slash = rreplace ( tmp_dbl_slash , x , "<STR_LIT>" , <NUM_LIT:1> ) <EOL> if tmp_dbl_slash not in final_urls : <EOL> final_urls . append ( tmp_dbl_slash . replace ( "<STR_LIT>" , "<STR_LIT>" , <NUM_LIT:1> ) ) <EOL> tmp_dbl_slash = tmp_dbl_slash [ : - <NUM_LIT:1> ] <EOL> sep_count -= <NUM_LIT:1> <EOL> final_urls = list ( set ( final_urls ) ) <EOL> return f_urls , final_urls <EOL> except Exception as e : <EOL> print "<STR_LIT>" + str ( e ) <EOL> def getURLS ( url , depth , lfi_depth ) : <EOL> print "<STR_LIT>" <EOL> VALIDURLS , PATHURLS = Parse ( url ) <EOL> if PATHURLS : <EOL> for x in PATHURLS : <EOL> LFIFuzzer ( x , lfi_depth ) <EOL> getURLS ( sys . argv [ <NUM_LIT:1> ] , DEPTH , LFI_DEPTH ) </s>
