예제 #1
0
파일: main.py 프로젝트: alexbagirov/py-smtp
def main() -> None:
    try:
        parser = Parser()
        args = parser.parse()
        if args.batch:
            sender = BatchSender(args.batch, args)
            sender.broadcast()
        else:
            run(args)
    except KeyboardInterrupt:
        pass
예제 #2
0
	def __init__(self, dimensions=[320,480], swipe_padding=[40,40,40,40], script_path="script"):
		self.dimensions = dimensions
		self.swipe_padding = swipe_padding
		self.script_path = script_path
		self.range_action_steps = 10
		self.short_steps_duration = 200
		self.long_steps_duration = 2000
		self.range_sleep = 5.0
		options = Parser.parser(sys.argv[1:])
		if 'config' in options:
			with open(options.config) as f:
				self.config = eval(f.read())
예제 #3
0
def main():
    if len(sys.argv) == 1:
        Parser.parser(["-h"])
        return

    options = Parser.parser(sys.argv[1:])
    config = load_config(options.config)

    startTime = datetime.now()
    logger.info("Starting " + startTime.strftime("%Y/%m/%d %H:%M:%S"))
    if not config['execution_time'] == 0:
        runningTime = timedelta(hours=config['execution_time']).total_seconds()
        logger.info("Running Time: %d " % runningTime)

        runner = Runner(config, options)
        signal.signal(signal.SIGALRM, runner.stopRunning)
        signal.alarm(int(runningTime))

        try:
            runner.run()
        except:
            logger.warn("Orangutan Test failed occasionally")
        signal.alarm(0)
    else:
        logger.info("Runnining Time: Infinity")
        try:
            logger.info("Press Control + C to force stop")
            while True:
                runner = Runner(config, options)
                runner.run(infinity=True)
                if runner.forceStopped:
                    break
        except KeyboardInterrupt:
            logger.info("Receive keyboard interrupt to force stop")
            runner.stopRunning()
        except:
            logger.warn("Orangutan Test failed unexpectedly")


    logger.info("Orangutan Test is Done at " + datetime.now().strftime("%Y/%m/%d %H:%M:%S"))
예제 #4
0
def main():
    if len(sys.argv) == 1:
        Parser.parser(["-h"])
        return

    options = Parser.parser(sys.argv[1:])
    config = load_config(options.config)

    startTime = datetime.now()
    logger.info("Starting " + startTime.strftime("%Y/%m/%d %H:%M:%S"))
    if not config['execution_time'] == 0:
        runningTime = timedelta(hours=config['execution_time']).total_seconds()
        logger.info("Running Time: %d " % runningTime)

        runner = Runner(config, options)
        signal.signal(signal.SIGALRM, runner.stopRunning)
        signal.alarm(int(runningTime))

        try:
            runner.run()
        except:
            logger.warn("Orangutan Test failed occasionally")
        signal.alarm(0)
    else:
        logger.info("Runnining Time: Infinity")
        try:
            logger.info("Press Control + C to force stop")
            while True:
                runner = Runner(config, options)
                runner.run(infinity=True)
                if runner.forceStopped:
                    break
        except KeyboardInterrupt:
            logger.info("Receive keyboard interrupt to force stop")
            runner.stopRunning()
        except:
            logger.warn("Orangutan Test failed unexpectedly")

    logger.info("Orangutan Test is Done at " +
                datetime.now().strftime("%Y/%m/%d %H:%M:%S"))
예제 #5
0
 def __init__(self,
              dimensions=[320, 480],
              swipe_padding=[40, 40, 40, 40],
              script_path="script"):
     self.dimensions = dimensions
     self.swipe_padding = swipe_padding
     self.script_path = script_path
     self.range_action_steps = 10
     self.short_steps_duration = 200
     self.long_steps_duration = 2000
     self.range_sleep = 5.0
     options = Parser.parser(sys.argv[1:])
     if 'config' in options:
         with open(options.config) as f:
             self.config = eval(f.read())
예제 #6
0
	def __init__(self, dimensions=[320,480], swipe_padding=[40,40,40,40], script_repo="script", amount=1, steps=10000, deviceName="Device"):
		self.dimensions = dimensions
		self.swipe_padding = swipe_padding
		self.script_repo = script_repo
		self.amount = amount
		self.steps = steps
		self.deviceName = deviceName
		self.range_action_steps = 20
		self.short_steps_duration = 200
		self.long_steps_duration = 2000
		self.range_sleep = 5.0
		if len(sys.argv) > 1:
			options = Parser.parser(sys.argv[1:])
			if str(options.config):
				with open(options.config) as f:
					self.config = eval(f.read())
					self.dimensions = [self.config['res_x'], self.config['res_y']]
					self.deviceName = self.config['device_name']
					self.script_repo = self.config['script_repo']
					self.amount = int(self.config['script_amount'])
					self.steps = int(self.config['script_steps'])
			if int(options.gen_scripts_amount): self.amount = int(options.gen_scripts_amount)
			if int(options.gen_scripts_steps): self.steps = int(options.gen_scripts_steps)
			if str(options.gen_scripts_output): self.script_repo = str(options.gen_scripts_output)
예제 #7
0
	def __init__(self, dimensions=[320,480], swipe_padding=[40,40,40,40], script_repo="script", amount=1, steps=10000, deviceName="Device"):
		self.dimensions = dimensions
		self.swipe_padding = swipe_padding
		self.script_repo = script_repo
		self.amount = amount
		self.steps = steps
		self.deviceName = deviceName
		self.range_action_steps = 10
		self.short_steps_duration = 200
		self.long_steps_duration = 2000
		self.range_sleep = 5.0
		if len(sys.argv) > 1:
			options = Parser.parser(sys.argv[1:])
			if str(options.config):
				with open(options.config) as f:
					self.config = eval(f.read())
					self.dimensions = [self.config['res_x'], self.config['res_y']]
					self.deviceName = self.config['device_name']
					self.script_repo = self.config['script_repo']
					self.amount = int(self.config['script_amount'])
					self.steps = int(self.config['script_steps'])
			if int(options.gen_scripts_amount): self.amount = int(options.gen_scripts_amount)
			if int(options.gen_scripts_steps): self.steps = int(options.gen_scripts_steps)
			if str(options.gen_scripts_output): self.script_repo = str(options.gen_scripts_output)
예제 #8
0
import cv2
import numpy as np 
from utils import halftoning, plot_histogram
from argparser import Parser

args = Parser()
img_path = args.get_arg('image')
output_filename = args.get_arg('output_path')
error_dist = args.get_arg('error_dist')
sweep_mode = args.get_arg('sweep_mode')
display_mode = args.get_arg('display_mode')

img_path = 'images/peppers.png' if img_path is None else img_path

img = cv2.imread(img_path, cv2.IMREAD_COLOR)
res_img = halftoning(np.array(img), edist_id=error_dist, sweep_mode=sweep_mode)

if output_filename is not None:
    cv2.imwrite(output_filename, res_img)

if display_mode == 'hist':
    plot_histogram(res_img)
elif display_mode is None or display_mode == 'images':
    cv2.imshow('source image', img)
    cv2.imshow('resulting image', res_img)

cv2.waitKey(0)
cv2.destroyAllWindows()
예제 #9
0
import cv2
from argparser import Parser
from interpolations import closest_neighboor

args = Parser()
mode = args.get_arg('mode')
input_path = args.get_arg('input-image')
output_path = args.get_arg('output-image')
angle = args.get_arg('angle')
scale_factor = args.get_arg('scale-factor')
dimension = args.get_arg('image-dimension')

img = cv2.imread(input_path, cv2.IMREAD_GRAYSCALE)
interpolated_img = closest_neighboor(img, scale_factor=scale_factor)

cv2.imshow('source img', img)
cv2.imshow('interpolated img', interpolated_img)

cv2.waitKey(0)
cv2.destroyAllWindows()
예제 #10
0
import cv2
import numpy as np
import sys
from argparser import Parser
from masks import get_mask
from filter_utils import show_filtered_image, filter_image, add_filters, show_src_and_filtered_image

MASK_COUNT = 11

parser = Parser()
filename = parser.get_arg('image')
mask_id = parser.get_arg('mask')
output_filename = parser.get_arg('output_path')
output_combined_filename = parser.get_arg('output_combined_path')
hflip = parser.get_arg('hflip')
skip_image_show = parser.get_arg('skip_image_show')

img = cv2.imread(filename, cv2.IMREAD_GRAYSCALE)
flip_axis = 1 if hflip else None
(filtered_image, combined_filters_image) = show_filtered_image(
    img,\
    mask_id,\
    flip_axis=flip_axis,\
    show_images=not skip_image_show\
)

if (output_filename):
    cv2.imwrite(output_filename, filtered_image)
if (combined_filters_image is not None and output_combined_filename):
    cv2.imwrite(output_combined_filename, combined_filters_image)
예제 #11
0
import cv2
import numpy as np
from matplotlib import pyplot as plt

from argparser import Parser
from codify import codify
from decodify import decodify
from bitplane_utils import extract_rgb_bitplane, merge_rgb

args = Parser()
# Command arguments
mode = args.get_arg('mode')
imgin_path = args.get_arg('imagein')
imgout_path = args.get_arg('imageout')
textin_path = args.get_arg('textin')
textout_path = args.get_arg('textout')
bitplan = args.get_arg('bitplan')

img = cv2.imread(imgin_path, cv2.IMREAD_COLOR)
if mode == 'codify':
    res_img = codify(img, open(textin_path).read(), bitplan=bitplan)
    cv2.imwrite(imgout_path, res_img)
elif mode == 'decodify':
    decodified_msg = decodify(img, bitplan=bitplan)
    textout_file = open(textout_path, 'w')
    textout_file.write(str(decodified_msg))
    textout_file.close()
elif mode == 'bitplanes':
    for bitplane in [0, 1, 2, 7]:
        bitplane_blue, bitplane_green, bitplane_red = extract_rgb_bitplane(img, bitplane)
        bitplanes_img = merge_rgb(bitplane_blue, bitplane_green, bitplane_red)
예제 #12
0
 env = RewardNegativeDeath(env, death_factor=2)
 env = ObservationReshape(env)
 # create agent
 model = CartpoleNetwork(learning_rate=LEARNING_RATE,
                         discount_factor=DISCOUNT_FACTOR,
                         input_shape=(env.observation_space.shape[0], ),
                         output_shape=env.action_space.n)
 agent = DQNAgent(actions=env.action_space.n,
                  expl_max=EXPLORATION_MAX,
                  expl_min=EXPLORATION_MIN,
                  expl_decay=EXPLORATION_DECAY,
                  model=model,
                  memory_size=MEMORY_SIZE,
                  batch_size=BATCH_SIZE)
 # get and parse user args
 args = Parser.parseargs(defaultTrainIterations=10000,
                         defaultEvalIterations=10)
 if args.load:
     agent.load(env, args.loadversion)
 if args.train != 0:
     #agent.init_fill_memory(env, 50000)
     agent.train(env, args.train, train_s=1, save_i=MODEL_SAVE_EVERY)
 if args.eval != 0:
     print("Evaluation results (higher scores are better):")
     agent.evaluate(env, args.eval)
 if args.save:
     agent.save(env, args.saveversion)
 if args.render:
     agent.render_episode(env, random_action=args.renderrandom)
 # close env
 env.close()
예제 #13
0
    def log_dumpstate(self, attach):
        os.system('adb shell dumpstate > dumpstate_' + attach + '.log')

    def log_crash_report(self):
        os.system('adb pull /data/b2g/Crash\ Reports' + self.logFolder)

    def getLogs(self):
        curTime = time.strftime('%m%d%H%M%S', time.localtime())
        if self.option['b2g-ps']:
            log_b2g_ps(curTime)
        if self.option['b2g-info']:
            log_b2g_info(curTime)
        if self.option['b2g-procrank']:
            log_b2g_proprank(curTime)
        if self.option['dumpstate']:
            log_dumpstate(curTime)
        if self.option['crash-report']:
            log_crash_report()


if __name__ == '__main__':
    if len(sys.argv) > 1:
        options = Parser.parser(sys.argv[1:])
        print os.getcwd()
        if 'config' in options:
            config = {}
            with open(options.config) as f:
                config = eval(f.read())
            log = LogCollector(config['device_name'], config['logs'])
예제 #14
0
            cmdevents = self.get_tap_event(*coord_1st, times=2)
        elif cmd == "pinch":
            args = coord_1st + coord_2nd + coord_3rd + coord_4th + short_latency
            cmdevents = self.get_pinch_event(*args)
        elif cmd == "sleep":
            if use_default:
                cmdevents = self.get_sleep_event()
            else:
                sleep_time = self.get_sleep_time()
                cmdevents = self.get_sleep_event(sleep_time)
        else:
            raise Exception("Unknown command")

        return cmdevents


def main():
    getrandomsc = GenRandomSC()


if __name__ == '__main__':
    testSample = ["--config", "testConfig"]
    if len(sys.argv) > 1:
        options = Parser.parser(sys.argv[1:])
        if 'config' in options:
            main()
        else:
            print Parser.parser(testSample)
    else:
        print Parser.parser(testSample)
예제 #15
0
import cv2
import numpy as np
from matplotlib import pyplot as plt
from argparser import Parser
from thresholding_method import ThresholdingMethod, ThresholdingConfig

args = Parser()
# Command arguments
img_path = args.get_arg('image')
out_path = args.get_arg('out')
method = args.get_arg('method')
T = args.get_arg('T')
n = args.get_arg('n')
k = args.get_arg('k')
R = args.get_arg('R')
p = args.get_arg('p')
q = args.get_arg('q')
display_mode = args.get_arg('display_mode')

img = cv2.imread(img_path, cv2.IMREAD_UNCHANGED)
thres_method = ThresholdingMethod(method)
res_img = thres_method.exec(img,
                            ThresholdingConfig(T=T, n=n, k=k, R=R, p=p, q=q))

