Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl
- ###
- #nFTP v1.0
- #Author: N3mes1s
- #E-mail:dottorjekill_mister[at]tiscali[dot]it
- #Using: perl <nFTP.pl>
- #Description: This is a simple shell FTP with module Net::FTP;
- #Development date: 28/12/2008
- ###
- use Net::FTP;
- use strict;
- use Switch;
- print "Insert Name HOST:\t";
- chomp(my $site=<STDIN>);
- print "Insert Username:\t";
- chomp(my $usr=<STDIN>);
- print "Insert User Password:\t";
- chomp(my $passw=<STDIN>);
- my $ftp=Net::FTP->new($site)
- or die "Impossible connect to $site\n";
- $ftp->login($usr,$passw)
- or die "Username or Password error.\n";
- print "Connect to $site\n";
- command();
- #Sub Main
- sub Main {
- print"\nnFTP>";
- chomp(my $cmd=<STDIN>);
- switch($cmd) {
- case "ls" {ls();}
- case "mkdir" {mkdire();}
- case "rmdir" {rmdire();}
- case "get" {get();}
- case "put" {put();}
- case "del" {del();}
- case "ren" {ren();}
- case "cd" {cd();}
- case "help" {command();}
- case "man" {man();}
- case "exit" {print "Thanks For Using nFTP by N3mes1s. Bye!\n"; exit(); }
- }
- }
- #Sub Command
- sub command {
- print q(
- [+] ls
- [+] mkdir
- [+] rmdir
- [+] get
- [+] put
- [+] del
- [+] ren
- [+] cd
- [+] help
- [+] man
- [+] exit
- );
- Main();
- }
- #Sub ls
- sub ls {
- my @dir =$ftp->ls();
- foreach my $lst(@dir) {
- print "[-] $lst\n";
- }
- Main();
- }
- #Sub exit
- #sub exiti {
- # $ftp->quit();
- # Main;
- #}
- #Sub mkdir
- sub mkdire {
- print "nFTP>Insert Name Dir: ";
- chomp(my $dir=<STDIN>);
- if($ftp->mkdir($dir)){
- print"nFTP> Dir Created";
- Main();
- }
- else {
- print "nFTP>Error";
- Main();
- }
- }
- #Sub rmDir
- sub rmdire {
- print "nFTP>Insert Name Dir: ";
- chomp(my $dir =<STDIN>);
- if($ftp->rmdir($dir)) {
- print "nFTP> Dir Deleted";
- Main();
- }
- else {
- print "nFTP>Error";
- Main();
- }
- }
- #Sub Get
- sub get {
- print "nFTP>Insert Name File: ";
- chomp(my $file =<STDIN>);
- if($ftp->get($file)) {
- print "nFTP>Download Complete";
- Main();
- }
- else {
- print "nFTP>Error";
- Main();
- }
- }
- #Sub Put
- sub put {
- print "nFTP>Insert Name File: ";
- chomp(my $file=<STDIN>);
- if($ftp->put($file)) {
- print "nFTP>File Uploaded";
- Main();
- }
- else {
- print "nFTP>Error";
- Main();
- }
- }
- #Sub Del
- sub del {
- print "nFTP>Insert Name File: ";
- chomp(my $file=<STDIN>);
- if($ftp->delete($file)) {
- print "nFTP>File Deleted";
- Main();
- }
- else {
- print "nFTP>Error";
- Main();
- }
- }
- #Sub ren
- sub ren {
- print "nFTP>Insert Name File: ";
- chomp(my $file=<STDIN>);
- print "nFTP>Insert NEW Name File: ";
- chomp(my $rmfile=<STDIN>);
- if($ftp->rename($file,$rmfile)) {
- print "nFTP>Rename Completed";
- Main();
- }
- else {
- print "nFTP>Error";
- Main();
- }
- }
- #Sub cd
- sub cd {
- print "nFTP>Insert Name Dir: ";
- chomp(my $dir=<STDIN>);
- if($ftp->cwd($dir)) {
- print"nFTP/$dir>Ok";
- Main();
- }
- else {
- print "nFTP>Error";
- Main;
- }
- }
- #Sub Man
- sub man {
- print q(
- It's a User Guide:
- Using Example :
- nFTP>ls
- [-] Joomla
- [-] css
- [-] images
- [-] index.html
- [-] templateDetails.xml
- [-] template_thumbnail.png
- nFTP>cd
- nFTP>Insert Name Dir: Joomla
- nFTP/Joomla>Ok
- nFTP>ls
- [-] administrator
- [-] cache
- [-] components
- [-] images
- [-] includes
- [-] installation
- [-] language
- [-] libraries
- [-] logs
- [-] media
- [-] modules
- [-] plugins
- [-] templates
- [-] tmp
- [-] xmlrpc
- nFTP>
- ls : Get a directory listing
- mkdir : Create a new directory with the name DIR;
- rmdir : Remove the directory with the name DIR;
- get : Get REMOTE_FILE from the server and store locally;
- put : Put a file on the remote server;
- del : Send a request to the server to delete FILENAME;
- ren : Rename a file on the remote FTP server from OLDNAME to NEWNAME;
- cd : Attempt to change directory to the directory given;
- help : Visualize Command;
- man : Visualize User Guide;
- exit : Exit to nFTP.
- );
- Main;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement