Merge pull request #5 from ChrisTruncer/catch_port_in_
Added check if port is in use for serversresolved_file
commit
f4ec56acc5
|
@ -0,0 +1,3 @@
|
|||
[12.24.2014]
|
||||
Released: Egress-Assess is now its own framework. Users can now create server or client support for new protocols, or modules for generating data.
|
||||
Modified: Added error message for trying to start http(s) or ftp server when port is in use.
|
|
@ -5,6 +5,8 @@ This is the code for the ftp server
|
|||
'''
|
||||
|
||||
import os
|
||||
import socket
|
||||
import sys
|
||||
from pyftpdlib.authorizers import DummyAuthorizer
|
||||
from pyftpdlib.handlers import FTPHandler
|
||||
from pyftpdlib.servers import FTPServer
|
||||
|
@ -40,8 +42,13 @@ class Server:
|
|||
# Define a customized banner (string returned when client connects)
|
||||
handler.banner = "Connecting to Egress-Assess's FTP server!"
|
||||
|
||||
server = FTPServer(('', 21), handler)
|
||||
server.serve_forever()
|
||||
try:
|
||||
server = FTPServer(('', 21), handler)
|
||||
server.serve_forever()
|
||||
except socket.error:
|
||||
print "[*][*] Error: Port 80 is currently in use!"
|
||||
print "[*][*] Error: Please restart when port is free!\n"
|
||||
sys.exit()
|
||||
except ValueError:
|
||||
print "[*] Error: The directory you provided may not exist!"
|
||||
print "[*] Error: Please re-run with a valid FTP directory."
|
||||
|
|
|
@ -4,6 +4,8 @@ This is the code for the web server
|
|||
|
||||
'''
|
||||
|
||||
import socket
|
||||
import sys
|
||||
from protocols.servers.serverlibs import base_handler
|
||||
from protocols.servers.serverlibs import threaded_http
|
||||
from threading import Thread
|
||||
|
@ -26,7 +28,12 @@ class Server:
|
|||
print "[!] Rage quiting, and stopping the web server!"
|
||||
|
||||
def serve_on_port(self):
|
||||
server80 = threaded_http.ThreadingHTTPServer(
|
||||
("0.0.0.0", 80), base_handler.GetHandler)
|
||||
server80.serve_forever()
|
||||
try:
|
||||
server80 = threaded_http.ThreadingHTTPServer(
|
||||
("0.0.0.0", 80), base_handler.GetHandler)
|
||||
server80.serve_forever()
|
||||
except socket.error:
|
||||
print "[*][*] Error: Port 80 is currently in use!"
|
||||
print "[*][*] Error: Please restart when port is free!\n"
|
||||
sys.exit()
|
||||
return
|
||||
|
|
|
@ -4,7 +4,9 @@ This is the code for the web server
|
|||
|
||||
'''
|
||||
|
||||
import socket
|
||||
import ssl
|
||||
import sys
|
||||
from common import helpers
|
||||
from protocols.servers.serverlibs import base_handler
|
||||
from protocols.servers.serverlibs import threaded_http
|
||||
|
@ -28,11 +30,16 @@ class Server:
|
|||
print "[!] Rage quiting, and stopping the web server!"
|
||||
|
||||
def serve_on_port(self):
|
||||
cert_path = helpers.ea_path() +\
|
||||
'/protocols/servers/serverlibs/server.pem'
|
||||
server = threaded_http.ThreadingHTTPServer(
|
||||
("0.0.0.0", 443), base_handler.GetHandler)
|
||||
server.socket = ssl.wrap_socket(
|
||||
server.socket, certfile=cert_path, server_side=True)
|
||||
server.serve_forever()
|
||||
try:
|
||||
cert_path = helpers.ea_path() +\
|
||||
'/protocols/servers/serverlibs/server.pem'
|
||||
server = threaded_http.ThreadingHTTPServer(
|
||||
("0.0.0.0", 443), base_handler.GetHandler)
|
||||
server.socket = ssl.wrap_socket(
|
||||
server.socket, certfile=cert_path, server_side=True)
|
||||
server.serve_forever()
|
||||
except socket.error:
|
||||
print "[*][*] Error: Port 443 is currently in use!"
|
||||
print "[*][*] Error: Please restart when port is free!\n"
|
||||
sys.exit()
|
||||
return
|
||||
|
|
Loading…
Reference in New Issue