if (out_path):
    cv2.imwrite(out_path, res_img)

if display_mode == 'hist':
    (h, w) = res_img.shape
    print(np.count_nonzero(res_img == 0) / (h * w))
    plt.hist(img.ravel(), 256, [0, 256])
예제 #16
0
     "Shortcut equivalent to -w [RUN_ALL_BASEWORDS] -t [RUN_ALL_TECHNIQUES] -s -p [RUN_ALL_PERCENTILE] -l [RUN_ALL_FIRST_PATHWELL_MASK, RUN_ALL_LAST_PATHWELL_MASK] -m -u -c -r. See config.py for values used.",
     action='store_true')
 lArgParser.add_argument(
     '-j',
     '--pass-through',
     type=str,
     help=
     "Pass-through the raw parameter to John the Ripper. Example: --pass-through=\"--fork=2\"\n\n",
     action='store')
 lArgParser.add_argument(
     '-v',
     '--verbose',
     help='Enable verbose output such as current progress and duration',
     action='store_true')
 lArgParser.add_argument('-d',
                         '--debug',
                         help='Enable debug mode',
                         action='store_true')
 requiredAguments = lArgParser.add_mutually_exclusive_group(required=True)
 requiredAguments.add_argument('-e',
                               '--examples',
                               help='Show example usage',
                               action='store_true')
 requiredAguments.add_argument(
     '-i',
     '--input-file',
     type=str,
     help='Path to file containing password hashes to attempt to crack',
     action='store')
 run_main_program(pParser=Parser(lArgParser.parse_args(), Config))
예제 #17
0
            r = subprocess.check_output('adb shell ls -al /data/b2g/mozilla/Crash\ Reports | grep LastCrash', shell=True)
        except:
            return False, None
        return True, r[38:54]

    def getCrashReport(self):
        if self.option['crash-report']:
            self.log_crash_report()

    def genReport(self):
        report = open(self.logFolder+'report.html', 'w')
        for dir_path, dir_names, dir_files in os.walk(self.logFolder):
            for f in dir_files:
                if dir_names:
                    report.write('File: <a href="%s">%s</a><br>\n' % (f, f))
                else:
                    base = os.path.basename(dir_path)
                    report.write('File: <a href="%s/%s">%s/%s</a><br>\n' % (base, f, base, f))
        report.close()

if __name__ == '__main__':
    if len(sys.argv) > 1:
        options = Parser.parser(sys.argv[1:])
        if 'config' in options:
            config = {}
            with open(options.config) as f:
                config = eval(f.read())
            log = LogCollector(config['device_name'], config['logs'])
            log.getLogs()
            log.genReport()
예제 #18
0
        help=
        'Report disabled agents and exit. Number of seconds is configurable on config.py. Exit code is non-zero if all agents are enabled.',
        action='store_true')
    l_report_group.add_argument(
        '-ri',
        '--report-issues',
        help=
        'Report issues and exit. Report issues by CVSS with -ribc, --report-issues-by-cvss. Report issues by issue with -ribi, --report-issues-by-issue',
        action='store_true')
    l_report_group.add_argument(
        '-rbsc',
        '--report-bsc',
        help='Report balanced scorecard data and exit.',
        action='store_true')

    l_vulnerability_options_group = lArgParser.add_argument_group(
        title="Reports Endpoint Options", description=None)
    l_vulnerability_options_group.add_argument(
        '-ribc',
        '--report-issues-by-cvss',
        help='Report the count of issues by CVSS category',
        action='store_true')
    l_vulnerability_options_group.add_argument(
        '-ribi',
        '--report-issues-by-issue',
        help='Report the count of issues by issue',
        action='store_true')

    Parser.parse_configuration(p_args=lArgParser.parse_args(),
                               p_config=__config)
    run_main_program()
예제 #19
0
				cmdevents = self.get_tap_event(*coord_1st, times=1, duration=short_latency[1])
		elif cmd == "double_tap":
			cmdevents = self.get_tap_event(*coord_1st, times=2)
		elif cmd == "pinch":
			args = coord_1st + coord_2nd + coord_3rd + coord_4th + short_latency
			cmdevents = self.get_pinch_event(*args)
		elif cmd == "sleep":
			if use_default:
				cmdevents = self.get_sleep_event()
			else:
				sleep_time = self.get_sleep_time()
				cmdevents = self.get_sleep_event(sleep_time)
		else:
			raise Exception("Unknown command")

		return cmdevents

def main():
	getrandomsc = GenRandomSC()
	
if __name__ == '__main__':
	testSample = ["--config", "testConfig"]
	if len(sys.argv) > 1:
		options = Parser.parser(sys.argv[1:])
		if 'config' in options:
			main()
		else:
			print Parser.parser(testSample)
	else:		
		print Parser.parser(testSample)