当前位置:   article > 正文

Decode详解_data.decode('ascii')

data.decode('ascii')
http://www.shiyanbar.com/ctf/1831
Decode:
flag格式:ctf{}
0x25346425353425343525333525343325366125343525373725346425353125366625373825346425343425363725346225346625353425366225346225346425353425343525373825343325366125343525373725346625353125366625373825346425343425343525346225346425353425343525333225343325366125343525373825346425353125366625373825346425353425353525346225346
4253534253431253330253433253661253435253737253465253531253666253738253464253661253435253462253466253534253633253
4622534642535342534352537372534332536612536622533342534332536612536622533332534332536612534352537382534652534312
53364253364
解:
1.Decode,肯定是运用各种解码
ox表示十六进制,从网上了解到十六进制编码是把整个数字4个一分求一个字符这样会超出ascii码范围,
网上的数据都是以ox开头比如网上数据ox12ox96ox48....
而本题数据就开头是ox唯一一个,那么我们就两个一分。

十六进制解码转化字符代码如下:

  1. #十六进制解码转化字符代码如下
  2. str='253464253534253435253335253433253661253435253737253464253531253666253738253464253434253637253462253466253534253662253462253464253534253435253738253433253661253435253737253466253531253666253738253464253434253435253462253464253534253435253332253433253661253435253738253464253531253666253738253464253534253535253462253464253534253431253330253433253661253435253737253465253531253666253738253464253661253435253462253466253534253633253462253464253534253435253737253433253661253662253334253433253661253662253333253433253661253435253738253465253431253364253364'
  3. def HexDe(str):
  4. decstr = ''
  5. #i+=4
  6. for i in range(0,len(str),2):
  7. decstr +=chr(int(str[i:i + 2],16))#unichr()跟chr()一样,只不过返回的是Unicode字符
  8. return decstr
  9. print(HexDe(str))


2.这就得到结果,很显然这是url编码
%4d%54%45%35%43%6a%45%77%4d%51%6f%78%4d%44%67%4b%4f%54%6b%4b%4d%54%45%78%43%6a%45%77%4f%51%6f%78%4d%44
%45%4b%4d%54%45%32%43%6a%45%78%4d%51%6f%78%4d%54%55%4b%4d%54%41%30%43%6a%45%77%4e%51%6f%78%4d%6a%45%4b
%4f%54%63%4b%4d%54%45%77%43%6a%6b%34%43%6a%6b%33%43%6a%45%78%4e%41%3d%3d


提供一个网址解它http://tool.chinaz.com/Tools/Unicode.aspx
3.解得:
MTE5CjEwMQoxMDgKOTkKMTExCjEwOQoxMD
EKMTE2CjExMQoxMTUKMTA0CjEwNQoxMjEK
OTcKMTEwCjk4Cjk3CjExNA==

4.利用Base64代码得到:

  1. #-*- coding: utf-8
  2. import base64
  3. str=b'MTE5CjEwMQoxMDgKOTkKMTExCjEwOQoxMDEKMTE2CjExMQoxMTUKMTA0CjEwNQoxMjEKOTcKMTEwCjk4Cjk3CjExNA=='
  4. str=base64.b64decode(str)
  5. print(str)
  6. str=str.decode('ascii')#bytes解码会得到str
  7. print(str)


119
101
108
99
111
109
101
116
111
115
104
105
121
97
110
98
97
114


5.利用Ascii代码得到welcometoshiyanbar

  1. #从数字转换到字母 按照ASCII编码
  2. L=[119,101,108,99,111,109,101,116,111,115,104,105,121,97,110,98,97,114]
  3. for x in L:
  4. print(chr(x),end='')


得到flag:ctf:{welcometoshiyanbar}

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/2023面试高手/article/detail/177189
推荐阅读
相关标签
  

闽ICP备14008679号