Some adjustments to the fake ftp
This commit is contained in:
parent
7bad267652
commit
45836391c7
1 changed files with 8 additions and 6 deletions
14
fakeftp.py
14
fakeftp.py
|
@ -453,17 +453,19 @@ class PasvCommandHandler(CommandHandler):
|
|||
class PortCommandHandler(CommandHandler):
|
||||
cmd = "PORT"
|
||||
def process(self, handler, message):
|
||||
handler.log("PORT: %s" % message.parameter)
|
||||
hp = message.parameter.split(",")
|
||||
if len(hp) != 6:
|
||||
handler.send( InvalidParametersMessage() )
|
||||
return
|
||||
|
||||
if int(hp[0]) == 10 or int(hp[0]) == 127 or int(hp[0]) == 192: #Prevent local scanning
|
||||
handler.log( "Attempt to port to local network." )
|
||||
handler.send( InvalidPortCommandMessage() )
|
||||
return
|
||||
#if int(hp[0]) == 11 or int(hp[0]) == 127 or int(hp[0]) == 192: #Prevent local scanning
|
||||
# handler.log( "Attempt to port to local network." )
|
||||
# handler.send( InvalidPortCommandMessage() )
|
||||
# return
|
||||
|
||||
addr = ( ".".join(hp[:4]), int(hp[4])<<8+int(hp[5]) )
|
||||
port = ( int(hp[4])<<8 )+int(hp[5])
|
||||
addr = ( ".".join(hp[:4]), port )
|
||||
|
||||
handler.log( "Creating active data connection to %s:%d" % addr )
|
||||
|
||||
|
@ -794,7 +796,7 @@ while True:
|
|||
server.serve_forever()
|
||||
break
|
||||
except Exception:
|
||||
if port < 1500:
|
||||
if port < 21:
|
||||
port += 1
|
||||
else:
|
||||
print "Failed to find a port"
|
||||
|
|
Loading…
Reference in a new issue