forked from deShal3v/zenysec-exploit-exercises
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
executable file
·41 lines (32 loc) · 1.85 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
__author__ = '@tomereyz'
import argparse
import os
from DockerFile import DockerFile
from ChallengeBuild import ChallengeBuild
def main(port, arch, docker_name, aslr, directory=None, no_cache=False,
build_run=False):
if not directory:
directory = os.getcwd()
with ChallengeBuild(directory=directory, arch=arch, aslr=aslr) as challenge_handle:
if build_run:
if not docker_name:
raise Exception("missing docker name")
with DockerFile(sources=challenge_handle.sources, docker_name=docker_name, no_cache=no_cache,
build_run=build_run, port=port, arch=arch, aslr=aslr) as docker_handle:
print docker_handle.docker_name
interactive = raw_input('execute `rm -f ~/.ssh/known_hosts` y/n?')
if interactive == 'y':
print 'rm -f ~/.ssh/known_hosts'
os.system('rm -f ~/.ssh/known_hosts')
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='ZenySec Exploitation Exercises')
parser.add_argument('-dir', '--directory', help='main directory', required=False, dest='directory')
parser.add_argument('-d', '--docker-name', help='docker name', required=True, dest='docker_name')
parser.add_argument('-ca', '--no-cache', help='use cache when building docker', required=False, dest='no_cache',
action='store_true')
parser.add_argument('-r', '--build-run', help='build and run docker', required=False, dest='build_run',
action='store_true')
parser.add_argument('-p', '--port', help='running docker port', required=True, dest='port')
parser.add_argument('-a', '--architecture', help='i386/arm32v7', required=True, dest='arch')
parser.add_argument('-as', '--aslr', help='yes/no', required=True, dest='aslr')
main(**vars(parser.parse_args()))