Exemplo n.º 1
0
	def fuzz(self, tests):
		"""Executes something in all the different pieces of software"""
		process = []		# info to be return and saved in the database
		# go through each test
		for test in tests:
			for piece in self.settings['software']:
				input = self.get_input(piece, test)
				try:
					process.append(Execute(self.settings, piece, input))
				except Exception:
					print "Error when trying to append a new process. Try using less parallel threads. Terminating..."
					sys.exit()
		for x in range(0, len(process)):
			process[x].join()
		for x in range(0, len(process)):
			process[x] = process[x].get_output()
		# save the network results
		if self.ids:
			for x in range(0, len(self.ids)):
				for z in range(0, len(process)):
					if process[z]['testcaseid'] == self.ids[x][0] and process[z]['softwareid'] == self.ids[x][1]:
						process[z]['network'] = self.ids[x][2]
						break
			self.ids = []
		self.settings['logger'].debug("Process: %s" % str(process))
		return process
Exemplo n.º 2
0
    def handle_message_callback(self, message, is_redelivered=True):
        self.log.info('Message callback invoked: {0}'.format(is_redelivered))
        response = {'success': True}
        try:
            self.execute = Execute(message)

            if self.execute.container_name != self.config['CONTAINER_NAME']:
                error_message = 'Invalid DS message received. ' \
                    'Unmatched container names. \n CONFIG: {0}' \
                    '\nCONTAINER_NAME {1}'.format(
                        self.config, self.execute.container_name)
                self.log.error(error_message)
                response['success'] = False
                response['error'] = error_message
                raise Exception(error_message)
            else:
                self.log.info('Valid DS message : {0}'.format(
                    self.config['BOOT_SUCCESS_MESSAGE']))
                self.log.info(self.execute.message)

                # this is read by HDQ to decide whether DS container
                # boot was successful or not
                print self.config['BOOT_SUCCESS_MESSAGE']
                boot_file = open('/home/shippable/bootinfo.txt', 'a')
                boot_file.write('success')
                boot_file.close()
                sys.stdout.flush()

            self.execute.run()
        except Exception as exc:
            self.log.error(str(exc))
            trace = traceback.format_exc()
            self.log.debug(trace)
        return response
Exemplo n.º 3
0
def case_run(request):
    if request.method == 'POST':
        case_id = request.POST['case_id']
        env_id = request.POST['env_id']
        execute = Execute(case_id, env_id)
        case_result = execute.run_case()
        return JsonResponse(case_result)
Exemplo n.º 4
0
 def ButtonReleased( self, w, ev, ev2 ):
     if ev.button == 1:
         if not hasattr( self, "press_x" ) or \
                 not w.drag_check_threshold( int( self.press_x ),
                                                                          int( self.press_y ),
                                                                          int( ev.x ),
                                                                          int( ev.y ) ):
             if self.Win.pinmenu == False:
                 self.Win.wTree.get_widget( "window1" ).hide()
             if "applications" in self.Win.plugins:
                 self.Win.plugins["applications"].wTree.get_widget( "entry1" ).grab_focus()
             Execute( w, self.Exec )
Exemplo n.º 5
0
    def __init__(self):
        super().__init__()

        self.exe = Execute()
        self.img_lbl.initXYBoxObjs(self.x_box, self.y_box)
        self.img_lbl.initReferLineNumObj(self.ref_num_lbl)
        self.img_lbl.initHorizonModifyObj(self.horizon_modify_btn)
        self.img_lbl.initSLObsNumObjs(self.small_obs_num_lbl, self.large_obs_num_lbl)

        self.start_flag = False
        self.mode = 'Horizon'
        self.horizon_method = 'Manual'
        self.refer_lines_flag = False
        self.obs_cls = 'Small Obstacle'
Exemplo n.º 6
0
 def sup_check(self):
     if self.mid < self.dfD.iloc[-1]['Daily Pivot Point']:
         print '**** Checking Support Pivots ****'
         sup = Support(self.instrument, self.mid, self.dfD, self.units,
                       self.pivot, self.sl1, self.sl2, self.sl3, self.rate1,
                       self.rate2)
         print sup.support()
         try:
             supUnits, supProfit, supLoss = sup.support()
             supex = Execute(self.api, self._id, self.instrument, supUnits,
                             supProfit, supLoss)
             supex.trade()
         except Exception as e:
             print(e)
Exemplo n.º 7
0
 def res_check(self):
     if self.mid > self.dfD.iloc[-1]['Daily Pivot Point']:
         print '**** Checking Resistance Pivots ****'
         res = Resistance(self.instrument, self.mid, self.dfD, self.units,
                          self.pivot, self.rl1, self.rl2, self.rl3,
                          self.rate1, self.rate2)
         print res.resistance()
         try:
             resUnits, resProfit, resLoss = res.resistance()
             resex = Execute(self.api, self._id, self.instrument, resUnits,
                             resProfit, resLoss)
             resex.trade()
         except Exception as e:
             print(e)
