Ejemplo n.º 1
0
def cmdline(socketObject):
	if socketObject is None:
		return -3

	while True:
		getcmd = str(input("\n--> "))
		if getcmd == "quit":
			Print.info("Closing connection...\n")
			if socketObject.endConnection() == 0:
				Print.info("Exiting...\n")
				exit(0)
			else:
				Print.error("ERROR WHILE CLOSING CONNECTION!!\n")
				Print.error("EXITING WITH ERROR!!\n")
				exit(-1)

		socketObject.sendMessage(getcmd)
		resp = socketObject.getMessage(1024)
		sys.stdout.flush()
		sys.stdout.write(resp)
Ejemplo n.º 2
0
		socketObject.sendMessage(getcmd)
		resp = socketObject.getMessage(1024)
		sys.stdout.flush()
		sys.stdout.write(resp)

try:
	argdict = argchk(sys.argv)
	host = argdict['connect']
	csock = CommSocket(host,__PORT__)
	banner(csock.getipaddr())

	initconn = initConnection(csock)
	if initconn == 0:
		Print.info("[CONNECT] Success - connected!\n")
	elif initconn == -2:
		Print.error("[CONNECT] Timeout - failed!\n")
		exit(-1)
	elif initconn == -1:
		Print.error("[CONNECT] General socket error - failed!\n")
		exit(-2)

	checks = checkThings(csock)
	if checks == -1:
		Print.error("Something wrong!!\n")
		exit(-3)
	elif checks == 0:
		Print.info("Access Granted!\n")
		cmdline(csock)

	endconn = closeConnection(csock)
	if endconn == 0: