Hello,
Encore un exercice que je doit résoudre:
- create a list of ftp sites
- create a worker thread and queue witch can login to these sites
and list the root directory and exit
- use 5 threads for this job and 10 ftp sites
Alors le premier essai n'est pas beau (ni le script , ni le résultat), mais il est plus ou moins fonctionnel, j'ai pris plusieurs sources en essayant d’interner tout ça a un de mes scripts.
J’avoue que je doit faire quelques recherches supplémentaires pour tout comprendre ^^
Soyez indulgent et ne tapez pas trop fort :) , c'est un premier test !!!
Voilà le script:
voila le script
Et son résultat :
Encore un exercice que je doit résoudre:
Citation:
- create a list of ftp sites
- create a worker thread and queue witch can login to these sites
and list the root directory and exit
- use 5 threads for this job and 10 ftp sites
J’avoue que je doit faire quelques recherches supplémentaires pour tout comprendre ^^
Soyez indulgent et ne tapez pas trop fort :) , c'est un premier test !!!
Voilà le script:
voila le script
Code:
import threading
from Queue import Queue
from ftplib import FTP
ftp_sites=['ftp.x.org',
'ftp4.FreeBSD.org',
'ftp.ncsa.uiuc.edu',
'ftp.mozilla.org',
'ftp.crans.org',
'ftp1.freebsd.org',
'ftp.cica.indiana.edu',
'ftp.ncsa.uiuc.edu',
'ftp.ctr.columbia.edu',
'ftp.univ-rennes1.frpub']
def CFTP(host) :
try:
# connect to FTP site
ftp = FTP(host)
print ftp.getwelcome()
ftp.login()
# send LIST command
ftp.retrlines('LIST')
print "\n"
# retrieve files
#ftp.retrbinary('RETR README', open('README', 'wb').write)
ftp.quit()
except:
print "\n"
def threader():
while True:
worker = q.get()
CFTP(worker)
q.task_done()
q = Queue()
for x in range(5):
t = threading.Thread(target=threader)
t.daemon = True
t.start()
for worker in ftp_sites:
q.put(worker)
q.join()
print "All tasks completed"
Code:
220 (vsFTPd 2.3.5)
220 This is ftp0.bme.freebsd.org - hosted at Bytemark.co.uk
220 ProFTPD 1.3.1 Server (X.Org) [::ffff:18.7.25.161]
220 ftp.ncsa.illinois.edu FTP Server (Apache/2.2.3 (CentOS) PHP/5.1.6 mod_ftp/0.9.6) ready.220-
220- ftp.mozilla.org / archive.mozilla.org - files are in /pub/mozilla.org
220-
220- releases.mozilla.org now points to our CDN distribution network and no longer works for FTP traffic
220
lrwxrwxrwx 1 0 0 10 Jun 14 2012 custom -> pub/custom
lrwxrwxrwx 1 9865 9865 10 May 24 2012 debian -> pub/debian
lrwxrwxrwx 1 9865 9865 20 May 27 2012 debian-backports -> pub/debian-backports
lrwxrwxrwx 1 9865 9865 22 May 24 2012 debian-multimedia -> pub/debian-multimedia/
lrwxrwxrwx 1 9865 9865 20 May 24 2012 debian-security -> pub/debian-security/
lrwxrwxrwx 1 0 0 10 Apr 14 2014 events -> pub/events
drwxrwsr-x 27 0 4 4096 Jan 27 2014 git
drwx------ 2 9865 9865 16384 Jun 08 2012 lost+found
drwxr-xr-x 14 9865 9865 4096 Nov 26 2013 pub
lrwxrwxrwx 1 9865 9865 11 May 24 2012 ubuntu -> pub/ubuntu/
lrwxrwxrwx 1 0 0 12 Jun 14 2012 videolan -> pub/videolan
-rw-r--r-- 1 ftp ftp 5430 Jul 19 2014 favicon.ico
-rw-r--r-- 1 ftp ftp 655 Nov 24 2014 index.html
drwxr-xr-x 3 ftp ftp 3 Jul 19 2014 pub
220 moss.cse.buffalo.edu FTP server (Version wu-2.6.2(1) Mon Aug 2 14:04:46 EDT 2010) ready.
-rw-r--r-- 2 ftp ftp 479 Nov 6 2001 banner2
lrwxrwxrwx 1 ftp ftp 7 Oct 9 2005 bin -> usr/bin
drwxr-xr-x 34 ftp ftp 4096 Nov 6 2001 contrib
d--x--x--x 2 ftp ftp 4096 Aug 8 2001 dev
drwxr-xr-x 2 ftp ftp 4096 Oct 12 1998 digest
d--x--x--x 3 ftp ftp 4096 Aug 8 2001 etc
-rw-r--r-- 1 ftp ftp 3075 Oct 7 1998 GettingBroadway
-rw-r--r-- 1 ftp ftp 3075 Oct 7 1998 GettingR6.3
-rw-r--r-- 1 ftp ftp 1847 Feb 1 1999 GettingR6.4
-rw-r--r-- 1 ftp ftp 1378 Aug 24 2000 GettingR6.5.1
-rw-r--r-- 1 ftp ftp 1229 Apr 24 2001 GettingR6.6
-rw-r--r-- 1 ftp ftp 301 Dec 22 2005 GettingR6.7
-rw-r--r-- 1 ftp ftp 396 Dec 22 2005 GettingR6.8
-rw-r--r-- 1 ftp ftp 396 Dec 22 2005 GettingR6.9
-rw-r--r-- 1 ftp ftp 396 Dec 22 2005 GettingR7.0
-rw-r--r-- 1 ftp ftp 195 Dec 30 2004 MIRROR.README
drwxrwxr-x 36 ftp ftp 4096 Jun 30 2013 pub
drwxr-xr-x 56 ftp ftp 24576 May 4 2001 R5contrib
drwxr-xr-x 2 ftp ftp 4096 May 4 2001 rcsfaq
-r--r--r-- 1 ftp ftp 1571 Dec 22 2005 README
lrwxrwxrwx 1 ftp ftp 6 Nov 27 2005 README.txt -> README
d--x--x--x 5 ftp ftp 4096 Aug 8 2001 usr
-rw-r--r-- 2 ftp ftp 479 Nov 6 2001 welcome.msg
220 ftp.ncsa.illinois.edu FTP Server (Apache/2.2.3 (CentOS) PHP/5.1.6 mod_ftp/0.9.6) ready.
-rw-r--r-- 1 ftp ftp 178 Apr 25 2014 README
drwxr-xr-x 41 ftp ftp 4096 May 21 16:20 pub
-rw-r--r-- 1 12873 floppy 784 Aug 22 1994 .index
-rw-r--r-- 1 80 root 663 Jan 7 1995 .message
-rw-r--r-- 1 80 root 25819 Dec 29 1994 Brochure
drwx------ 2 80 ncsa 2048 Jun 16 1998 Cyberia
drwxr-xr-x 2 12873 root 2048 Aug 22 1994 DTM
drwxrwxrwx 4 root root 2048 Dec 4 2003 Director
drwxr-xr-x 13 14453 root 2048 Aug 22 1994 Documentation
drwxr-xr-x 9 root root 2048 Feb 5 1997 Education
drwxrwxrwx 2 root root 2048 Apr 9 1996 FigLeaf
drwxr-xr-x 13 19099 root 2048 Aug 22 1994 GlobalModels
drwxr-xr-x 8 12873 root 2048 May 17 1996 Mac
drwxr-xr-x 10 12873 root 2048 Feb 15 2002 Mosaic
drwxr-xr-x 5 12873 root 2048 Jan 5 1995 PC
-rw-r--r-- 1 80 root 16557 Jan 3 1995 README
-rw-r--r-- 1 12873 root 1933 Jan 12 1995 README.FIRST
drwxr-xr-x 5 12873 root 2048 Feb 15 2002 SGI
drwxr-xr-x 4 12873 root 2048 Dec 20 1994 Telnet
drwxr-xr-x 7 12873 root 2048 Aug 24 1994 Unix
drwxrwxrwx 12 root root 2048 Jan 30 2004 VR
drwxr-xr-x 24 12873 root 2048 May 31 1997 Visualization
drwxrwxrwx 2 root root 2048 May 20 1996 Vosaic
drwxr-xr-x 6 12873 root 2048 May 16 1997 Web
drwxrwxrwx 24 root root 2048 Sep 22 2006 aces
drwxr-xr-x 10 12873 root 2048 Aug 22 1994 aff
drwxrwxrwx 2 root root 2048 Jul 24 2002 aips
drwxrwxrwx 12 root root 43008 Jun 6 22:11 alg
drwxrwxrwx 4 root root 2048 Mar 17 2003 benchmarks
dr-xrwxrwx 2 root root 2048 Apr 21 2006 bin
drw-r--r-- 2 15332 wheel 2048 Jan 27 1999 chemistry
drwxrwxrwx 68 root root 4096 Apr 12 2007 cosmic
drwx------ 3 80 ncsa 2048 May 24 2002 dbalsara
drwx------ 2 80 games 2048 Dec 23 1997 emerge
drwxr-xr-x 3 80 root 2048 Jun 27 2006 etc
drwxr-xr-x 4 80 sys 2048 May 12 2009 incoming
drwx------ 3 80 games 2048 Aug 25 1997 javatotal 10
drwx------ 2 80 games 2048 Jul 22 1997 jouledrwxrwxr-x 2 0 5 512 Apr 2 2014 .snap
drwx------ 7 80 ncsa 2048 Jun 5 2000 lcadrwxr-xr-x 2 0 0 512 Aug 1 2008 bin
drwxrwxrwx 2 root root 2048 Nov 9 2001 libdrwxr-xr-x 4 89987 546 512 Apr 4 2014 mirror
drwxrwxrwx 16 root root 2048 Sep 25 2003 mediadrwxrwxr-x 2 89987 546 512 Jun 14 2009 pub
drwxr-xr-x 14 12873 root 2048 Nov 21 2001 miscdrwxr-xr-x 3 0 0 512 Dec 9 2014 users
drwxrwxrwx 21 root root 2048 Mar 16 2001 ncsapubs
drwxrwxrwx 14 root root 2048 Oct 3 2007 netdev
drwxrwxr-x 31 12984 wheel 2048 Mar 19 10:51 outgoing
drwxr-xr-x 4 12873 root 2048 Dec 21 1999 sc22wg5
drwx------ 2 nobody games 2048 Mar 15 2007 security
drwxr-xr-x 2 root root 2048 Dec 22 1999 x3j3
-rw-r--r-- 1 12873 floppy 784 Aug 22 1994 .index
-rw-r--r-- 1 80 root 663 Jan 7 1995 .message
-rw-r--r-- 1 80 root 25819 Dec 29 1994 Brochure
drwx------ 2 80 ncsa 2048 Jun 16 1998 Cyberia
drwxr-xr-x 2 12873 root 2048 Aug 22 1994 DTM
drwxrwxrwx 4 root root 2048 Dec 4 2003 Director
drwxr-xr-x 13 14453 root 2048 Aug 22 1994 Documentation
drwxr-xr-x 9 root root 2048 Feb 5 1997 Education
drwxrwxrwx 2 root root 2048 Apr 9 1996 FigLeaf
drwxr-xr-x 13 19099 root 2048 Aug 22 1994 GlobalModels
drwxr-xr-x 8 12873 root 2048 May 17 1996 Mac
drwxr-xr-x 10 12873 root 2048 Feb 15 2002 Mosaic
drwxr-xr-x 5 12873 root 2048 Jan 5 1995 PC
-rw-r--r-- 1 80 root 16557 Jan 3 1995 README
-rw-r--r-- 1 12873 root 1933 Jan 12 1995 README.FIRST
drwxr-xr-x 5 12873 root 2048 Feb 15 2002 SGI
drwxr-xr-x 4 12873 root 2048 Dec 20 1994 Telnet
drwxr-xr-x 7 12873 root 2048 Aug 24 1994 Unix
drwxrwxrwx 12 root root 2048 Jan 30 2004 VR
drwxr-xr-x 24 12873 root 2048 May 31 1997 Visualization
drwxrwxrwx 2 root root 2048 May 20 1996 Vosaic
drwxr-xr-x 6 12873 root 2048 May 16 1997 Web
drwxrwxrwx 24 root root 2048 Sep 22 2006 aces
drwxr-xr-x 10 12873 root 2048 Aug 22 1994 aff
drwxrwxrwx 2 root root 2048 Jul 24 2002 aips
drwxrwxrwx 12 root root 43008 Jun 6 22:11 alg
drwxrwxrwx 4 root root 2048 Mar 17 2003 benchmarks
dr-xrwxrwx 2 root root 2048 Apr 21 2006 bin
drw-r--r-- 2 15332 wheel 2048 Jan 27 1999 chemistry
drwxrwxrwx 68 root root 4096 Apr 12 2007 cosmic
drwx------ 3 80 ncsa 2048 May 24 2002 dbalsara
drwx------ 2 80 games 2048 Dec 23 1997 emerge
drwxr-xr-x 3 80 root 2048 Jun 27 2006 etc
drwxr-xr-x 4 80 sys 2048 May 12 2009 incoming
drwx------ 3 80 games 2048 Aug 25 1997 java
drwx------ 2 80 games 2048 Jul 22 1997 joule
drwx------ 7 80 ncsa 2048 Jun 5 2000 lca
drwxrwxrwx 2 root root 2048 Nov 9 2001 lib
drwxrwxrwx 16 root root 2048 Sep 25 2003 media
drwxr-xr-x 14 12873 root 2048 Nov 21 2001 misc
drwxrwxrwx 21 root root 2048 Mar 16 2001 ncsapubs
drwxrwxrwx 14 root root 2048 Oct 3 2007 netdev
drwxrwxr-x 31 12984 wheel 2048 Mar 19 10:51 outgoing
drwxr-xr-x 4 12873 root 2048 Dec 21 1999 sc22wg5
drwx------ 2 nobody games 2048 Mar 15 2007 security
drwxr-xr-x 2 root root 2048 Dec 22 1999 x3j3
All tasks completed
from Hackademics : Forum de hacking hackers white hat cours de securite informatique, apprendre langage python, tutoriels de reverse engineering http://ift.tt/1U4DUHQ
via IFTTT
Aucun commentaire:
Enregistrer un commentaire