Exemplo n.º 8
0
 def __init__(self, main):
     """
     Parent constructor call,
     call setup for gui, 
     create thread object for 
     the script and connect signals
     to slots
     """
     super(Gui_Main, self).__init__()
     self.setupUi(main)
     self.execute = Execute()
     self.connect(self.execute, SIGNAL("setOutput(QString)"),
                  self.setOutput)
     self.connect(self.execute, SIGNAL("finished(bool)"), self.finished)
     self.step = 0
Exemplo n.º 9
0
def main():
	global _username,_domain,_classes, prevId

	init()

	print(Fore.WHITE + Style.BRIGHT + printBanner() , end='')

	with open(baseWritePath + prevId, 'r') as f:
		first = json.load(f)

	nextId = ''.join(random.choice(string.ascii_uppercase + string.digits) for _ in range(10))
	first['NextId'] =  nextId

	with open(baseWritePath + prevId, 'w') as f:
		json.dump(first, f)

	prevId = nextId

	content = waitAndReadFile(baseReadPath + prevId)

	userAndDomain = content['Output']
	userAndDomain = userAndDomain.split("\\")
	_domain = userAndDomain[0]
	_username = userAndDomain[1]
	


	_classes.append(Download())
	_classes.append(Execute())
	_classes.append(Move())
	_classes.append(Base64encode())
	_classes.append(Base64decode())
	_classes.append(Compile())
	_classes.append(Inject())
	_classes.append(Downexec())
	_classes.append(Powershell())
	_classes.append(Send())
	_classes.append(Impersonate())
	_classes.append(Exfiltrate())
	_classes.append(Runas())
	_classes.append(Shell())


	mainConsole()

	deinit()
Exemplo n.º 10
0
def plan_run(request):
    if request.method == 'POST':
        plan_id = request.POST['plan_id']
        plan = Plan.objects.get(plan_id=plan_id)
        env_id = plan.environment.env_id
        case_id_list = eval(plan.content)
        case_num = len(case_id_list)
        content = []
        pass_num = 0
        fail_num = 0
        error_num = 0
        for case_id in case_id_list:
            execute = Execute(case_id, env_id)
            case_result = execute.run_case()
            content.append(case_result)
            if case_result["result"] == "pass":
                pass_num += 1
            if case_result["result"] == "fail":
                fail_num += 1
            if case_result["result"] == "error":
                error_num += 1
        report_name = plan.plan_name + "-" + time.strftime("%Y%m%d%H%M%S")
        if Report.objects.filter(plan=plan):
            Report.objects.filter(plan=plan).update(report_name=report_name,
                                                    content=content,
                                                    case_num=case_num,
                                                    pass_num=pass_num,
                                                    fail_num=fail_num,
                                                    error_num=error_num)
        else:
            report = Report(plan=plan,
                            report_name=report_name,
                            content=content,
                            case_num=case_num,
                            pass_num=pass_num,
                            fail_num=fail_num,
                            error_num=error_num)
            report.save()
        return HttpResponse(plan.plan_name + " 执行成功!")
Exemplo n.º 11
0
 def ButtonClicked(self, widget, Exec):
     self.mintMenuWin.hide()
     if Exec:
         Execute(Exec)
Exemplo n.º 12
0
Arquivo: kernel.py Projeto: veghen/Y86
    lst.write('E', cur.regE)
    lst.write('M', cur.regM)
    lst.write('W', cur, regW)


mem = Memory()
InsCode = {}
Init(InsCode, mem)
reg = Register()
pipereg = PipeRegister()
tmp_pipereg = PipeRegister()
CC = ConditionCode()
Stat = Status()

PC = 0
while Stat.stat == 'AOK':
    print 'Current Time:', PC
    tmp_pipereg = PipeRegister()
    Fetch(tmp_pipereg, InsCode[hex(PC)], PC)
    Decode(pipereg, tmp_pipereg, reg)
    Execute(pipereg, tmp_pipereg)
    Memory(pipereg, tmp_pipereg)
    WriteBack(pipereg, tmp_pipereg)
    PC = pipereg.regF['predPC']
    Update(cur=tmp_pipereg, lst=pipireg)
    print 'RegF:', reg.regF
    print 'RegD:', reg.regD
    print 'RegE:', reg.regE
    print 'RegM:', reg.regM
    print 'RegW:', reg.regW
Exemplo n.º 13
0
    def downexec(self, cmdSpl):

        d = Download()
        e = Execute()
        d.executeCommand(cmdSpl)
        e.executeCommand(cmdSpl[1:])
Exemplo n.º 14
0
import os
from execute import Execute

