• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python utility.CtfUtil类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中utility.CtfUtil的典型用法代码示例。如果您正苦于以下问题:Python CtfUtil类的具体用法?Python CtfUtil怎么用?Python CtfUtil使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了CtfUtil类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: createUser

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,代码行数:30,代码来源:EstoreServiceScript.py


示例2: score

def score(ip,flag,cookie):

	#get old flag  
	if cookie != None:
		try:
			name = cookie

			personality = browserpersonality.getRandomPersonality()
			mainpg = pybrowse.Browser("http://" + ip + "/~feedback/cgi-bin/candidates.php", personality)
			mainpg.open()
			mainpg.parse()

			candidate = random.randint(0,4)

			feedbackForm = mainpg.forms[candidate]
			feedbackForm.fields['name'] = name
			feedbackForm.fields['comment'] = CtfUtil.getRandomString(5) + " " + CtfUtil.getRandomString(random.randint(4,9)) + random.choice(['?','.','!'])

			resultPage = feedbackForm.click(None)

			successPtr = resultPage.page.find("About")
			if successPtr != -1:
				oldFlag = resultPage.page[successPtr+9:][:len(flag)]
				print "FLAG:",oldFlag

		except Exception, e:
			print "ERROR: got exception %s getting flag" % (e)
开发者ID:RootFu,项目名称:ctf-scorebot,代码行数:27,代码来源:FeedbackServiceScript.py


示例3: score

def score(ip,flag,cookie):
	try:
		#Login to ftp
		ftp = ftplib.FTP(ip)
		ftp.login() 
		ftp.cwd("/home/ftp/incoming")
        
		if cookie != None:
			ftp.retrlines("RETR "+cookie,flagCallback)
            
		#set new flag
		filename = CtfUtil.getRandomString(9)
            
		file = open(filename,'w')
		file.write(flag)
		file.close();
            
		file = open(filename,'r')
		ftp.storlines("stor "+filename,file)
		file.close()
		os.remove(filename)

		cookie = filename
		print "COOKIE:",cookie
                
	except Exception, e:
		print "ERROR: Failed to set new flag!"
开发者ID:RootFu,项目名称:ctf-scorebot,代码行数:27,代码来源:FtpServiceScript.py


示例4: score

def score(ip,flag,cookie):
	#get old flag  
	if cookie != None:
		try:
			userName,password = cookie.split(":")
                
			mainpage = pybrowse.Browser("http://" + ip + "/~estore/index.html")
			mainpage.open()
			mainpage.parse()
			loginMainPage = login(mainpage, userName, password)
			updatePage = loginMainPage.click("cgi-bin/update.php")
			updatePage.parse()
			updateForm = updatePage.forms[0]
			updateForm.fields['username'] = userName
			updateForm.fields['password'] = password
			updateForm.fields['email'] = CtfUtil.getRandomEmail() 
                
			resultPage = updateForm.click(None)
			successPtr = resultPage.page.find("address was:")

			if(successPtr != -1):
				oldFlag = resultPage.page[successPtr+13:][:len(flag)]
				print "FLAG:",oldFlag
 
			logout(loginMainPage)
                
		except Exception, e:
			print "ERROR: got exception %s getting flag" % (e)
开发者ID:RootFu,项目名称:ctf-scorebot,代码行数:28,代码来源:EstoreServiceScript.py


示例5: createAccount

def createAccount(name, passwd, role):
	global myHost
        
	mainpg = pybrowse.Browser("http://" + myHost + "/Therapy/createuser.do?role=" + role)
	mainpg.open()
	mainpg.parse()
        
	userform = mainpg.forms[0]
	userform.fields['firstname'] = CtfUtil.getRandomString(random.randint(4,10))
	userform.fields['lastname'] = CtfUtil.getRandomString(random.randint(5,10))
	userform.fields['email'] = CtfUtil.getRandomEmail()
	userform.fields['username'] = name
	userform.fields['password'] = passwd
	userform.fields['role'] = role
	resultPage = userform.click("submit")
	resultPage = resultPage.doRedirects()
	return resultPage
开发者ID:Steccas,项目名称:ctf-scorebot,代码行数:17,代码来源:TherapyServiceScript.py


示例6: score

def score(ip,flag,cookie):
	#get old flag
	if cookie != None:
		try:
			wwid = cookie
			vote = CtfUtil.getRandomString(random.randint(5,10))

			response = sendMessage(ip,encrypt("!"+wwid+" "+vote))
			successPtr = response.find("OK")
			if successPtr != -1:
				oldFlag = decrypt(response[successPtr+3:].strip())
				print "FLAG:",oldFlag

		except Exception, e:
			print "ERROR: got exception %s getting flag" % (e)
开发者ID:RootFu,项目名称:ctf-scorebot,代码行数:15,代码来源:VotecastServiceScript.py


示例7: score

def score(ip,flag,cookie):
	#get old flag  
	if cookie != None:
		try:
			user,email = cookie.split(":")
			resultPage = getNotePage(ip,user,email,CtfUtil.getRandomString(random.randint(5,10)))
                                
			successPtr = resultPage.page.find("NOTE:")

			if successPtr != -1:
				endPointer = resultPage.page[successPtr+6:].find("\n")
				oldFlagText = resultPage.page[successPtr+6:][:endPointer]
				oldFlag = urllib.unquote(oldFlagText)[:len(flag)]
				print "FLAG:",oldFlag
     
		except Exception, e:
			print "ERROR: got exception %s setting new flag" % (e)
			sys.exit(1)
开发者ID:RootFu,项目名称:ctf-scorebot,代码行数:18,代码来源:BassretardServiceScript.py


示例8: score

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,代码行数:21,代码来源:DiscussitServiceScript.py


示例9: create_flag

def create_flag(s, flag):
	username = CtfUtil.getRandomString(6)
	password = random.choice(good_password)
	s.send('new %s %s\n'%(username,password))
        
	res = readline(s)

	if res[:3] != "200":
		return ""
        
	s.send("to: xxxx\n")
	res = readline(s)
        
	s.send("spam\n")
	res = readline(s)
	res = readline(s)
	res = readline(s)
        
	s.send("%s\n"%flag)
	s.send(".\n")
	res = readline(s)
        
	return username+":"+password
开发者ID:RootFu,项目名称:ctf-scorebot,代码行数:23,代码来源:SpammerServiceScript.py


示例10: FlagClient

#!/usr/bin/python -u

from utility import CtfUtil
from utility.flagclient import FlagClient

if __name__ == "__main__":
    flagClient = FlagClient(port=8082)
    CtfUtil.main(flagClient.score)
开发者ID:kudox,项目名称:ctf_scorebot5,代码行数:8,代码来源:valves.py


示例11: len

			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)

	#set the new flag
	try:  
		sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
		sock.connect((ip, port))

		name = CtfUtil.getRandomString(random.randint(6,8))
		msg = name+" " + flag + "\n"    
		response = initConversation(msg,sock)

		successPtr = response.find("summoning operator")
		if successPtr == -1:
			print "ERROR: Could not set new flag"
			return

		for i in range(random.randint(1,3)):
			if len(askRandomQuestion(sock)) < 1:
				print "ERROR: Something doesnt look right"
				return

		sock.close()
		cookie = name
开发者ID:RootFu,项目名称:ctf-scorebot,代码行数:31,代码来源:DiscussitServiceScript.py


示例12: str

				oldFlag = resultingPage.page[successPtr+19:][: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 + "/~register/register.html", personality)
		mainpg.open()
		mainpg.parse()

		registrationForm = mainpg.forms[0]

		password = CtfUtil.getRandomAlphaNum(8)
		wwid = flag

		registrationForm.fields['first'] = CtfUtil.getRandomString(random.randint(5,7))
		registrationForm.fields['last'] = CtfUtil.getRandomString(random.randint(6,9))
		registrationForm.fields['dob'] = str(random.choice(months))+" "+str(random.randint(1,29))+", "+str(random.randint(1900,2000))
		registrationForm.fields['email'] = CtfUtil.getRandomEmail()
		registrationForm.fields['password'] = password
		registrationForm.fields['wwid'] = wwid

		resultingPage = registrationForm.click(None)

		successPtr = resultingPage.page.find("Registration successful!")

		if successPtr == -1:
			print "ERROR: Could not set new flag"
开发者ID:RootFu,项目名称:ctf-scorebot,代码行数:31,代码来源:RegisterServiceScript.py


示例13:

		personality = browserpersonality.getRandomPersonality()
		mainpg = pybrowse.Browser("http://" + ip + "/Site/Would_you.html")
		mainpg.open()
		mainpg = pybrowse.Browser("http://" + ip + "/Site//Would_you_files/widget1_markup.html")
		mainpg.open()
		mainpg.parse()
            
		qForm = mainpg.forms[0]
		qForm.fields["q1"] = random.choice(("yes", "no")) 
		qForm.fields["q2"] = random.choice(("yes", "no")) 
		qForm.fields["q3"] = random.choice(("yes", "no")) 
		qForm.fields["q5"] = random.choice(("yes", "no")) 
		qForm.fields["q6"] = random.choice(("yes", "no")) 
		qForm.fields["q7"] = random.choice(("yes", "no")) 

		cookie = CtfUtil.getRandomString(random.randint(3,10))

		qForm.fields["steal"] =  flag
		qForm.fields["signature"] = cookie
		resultingPage = qForm.click(None)
		resultingPage = resultingPage.doRedirects()
   
		successPtr = resultingPage.page.find("was successfully saved.")
		if successPtr == -1:
			print "ERROR: cannot set flag"
    
		print "COOKIE:",cookie
        
	except Exception, e:
		print "ERROR: got exception %s getting flag" % (e)
        
