當前位置: 首頁>>代碼示例>>Python>>正文


Python CtfUtil.getRandomAlphaNum方法代碼示例

本文整理匯總了Python中utility.CtfUtil.getRandomAlphaNum方法的典型用法代碼示例。如果您正苦於以下問題:Python CtfUtil.getRandomAlphaNum方法的具體用法?Python CtfUtil.getRandomAlphaNum怎麽用?Python CtfUtil.getRandomAlphaNum使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在utility.CtfUtil的用法示例。


在下文中一共展示了CtfUtil.getRandomAlphaNum方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: createUser

# 需要導入模塊: from utility import CtfUtil [as 別名]
# 或者: from utility.CtfUtil import getRandomAlphaNum [as 別名]
def createUser(mainpage,flag):
	try:
		userPage = mainpage.click("cgi-bin/createuser.php")
		userPage.parse()
            
		userForm = userPage.forms[0];
            
		userName = CtfUtil.getRandomString(random.randint(6,8))
		firstName = CtfUtil.getRandomString(random.randint(6,8))
		lastName = CtfUtil.getRandomString(random.randint(6,8))
		password = CtfUtil.getRandomAlphaNum(8)
		email = flag
            
		userForm.fields['username'] = userName
		userForm.fields['lastname'] = lastName
		userForm.fields['firstname']= firstName
		userForm.fields['password'] = password
		userForm.fields['email'] = email
            
		resultPage = userForm.click(None)
		successPtr = resultPage.page.find("User successfully created!")

		if successPtr != -1:
			return userName,password
		else:
			sys.exit(-1)
                
	except Exception, e:
		print "ERROR: got exception %s creating user" % (e)
		sys.exit(-1)
開發者ID:RootFu,項目名稱:ctf-scorebot,代碼行數:32,代碼來源:EstoreServiceScript.py

示例2: score

# 需要導入模塊: from utility import CtfUtil [as 別名]
# 或者: from utility.CtfUtil import getRandomAlphaNum [as 別名]
def score(ip,flag,cookie):
	#get old flag
	if cookie != None:
		try:
			sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
			sock.connect((ip, port))

			name = cookie
			topic = CtfUtil.getRandomAlphaNum(random.randint(3,8))
			msg = name+" " + topic + "\n" 

			response = initConversation(msg,sock)
			successPtr = response.find("Last time")

			if successPtr != -1:
				oldFlag = response[successPtr+32:][:len(flag)]
				print "FLAG:",oldFlag
			sock.close()

		except Exception, e:
			print "ERROR: got exception %s getting flag" % (e)
開發者ID:RootFu,項目名稱:ctf-scorebot,代碼行數:23,代碼來源:DiscussitServiceScript.py

示例3: postAgentText

# 需要導入模塊: from utility import CtfUtil [as 別名]
# 或者: from utility.CtfUtil import getRandomAlphaNum [as 別名]
			codeText = "<code>set flag [store get flag]; results set $flag</code>"
			agentText = "<agent>\n" + senderText +"\n"+codeText+"\n</agent>"
                
			resultPage = postAgentText(ip,agentText)
                
			oldFlag = resultPage[:len(flag)]
			print "FLAG:",oldFlag
 
		except Exception, e:
			print "ERROR: got exception '%s' when getting flag" % (e)
			return
        
	#set new flag
	try:
		name = CtfUtil.getRandomString(random.randint(6,8))
		password = CtfUtil.getRandomAlphaNum(8)
            
		senderText = "<sender><user>"+name+"</user><password>"+password+"</password></sender>"
		codeText = "<code>store set flag \""+flag+"\"; results set \"Flag was set\";</code>"
            
		agentText = "<agent>\n" + senderText +"\n"+codeText+"\n</agent>"
             
		resultPage = postAgentText(ip,agentText)
            
		successPattern = "Flag was set"
		successPtr = resultPage.find(successPattern)

		if successPtr >= 0:
			cookie = name+":"+password
           	print "COOKIE:",cookie 
開發者ID:Steccas,項目名稱:ctf-scorebot,代碼行數:32,代碼來源:SpamAgentServiceScript.py

示例4: exception

# 需要導入模塊: from utility import CtfUtil [as 別名]
# 或者: from utility.CtfUtil import getRandomAlphaNum [as 別名]
			if successPtr != -1:
				oldFlag = resultPage.page[successPtr+3:][:len(flag)]
				print "FLAG:",oldFlag

		except Exception, e:
			print "ERROR: got exception (%s) getting flag" % (e)

	#set the new flag
	try:
		personality = browserpersonality.getRandomPersonality()
		mainpg = pybrowse.Browser("http://" + ip + "/~pollit/pollit.html", personality)
		mainpg.open()
		mainpg.parse()

		name = CtfUtil.getRandomString(random.randint(6,8))
		id = CtfUtil.getRandomAlphaNum(6)

		createPollForm = mainpg.forms[0]

		for candidate in candidates:
			createPollForm.fields[candidate] = str(random.randint(1,100))

		candidate = random.choice(candidates)
		createPollForm.fields[candidate] = "-1 "+flag

		createPollForm.fields['username'] = name
		createPollForm.fields['pollid'] = id

		resultPage = createPollForm.click(None)

		successPtr = resultPage.page.find("saved.")
開發者ID:RootFu,項目名稱:ctf-scorebot,代碼行數:33,代碼來源:PollitServiceScript.py


注:本文中的utility.CtfUtil.getRandomAlphaNum方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。