if __name__ == '__main__':
    print('Booting up CEXEC')
    executor = Execute()
    print('Running CEXEC script')
    exit_code = executor.run()
    print('CEXEC has completed')
    os._exit(exit_code)
Exemplo n.º 15
0
import time
from collections import defaultdict, Counter
from os.path import join, dirname, realpath, split
try:
    scriptdir = dirname(realpath(__file__))
except NameError:
    scriptdir = dirname(realpath(sys.argv[0]))
scriptdir1 = realpath(join(scriptdir, '..', '..', 'common', 'src'))
sys.path.append(scriptdir1)
try:
    scriptextn = "." + os.path.split(sys.argv[0])[1].rsplit('.', 1)[1]
except:
    scriptextn = ""

from execute import Execute
execprog = Execute(scriptdir, scriptdir1, extn=scriptextn)

from optparse_gui import OptionParser, OptionGroup, GUI, UserCancelledError, ProgressText
from util import *

from version import VERSION
VERSION = '%s' % (VERSION, )


def excepthook(etype, value, tb):
    traceback.print_exception(etype, value, tb)
    print("Type <Enter> to Exit...", end=' ', file=sys.stderr)
    sys.stderr.flush()
    input()

Exemplo n.º 16
0
 def __init__(self):
     self.utils = Utils()
     self.execute = Execute()
     self.filereader = FileReader()
Exemplo n.º 17
0
    def handle(self, cmd, json_data, filedata=None):
        #python 3 conversion
        #cmd = cmd.decode('ascii')
        print("[INFO] Command sent:" + str(cmd))
        res = {}
        try:
            # pdb.set_trace()
            browserdata = {
                'remote_ip': self.request.remote_ip,
                'browser': self.request.headers.get('User-Agent')
            }
            Log.i(browserdata)
            # Python 3 conversion needed.
            #pdb.set_trace()
            lang = json_data.get('lang', 'C')
            name = json_data.get('name', 'Solution')
            code = json_data.get('code', '')
            input = json_data.get('input', '')
            depends = json_data.get('depends', '')
            testcases = json_data.get('testcases', '')
            func = ''

            # Unicode
            #[ cmd, lang, name, code, input, depends] = [ xx.encode('utf8') if xx else '' for xx in [ cmd, lang, name, code, input, depends]]
            # Logic  Here ..
            try:
                #pdb.set_trace()
                if cmd == 'compile':
                    res = Execute(lang, name, code, func, input, depends,
                                  testcases).save(name, code, func,
                                                  input).compile(name)
                elif cmd == 'run':
                    res = Execute(lang, name, code, func, input, depends,
                                  testcases).save(name, code, func,
                                                  input).fullrun(name)
                elif cmd == 'crashbt':
                    res = Execute(lang, name, code, func, input, depends,
                                  testcases).getCrashBackTrace()
                elif cmd == 'mleaks':
                    res = Execute(lang, name, code, func, input, depends,
                                  testcases).getMemoryleaks()
                elif cmd == 'perf':
                    res = Execute(lang, name, code, func, input, depends,
                                  testcases).testperf(name)
                else:
                    res = {
                        'status': 'error',
                        'msg': 'Invalid cmd send to codestudio',
                        'help': 'valid command : run | compile | debug |'
                    }
            except Exception as e:
                LE(e)
                res = {
                    'status': 'error',
                    'msg':
                    'Internal error occure with codestudio. Please contact ddutta',
                    'sys_error': str(e)
                }
        except Exception as e:
            LE(e)
            res['status'] = 'error'
            res['msg'] = 'Some internal Error'
            res['help'] = 'Talk to dev ops:' + str(e)

        #self.write(json.dumps(res, default=json_util.default))
        self.write(json.dumps(res))
Exemplo n.º 18
0
    scriptdir = dirname(realpath(sys.executable))
    if not scriptdir.endswith('/bin') and not scriptdir.endswith('/MacOS'):
        scriptdir = realpath(os.path.join(scriptdir, ".."))
    scriptdirs = [scriptdir]
else:
    scriptdir = dirname(realpath(sys.argv[0]))
    scriptdir1 = realpath(join(scriptdir, '..', '..', 'ReadCounts', 'src'))
    scriptdirs = [scriptdir, scriptdir1]

try:
    scriptextn = "." + os.path.split(sys.argv[0])[1].rsplit('.', 1)[1]
except:
    scriptextn = ""

from execute import Execute
execprog = Execute(*scriptdirs, extn=scriptextn)

from release import RELEASE, VERSION
VERSION = "%s (%s:%s)" % (VERSION, RELEASE, VERSION)


def excepthook(etype, value, tb):
    traceback.print_exception(etype, value, tb)
    print("Type <Enter> to Exit...", end=' ', file=sys.stderr)
    sys.stderr.flush()
    input()


toremove = []