从循环中的文件中添加并删除字节

发布于 2025-02-13 20:36:32 字数 421 浏览 2 评论 0原文

我是一名安全研究人员,想知道如何从文件中删除添加的字节。下面的此功能每4个字节添加一个字节。但是我想知道如何也可以删除这些字节。需要一个可以按添加的顺序删除这些字节的函数。

特拉维斯

int AddByte(BYTE* bIn, BYTE* bOut, DWORD dwSize, int inc_every)
{
    int increased = 0;

    for (int i = 0; i < dwSize; i++)
    {
        *(bOut + increased) = *(bIn + i);
        increased++;

        if (i % inc_every == 0)
            increased += 1;
    }

    return increased;
}

I'm a security researcher and am wondering how I could remove the added bytes from a file. This function below adds a byte every 4 bytes. But I'd like to know how I could remove those bytes as well. Need a function that will remove these bytes in the order they were added.

Travis

int AddByte(BYTE* bIn, BYTE* bOut, DWORD dwSize, int inc_every)
{
    int increased = 0;

    for (int i = 0; i < dwSize; i++)
    {
        *(bOut + increased) = *(bIn + i);
        increased++;

        if (i % inc_every == 0)
            increased += 1;
    }

    return increased;
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

a√萤火虫的光℡ 2025-02-20 20:36:32
int RemoveByte(BYTE* bIn, BYTE* bOut, DWORD dwSize, int inc_every)
{
    int increased = 0;

    for (int i = 0; i < dwSize; i++)
    {

        if ((i - 1) % inc_every != 0)
        {
             *(bOut + increased) = *(bIn + i);
            increased++;
        }
    }

    return increased;
}

addByte()后应用此功能将回馈原始字符串。您的原始功能的偏移为1(它将跳过第二个字节),因此此功能包含相同的偏移

int RemoveByte(BYTE* bIn, BYTE* bOut, DWORD dwSize, int inc_every)
{
    int increased = 0;

    for (int i = 0; i < dwSize; i++)
    {

        if ((i - 1) % inc_every != 0)
        {
             *(bOut + increased) = *(bIn + i);
            increased++;
        }
    }

    return increased;
}

Applying this function after AddByte() would give back the original string. Your original function has an offset of 1 (it will skip the second byte), so this function includes the same offset

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文