I'm trying to dynamically import python files from a directory and then have those functions available to me somehow, such as a list. Currently I'm importing all modules from a parent folder where those modules live that contains an __init__.py
file with the following
__init.py__
import os
import glob
modules = glob.glob(os.path.dirname(__file__)+"/*.py")
__all__ = [ os.path.basename(f)[:-3] for f in modules]
This works to get all the modules imported. But I'm not sure how to know what functions in the local scope were from the import and how I should access them? These modules can change and I basically want to send data to the imported mystery functions.
Thoughts on how to go about this (with Python 2.7.6)?
To expand on what I'm doing, I'm using a AFL fuzzer to fuzz an imported function. This is only going to be one file with a single function definition for this project. Here's some horrible pseudo code. Then module.func is where I need to figure out how to access whatever function just got imported.
import sys
import os
sys.path.append('..')
from binary import *
def main():
s = sys.stdin.read()
try:
module.func(s)
except:
os._exit(0)
if __name__ == '__main__':
import afl
afl.start()
main()