[Reverse]div xp0int Posted on Oct 28 2018 # div <br> 题目是一段汇编除法优化的代码,具体是如何优化的可以Google搜索。 这里给出一个用二分法查找的方法(也可以去理解优化过程来解决) ```c++ #include <iostream> int main() { char function[] = {"\x48\x89\xf8\x48\xba\x01\x0d\x1a\x82\x9a\x30\xea\x49\x48\xc1\xff\x3f\x48\xf7\xea\x48\xc1\xfa\x30\x48\x89\xd0\x48\x29\xf8\xc3"}; // funtion为div函数机器码 long long (*foo_ptr)(long long) = (long long (*)(long long)) function; long long a = 0; long long b = 0x7FFFFFFFFFFFFFFF; while (b - a > 1) { long long mid = a / 2 + b / 2; // more or less; avoiding overflow if (foo_ptr(mid) >= 1) { b = mid; } else { a = mid; } } std::cout << a << "\n" << b << "\n"; } ``` `g++ exp.cpp -z execstack && ./a.out` 编译运行即可得到flag 打赏还是打残,这是个问题 赏 Wechat Pay Alipay [Misc]bitcoin_base [Misc]加密了吗
没有帐号? 立即注册