008. working hard?

Bz2

关卡地址#

解决方案:#

思路:#

这一关,图片下面有这样的提示:

Where is the missing link?

鼠标在图片上“扫描”一遍发现,图片中蜜蜂区域是可点击的,访问的就是下一关的地址。

对,你没有看错,就是下一关地址。不过在此之前,你需要认证。

所以这一关的目的就是找到用户名和密码。

查看源代码得到如下提示:

un: 'BZh91AY&SYA\xaf\x82\r\x00\x00\x01\x01\x80\x02\xc0\x02\x00 \x00!\x9ah3M\x07<]\xc9\x14\xe1BA\x06\xbe\x084'
pw: 'BZh91AY&SY\x94$|\x0e\x00\x00\x00\x81\x00\x03$ \x00!\x9ah3M\x13<]\xc9\x14\xe1BBP\x91\xf08'

很明显,un就是username的简写,pw就是password的简写。

字符串是经过bz2编码之后的输出,我们要解码得到原始字符串。

代码:#

# ================================
# 写bz2文件,可以使用7zip直接查看
def makeBz2(filename, data):
    fp=open(filename, 'wb')
    fp.write(data)
    fp.close()

import helper
dir="../../Data/008"
helper.ensureDir(dir)

un=b'BZh91AY&SYA\xaf\x82\r\x00\x00\x01\x01\x80\x02\xc0\x02\x00 \x00!\x9ah3M\x07<]\xc9\x14\xe1BA\x06\xbe\x084'
pw=b'BZh91AY&SY\x94$|\x0e\x00\x00\x00\x81\x00\x03$ \x00!\x9ah3M\x13<]\xc9\x14\xe1BBP\x91\xf08'

makeBz2(dir+'/user.bz2', un)
makeBz2(dir+'/pwd.bz2', pw)
# ================================

import codecs

username=codecs.decode(un, 'bz2').decode('utf-8')
password=codecs.decode(pw, 'bz2').decode('utf-8')
# or
# username=codecs.decode(open(dir+'/user.bz2','rb').read(), 'bz2').decode('utf-8')
# password=codecs.decode(open(dir+'/pwd.bz2','rb').read(), 'bz2').decode('utf-8')

print('username: %s\npassword: %s' % (username, password))
$un='BZh91AY&SYA\xaf\x82\r\x00\x00\x01\x01\x80\x02\xc0\x02\x00 \x00!\x9ah3M\x07<]\xc9\x14\xe1BA\x06\xbe\x084'
$pw='BZh91AY&SY\x94$|\x0e\x00\x00\x00\x81\x00\x03$ \x00!\x9ah3M\x13<]\xc9\x14\xe1BBP\x91\xf08'

$path="../../Data/008"
. .\helper.ps1
New-Dir -Dir $path
$path=$(Resolve-Path $path).Path

Write-BinaryFile -Filename $($path+"/user.bz2") -Data $(ConvertFrom-Bz2String -InStr $un)
Write-BinaryFile -Filename $($path+"/pwd.bz2") -Data $(ConvertFrom-Bz2String -InStr $pw)

# 使用bzip2解压并输出
Write-Output $("username: {0}" -f $(.\bin\bzip2.exe -d -k -c $($path+"/user.bz2")))
Write-Output $("password: {0}" -f $(.\bin\bzip2.exe -d -k -c $($path+"/pwd.bz2")))
package main

import(
	"fmt"
	"os"
	"compress/bzip2"
	"io/ioutil"
)

func (c *Challenge) Challenge008() {
	unfile:="../../Data/008/user.bz2"
	pwfile:="../../Data/008/pwd.bz2"

	username:=bz2Decode(unfile)
	password:=bz2Decode(pwfile)

	fmt.Printf("username: %s\npassword: %s\n", username, password)
}

func bz2Decode(filename string) string {
	reader,err := os.Open(filename)
	if err != nil {
		fmt.Printf("open file %s failed![%v]", filename, err)
		return ""
	}
	defer reader.Close()

	bzrd := bzip2.NewReader(reader)

	bytes,ierr := ioutil.ReadAll(bzrd)
	if ierr != nil {
		fmt.Printf("read file %s failed![%v]", filename, ierr)
		return ""
	}

	return string(bytes)
}

最终结果: username: huge, password: file#

下一关地址#

017. eat?

关卡地址#

解决方案:#

思路:#

这一关图片中是曲奇饼干,左下角图片是不是有点熟悉?是第四关啦!

查看源代码并没有什么提示。

但是!根据cookie可以联想到什么?对!就是浏览器缓存。

通过浏览器开发者工具查看cookie后,可以得到如下提示:

you+should+have+followed+busynothing…

在第四关,我们请求的是:http://www.pythonchallenge.com/pc/def/linkedlist.php?nothing=

这里需要将nothing替换为busynothing,并且收集cookieinfo的值。

之后得到BZh91AY开头的经过url编码的字符串,是不是又有点熟悉?不熟悉的请回顾第八关

使用python在解码时会有小问题:

OSError: Invalid data stream

在解码前将+替换为%20可以解决该问题。

解码后得到提示:

is it the 26th already? call his father and inform him that “the flowers are on their way”. he’ll understand.

这句话信息量有点大,26号暗示第十五关call his father则暗示第十三关,Mozart的父亲是Leopold(注意L大写)。

给Leopold打电话之后得到:

555-VIOLIN

访问violin.html得到如下提示:

no! i mean yes! but ../stuff/violin.php.

替换url之后访问,得到的是一张Leopold的照片,及:

it’s me. what do you want?

额。。。对,and inform him that “the flowers are on their way”

❤️ 如果这篇文章对你有帮助,欢迎赞助支持我继续维护 ❤️

☕ Support me ⚡ 爱发电赞助