Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to conduct buffer overflow in PHP/Python?

Here is an example in 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();
}
like image 555
user198729 Avatar asked Jan 17 '10 14:01

user198729


1 Answers

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.

like image 159
Ants Aasma Avatar answered Sep 22 '22 05:09

Ants Aasma