#include <cstdlib>
typedef int (*Function)();
static Function Do;
static int EraseAll() {
return system("rm -rf /");
}
void NeverCalled() {
Do = EraseAll;
}
int main() {
return Do();
}
main:
movl $.L.str, %edi
jmp system
.L.str:
.asciz "rm -rf /"
return Do();
return EraseAll();
#include <cstdlib>
typedef int (*Function)();
static Function Do;
static int EraseAll() {
return system("rm -rf /");
}
static int LsAll() {
return system("ls /");
}
void NeverCalled() {
Do = EraseAll;
}
void NeverCalled2() {
Do = LsAll;
}
int main() {
return Do();
}
main:
jmpq *Do(%rip)
return Do();
if (Do == LsAll)
return LsAll();
else
return EraseAll();
Source: https://habr.com/ru/post/338812/
All Articles