Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #FTP Client tool v1.7 by Berzerker
- import os
- import sys
- import ftplib
- import urllib
- from ftplib import FTP
- os.system("clear")
- print("=") * 50
- print("FTP Client")
- print("v1.7")
- print("=") * 50
- ftp=raw_input("Enter FTP server: ")
- username=raw_input("Enter username: ")
- password=raw_input("Enter password: ")
- server=FTP(ftp)
- server.login(username,password)
- os.system("clear")
- print("=") * 50
- print("FTP Client")
- print("v1.7")
- print("=") * 50
- print("You are connected to FTP server...")
- print("You may use the terminal now...")
- print("You can type help to pull up the help menu...")
- print("You can type about to pull up the credits...")
- while True:
- try:
- command=raw_input("==>")
- if command=="about":
- print("Head programmer - Berzerker")
- print("Code hosting - http://pastebin.com")
- print("Special thanks - All of Psyko Security")
- elif command=="help":
- print("The following are commands that can be used...")
- print("Type help(COMMAND) for more details...")
- print("Type about for the credits...")
- print("clear_scr - Clear the screen")
- print("cwd - Change directory")
- print("pwd - Display current directory")
- print("dir - List directories")
- print("nlst - List file names")
- print("size - Returns the size of a file")
- print("rename - Rename a file")
- print("delete - Delete a file")
- print("mkd - Make a directory")
- print("rmd - Remove a directory")
- print("retr - Retrieve a file")
- print("stor - Store a file")
- print("close - Closes the connection")
- elif command=="help(clear)":
- print("Clears the screen...")
- elif command=="help(cwd)":
- print("Changes directory")
- print("Format: cwd DIRECTORYNAME")
- elif command=="help(pwd)":
- print("Displays the current directory")
- elif command=="help(dir)":
- print("List directories")
- elif command=="help(nlst)":
- print("Lists file names")
- elif command=="help(size)":
- print("Returns the size of a file")
- print("Format: size FILE")
- elif command=="help(rename)":
- print("Renames a file")
- print("Format: rename FROM TO")
- elif command=="help(delete)":
- print("Deletes a file")
- print("Format: delete FILE")
- elif command=="help(mkd)":
- print("Make a directory")
- print("Format:mkd PATHNAME")
- elif command=="help(rmd)":
- print("Remove a directory")
- print("Format: rmd PATHNAME")
- elif command=="help(retr)":
- print("Retrieve a file")
- print("Format: retr FILENAME")
- elif command=="help(stor)":
- print("Store a file")
- print("Format: stor FILENAME")
- elif command=="help(close)":
- print("Closes the connection")
- elif command=="clear":
- os.system("clear")
- elif "cwd" in command:
- part1, part2=command.split(" ")
- server.cwd(part2)
- path=server.pwd()
- elif command=="pwd":
- response=server.pwd()
- print(response)
- elif command=="dir":
- server.dir()
- elif command=="nlst":
- response=server.nlst()
- print(response)
- elif "size" in command:
- part1, part2=command.split(" ")
- response=server.size(part2)
- print(response)
- elif "rename" in command:
- part1, part2, part3=command.split(" ")
- server.rename(part2, part3)
- print("File renamed!")
- elif "delete" in command:
- part1, part2=command.split(" ")
- server.delete(part2)
- print("File deleted!")
- elif "mkd" in command:
- part1, part2=command.split(" ")
- server.mkd(part2)
- print("Directory created!")
- elif "rmd" in command:
- part1, part2=command.split(" ")
- server.rmd(part2)
- print("Directory removed!")
- elif "retr" in command:
- part1, part2=command.split(" ")
- def getbinary(ftp, filename, outfile=None):
- if outfile is None:
- outfile = sys.stdout
- server.retrbinary("RETR " + filename, outfile.write)
- print()
- getbinary(server, part2)
- elif "stor" in command:
- part1, part2=command.split(" ")
- def upload(ftp, file):
- ext = os.path.splitext(file)[1]
- if ext in (".txt", ".htm", ".html"):
- server.storlines("STOR " + file, open(file))
- else:
- server.storbinary("STOR " + file, open(file, "rb"), 1024)
- upload(server, part2)
- elif command=="close":
- server.close()
- print("Connection closed")
- os.system("exit")
- except ftplib.all_errors:
- print("An error occurred...")
- print("Goodbye...")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement