Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- alias ftp {
- var %file $iif($$1 == upload,$mircdirnametest.txt,$mircdir), $&
- %getfile $iif($1 == upload,/public_html,/public_html/namebans.txt)
- sockclose *ftp_test. $+ $1
- sockopen ftp_test. $+ $1 mcwall.bugs3.com 21
- sockmark ftp_test. $+ $1 $+(%getfile,ÿ,%file)
- }
- on *:sockopen:ftp_test.*:{
- sockwrite -nt $sockname USER u106703019
- sockwrite -nt $sockname PASS REPLACETHEACTUALPASSHERE
- ; Specify a BINARY transfer
- sockwrite -nt $sockname TYPE I
- ; Set the start position to 0
- sockwrite -nt $sockname REST 0
- sockwrite -nt $sockname CWD /
- ; Initiate a PASSIVE connection, meaning that we wait for the server to tell us which port/IP to connect to
- sockwrite -nt $sockname PASV
- }
- on *:sockread:ftp_test.*:{
- var %s
- sockread %s
- echo -a S1: %s
- ; 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.
- if ($regex(%s,/227.*?\(([0-9,]+)\)/)) {
- tokenize 44 $regml(1)
- ; Establish a NEW connection to the IP with the port suggested by the server (it's a passive connection)
- sockopen 2 $+ $sockname $replace($1-4,$chr(32),.) $calc($5* 256+$6)
- }
- }
- ; A little regex is used so that $regml(1) will contain either "upload" or "download"
- on $*:sockopen:/2ftp_test\.(.*)/:{
- ; Now we have connected to the IP on the port suggested by the FTP server, tokenize the sock mark
- tokenize 255 $sock($mid($sockname,2)).mark
- ; Now we need to check if the user wanted to upload or download a file
- if ($regml(1) == upload) {
- ; Tell the original connection the name of the file we want to upload
- sockwrite -nt $mid($sockname,2) STOR $1 $+ $nopath($2)
- ; Read the contents of the file into a binary variable (called &bvar)
- bread $qt($2) 0 $file($2).size &bvar
- ; Write the data to the new connection
- sockwrite $sockname &bvar
- }
- else {
- ; Tell the original connection the path and name of the file we want to retrieve
- sockwrite -nt $mid($sockname,2) RETR $1
- ; Set the sockmark to 1 so that we know the next lot of data will be the bytes of the file
- sockmark $sockname 1
- }
- }
- on *:sockread:2ftp_test.*:{
- tokenize 255 $sock($mid($sockname,2)).mark
- sockread &b
- ; If the "226 Transfer complete" message is displayed, stop writing to the file.
- if ($bfind(&b,1,226).text == 1) sockmark $sockname
- ; If the sock mark is set to the value "1", it means the server is sending us the bytes of the file
- if ($sock($sockname).mark) bwrite $qt($2 $+ $nopath($1)) -1 -1 &b
- else echo -a S2: $bvar(&b,1-).text
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement