前言
西湖论剑,错过了。只有现在才可以。只好先把题目下载下来,半夜三根的慢慢做。
我的顺序是先misc->web->pwn,其他题目我就真的做不来啦。
现在也先写一个Misc题目吧,题目如下:
资深宅“flag{”在朋友邀请下,参加了一场聚会。
在聚会上看到了美女“75D}”,一时心花荡漾、不能自己,坚信彼此就是天造地设的一双。
想通过层层朋友的关系认识她,却无奈性格问题,不敢劳师动众。
好在朋友帮忙搞到一张聚会人员关系图,如下:[('FloraPrice','E11'),('FloraPrice','E9'),('FloraPrice','75D}'),('NoraFayette','E11'),('NoraFayette','E10'),('NoraFayette','E13'),('NoraFayette','E12'),('NoraFayette','E14'),('NoraFayette','E9'),('NoraFayette','E7'),('NoraFayette','E6'),('E10','SylviaAvondale'),('E10','MyraLiddel'),('E10','HelenLloyd'),('E10','KatherinaRogers'),('VerneSanderson','E7'),('VerneSanderson','E12'),('VerneSanderson','E9'),('VerneSanderson','E8'),('E12','HelenLloyd'),('E12','KatherinaRogers'),('E12','SylviaAvondale'),('E12','MyraLiddel'),('E14','SylviaAvondale'),('E14','75D}'),('E14','KatherinaRogers'),('FrancesAnderson','E5'),('FrancesAnderson','E6'),('FrancesAnderson','E8'),('FrancesAnderson','E3'),('DorothyMurchison','E9'),('DorothyMurchison','E8'),('EvelynJefferson','E9'),('EvelynJefferson','E8'),('EvelynJefferson','E5'),('EvelynJefferson','E4'),('EvelynJefferson','E6'),('EvelynJefferson','E1'),('EvelynJefferson','E3'),('EvelynJefferson','E2'),('RuthDeSand','E5'),('RuthDeSand','E7'),('RuthDeSand','E9'),('RuthDeSand','E8'),('HelenLloyd','E11'),('HelenLloyd','E7'),('HelenLloyd','E8'),('OliviaCarleton','E11'),('OliviaCarleton','E9'),('EleanorNye','E5'),('EleanorNye','E7'),('EleanorNye','E6'),('EleanorNye','E8'),('E9','TheresaAnderson'),('E9','PearlOglethorpe'),('E9','KatherinaRogers'),('E9','SylviaAvondale'),('E9','MyraLiddel'),('E8','TheresaAnderson'),('E8','PearlOglethorpe'),('E8','KatherinaRogers'),('E8','SylviaAvondale'),('E8','BrendaRogers'),('E8','LauraMandeville'),('E8','MyraLiddel'),('E5','TheresaAnderson'),('E5','BrendaRogers'),('E5','LauraMandeville'),('E5','CharlotteMcDowd'),('E4','CharlotteMcDowd'),('E4','TheresaAnderson'),('E4','BrendaRogers'),('E7','TheresaAnderson'),('E7','SylviaAvondale'),('E7','BrendaRogers'),('E7','LauraMandeville'),('E7','CharlotteMcDowd'),('E6','TheresaAnderson'),('E6','PearlOglethorpe'),('E6','BrendaRogers'),('E6','LauraMandeville'),('E1','LauraMandeville'),('E1','BrendaRogers'),('E3','TheresaAnderson'),('E3','BrendaRogers'),('E3','LauraMandeville'),('E3','CharlotteMcDowd'),('E3','flag{'),('E2','LauraMandeville'),('E2','TheresaAnderson'),('KatherinaRogers','E13'),('E13','SylviaAvondale')]
你能在让最少人知道的情况下,帮助flag先生联系上75D小姐姐吗?
求节点“flag{”到“75D”的最短路径,即为flag,比如:flag{E3AliceBobXXXXXXXXXXXXXXXX75D}
很明显一个BFS搜索最短路径。
虽然说直接用手算就行,但是我一定要整一个软件出来
分析
我们先看上面这么多数据,我们假设把名字当成节点,En当成line。
我们就能分为两种分类,一种是 名字开头,成员是线的标准node maps。
friendship = {'FloraPrice': ['E11', 'E9', '75D}'], 'NoraFayette': ['E11', 'E10', 'E13', 'E12', 'E14', 'E9', 'E7', 'E6'], 'VerneSanderson': ['E7', 'E12', 'E9', 'E8'], 'FrancesAnderson': ['E5', 'E6', 'E8', 'E3'], 'DorothyMurchison': ['E9', 'E8'], 'EvelynJefferson': ['E9', 'E8', 'E5', 'E4', 'E6', 'E1', 'E3', 'E2'], 'RuthDeSand': ['E5', 'E7', 'E9', 'E8'], 'HelenLloyd': ['E11', 'E7', 'E8'], 'OliviaCarleton': ['E11', 'E9'], 'EleanorNye': ['E5', 'E7', 'E6', 'E8'], 'KatherinaRogers': ['E13']}
另一种就是已线为节点,名字为成员的 初始Line搜索的图。
line = {'E10': ['SylviaAvondale', 'MyraLiddel', 'HelenLloyd', 'KatherinaRogers'], 'E12': ['HelenLloyd', 'KatherinaRogers', 'SylviaAvondale', 'MyraLiddel'], 'E14': ['SylviaAvondale', '75D}', 'KatherinaRogers'], 'E9': ['TheresaAnderson', 'PearlOglethorpe', 'KatherinaRogers', 'SylviaAvondale', 'MyraLiddel'], 'E8': ['TheresaAnderson', 'PearlOglethorpe', 'KatherinaRogers', 'SylviaAvondale', 'BrendaRogers', 'LauraMandeville', 'MyraLiddel'], 'E5': ['TheresaAnderson', 'BrendaRogers', 'LauraMandeville', 'CharlotteMcDowd'], 'E4': ['CharlotteMcDowd', 'TheresaAnderson', 'BrendaRogers'], 'E7': ['TheresaAnderson', 'SylviaAvondale', 'BrendaRogers', 'LauraMandeville', 'CharlotteMcDowd'], 'E6': ['TheresaAnderson', 'PearlOglethorpe', 'BrendaRogers', 'LauraMandeville'], 'E1': ['LauraMandeville', 'BrendaRogers'], 'E3': ['TheresaAnderson', 'BrendaRogers', 'LauraMandeville', 'CharlotteMcDowd', 'flag{'], 'E2': ['LauraMandeville', 'TheresaAnderson'], 'E13': ['SylviaAvondale']}
之后就很简单啦,首先我们line搜索出flag{的初始线E3。之后去friendship查找关系,更具line查找到Node名,然后加入queue防止重复搜索,然后继续遍历Node下的line依次反复,直到找到end。
代码
queue = []
def get_line(txt):
for i in line:
if txt in line[i]:
return i
def dfs(txt,target,vector):
for i in friendship:
if txt in friendship[i]:
queue.insert(0,(i,txt))
new = vector + i
for j in friendship[i]:
if j == target:
print(new+"75D}")
return
if (i,j) not in queue:
new = new + j
dfs(j,target,new)
queue.pop()
dfs(get_line("flag{"), '75D}',"")
结果
从结果列表中找到最短的,然后加上flag。
最后得出flag就是
flag{E3EvelynJeffersonE9FloraPrice75D}
不用写啦,我有现成的,不仅有BFS还有DFS (逃
这种不现写用轮子那还有什么比的意义(逃