python学习——解码的小脚本

帮同学做了个小作业,相信大家也可以是试一试,勤动手。脚本要求如下:

from urllib import parse
from urllib import request
import binascii
def unincode(strtest):
    print(strtest.encode('utf8').decode('unicode_escape'))
def urlcode(strtest):
    strtest.encode('utf8').decode('unicode_escape')
    urlcode2 = parse.unquote(strtest)
    print(urlcode2)
def hexcode(strtest):
     hex = strtest.encode('utf-8')
     str_bin = binascii.unhexlify(hex)
     print(str_bin.decode('utf-8'))
url_code= "%"
unincode_code="\/"


input_psd="\sdada"
string = "[]\/"
string1 =  "%/"
flag=True
file_path = "/root/codetest.txt"
with open("/root/codetest.txt", "r") as f:
    for line in f.readlines():
        line = line.strip('\n')  #去掉列表中每一个元素的换行符
        for i in string:
            if i in line:
                unincode(line)
        for i in string1:
            if i in line:
                urlcode(line)
        if line.isdigit()==flag:
            hexcode(line)

脚本存在如下问题:

1.脚本的判断编码格式存在问题,我暂时还没想到有什么非常优秀的解决方案,当然换一种思考方式,我可以增加参数选项,但是这就和自动化去跑解码没关系了。

2.脚本目前实现了解码hex,解码url编码,解码unicode,反正是readlines按行读取文本,暴力的按照题意解决了题目问题。

3.脚本可以拿来直接用,但是我觉得放着已有的优秀工具不用就是找苦吃。

可以编解码工具,burp,小葵转码,chrome插件------等我csdn上传工具即可

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值