Created
June 29, 2020 21:27
-
-
Save stestagg/70b9af5021d602608052a8fa79029461 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <Python.h> | |
#define IN_BUF_SIZE 16384 | |
int main(int argc, char **argv) { | |
char script[IN_BUF_SIZE + 1]; | |
const wchar_t *prefix = L"/python"; | |
const wchar_t *syspath = L"/python/lib/python310.zip:/python/lib/python3.10:/python/lib/python3.10/lib-dynload"; | |
PyConfig config; | |
PyConfig_InitPythonConfig(&config); | |
config.base_exec_prefix = prefix; | |
config.base_prefix = prefix; | |
config.exec_prefix = prefix; | |
config.prefix = prefix; | |
config.pythonpath_env = syspath; | |
Py_InitializeFromConfig(&config); | |
PyRun_SimpleString("file = open"); | |
PyRun_SimpleString("from sys import *"); | |
PyRun_SimpleString("from bisect import *"); | |
PyRun_SimpleString("from struct import *"); | |
PyRun_SimpleString("from pathlib import *"); | |
PyRun_SimpleString("from dataclasses import *"); | |
PyRun_SimpleString("from mmap import *"); | |
PyRun_SimpleString("from os import *"); | |
PyRun_SimpleString("from struct import *"); | |
PyRun_SimpleString("from contextlib import *"); | |
PyRun_SimpleString("from itertools import *"); | |
PyRun_SimpleString("from traceback import *"); | |
PyRun_SimpleString("from gc import *"); | |
PyRun_SimpleString("from abc import *"); | |
PyRun_SimpleString("from string import *"); | |
PyRun_SimpleString("from array import *"); | |
PyRun_SimpleString("from asyncio import *"); | |
PyRun_SimpleString("del abort"); | |
#ifdef __AFL_HAVE_MANUAL_CONTROL | |
__AFL_INIT(); | |
#endif | |
while(__AFL_LOOP(1000)){ | |
size_t n_read = read(STDIN_FILENO, script, IN_BUF_SIZE); | |
script[n_read] = 0; | |
PyRun_SimpleString(script); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment