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):
|
class PortCommandHandler(CommandHandler):
|
||||||
cmd = "PORT"
|
cmd = "PORT"
|
||||||
def process(self, handler, message):
|
def process(self, handler, message):
|
||||||
|
handler.log("PORT: %s" % message.parameter)
|
||||||
hp = message.parameter.split(",")
|
hp = message.parameter.split(",")
|
||||||
if len(hp) != 6:
|
if len(hp) != 6:
|
||||||
handler.send( InvalidParametersMessage() )
|
handler.send( InvalidParametersMessage() )
|
||||||
return
|
return
|
||||||
|
|
||||||
if int(hp[0]) == 10 or int(hp[0]) == 127 or int(hp[0]) == 192: #Prevent local scanning
|
#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.log( "Attempt to port to local network." )
|
||||||
handler.send( InvalidPortCommandMessage() )
|
# handler.send( InvalidPortCommandMessage() )
|
||||||
return
|
# 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 )
|
handler.log( "Creating active data connection to %s:%d" % addr )
|
||||||
|
|
||||||
|
@ -794,7 +796,7 @@ while True:
|
||||||
server.serve_forever()
|
server.serve_forever()
|
||||||
break
|
break
|
||||||
except Exception:
|
except Exception:
|
||||||
if port < 1500:
|
if port < 21:
|
||||||
port += 1
|
port += 1
|
||||||
else:
|
else:
|
||||||
print "Failed to find a port"
|
print "Failed to find a port"
|
||||||
|
|
Loading…
Reference in a new issue