工具chrome+python
chrome打开虾米的播放列表,f12看network情况
请求了(此处sid不一定能打开)
http://www.xiami.com/song/gethqsong/sid/177005963
内容
{"status":1,"location":"","msg":"8h2fmFjWI5TrY55eHg2tFiihuFsEGUwCEEGzOt%l.%dl%eEtJRC7eK1p2ec2Gg54xtfXCq1m4%F.oFIaEu4zIQWcaCe3mxm%pScz9sv9r3RHGA3i%5NeBXV8wKETNUu%.a2EvT%GtIl%c5uuk"}
mp3路径
http://m3.file.xiami.com/h/0judGIpNvWFlgaSeTIs0cB0e4uzXGTGEx49VtrUttzs8IYwJfIvwl5CRXQ9K0CCWrEceE7qc3T5HGe1aRNugzKmCHUu2O14eGuk
比对一下密文和明文的情况看看是不是线性的
s='8h2fmFjWI5TrY55eHg2tFiihuFsEGUwCEEGzOt%l.%dl%eEtJRC7eK1p2ec2Gg54xtfXCq1m4%F.oFIaEu4zIQWcaCe3mxm%pScz9sv9r3RHGA3i%5NeBXV8wKETNUu%.a2EvT%GtIl%c5uuk' d = 'http://m3.file.xiami.com/h/0judGIpNvWFlgaSeTIs0cB0e4uzXGTGEx49VtrUttzs8IYwJfIvwl5CRXQ9K0CCWrEceE7qc3T5HGe1aRNugzKmCHUu2O14eGuk' o = '' for i,j in enumerate(d): if j in s[i:]: o += j print d print o
匹配的结果,有部分匹配不了,把能匹配上的分割一下
http://m3.file.xiami.com/h/0judGIpNvWFlgaSeTIs0cB0e4uzXGTGEx49VtrUttzs8IYwJfIvwl5CRXQ9K0CCWrEceE7qc3T5HGe1aRNugzKmCHUu2O14eGuk
http m3.file.xiami.com udGIpNvWFlgaSeTIs cB e4uzXGTGEx49VtrUttzs8I w Ivwl5CRXQ9K CC rEceE c3T5HGe a Nu K Uu2 Guk
把第二行逐字在密文里搜,然后断开,注意:和/要转成url编码(比如:是%3A)
得到一个这种东西
8
h2fmFjWI5TrY55eHg2
tFiihuFsEGUwCEEGzO
t%l.%dl%eEtJRC7eK1
p2ec2Gg54xtfXCq1m4
%F.oFIaEu4zIQWcaCe
3mxm%pScz9sv9r3RHG
A3i%5NeBXV8wKETNUu
%.a2EvT%GtIl%c5uuk
其实挺明显了,第一个数字就是表示去掉数字剩余部分的行数,列数=去掉8剩余部分的长度/行数
竖着读就是
http%3A%2f%2fm3.file.xiami.com%2Fh%2F%5Ejud……(下略)
然后把%5E替换成0即可,其实代码非常短
本来以为结束了,尼码居然有这种形式的
8
h2fmF2YeBXU8wKETNUu
tFiih5uT%GtIl%c5uqk
t%l.%2WI5TrY55eHg2
p2ec2B1sEGUwCEEGzO
%F.oFZl%eAtJRC7eK1
3mxmhSg54xtfXCq1m4
A3i%DIaEuYzIQWcVCe
%.a2%wScz5sv9r3RHG
最终代码
def xiami(s): import urllib2 start = s.find('h') row = int(s[0:start]) length = len(s[start:]) column = length / row output = '' real_s = list(s[1:]) sucks = [] suck = length % row for i in range(1,suck+1): sucks.append(real_s[i*(column)]) real_s[i*(column)] = 'sucks' real_s.remove('sucks') for i in range(column): output += ''.join(real_s[i:][slice(0,length,column)]) output += ''.join(sucks) return urllib2.unquote(output).replace('^','0')
updated 2014-2-9:
原来这玩意叫做凯撒方阵,感觉没文化真可怕啊……