Advertisement
illpastethat

FTP madmatty

Sep 5th, 2013
419
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
mIRC 2.59 KB | None | 0 0
  1. alias ftp {
  2.   var %file $iif($$1 == upload,$mircdirnametest.txt,$mircdir), $&
  3.     %getfile $iif($1 == upload,/public_html,/public_html/namebans.txt)
  4.   sockclose *ftp_test. $+ $1
  5.   sockopen ftp_test. $+ $1 mcwall.bugs3.com 21
  6.   sockmark ftp_test. $+ $1 $+(%getfile,ÿ,%file)
  7. }
  8. on *:sockopen:ftp_test.*:{
  9.   sockwrite -nt $sockname USER u106703019
  10.   sockwrite -nt $sockname PASS REPLACETHEACTUALPASSHERE
  11.   ; Specify a BINARY transfer
  12.   sockwrite -nt $sockname TYPE I
  13.   ; Set the start position to 0
  14.   sockwrite -nt $sockname REST 0
  15.   sockwrite -nt $sockname CWD /
  16.   ; Initiate a PASSIVE connection, meaning that we wait for the server to tell us which port/IP to connect to
  17.   sockwrite -nt $sockname PASV
  18. }
  19. on *:sockread:ftp_test.*:{
  20.   var %s
  21.   sockread %s
  22.   echo -a S1: %s
  23.   ; A simple bit of regex to determine that the server's reply is in the format: "227 Entering Passive Mode (a1,a2,a3,a4,p1,p2)" - a1.a2.a3.a4 is the IP and 256*p1+p2 is the port.
  24.   if ($regex(%s,/227.*?\(([0-9,]+)\)/)) {
  25.     tokenize 44 $regml(1)  
  26.     ; Establish a NEW connection to the IP with the port suggested by the server (it's a passive connection)
  27.     sockopen 2 $+ $sockname $replace($1-4,$chr(32),.) $calc($5* 256+$6)
  28.   }
  29. }
  30. ; A little regex is used so that $regml(1) will contain either "upload" or "download"
  31. on $*:sockopen:/2ftp_test\.(.*)/:{
  32.   ; Now we have connected to the IP on the port suggested by the FTP server, tokenize the sock mark
  33.   tokenize 255 $sock($mid($sockname,2)).mark
  34.   ; Now we need to check if the user wanted to upload or download a file
  35.   if ($regml(1) == upload) {
  36.     ; Tell the original connection the name of the file we want to upload
  37.     sockwrite -nt $mid($sockname,2) STOR $1 $+ $nopath($2)
  38.     ; Read the contents of the file into a binary variable (called &bvar)
  39.     bread $qt($2) 0 $file($2).size &bvar
  40.     ; Write the data to the new connection
  41.     sockwrite $sockname &bvar
  42.   }
  43.   else {
  44.     ; Tell the original connection the path and name of the file we want to retrieve
  45.     sockwrite -nt $mid($sockname,2) RETR $1
  46.     ; Set the sockmark to 1 so that we know the next lot of data will be the bytes of the file
  47.     sockmark $sockname 1
  48.   }
  49. }
  50. on *:sockread:2ftp_test.*:{
  51.   tokenize 255 $sock($mid($sockname,2)).mark
  52.   sockread &b
  53.   ; If the "226 Transfer complete" message is displayed, stop writing to the file.
  54.   if ($bfind(&b,1,226).text == 1) sockmark $sockname
  55.   ; If the sock mark is set to the value "1", it means the server is sending us the bytes of the file
  56.   if ($sock($sockname).mark) bwrite $qt($2 $+ $nopath($1)) -1 -1 &b
  57.   else echo -a S2: $bvar(&b,1-).text
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement