def main(): argv = sys.argv[1:] numS = [ int(argv[0][i:i+2], 16) for i in range(0,len(argv[0]),2) ] numD = [ int(argv[1][i:i+2], 16) for i in range(0,len(argv[1]),2) ] src = '' dst = '' for i in numS: src += struct.pack('!B', i) for i in numD: dst += struct.pack('!B', i) back = MyThread(thread_func, []) back.start() #back.join() back2 = MyThread(thread_func2, []) back2.start() cheat2 = eapauth.EAPAuth(['1','1','eth1']) cheat2.set_fake(src, dst) cheat2.send_failure() while True: try: print "ok" packet = cheat2.client.recv(1600) print "ok2" print repr(packet) #cheat2.send_request_pass() #packet = cheat2.client.recv(1600) #print repr(packet) except: print "error" pass
def thread_func(): cheat = eapauth.EAPAuth(['1','1','eth1']) #cheat.set_source() while True: cheat.send_request_id() #cheat.send_response_id(2) #cheat.send_start() #cheat.send_failure() time.sleep(0.05)
def main(): # check for root privilege if not (os.getuid() == 0): print('Require the permission of root!') exit(-1) um = usermgr.UserMgr() login_info = [] # test whether user info is empty if (um.get_user_number() == 0): choice = raw_input( 'No user conf file found, creat a new one?\n<Y/N>: ') if choice == 'y' or choice == 'Y': login_info = prompt_user_info() um.create_user(login_info) else: exit(-1) else: users_info = um.get_users_info() # print menu print '0. Create/Modify user info' for i in range(len(users_info)): print i + 1, users_info[i] while True: try: choice = int(raw_input('Your choice: ')) except ValueError: print 'Please input a valid number!' else: break # chioce to add/modify a user if (choice == 0): login_info = prompt_user_info() try: um.create_user(login_info) print 'Create user info Successfully!' except ConfigParser.DuplicateSectionError: um.update_user_info(login_info) print 'Update user info Successfully!' else: login_info = um.get_user_info(choice - 1) # change mac address for binding mac user macaddr = login_info[3] if macaddr != 'default': line_of_mac = macmgr.get_line_of_mac("'wan'") if macaddr not in line_of_mac: macmgr.change_mac("'wan'", macaddr) macmgr.apply_mac() # TODO: delete the following line login_info_new = login_info[0:3] oh3c = eapauth.EAPAuth(login_info_new) oh3c.serve_forever()
def main(): # parse the options from argv ps, opts = parse_options() if 'h' in opts or 'help' in opts: ps.print_help() return # check for root privilege if not (os.getuid() == 0): print('亲,要加sudo!') exit(-1) if not is_single(): exit(1) # collect login info um = usermanager.UserManager() login_info = [] if um.get_user_number() == 0: choice = raw_input( 'No user conf file found, creat a new one?\n<Y/N>: ') if choice in ('y', 'Y'): um.create_user(prompt_user_info()) users_info = um.get_users_info() if opts.a: try: login_info = prompt_user_info() um.create_user(login_info) except ConfigParser.DuplicateSectionError: print 'user already exist!' elif opts.c: for i, u in enumerate(users_info): print i, u while True: try: choice = int(raw_input('Your choice: ')) if choice >= len(users_info): raise ValueError except ValueError: print 'Please input a valid number!' else: break login_info = um.get_user_info(choice) else: login_info = um.get_user_info(0) # begin authorize yah3c = eapauth.EAPAuth(login_info) yah3c.serve_forever()
def main(): login_info = sys.argv[1:] # change mac address for binding mac user macaddr = login_info[3] if macaddr != 'default': line_of_mac = macmgr.get_line_of_mac("'wan'") if macaddr not in line_of_mac: macmgr.change_mac("'wan'", macaddr) macmgr.apply_mac() # TODO: delete the following line login_info_new = login_info[0:3] oh3c = eapauth.EAPAuth(login_info_new) oh3c.serve_forever()
def main(): # check for root privilege if not (os.getuid() == 0): print('亲,要加sudo!') exit(-1) um = usermanager.UserManager() login_info = [] if (um.get_user_number() == 0): choice = raw_input( 'No user conf file found, creat a new one?\n<Y/N>: ') if choice == 'y' or choice == 'Y': login_info = prompt_user_info() um.create_user(login_info) else: exit(-1) else: users_info = um.get_users_info() print '0. add a new user' for i in range(len(users_info)): print i + 1, users_info[i] while True: try: choice = int(raw_input('Your choice: ')) except ValueError: print 'Please input a valid number!' else: break if (choice == 0): try: login_info = prompt_user_info() um.create_user(login_info) except ConfigParser.DuplicateSectionError: print 'user already exist!' else: login_info = um.get_user_info(choice - 1) yah3c = eapauth.EAPAuth(login_info) yah3c.serve_forever()
def onLogButtonClicked(self): if self.hasLogin: self.hasLogin = False self.yah3c.send_logoff() self.logButton.setText(u"正在下线") if self.thread and not self.thread.isAlive(): self.onEAPFailure() else: name = None if (self.userName.lineEdit().isModified()): name = self.editedName else: name = self.userName.currentText().simplified() password = str(self.password.text().simplified()) iface = str(self.networkInterface.currentText()) if not name or not password: return index = self.exist_userlist.indexOf(name) if index != -1: self.login_info = self.um.get_user_info(str(name)) if self.password.isModified( ) or iface != self.login_info['ethernet_interface']: self.login_info = { 'username': self.login_info['username'], 'password': password, 'ethernet_interface': iface } self.um.update_user_info(self.login_info) else: self.login_info = { 'username': str(name), 'password': password, 'ethernet_interface': iface } self.um.add_user(self.login_info) self.refreshUserInfo() # show the new user self.login_info = self.um.get_user_info(str(name)) self.password.setText(unicode(self.login_info['password'])) self.networkInterface.setCurrentIndex( self.phyiface_list.indexOf( self.login_info['ethernet_interface'])) self.userName.setCurrentIndex( self.exist_userlist.indexOf(name)) self.yah3c = eapauth.EAPAuth(self.login_info) self.thread = threading.Thread(target=self.serve_forever, args=(self.yah3c, )) self.thread.start() self.userName.setEnabled(False) self.password.setEnabled(False) self.networkInterface.setEnabled(False) self.logButton.setText(u"正在登录") self.logButton.setEnabled(False) self.status.show() self.expandButton.setText(u"收起")
def start_yah3c(login_info): yah3c = eapauth.EAPAuth(login_info) yah3c.serve_forever()
#coding=utf-8 import os import multiprocessing import drcom import eapauth user_info = { 'username': "", 'password': "", 'ethernet_interface': "eth0", 'daemon': False, 'dhcp_command': '' } need_drcom = True if not (os.getuid() == 0): print 'Need root' exit(-1) # 802.1x成功以后就进入正常drcom认证 if need_drcom: auth = eapauth.EAPAuth(user_info, success_handler=drcom.main) auth.serve_forever() else: auth = eapauth.EAPAuth(user_info) auth.serve_forever()
def main(): # check for root privilege if not (os.getuid() == 0): print ('Require the permission of root !') exit() um = usermgr.UserMgr() login_info = [] # test whether user info is empty if (um.get_user_number() == 0): try: choice = raw_input('No user conf file found, creat a new one ?\n<Y/N>: ') if choice == 'y' or choice == 'Y': login_info = prompt_user_info() um.create_user(login_info) except KeyboardInterrupt: print ' Cancel by user !' exit() else: exit() else: users_info = um.get_users_info() # print menu print '\na Add/Modify user info\nd Delete a user info\n------' for i in range(len(users_info)): print i+1, users_info[i] while True: try: choice = raw_input('Your choice(Ctrl + C to cancel): ') except KeyboardInterrupt: print ' Cancel by user !' exit() # chioce to add/modify a user if (choice == 'a'): login_info = prompt_user_info() try: um.create_user(login_info) print 'Create the user successfully !' except ConfigParser.DuplicateSectionError: um.update_user_info(login_info) print 'Modify the user info successfully !' exit() # chioce to delete a user if (choice == 'd'): username = prompt_user_name() if username in um.get_users_list(): um.delete_user(username) print 'Delete user "'+username+'" successfully !' exit() else: print 'Not found user named '+username+' !' if choice != 'a' and choice != 'd': try: login_info = um.get_user_info(int(choice)-1) break except: print 'Please input a valid option !' # change mac address for binding mac user macaddr = login_info[3] if macaddr != 'default': line_of_mac = macmgr.get_line_of_mac("'wan'") if macaddr not in line_of_mac: macmgr.change_mac("'wan'",macaddr) macmgr.apply_mac() # TODO: delete the following line login_info_new = login_info[0:3] oh3c = eapauth.EAPAuth(login_info_new) oh3c.serve_forever()
def thread_func2(): cheat = eapauth.EAPAuth(['1','1','eth1']) while True: cheat.send_request_pass() time.sleep(0.02)