开发者ID:RootFu,项目名称:ctf-scorebot,代码行数:30,代码来源:WouldYouServiceScript.py


示例14:

			print "ERROR: got exception [%s] getting flag" % (e)
			sys.exit(1)
                
        
	# set the new flag
	try:
		personality = browserpersonality.getRandomPersonality()
		mainpg = pybrowse.Browser("http://" + ip + "/Site/Sound_of_music.html")
		mainpg.open()
		mainpg = pybrowse.Browser("http://" + ip + "/Site/Sound_of_music_files/widget1_markup.html")
		mainpg.open()
		mainpg.parse()

		qForm = mainpg.forms[0]
		myfirst =flag 
		mylast = CtfUtil.getRandomString(random.randint(3,10))
		myemail = CtfUtil.getRandomEmail()
		mypassword = CtfUtil.getRandomString(random.randint(3,10))
            
		qForm.fields["first"] = myfirst
		qForm.fields["last"] = mylast
		qForm.fields["email"] = myemail
		qForm.fields["password"] = mypassword
            
		cookie = qForm.fields["email"] + ":" + qForm.fields["password"]
		resultingPage = qForm.click(None)
		resultingPage = resultingPage.doRedirects()
		successPtr = resultingPage.page.find("successfully created")

		if successPtr == -1:
			print "ERROR: Error setting new flag"
开发者ID:Steccas,项目名称:ctf-scorebot,代码行数:31,代码来源:CopyrightServiceScript.py


示例15: getRandomSentence

def getRandomSentence(len):
	ret = ""
	for i in range(len):
		ret += CtfUtil.getRandomString(random.randint(1,8)) + " "
	return ret
开发者ID:Steccas,项目名称:ctf-scorebot,代码行数:5,代码来源:CopyrightServiceScript.py


示例16:

	try:
		personality = browserpersonality.getRandomPersonality()
        
		# 1. go to the shell's page
		mainpg = pybrowse.Browser("http://" + ip + "/Site/Bosses_and_artists.html")
		mainpg.open()
        
		# 2. create a new boss
		mainpg = pybrowse.Browser("http://" + ip + ":" + myPort + "/bosses/new/")
    
		mainpg.open()
		mainpg.parse()
            
		myform = mainpg.forms[0]

		boss_name = CtfUtil.getRandomString(random.randint(6,16))
		boss_pwd = CtfUtil.getRandomString(random.randint(6,8))
            
		myform.fields["name"] = boss_name.capitalize()
		myform.fields["username"] = boss_name
		myform.fields["password"] = boss_pwd
		myform.fields["password_again"] = boss_pwd
            
		resultingPage = myform.click( None )
		resultingPage = resultingPage.doRedirects( )
		resultingPage.parse()
            
		checkError(resultingPage)
        
		# resulting page should be /bosses/view/N/
		boss_id = resultingPage.documentroot.split("/")[3]
开发者ID:RootFu,项目名称:ctf-scorebot,代码行数:31,代码来源:ShakedownServiceScript.py


示例17: getNotePage

                                
			successPtr = resultPage.page.find("NOTE:")

			if successPtr != -1:
				endPointer = resultPage.page[successPtr+6:].find("\n")
				oldFlagText = resultPage.page[successPtr+6:][:endPointer]
				oldFlag = urllib.unquote(oldFlagText)[:len(flag)]
				print "FLAG:",oldFlag
     
		except Exception, e:
			print "ERROR: got exception %s setting new flag" % (e)
			sys.exit(1)
         
	#set the new flag
	try:
		user = CtfUtil.getRandomString(random.randint(6,8))
		email = CtfUtil.getRandomEmail()
		note = flag
            
		resultPage = getNotePage(ip,user,email,note)
            
		successPtr = resultPage.page.find("Annotation saved!")
		if successPtr == -1:
			return
            
		cookie = user+":"+email
		print "COOKIE:",cookie
            
	except Exception, e:
		print "ERROR: got exception %s setting new flag" % (e)
        
开发者ID:RootFu,项目名称:ctf-scorebot,代码行数:29,代码来源:BassretardServiceScript.py


示例18: score

