开启辅助访问 切换到宽版

精易论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

用微信号发送消息登录论坛

新人指南 邀请好友注册 - 我关注人的新帖 教你赚取精币 - 每日签到


求职/招聘- 论坛接单- 开发者大厅

论坛版规 总版规 - 建议/投诉 - 应聘版主 - 精华帖总集 积分说明 - 禁言标准 - 有奖举报

查看: 123|回复: 1
收起左侧

[精币悬赏] 求易语言例子或者转易语言

[复制链接]
结帖率:75% (3/4)
发表于 2025-5-13 20:02:37 | 显示全部楼层 |阅读模式   四川省成都市
80精币
请求大佬们,下面这个代码在易语言怎么实现,AI翻译有问题或者无法使用



    # mix with FNV prime & mask
    client_rand_mix = (0x1000193 * client_rand)
    client_rand_mask = client_rand_mix & 0x8000003f
    print(f"{client_rand_mix=}")
    print(f"{client_rand_mask=}")

    client_xor_server = client_rand_mask ^ server_rand
    client_xor_server_mod = client_xor_server % 60
    print(f"{client_xor_server=}")
    print(f"{client_xor_server_mod=}")

    index = client_xor_server_mod
    print(f"{index=}")

    aes_key = map(lambda x: (x ^ 0xA5) & 0xFF, KEY_POOL[index:index + 24])
    aes_key = bytes(aes_key)
    print(f"aes_key={aes_key.hex()}")

    aes = AES.new(aes_key, AES.MODE_ECB)

    print(f"local_mac={LOCAL_MAC.hex()}")

    payload_arr = create_payload_array(server_mac, LOCAL_MAC, index)
    if not verify_do_check_client(payload_arr, LOCAL_MAC, index, server_mac):
        print("we are sad :(")

    payload = f"SendInfo.gch?info={len(payload_arr)}|{b''.join(map(lambda x: x.to_bytes(4, 'little'), payload_arr)).decode('utf-8')}"

    url = "/webFacEntry"
    print(f'--> POST {url} "{payload}"')

    res = s.post(
        ROOT + url,
        data=aes.encrypt(
            pad(payload.encode(), 16)
        )
    )
    print(f'<-- {res.status_code} {len(res.content)} bytes')
    if res.status_code != 200:
        raise Exception(f"expected 200. got {res.status_code}")








def evaluate_alphabet(alphabet: str, exponent: int, modulus: int, value_map = lambda x: x):
    """
    Determine if a proposed alphabet of payload bytes is still able to encode all values that
    a payload with no restrictions could represent.

    value_map can be used to to make the search faster by limiting the search space.

    Returns a mapping of desired inputs and the inputs that produce them (we're just
    going to brute force this because of the alphabet constraints)
    """
    unrestricted_possible_values = set()
    for i in range(modulus):
        unrestricted_possible_values.add(value_map(pow(i, exponent, modulus)))

    possible_values = dict()
    for num in int_alphabet_generator(alphabet, 4):
        result = value_map(pow(num, exponent, modulus))
        if result not in possible_values:
            possible_values[result] = num
            if len(possible_values) == len(unrestricted_possible_values):
                return possible_values

    assert False, f"Not all possible values found within modulus {len(possible_values)} / {len(unrestricted_possible_values)}"

# some subset of chars it should be safe to use in the urlparam
alphabet = "lmaoztebcdfghijknpqrsuvwxy"

# used for the first 4 entries in client_data, before a new exponent and
# modulus are derived. figure out all representable values so we can use
# this when we craft the first 4 integers of payload which let us control
# the derived values used for the rest of the decoding
header_encoding_map = evaluate_alphabet(alphabet, 0x1687, 0x7561)

# since it turns out we have absolute control over the exponent and modulus,
# can just precalculate. we also only care about the lower byte of the encoded
# values, as do_check_client truncates the modular exponentation result when
# calculating mac address bytes. so once we have all possible lower bytes, we're
# done.
mac_encoding_map = evaluate_alphabet(alphabet, 0x1, 0x1687, lambda x: x & 0xff)

def verify_do_check_client(client_data: list[int], server_mac: bytes,
                           calculated_idx: int, LOCAL_MAC: bytes) -> int:
    processed_word0 = pow(client_data[0], 0x1687, 0x7561)
    processed_word1 = pow(client_data[1], 0x1687, 0x7561)
    processed_word2 = pow(client_data[2], 0x1687, 0x7561)
    processed_word3 = pow(client_data[3], 0x1687, 0x7561)

    derived_exponent = (processed_word0 * calculated_idx) + processed_word1
    derived_modulus = (processed_word2 * calculated_idx) + processed_word3

    client_data = client_data[4:]
    remaining_word_len = len(client_data)
    work_buffer = [0] * len(client_data)

    if remaining_word_len < 6:
        print(f"Warning: Remaining client_data words are less than 6")
        return 0

    for i in range(6):
        work_buffer[i] = pow(client_data[i], derived_exponent, derived_modulus) & 0xff

    calculated_LOCAL_MAC = bytes(work_buffer[:6])
    if calculated_LOCAL_MAC != LOCAL_MAC:
        print(f"local mismatch {calculated_LOCAL_MAC} != {LOCAL_MAC}")
        return 0

    for i in range(6, remaining_word_len):
        work_buffer[i] = pow(client_data[i], derived_exponent, derived_modulus) & 0xff

        if i >= 6 and (i + 1) % 6 == 0:
            calculated_server_mac = bytes(work_buffer[ i-5 : i+1 ])
            if calculated_server_mac != server_mac:
                print(f"local mismatch {calculated_server_mac} != {server_mac}")
                continue
            return 1

    return 0

def create_payload_array(LOCAL_MAC, server_mac, _calculated_idx: int):
    payload = []

    # new exponent/modulus will be derived based on our input and this
    # index which is selected randomly and given to us. we have to work
    # with a exponent of the form:
    #
    # new_exponent = (pow(input1, 0x1687, 0x7561) * calculated_idx) + pow(input2, 0x1687, 0x7561)
    # new_modulus = (pow(input3, 0x1687, 0x7561) * calculated_idx) + pow(input4, 0x1687, 0x7561)
    #
    # we're going to take advantage of the multiply, and pick input1 and input3 such that
    # calculated_idx is multiplied by 0, making it irrelevant to payload generation.

    # exponent
    payload.append(header_encoding_map[0])      # input1; cancels out calculated_idx
    payload.append(header_encoding_map[1])      # input2; selected exponent

    # modulus
    payload.append(header_encoding_map[0])      # input3; cancels out calculated_idx
    payload.append(header_encoding_map[0x1687]) # input4; selected modulus

    # since we've now gotten control of the exponent and modulus, we just staple the
    # local and remote mac addresses to the payload.
    payload.extend(map(mac_encoding_map.__getitem__, LOCAL_MAC + server_mac + server_mac))

    return payload






补充内容 (2025-5-13 20:19):
主要是加密部分,该如何用易语言写

点评

手工费用愿意支fu不 737846259 愿意联系   江苏省苏州市  发表于 2025-5-14 08:45
您需要登录后才可以回帖 登录 | 注册

本版积分规则 致发广告者

发布主题 收藏帖子 返回列表

sitemap| 易语言源码| 易语言教程| 易语言论坛| 易语言模块| 手机版| 广告投放| 精易论坛
拒绝任何人以任何形式在本论坛发表与中华人民共和国法律相抵触的言论,本站内容均为会员发表,并不代表精易立场!
论坛帖子内容仅用于技术交流学习和研究的目的,严禁用于非法目的,否则造成一切后果自负!如帖子内容侵害到你的权益,请联系我们!
防范网络诈骗,远离网络犯罪 违法和不良信息举报电话0663-3422125,QQ: 793400750,邮箱:wp@125.la
网站简介:精易论坛成立于2009年,是一个程序设计学习交流技术论坛,隶属于揭阳市揭东区精易科技有限公司所有。
Powered by Discuz! X3.4 揭阳市揭东区精易科技有限公司 ( 粤ICP备12094385号-1) 粤公网安备 44522102000125 增值电信业务经营许可证 粤B2-20192173

快速回复 返回顶部 返回列表