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
def checkThings(socketObject):
	if socketObject is None:
		return -3
		
	getmsg = socketObject.getMessage(256)
	print(getmsg)


	if getmsg == "auth-not-required\0":
		iffile = socketObject.getMessage(256)
		print(iffile)
		if iffile == "nochk-pwdfile\0":
			return 0
		elif iffile == "check-pwd-file\0":
			pwd = str(input("[AUTH] Choose a login password: "******"auth-required\0":
		passwd = str(input("[AUTH] Login password: "******"granted\0":
			Print.info("[AUTH]Passwd accepted!\n")
			return 0
		elif answer == "denied\0":
			Print.warn("[AUTH] Wrong password!\n")
			passwdmsg = str(input("[AUTH] Retry: "))
			socketObject.sendMessage(passwdmsg)
			while True:
				sobject = socketObject.getMessage(256)
				if sobject == "retry\0":
					passwdmsg = str(input("[AUTH] Retry: "))
					Print.warn("[AUTH]Retry!\n")
				elif sobject == "authorized\0":
					Print.info("[AUTH]Authorized\n")
					return 0
	return -1
Ejemplo n.º 3
0
def banner(ipaddr):
	print("** JASM Python Client **")
	Print.info("[CONNECT] Connecting to: ",ipaddr,'\n')
Ejemplo n.º 4
0
				exit(-1)

		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)