def score(ip,flag,cookie):
	try: 
		# ------------------------- 
		# Retrieve old flag
		# ------------------------- 
        
		old_flag = "None"
            
		real_path = execution_path("./snitch_data/snitch_clean.jpg")
		save_path = execution_path("./snitch_data/%s.jpg"%ip)
		font_path = execution_path("./snitch_data/arial.ttf")
           
		if cookie:
			name = cookie.replace("_"," ")
			img = Image.open(real_path)
			draw = ImageDraw.Draw(img)
			font = ImageFont.truetype(font_path, 20)
			draw.text(( 5, 40), name, fill="black", font=font)
			draw.text(( 5, 80), "abcde", fill="black", font=font)
			img.save(save_path)
        
			f = open(save_path)
			fdata = f.read()
			f.close()
        
			#print "Getting the flag..."
			status, reason, data = post_multipart(
				ip, "/~snitch/cgi-bin/snitch.py", [], [('paper',"%s"%save_path, fdata)])
        
			pos = data.find("thanks to paper")
			if pos != -1:
				old_flag = data[pos+21:][:len(flag)]
				print "FLAG:",old_flag         
        
		# ------------------------- 
		# Set the new one
		# ------------------------- 
		img = Image.open(real_path)
		draw = ImageDraw.Draw(img)
        
		first = CtfUtil.getRandomString(random.randint(6,10))
		last = CtfUtil.getRandomString(random.randint(6,10))
		name = first + " " + last
            
		address = "xxxxx" 
             
		#print "Generating picture..."
        
		font = ImageFont.truetype(font_path, 20)
		draw.text(( 5, 40), name, fill="black", font=font)
		draw.text(( 5, 80), address, fill="black", font=font)
        
		img.save(save_path)
        
		#print "Setting exif info..."
		os.popen("""exiv2 -M"set Exif.Photo.UserComment Paper_ID=%s" %s"""%(flag, save_path))
        
		f = open(save_path)
		fdata = f.read()
		f.close()
        
		#print "Setting flag..."
		status, reason, data = post_multipart(
			ip, "/~snitch/cgi-bin/snitch.py", [], [('paper', "%s"%save_path, fdata)])
		#print "Status ",status
        
		cookie = name.replace(" ","_")
		print "COOKIE:",cookie
        
	except Exception, e:
		print "ERROR: %s" % e 
开发者ID:RootFu,项目名称:ctf-scorebot,代码行数:71,代码来源:SnitchServiceScript.py


示例19:

				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 + "/Site/Petition.html")
		mainpg.open()
		mainpg = pybrowse.Browser("http://" + ip + "/Site//Petition_files/widget1_markup.html")
		mainpg.open()
		mainpg.parse()

		myform = mainpg.forms[0]
		myform.fields["first"] = CtfUtil.getRandomString(random.randint(4,10))
		myform.fields["last"] = CtfUtil.getRandomString(random.randint(4,10))
		myform.fields["email"] = CtfUtil.getRandomEmail()
		myform.fields["comment"] = flag

		myform.fields["id"] = ""
		resultingPage = myform.click(None)
		resultingPage = resultingPage.doRedirects()
		successPtr = resultingPage.page.find( "Your ID is " )
        
		if successPtr != -1:
			cookie = resultingPage.page[successPtr+11:][:8]
			print "COOKIE:",cookie
        
	except Exception, e:
		print "ERROR: got exception %s setting new flag" % (e)
开发者ID:Steccas,项目名称:ctf-scorebot,代码行数:31,代码来源:PetitionServiceScript.py


示例20: getRandomPiratedFiles

				oldFlag = rawPage[successPtr+21:][:len(flag)] 
				print "FLAG:",oldFlag
                
		except Exception, e:
			print "ERROR: got exception '%s' when getting flag" % (e)
			sys.exit(1)
        
	# set new flag
	try:
		url = "http://" + ip + "/Site/Make_amends.html"
		personality = browserpersonality.getRandomPersonality()
		mainpg = pybrowse.Browser(url, personality)
		mainpg.open()
            
		# create a new user acccount
		fname = CtfUtil.getRandomString(random.randint(6,10))
		lname = CtfUtil.getRandomString(random.randint(6,10))
		eaddr = CtfUtil.getRandomEmail()
		files = getRandomPiratedFiles(random.randint(1,5))
		price = getRandomDollarAmount(random.randint(1,5))
		resultPage = createAccount(ip,fname, lname, eaddr, files, price)
        
		# choose settlement letter format preference and get case id
		caseid = chooseFormatPref(resultPage)
        
		# login using the new account
		resultPage = doNewLogin(ip, eaddr, caseid)
        
		# view the settlement letter
		viewSettlementLetter(resultPage)
        
开发者ID:RootFu,项目名称:ctf-scorebot,代码行数:30,代码来源:AmendsServiceScript.py



注:本文中的utility.CtfUtil类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python utility.Utility类代码示例发布时间:2022-05-26
下一篇:
Python utility.Bits类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap