Browse Source

logfile argument, waf update

master
JoYo 5 years ago
parent
commit
a76854e457
  1. 71
      run.py
  2. 16
      waf.py

71
run.py

@ -10,7 +10,7 @@ class Sins():
logger = logging.getLogger()
def __init__(self, parent, seed=None, run_dir=None):
self.logger.info('execute\n{}'.format((
self.logger.info('execute\n {}'.format((
(parent, seed, run_dir))
))
@ -20,14 +20,18 @@ class Sins():
self.seed = os.path.abspath(seed)
if os.path.isdir(run_dir):
self.run_dir = os.path.abspath(run_dir)
shutil.copy2(args.seed, args.dir)
else:
self.run_dir = os.path.dirname(self.seed)
self.run_dir = os.path.abspath(run_dir)
if not os.path.isdir(self.run_dir):
try:
os.mkdir(self.run_dir)
except:
self.run_dir = os.path.dirname(self.seed)
shutil.copy2(self.seed, self.run_dir)
parsed = self.parent, self.seed, self.run_dir
self.logger.info('parsed\n{}'.format((parsed)))
self.logger.info('parsed\n {}'.format((parsed)))
while True:
self.execute(self.parent, self.seed, self.run_dir)
@ -50,7 +54,7 @@ class Sins():
return None
def execute(self, parent, scrap, cwd):
self.logger.info('execute\n{}'.format(((parent, scrap, cwd))))
self.logger.info('execute\n {}'.format(((parent, scrap, cwd))))
subprocess.run([parent, scrap], cwd=cwd)
@ -82,25 +86,44 @@ if __name__ == '__main__':
import argparse
import sys
logger = logging.getLogger()
logger.setLevel(logging.DEBUG)
parser = argparse.ArgumentParser(
description='position independent code (PIC) mutation experiment.'
)
parser.add_argument('--verbose', '-v', action='count')
parser.add_argument('-build', action='store_true',
help='build parent and seed PIC image, exit.')
parser.add_argument('-provision', action='store_true',
help='provision ubuntu for run, exit.')
parser.add_argument('-logfile', help='log to file.')
parser.add_argument('-seed', default='build/scrap.asm.2.o',
help='path to PIC image.')
parser.add_argument('-parent', default='build/sins',
help='path to parent process.')
parser.add_argument('-dir', default='sandbox',
help='path to execution directory.')
parser.add_argument('-dumps', action='store_true',
help='dump hex values of scraps in directory, exit.')
args = parser.parse_args()
# handler = logging.FileHandler(filename='sins.log')
handler = logging.StreamHandler()
logger = logging.getLogger()
formatter = logging.Formatter(
'#%(asctime)s %(name)s %(levelname)s\n##%(message)s\n'
'#%(asctime)s %(levelname)s\n##%(message)s\n'
)
handler.setFormatter(formatter)
logger.addHandler(handler)
parser = argparse.ArgumentParser()
parser.add_argument('-seed', default='build/scrap.asm.2.o')
parser.add_argument('-parent', default='build/sins')
parser.add_argument('-dir', default='sandbox')
parser.add_argument('-dumps', action='store_true')
parser.add_argument('-build', action='store_true')
parser.add_argument('-provision', action='store_true')
args = parser.parse_args()
if args.verbose:
logger.setLevel(logging.DEBUG)
else:
print('Verbose not set, running in silence.')
if args.logfile:
file_handler = logging.FileHandler(args.logfile, 'a')
file_handler.setFormatter(formatter)
logger.setLevel(logging.DEBUG)
logger.addHandler(file_handler)
else:
stream_handler = logging.StreamHandler()
stream_handler.setFormatter(formatter)
logger.addHandler(stream_handler)
if args.provision:
provision = ['sudo', 'sh', 'provision-ubuntu.sh']

16
waf.py

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save