CTF中遇到的有趣异或加密
代码整理为了C语言.
提取了核心的异或代码.
unsigned char* encode(const unsigned char* enbuffer, int enbufferlen)
{
unsigned char* result = (unsigned char*)malloc(enbufferlen * sizeof(char) + 1);
if (result == nullptr) return nullptr;
memset(result, 0, enbufferlen + 1);
for (int i = 0; i < enbufferlen; i += 3)
{
result[i] = enbufferlen ^ (enbuffer[i] + 6);
result[i + 1] = (enbuffer[i + 1] - 6) ^ enbufferlen;
result[i + 2] = enbuffer[i + 2] ^ 6 ^ enbufferlen;
}
return result; // //zerobuffer = flag
}
unsigned char* decode(const unsigned char* debuffer, int debufferlen)
{
unsigned char* result = (unsigned char*)malloc(debufferlen * sizeof(char));
if (result == nullptr) return nullptr;
memset(result, 0, debufferlen + 1);
for (int i = 0; i < debufferlen; i += 3)
{
result[i] = (debufferlen ^ debuffer[i]) -6;
result[i + 1] = (debuffer[i + 1] ^ debufferlen) + 6;
result[i + 2] = debuffer[i + 2] ^ 6 ^ debufferlen;
}
return result;
}
int main(int argc,char**argv)
{
unsigned char buffer[] = "HelloIBinary";
int size = sizeof(buffer) / sizeof(buffer[0]);
unsigned char * CipherText = encode(buffer, size);
unsigned char * PlantText = decode(CipherText, size);
}
作者:IBinary
坚持两字,简单,轻便,但是真正的执行起来确实需要很长很长时间.当你把坚持两字当做你要走的路,那么你总会成功. 想学习,有问题请加群.群号:725864912(收费)群名称: 逆向学习小分队 群里有大量学习资源. 以及定期直播答疑.有一个良好的学习氛围. 涉及到外挂反外挂病毒 司法取证加解密 驱动过保护 VT 等技术,期待你的进入。
详情请点击链接查看置顶博客 https://www.cnblogs.com/iBinary/p/7572603.html
本文来自博客园,作者:iBinary,未经允许禁止转载 转载前可联系本人.对于爬虫人员来说如果发现保留起诉权力.https://www.cnblogs.com/iBinary/p/15474514.html
欢迎大家关注我的微信公众号.不定期的更新文章.更新技术. 关注公众号后请大家养成 不白嫖的习惯.欢迎大家赞赏. 也希望在看完公众号文章之后 不忘 点击 收藏 转发 以及点击在看功能. QQ群: