def do_compute(self): # step 1, get prompt information from web source words_hint = TextHelper.find_text_between_tag(self.web_source, "<!-- ", " -->") print words_hint img_url_short = TextHelper.find_text_between_tag(self.web_source, "<img src=\"", "\" border=") ImageHelper.show_image_from_web(WebHelper.join_url(self.url, img_url_short)) # It shows a same picture with different brightness print "brightness" prompt_url = WebHelper.join_url(self.url, "brightness") print "get new prompt url: %s" % prompt_url # step 2, download gz file from web prompt_url = WebHelper.get_prompt_url_from_web(prompt_url, "<!-- maybe consider ", " -->") local_gz = WebHelper.get_url_page(prompt_url) WebHelper.download_with_auth(prompt_url, local_gz) # step 3, get png data and show the image gz_content = FileHelper.read_gzip_file(local_gz) png = T18.get_png_data_from_diff_data(gz_content) for i in range(3): ImageHelper.show_image_from_data(png[i]) # from image, we can see "../hex/bin.html", "butter", "fly" ==> These last two words will be used in next level prompt_url = "../hex/bin.html" print 'we can see "../hex/bin.html", "butter", "fly" in these image, set new user, password for next level' self.result.set_user_password("butter", "fly") # step 4, set prompt self.set_prompt(prompt_url) # step 5, clean zip file FileHelper.remove_file(local_gz)
def do_compute(self): # step 1, get prompt information from web source print TextHelper.find_text_between_tag(self.web_source, '<!-- ', '-->') wav_suffix = 'wav' print "Above prompt words ask us to replace the suffix of jpg to %s" % wav_suffix wave_img_url = WebHelper.join_url( self.url, TextHelper.find_text_between_tag(self.web_source, '<img src="', '">')) print "wave image web url is %s" % wave_img_url ImageHelper.show_image_from_web( WebHelper.join_url(self.url, wave_img_url), self.user, self.password) print "This picture prompt us: there is 25 block, we need to combine them" # step 2, download waves wave_url = WebHelper.change_suffix_url(wave_img_url, wav_suffix) print "After change suffix: %s" % wave_url local_directory = 't25' FileHelper.mkdir(local_directory) waves = [] for i in range(25): store_path = FileHelper.join_path(local_directory, WebHelper.get_url_page(wave_url)) WebHelper.download_with_auth(wave_url, store_path, self.user, self.password) waves.append(wave.open(store_path)) wave_url = WebHelper.url_add(wave_url) # step 3, Create combine image from waves img = Image.new('RGB', (300, 300), 'black') frames = waves[0].getnframes() print "Totally waves: %d" % len(waves) for i in range(len(waves)): tmp_img = Image.frombytes('RGB', (60, 60), waves[i].readframes(frames)) current_pos = (60 * (i % 5), 60 * (i // 5)) print "Put image to position%s" % str(current_pos) img.paste(tmp_img, current_pos) img.show() # It shows a words 'decent' # step 4, set prompt words prompt_word = 'decent' print "Get prompt words from combined picture: %s" % prompt_word self.set_prompt(prompt_word) # step 5, clean unused file FileHelper.remove_folder(local_directory)
def do_compute(self): # step 1, get prompt information from web source gif_prompt = TextHelper.find_text_between_tag(self.web_source, '<!-- or maybe ', ' would be more') gif_url = WebHelper.join_url(self.url, gif_prompt) print "Get gif url: %s" % gif_url ImageHelper.show_image_from_web(gif_url, self.user, self.password) local_image = WebHelper.get_url_page(gif_url) WebHelper.download_with_auth(gif_url, local_image, self.user, self.password) ImageHelper.show_from_file(local_image) # step 2, get Image draw img = Image.open(local_image) prompt_img = Image.new("RGB", (500, 200)) draw = ImageDraw.Draw(prompt_img) cx, cy = 0, 100 for frame in range(img.n_frames): img.seek(frame) left, upper, right, lower = img.getbbox() dx = left - 100 dy = upper - 100 if dx == dy == 0: cx += 50 cy = 100 cx += dx cy += dy draw.point([cx, cy]) prompt_img.show() # shows 'bonus' # step 3, set prompt prompt_words = 'bonus' print "get prompt words from image %s" % prompt_words self.set_prompt(prompt_words) # step 4, clean unused files FileHelper.remove_file(local_image)
def do_compute(self): # step 1. get picture from web prompt_img_url = TextHelper.find_text_between_tag( self.web_source, "<img src=\"", "\" width=\"640\" height") img_url = WebHelper.join_url(self.url, prompt_img_url) local_img = WebHelper.get_url_page(img_url) WebHelper.download_with_auth(img_url, local_img) # step 2. get odd picture img = Image.open(local_img) odd = Image.new(img.mode, (img.size[0], img.size[1])) for x in range(img.size[0]): for y in range(img.size[1]): if (x + y) % 2 == 0: odd.putpixel((x, y), img.getpixel((x, y))) odd.show() # shows: 11 evil odd.close() # step 3. set prompt self.set_prompt("evil") # step 4. clear the files FileHelper.remove_file(local_img)