http://www.pythonchallenge.com/pc/return/bull.html
len(a[30]) = ?
这是源代码:
<html>
<head>
<title>what are you looking at?</title>
<link rel="stylesheet" type="text/css" href="../style.css">
</head>
<body>
<br><br>
<center>
<img src="bull.jpg" width="640" height="480" border="0" usemap="#bull"/>
<map name="bull">
<area shape="poly" coords="146,399,163,403,170,393,169,391,166,386,170,381,170,371,170,355,169,346,167,335,170,329,170,320,170,310,171,301,173,290,178,289,182,287,188,286,190,286,192,291,194,296,195,305,194,307,191,312,190,316,190,321,192,331,193,338,196,341,197,346,199,352,198,360,197,366,197,373,196,380,197,383,196,387,192,389,191,392,190,396,189,400,194,401,201,402,208,403,213,402,216,401,219,397,219,393,216,390,215,385,215,379,213,373,213,365,212,360,210,353,210,347,212,338,213,329,214,319,215,311,215,306,216,296,218,290,221,283,225,282,233,284,238,287,243,290,250,291,255,294,261,293,265,291,271,291,273,289,278,287,279,285,281,280,284,278,284,276,287,277,289,283,291,286,294,291,296,295,299,300,301,304,304,320,305,327,306,332,307,341,306,349,303,354,301,364,301,371,297,375,292,384,291,386,302,393,324,391,333,387,328,375,329,367,329,353,330,341,331,328,336,319,338,310,341,304,341,285,341,278,343,269,344,262,346,259,346,251,349,259,349,264,349,273,349,280,349,288,349,295,349,298,354,293,356,286,354,279,352,268,352,257,351,249,350,234,351,211,352,197,354,185,353,171,351,154,348,147,342,137,339,132,330,122,327,120,314,116,304,117,293,118,284,118,281,122,275,128,265,129,257,131,244,133,239,134,228,136,221,137,214,138,209,135,201,132,192,130,184,131,175,129,170,131,159,134,157,134,160,130,170,125,176,114,176,102,173,103,172,108,171,111,163,115,156,116,149,117,142,116,136,115,129,115,124,115,120,115,115,117,113,120,109,122,102,122,100,121,95,121,89,115,87,110,82,109,84,118,89,123,93,129,100,130,108,132,110,133,110,136,107,138,105,140,95,138,86,141,79,149,77,155,81,162,90,165,97,167,99,171,109,171,107,161,111,156,113,170,115,185,118,208,117,223,121,239,128,251,133,259,136,266,139,276,143,290,148,310,151,332,155,348,156,353,153,366,149,379,147,394,146,399"
href="sequence.txt" />
</map>
<br>
<br>
<font color="gold" size="+1">len(a[30]) = ?</font>
</body>
</html>
有用的一是coords, 二是 sequence.txt。 ord用matplotlib画出来还是个牛,对了一下,跟上一关的first数列一样,就不放图了。sequence.txt 内容是 a = [1, 11, 21, 1211, 111221, 图片下方问len(a[30]) = ? 看来是要问这个答案了,推理a数值的规律:
忽然想到个取巧的主意,因为数列长度肯定是整数,直接request一下,看看能不能返回正确数值?当然极大可能性是作者早就设了一堆坑。为了不低估作者的BT程度(鬼知道长度多长),写个长点的程序丢在这跑一跑,看看能不能出来,
import requests
import time
def get_text(url):
try:
r = requests.get(url, timeout=40)
r.raise_for_status()
r.encoding = r.apparent_encoding
Flag = True
except BaseException:
Flag = False
return Flag
if __name__ == '__main__':
start = time.time()
for i in range(10000):
url = 'http://www.pythonchallenge.com/pc/return/' + str(i) + '.html'
status = get_text(url)
if status == True:
print(url)
end = time.time()
print('一共耗时{}s'.format(end-start))
发现拿不到,然后看了看status_code, 返回401,是需要授权认证,再试了加了cookie也不行,看来作者堵死了我们这条路,老老实实的继续破解
import re
def describe(s):
return "".join([str(len(m.group(0))) + m.group(1) for m in re.finditer(r"(\d)\1*", s)])
strs = "1"
for dummy in range(30):
strs = describe(strs)
print len(strs)
输出5808 ,进入下一关
=一个月后搞定了401,,继续跑一下穷举====
#!/usr/bin/env python
# -*- encoding: utf-8 -*-
"""
@File : Python_challenge_13.py.py
@Time : 2019/7/19 20:19
@Author : 麦地吃大米
"""
import requests.auth
authorize = requests.auth.HTTPBasicAuth('huge', 'file')
url = 'http://www.pythonchallenge.com/pc/return/'
url_list = [url + str(i) + '.html' for i in range(10000)]
for u in url_list:
try:
r = requests.post(u, auth=authorize)
if r.status_code == 404:
print('\r 当前网页为{},找不到网页'.format(u.split('/')[-1]), end='')
else:
print(r.content.decode())
print('\r 当前网页为{},找到网页'.format(u.split('/')[-1]))
break
except BaseException:
continue
等等看看结果,1跑到10000挺长,能跑出来的话,想办法加个多线程。结果" 当前网页为5808.html,找到网页",收工。