You have been assigned to modify the FTP client (active mode) to send files to a
ID: 3864330 • Letter: Y
Question
You have been assigned to modify the FTP client (active mode) to send files to a working FTP Server designed for digital forensics evidence. This means that the FTP server will required to send a file and file containing the hash of the file, for verification purposes. Given that multiple files can be send, you will implement mput. This command, mput can take multiple files separated by commas (for simplicity, we will not used wildcards * ?). For example, mput file1.jpeg file2.jpeg. To obtain the hashcode, you will called a function created for you: getHashedFile(filename). This function creates a text file with a few lines: #1 filename, #2 date, #3 hashcode and returns the filename and path in fileName. You must create:
You are given the following global variables.
mindc = 50000
maxdc = 60000
nport = 0
tList = []
Assume cmd_socket is an active socket for the command channel
getDataChannel() : This function returns a tuple with the correct string for each “PORT” command (since you are doing active mode). This function does not do anything with sockets. You have to take into account that you always sends two ports because you will send a file and the hashfile.
mput(mstrings,cmdSocket): This function sends multiple files. For each file, mput also sends the hashfile created with getHashedFile. mput threads each file sent with its hashfile (meaning that a thread will send two files). Remember to call getDataChannel inside of mput. Don’t worry about joins. Assume that is taking care. However, store your threads in tList
handleFilePut(filename1, hashfilename,strPort1, strPort2, cmdSocket). This function sends two files. This is a function that was threaded. Remember to create the data channels here. Assume that you can pass sendFile(filename,datasocket) to send a file (that way you don’t have to open the file)
*NOTE: You may assume getIPandPortFromPortStr(portstr). This returns ip, port when you pass strPort1 or strPort2.
Assume functions if needed. For example, *NOTE.
Use python.
def mput(mstrings,cmdSocket):
#
tokens =
for file in tokens:
#one thread, two files.
def getDataChannel():
#function returns strport1, strport2
global mindc #min. data channel
global maxdc #max. data channel
global nport # next port
host = gethostname()
haddr = gethostbyname(host)
nport = nport + 1
#assign port to use below
dport =
dport_high =
dport_low =
#split haddr and prepare port command
hsplit =
#(finish strport1 and then do strport2)
def handleFilePut(filename1, hashfilename,strPort1, strPort2, cmdSocket):
Explanation / Answer
You have been assigned to modify the FTP client (active mode) to send files to a working FTP Server designed for digital forensics evidence. This means that the FTP server will required to send a file and file containing the hash of the file, for verification purposes. Given that multiple files can be send, you will implement mput.
Active and passive are the two modes that FTP can run in. FTP uses two channels between client and server, the command channel and the data channel, which are actually separate TCP connections. The command channel is for commands and responses, the data channel is for actually transferring files. It's a nifty way of sending commands to the server without having to wait for the current data transfer to finish.
In active mode, the client establishes the command channel (from client port X to server port 21(b)) but the server establishes the data channel (from server port 20(b) to client port Y, where Y has been supplied by the client).
In passive mode, the client establishes both channels. In that case, the server tells the client which port should be used for the data channel.
Passive mode is generally used in situations where the FTP server is not able to establish the data channel. One of the major reasons for this is network firewalls. While you may have a firewall rule which allows you to open up FTP channels to ftp.microsoft.com, Microsoft's servers may not have the power to open up the data channel back through your firewall.
Passive mode solves this by opening up both types of channel from the client side. In order to make this hopefully clearer:
Active mode:
Passive mode:
At this point, the command and data channels are both open.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.