sarabb 0 Newbie Poster

HI,
I am trying to write a script to find some mp3 file in some sites. But the code doesn't give any result.

any help please ?

#!/usr/bin/python

import sys,os, re, urllib2, socket ,string

if sys.platform == 'linux-i386' or sys.platform == 'linux2' or sys.platform == 'darwin':
	SysCls = 'clear'
elif sys.platform == 'win32' or sys.platform == 'dos' or sys.platform[0:5] == 'ms-dos':
	SysCls = 'cls'
else:
	SysCls = 'unknown'

os.system(SysCls)

print "\n|---------------------------------------------------------------|"
print "| file finder..                            |"
print "|---------------------------------------------------------------|\n"

if len(sys.argv) < 2: 
	print "\nUsage: ./finder.py sitelist.txt" 
	print "Ex: ./finder.py list.txt\n" 
	sys.exit(1)

list= sys.argv[1]
try:

	hosts= open(list,'r')
except (IOError):
	print " \n\nSite List Missing ..Exiting :("
	sys.exit(0)

paths = ["example.mp3"]

for host in hosts:
 	host=host[:-1]
	socket.setdefaulttimeout(10)
	file=open ('result.txt' , 'a')
	file.write(host +'\t : ') 
	print "[+] SitePath:",host 
	print "[+] Site. Loaded:",len(paths) 
	if host[:7] != "http://": 
		host = "http://"+host 
	if host[-1:] != "/": 
		host = host+"/" 
	print "[+] Testing..." 
	for path in paths: 
		try: 
			#print host+path 
			source = urllib2.urlopen(host+path, "80").readlines() 
			for line in source:
				print "\nHost:",host+path 
											
				print "Found:" 
						

		except(urllib2.URLError, socket.timeout, socket.gaierror, socket.error): 
				pass 
		except(KeyboardInterrupt): 
				pass 
		
	print "\n[-] Done\n"
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.