吾爱破解 - LCG - LSG |安卓破解|病毒分析|www.52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 4132|回复: 4
收起左侧

[C&C++ 转载] 字节高低4位交换

  [复制链接]
爱飞的猫 发表于 2018-3-2 09:09
本帖最后由 jixun66 于 2018-3-2 12:10 编辑

对每个字节的高低4位进行交换。

起因:歌者盟视频加密

Swap4Bit.7z (97.19 KB, 下载次数: 19)

用法:解压,拖放文件到程序上,或自行查阅说明。

#include <fstream>
#include <string>
#include <algorithm>

#define BUFFER_SIZE (4 * 1024)
unsigned char g_buffer[BUFFER_SIZE];

void TransformBuffer(unsigned char* buffer, const int size)
{
        for(int i = 0; i < size; i++)
        {
                const unsigned char c = buffer[i];
                buffer[i] = (c >> 4) | (c << 4);
        }
}

void ProcessFile(std::wstring path)
{
        printf("Processing %ls...\n", path.c_str());

        std::fstream in_stream;
        std::fstream out_stream;
        in_stream.open(path, std::fstream::in | std::fstream::binary);
        in_stream.seekg(0, in_stream.end);
        int length = static_cast<int>(in_stream.tellg());
        in_stream.seekg(0, in_stream.beg);

        const std::string::size_type ext_pos = path.find_last_of(L'.');
        std::wstring output_path;
        if (ext_pos == std::string::npos)
        {
                output_path = path + L".swap";
        } else
        {
                output_path = path.substr(0, ext_pos) + L".swap" + path.substr(ext_pos);
        }

        out_stream.open(output_path, std::fstream::out | std::fstream::binary);

        char* signed_buffer_ptr = reinterpret_cast<char*>(g_buffer);

        while(length > 0)
        {
                const int transform_size = std::min(BUFFER_SIZE, length);
                in_stream.read(signed_buffer_ptr, transform_size);
                TransformBuffer(g_buffer, transform_size);
                out_stream.write(signed_buffer_ptr, transform_size);
                length -= transform_size;
        }
}

int wmain(int argc, wchar_t *argv[], wchar_t *envp[])
{
        printf("4 bit swapper by jixun66@52pojie\n");

        if (argc == 1)
        {
                printf("Usage: <swap4bit> <file1> [file2 [file3] ...]\n\n");
        } else for(int i = 1; i < argc; i++)
        {
                ProcessFile(argv[i]);
        }

    return 0;
}

免费评分

参与人数 2热心值 +2 收起 理由
liphily + 1 感谢发布原创作品,吾爱破解论坛因你更精彩!
610100 + 1 感谢发布原创作品,吾爱破解论坛因你更精彩!

查看全部评分

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

小刀电动车 发表于 2018-3-2 12:55 来自手机
大佬,?
oriwqz 发表于 2018-6-10 11:33
远方通用算法注册机 v2 在 远方驾考 V2018.05.20 版本下失效了。
136208999 发表于 2018-6-12 10:15
shenwq 发表于 2019-4-16 11:07
向提供源代码者表示感谢
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则 警告:本版块禁止灌水或回复与主题无关内容,违者重罚!

快速回复 收藏帖子 返回列表 搜索

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2024-4-27 06:46

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

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