本文整理汇总了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)
示例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)
示例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
示例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.")