HTB-reverse

本文介绍了在HTB挑战中遇到的加密文件,使用SimpleEncryptor实现的加密方法,包括读取文件、随机数生成和数据位操作。文章还探讨了如何通过Bypass技巧来解密该加密内容。
摘要由CSDN通过智能技术生成

title: HTB-reverse
date: 2023-12-20 15:56:46
categories: REVERSE
tags: HTB

Behind the Scenes

ida打开后能看到HTB{%S%S}标识,直接找到带入即可

Simple Encryptor

这个的话主要看前面那个代码然后本地分析,需要注意的是这个要在linux运行才能对

#include <stdio.h>
#include <stdlib.h>

int read_file(char *name, char **buff)
{
    FILE *file;
    int sz;

    file = fopen(name, "rb");
    fseek(file, 0, SEEK_END);
    sz = ftell(file);
    rewind(file);
    *buff = (char *)calloc(sz + 1, 1);
    fread(*buff, 1, sz, file);
    fclose(file);

    return sz;
}

int main()
{
    char *buff;
    int i, r1, r2, size;

    size = read_file("flag.enc", &buff);

    r1 = *(int *)buff;
    srand(r1);
    printf("%d\n", r1);
    for (i = 4; i < size; ++i)
    {
        r1 = rand();
        r2 = rand() & 7;
        buff[i] = (buff[i] << (8 - r2)) | ((unsigned char)buff[i] >> r2);
        buff[i] ^= r1;
    }
    printf("%s\n", &buff[4]);

    free(buff);
}

Bypass

  • 8
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值