Advertisement
Guest User

Untitled

a guest
May 7th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 3.83 KB | None | 0 0
  1. #!/usr/bin/perl
  2.  
  3. ###
  4. #nFTP v1.0
  5. #Author: N3mes1s
  6. #E-mail:dottorjekill_mister[at]tiscali[dot]it
  7. #Using: perl <nFTP.pl>
  8. #Description: This is a simple shell FTP with module Net::FTP;
  9. #Development date: 28/12/2008
  10. ###
  11.  
  12. use Net::FTP;
  13. use strict;
  14. use Switch;
  15.  
  16. print "Insert Name HOST:\t";
  17. chomp(my $site=<STDIN>);
  18. print "Insert Username:\t";
  19. chomp(my $usr=<STDIN>);
  20. print "Insert User Password:\t";
  21. chomp(my $passw=<STDIN>);
  22.  
  23. my $ftp=Net::FTP->new($site)
  24.     or die "Impossible connect to $site\n";
  25. $ftp->login($usr,$passw)
  26.     or die "Username or Password error.\n";
  27. print "Connect to $site\n";
  28. command();
  29.  
  30. #Sub Main
  31. sub Main {
  32. print"\nnFTP>";
  33. chomp(my $cmd=<STDIN>);
  34.  
  35. switch($cmd) {
  36.     case "ls"    {ls();}
  37.     case "mkdir"     {mkdire();}
  38.     case "rmdir"     {rmdire();}
  39.     case "get"   {get();}
  40.     case "put"   {put();}
  41.     case "del"   {del();}
  42.     case "ren"       {ren();}
  43.     case "cd"    {cd();}
  44.     case "help"  {command();}
  45.     case "man"   {man();}
  46.     case "exit"  {print "Thanks For Using nFTP by N3mes1s. Bye!\n"; exit(); }
  47.  }
  48. }
  49.  
  50. #Sub Command
  51. sub command {
  52.     print q(
  53. [+] ls
  54. [+] mkdir
  55. [+] rmdir
  56. [+] get
  57. [+] put
  58. [+] del
  59. [+] ren
  60. [+] cd
  61. [+] help
  62. [+] man
  63. [+] exit
  64. );
  65. Main();
  66. }
  67.  
  68. #Sub ls
  69. sub ls {
  70.     my @dir =$ftp->ls();
  71.     foreach my $lst(@dir) {
  72.         print "[-] $lst\n";
  73.     }
  74.     Main();
  75. }
  76.  
  77. #Sub exit
  78. #sub exiti {
  79. #   $ftp->quit();
  80. #   Main;
  81. #}
  82.  
  83. #Sub mkdir
  84. sub mkdire {
  85.     print "nFTP>Insert Name Dir: ";
  86.     chomp(my $dir=<STDIN>);
  87.     if($ftp->mkdir($dir)){
  88.         print"nFTP> Dir Created";
  89.         Main();
  90.     }
  91.     else {
  92.         print "nFTP>Error";
  93.         Main();
  94.     }
  95. }
  96.  
  97. #Sub rmDir
  98. sub rmdire {
  99.     print "nFTP>Insert Name Dir: ";
  100.     chomp(my $dir =<STDIN>);
  101.     if($ftp->rmdir($dir)) {
  102.         print "nFTP> Dir Deleted";
  103.         Main();
  104.     }
  105.     else {
  106.         print "nFTP>Error";
  107.         Main();
  108.     }
  109. }
  110.  
  111. #Sub Get
  112. sub get {
  113.     print "nFTP>Insert Name File: ";
  114.     chomp(my $file =<STDIN>);
  115.     if($ftp->get($file)) {
  116.         print "nFTP>Download Complete";
  117.         Main();
  118.     }
  119.     else {
  120.         print "nFTP>Error";
  121.         Main();
  122.     }
  123. }
  124.  
  125. #Sub Put
  126. sub put {
  127.     print "nFTP>Insert Name File: ";
  128.     chomp(my $file=<STDIN>);
  129.     if($ftp->put($file)) {
  130.         print "nFTP>File Uploaded";
  131.         Main();
  132.     }
  133.     else {
  134.         print "nFTP>Error";
  135.         Main();
  136.     }
  137. }
  138.  
  139. #Sub Del
  140. sub del {
  141.     print "nFTP>Insert Name File: ";
  142.     chomp(my $file=<STDIN>);
  143.     if($ftp->delete($file)) {
  144.         print "nFTP>File Deleted";
  145.         Main();
  146.     }
  147.     else {
  148.         print "nFTP>Error";
  149.         Main();
  150.     }
  151. }
  152.  
  153. #Sub ren
  154. sub ren {
  155.     print "nFTP>Insert Name File: ";
  156.     chomp(my $file=<STDIN>);
  157.     print "nFTP>Insert NEW Name File: ";
  158.     chomp(my $rmfile=<STDIN>);
  159.     if($ftp->rename($file,$rmfile)) {
  160.         print "nFTP>Rename Completed";
  161.         Main();
  162.     }
  163.     else {
  164.         print "nFTP>Error";
  165.         Main();
  166.     }
  167. }
  168.  
  169. #Sub cd
  170. sub cd {
  171.     print "nFTP>Insert Name Dir: ";
  172.     chomp(my $dir=<STDIN>);
  173.     if($ftp->cwd($dir)) {
  174.         print"nFTP/$dir>Ok";
  175.         Main();
  176.     }
  177.     else {
  178.         print "nFTP>Error";
  179.         Main;
  180.     }
  181. }
  182.  
  183. #Sub Man
  184.  
  185. sub man {
  186.     print q(
  187. It's a User Guide:
  188.  
  189. Using Example :
  190. nFTP>ls
  191. [-] Joomla
  192. [-] css
  193. [-] images
  194. [-] index.html
  195. [-] templateDetails.xml
  196. [-] template_thumbnail.png
  197.  
  198. nFTP>cd
  199. nFTP>Insert Name Dir: Joomla
  200. nFTP/Joomla>Ok
  201. nFTP>ls
  202. [-] administrator
  203. [-] cache
  204. [-] components
  205. [-] images
  206. [-] includes
  207. [-] installation
  208. [-] language
  209. [-] libraries
  210. [-] logs
  211. [-] media
  212. [-] modules
  213. [-] plugins
  214. [-] templates
  215. [-] tmp
  216. [-] xmlrpc
  217. nFTP>
  218.    
  219.  
  220. ls    :   Get a directory listing
  221.  
  222. mkdir :   Create a new directory with the name DIR;
  223.  
  224. rmdir :   Remove the directory with the name DIR;
  225.  
  226. get   :   Get REMOTE_FILE from the server and store locally;
  227.  
  228. put   :   Put a file on the remote server;
  229.  
  230. del   :   Send a request to the server to delete FILENAME;
  231.  
  232. ren   :   Rename a file on the remote FTP server from OLDNAME to NEWNAME;
  233.  
  234. cd    :   Attempt to change directory to the directory given;
  235.  
  236. help  :   Visualize Command;
  237.  
  238. man   :   Visualize User Guide;
  239.  
  240. exit  :   Exit to nFTP.
  241. );
  242. Main;
  243. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement