-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFTPScanner.py
More file actions
40 lines (32 loc) · 1003 Bytes
/
FTPScanner.py
File metadata and controls
40 lines (32 loc) · 1003 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/env python
#login to FTP and print the details of root folders
import socket
import os
import time
import threading
import Queue
from ftplib import FTP
ftp_sites=['ftp1.freebsd.org','ftp.it.freebsd.org','ftp.freshrpms.net','ftp.heanet.ie','ftp.it.freebsb.org','ftp.mirror.nl','ftp.ch.freebsb.org','ftp.lublin.pl','ftp.tc-chemitz.de','ftp.tiscali.de']
class WorkerThread(threading.Thread):
def __init__(self,queue,id):
threading.Thread.__init__(self)
self.queue=queue
self.id=id
def run(self):
sites=self.queue.get()
ftp=FTP(sites)
ftp.login()
ftp.retrlines('LIST')
print "finished listing of %s"%sites
self.queue.task_done()
queue=Queue.Queue()
for i in range(5):
print "Creating Worker Thread: %d"%i
worker=WorkerThread(queue,i)
worker.setDaemon(True)
worker.start()
print "Worker Thread %d Created"%i
for x in ftp_sites:
queue.put(x)
queue.join()
print "All Tasks Over"