当前位置: 首页>>代码示例>>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;未经允许,请勿转载。