print statements fixed
This commit is contained in:
parent
bf14bbffc5
commit
8335db586c
@ -36,16 +36,16 @@ import knockknock.daemonize
|
|||||||
|
|
||||||
def checkPrivileges():
|
def checkPrivileges():
|
||||||
if (not os.geteuid() == 0):
|
if (not os.geteuid() == 0):
|
||||||
print "Sorry, you have to run knockknock-daemon as root."
|
print("Sorry, you have to run knockknock-daemon as root.")
|
||||||
sys.exit(3)
|
sys.exit(3)
|
||||||
|
|
||||||
def checkConfiguration():
|
def checkConfiguration():
|
||||||
if (not os.path.isdir('/etc/knockknock.d/')):
|
if (not os.path.isdir('/etc/knockknock.d/')):
|
||||||
print "/etc/knockknock.d/ does not exist. You need to setup your profiles first.."
|
print("/etc/knockknock.d/ does not exist. You need to setup your profiles first..")
|
||||||
sys.exit(3)
|
sys.exit(3)
|
||||||
|
|
||||||
if (not os.path.isdir('/etc/knockknock.d/profiles/')):
|
if (not os.path.isdir('/etc/knockknock.d/profiles/')):
|
||||||
print "/etc/knockknock.d/profiles/ does not exist. You need to setup your profiles first..."
|
print("/etc/knockknock.d/profiles/ does not exist. You need to setup your profiles first...")
|
||||||
sys.exit(3)
|
sys.exit(3)
|
||||||
|
|
||||||
def dropPrivileges():
|
def dropPrivileges():
|
||||||
@ -77,7 +77,7 @@ def main(argv):
|
|||||||
config = DaemonConfiguration('/etc/knockknock.d/config')
|
config = DaemonConfiguration('/etc/knockknock.d/config')
|
||||||
|
|
||||||
if (profiles.isEmpty()):
|
if (profiles.isEmpty()):
|
||||||
print 'WARNING: Running knockknock-daemon without any active profiles.'
|
print('WARNING: Running knockknock-daemon without any active profiles.')
|
||||||
|
|
||||||
knockknock.daemonize.createDaemon()
|
knockknock.daemonize.createDaemon()
|
||||||
|
|
||||||
|
@ -30,12 +30,12 @@ DAEMON_DIR = '/etc/knockknock.d/'
|
|||||||
PROFILES_DIR = DAEMON_DIR + 'profiles/'
|
PROFILES_DIR = DAEMON_DIR + 'profiles/'
|
||||||
|
|
||||||
def usage():
|
def usage():
|
||||||
print "knockknock-genprofile <profileName> <knockPort>"
|
print("knockknock-genprofile <profileName> <knockPort>")
|
||||||
sys.exit(3)
|
sys.exit(3)
|
||||||
|
|
||||||
def checkProfile(profileName):
|
def checkProfile(profileName):
|
||||||
if (os.path.isdir(PROFILES_DIR + profileName)):
|
if (os.path.isdir(PROFILES_DIR + profileName)):
|
||||||
print "Profile already exists. First rm " + PROFILES_DIR + profileName + "/"
|
print("Profile already exists. First rm " + PROFILES_DIR + profileName + "/")
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
def checkPortConflict(knockPort):
|
def checkPortConflict(knockPort):
|
||||||
@ -46,7 +46,7 @@ def checkPortConflict(knockPort):
|
|||||||
matchingProfile = profiles.getProfileForPort(knockPort)
|
matchingProfile = profiles.getProfileForPort(knockPort)
|
||||||
|
|
||||||
if (matchingProfile != None):
|
if (matchingProfile != None):
|
||||||
print "A profile already exists for knock port: " + str(knockPort) + " at this location: " + matchingProfile.getDirectory()
|
print("A profile already exists for knock port: " + str(knockPort) + " at this location: " + matchingProfile.getDirectory())
|
||||||
|
|
||||||
def createDirectory(profileName):
|
def createDirectory(profileName):
|
||||||
if not os.path.isdir(DAEMON_DIR):
|
if not os.path.isdir(DAEMON_DIR):
|
||||||
@ -79,7 +79,7 @@ def main(argv):
|
|||||||
profile.serialize()
|
profile.serialize()
|
||||||
random.close()
|
random.close()
|
||||||
|
|
||||||
print "Keys successfully generated in " + PROFILES_DIR + profileName
|
print("Keys successfully generated in " + PROFILES_DIR + profileName)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main(sys.argv[1:])
|
main(sys.argv[1:])
|
||||||
|
@ -45,7 +45,7 @@ class ProxyServer(asyncore.dispatcher):
|
|||||||
|
|
||||||
|
|
||||||
def usage():
|
def usage():
|
||||||
print "knockknock-proxy <listenPort>"
|
print("knockknock-proxy <listenPort>")
|
||||||
sys.exit(3)
|
sys.exit(3)
|
||||||
|
|
||||||
def getProfiles():
|
def getProfiles():
|
||||||
@ -57,14 +57,14 @@ def getProfiles():
|
|||||||
|
|
||||||
def checkPrivileges():
|
def checkPrivileges():
|
||||||
if not os.geteuid() == 0:
|
if not os.geteuid() == 0:
|
||||||
print "\nSorry, knockknock-proxy has to be run as root.\n"
|
print("\nSorry, knockknock-proxy has to be run as root.\n")
|
||||||
usage()
|
usage()
|
||||||
|
|
||||||
def checkProfiles():
|
def checkProfiles():
|
||||||
homedir = os.path.expanduser('~')
|
homedir = os.path.expanduser('~')
|
||||||
|
|
||||||
if not os.path.isdir(homedir + '/.knockknock/'):
|
if not os.path.isdir(homedir + '/.knockknock/'):
|
||||||
print "Error: you need to setup your profiles in " + homedir + "/.knockknock/"
|
print("Error: you need to setup your profiles in " + homedir + "/.knockknock/")
|
||||||
sys.exit(2)
|
sys.exit(2)
|
||||||
|
|
||||||
def main(argv):
|
def main(argv):
|
||||||
|
@ -29,7 +29,7 @@ from struct import *
|
|||||||
from knockknock.Profile import Profile
|
from knockknock.Profile import Profile
|
||||||
|
|
||||||
def usage():
|
def usage():
|
||||||
print "Usage: knockknock.py -p <portToOpen> <host>"
|
print("Usage: knockknock.py -p <portToOpen> <host>")
|
||||||
sys.exit(2)
|
sys.exit(2)
|
||||||
|
|
||||||
def parseArguments(argv):
|
def parseArguments(argv):
|
||||||
@ -61,18 +61,18 @@ def getProfile(host):
|
|||||||
homedir = os.path.expanduser('~')
|
homedir = os.path.expanduser('~')
|
||||||
|
|
||||||
if not os.path.isdir(homedir + '/.knockknock/'):
|
if not os.path.isdir(homedir + '/.knockknock/'):
|
||||||
print "Error: you need to setup your profiles in " + homedir + '/.knockknock/'
|
print("Error: you need to setup your profiles in " + homedir + '/.knockknock/')
|
||||||
sys.exit(2)
|
sys.exit(2)
|
||||||
|
|
||||||
if not os.path.isdir(homedir + '/.knockknock/' + host):
|
if not os.path.isdir(homedir + '/.knockknock/' + host):
|
||||||
print 'Error: profile for host ' + host + ' not found at ' + homedir + '/.knockknock/' + host
|
print('Error: profile for host ' + host + ' not found at ' + homedir + '/.knockknock/' + host)
|
||||||
sys.exit(2)
|
sys.exit(2)
|
||||||
|
|
||||||
return Profile(homedir + '/.knockknock/' + host)
|
return Profile(homedir + '/.knockknock/' + host)
|
||||||
|
|
||||||
def verifyPermissions():
|
def verifyPermissions():
|
||||||
if os.getuid() != 0:
|
if os.getuid() != 0:
|
||||||
print 'Sorry, you must be root to run this.'
|
print('Sorry, you must be root to run this.')
|
||||||
sys.exit(2)
|
sys.exit(2)
|
||||||
|
|
||||||
def existsInPath(command):
|
def existsInPath(command):
|
||||||
@ -100,7 +100,7 @@ def main(argv):
|
|||||||
hping = existsInPath("hping3")
|
hping = existsInPath("hping3")
|
||||||
|
|
||||||
if hping is None:
|
if hping is None:
|
||||||
print "Error, you must install hping3 first."
|
print("Error, you must install hping3 first.")
|
||||||
sys.exit(2)
|
sys.exit(2)
|
||||||
|
|
||||||
command = [hping, "-S", "-c", "1",
|
command = [hping, "-S", "-c", "1",
|
||||||
@ -113,10 +113,10 @@ def main(argv):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
subprocess.call(command, shell=False, stdout=open('/dev/null', 'w'), stderr=subprocess.STDOUT)
|
subprocess.call(command, shell=False, stdout=open('/dev/null', 'w'), stderr=subprocess.STDOUT)
|
||||||
print 'Knock sent.'
|
print('Knock sent.')
|
||||||
|
|
||||||
except OSError:
|
except OSError:
|
||||||
print "Error: Do you have hping3 installed?"
|
print("Error: Do you have hping3 installed?")
|
||||||
sys.exit(3)
|
sys.exit(3)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
2
setup.py
2
setup.py
@ -26,7 +26,7 @@ setup (name = 'knockknock',
|
|||||||
('/etc/knockknock.d/', ['config'])]
|
('/etc/knockknock.d/', ['config'])]
|
||||||
)
|
)
|
||||||
|
|
||||||
print "Cleaning up..."
|
print("Cleaning up...")
|
||||||
|
|
||||||
if os.path.exists("build/"):
|
if os.path.exists("build/"):
|
||||||
shutil.rmtree("build/")
|
shutil.rmtree("build/")
|
||||||
|
Loading…
Reference in New Issue
Block a user