如何在PHP/Python中进行缓冲区溢出? [英] How to conduct buffer overflow in PHP/Python?

查看:213
本文介绍了如何在PHP/Python中进行缓冲区溢出?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下是c中的示例:

#include <stdio.h>
#include <string.h>

void bad() {
    printf("Oh shit really bad~!\r\n");
}

void foo() {
    char overme[4] = "WOW";
    *(int*)(overme+8) = (int)bad;
}

int main() {
   foo();
}

推荐答案

像其他人一样解释Python和PHP的事实实际上并不是重点.关键是,它们所公开的几乎所有API和语言语义都经过严格的错误检查,因此不可能具有可利用的未定义行为.即使您编译语言,也仍然是不可能的.这并不意味着您不能公开可以做任何事情的不安全的API.实际上,使用Python的ctypes模块,应该有可能创建类似的行为,但是要偶然地做到这一点要困难得多.

The fact that Python and PHP are interpreted like suggested by others isn't actually the point. The point is that almost all of the APIs and language semantics that they expose are heavily error-checked making it impossible to have exploitable undefined behavior. Even if you compile the languages, it would still be impossible. This doesn't mean that you couldn't expose unsafe APIs that can do whatever. In fact, using Pythons ctypes module, it should be possible to create a similar behavior, but significantly harder to do so by accident.

这篇关于如何在PHP/Python中进行缓冲区溢出?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