Esempio n. 1
0
 def run(self):
     # initializing callbacks
     init_callbacks(self.tox, self.ms, self.tray)
     # bootstrap
     try:
         for data in node_generator():
             if self.stop:
                 return
             self.tox.bootstrap(*data)
             self.tox.add_tcp_relay(*data)
     except:
         pass
     for _ in range(10):
         if self.stop:
             return
         self.msleep(1000)
     while not self.tox.self_get_connection_status():
         try:
             for data in node_generator():
                 if self.stop:
                     return
                 self.tox.bootstrap(*data)
                 self.tox.add_tcp_relay(*data)
         except:
             pass
         finally:
             self.msleep(5000)
Esempio n. 2
0
 def run(self):
     # initializing callbacks
     init_callbacks(self.tox, self.ms, self.tray)
     # download list of nodes if needed
     download_nodes_list()
     # bootstrap
     try:
         for data in generate_nodes():
             if self.stop:
                 return
             self.tox.bootstrap(*data)
             self.tox.add_tcp_relay(*data)
     except:
         pass
     for _ in range(10):
         if self.stop:
             return
         self.msleep(1000)
     while not self.tox.self_get_connection_status():
         try:
             for data in generate_nodes():
                 if self.stop:
                     return
                 self.tox.bootstrap(*data)
                 self.tox.add_tcp_relay(*data)
         except:
             pass
         finally:
             self.msleep(5000)
Esempio n. 3
0
 def run(self):
     # initializing callbacks
     init_callbacks(self.tox, self.ms, self.tray)
     # bootstrap
     try:
         for data in node_generator():
             if self.stop:
                 return
             self.tox.bootstrap(*data)
     except:
         pass
     for _ in xrange(10):
         if self.stop:
             return
         self.msleep(1000)
     while not self.tox.self_get_connection_status():
         try:
             for data in node_generator():
                 if self.stop:
                     return
                 self.tox.bootstrap(*data)
         except:
             pass
         finally:
             self.msleep(5000)
Esempio n. 4
0
def __create_callbacks():
    print("\nCreating callbacks:")
    callback_list = []
    for unit in __get_units():
        callback_list.extend(__call_function(unit, "create_callbacks"))

    callbacks.init_callbacks(callback_list)
Esempio n. 5
0
def test_smi_dispatching():
    TEST_NAME = b'SmiDispatching'

    enable_trace = True
    ql = Qiling(
        ['./bin/EfiFuzzTests.efi'],
        ".",  # rootfs
        console=True if enable_trace else False,
        stdout=1 if enable_trace else None,
        stderr=1 if enable_trace else None,
        output='debug',
        profile='../smm/smm.ini')

    # NVRAM environment.
    ql.env.update({'TestName': TEST_NAME})

    # Init SMM
    callbacks.init_callbacks(ql)
    smm.init(ql, in_smm=True)

    def smi_intercept(ql):
        # Validate EFI_SMM_SW_REGISTER_CONTEXT
        register_context = EFI_SMM_SW_REGISTER_CONTEXT.loadFrom(ql, ql.reg.rdx)
        assert register_context.SwSmiInputValue == 0x9F

        # Validate EFI_SMM_SW_CONTEXT
        sw_context = EFI_SMM_SW_CONTEXT.loadFrom(ql, ql.reg.r8)
        assert sw_context.SwSmiCpuIndex == 0
        assert sw_context.DataPort == 0
        assert sw_context.CommandPort == 0x9F

    smi_intercept = mockito.spy(smi_intercept)

    def hook_smi(ql, address, params):
        # Hook the SMI handler.
        ql.hook_address(smi_intercept, params['DispatchFunction'])
        return (address, params)

    # Hook ReadSection() to check the taint on the buffer.
    ql.set_api("SMM_SW_DISPATCH2_Register", hook_smi, QL_INTERCEPT.EXIT)

    # okay, ready to roll.
    ql.run()

    # Make sure that the SMI handler was intercepted once.
    mockito.verify(smi_intercept, times=1).__call__(*mockito.ARGS)
Esempio n. 6
0
	def main(self):
		self.tox = tox_factory(ProfileHelper.open_profile(self.path))
		print self.tox.self_get_address()
		init_callbacks(self.tox)
		sonek=str(self.tox.self_get_address())[0:2]
		com_file="gelen_komutlar"+sonek
		# bootstrap
		for data in node_generator():
			self.tox.bootstrap(*data)
		settings = Settings()
		self.profile = Bot(self.tox)
		self.tox.self_set_name("Toxfs_Agent-0.1"+sonek)
		self.tox.self_set_status_message("Tox File Sharing Agent")
		for num in self.tox.self_get_friend_list():
			print num,self.tox.friend_get_name(self.tox.self_get_friend_list()[num])
		print 'Iterate'
		try:
			while not self.stop:
				self.tox.iterate()
				time.sleep(self.tox.iteration_interval() / 1000.0)
				if os.path.exists(com_file) and '##' in open(com_file,"r").read():
					print com_file,"isleniyor..."
					data=open(com_file,"r").read()
					datalar=data.split('##')
					arkadasno=datalar[0]
					islemtip=datalar[1]
					param=datalar[2]
					param2=datalar[3]
					print "gelen ",islemtip,":",arkadasno,islemtip,param,param2
					if self.tox.friend_get_connection_status(int(arkadasno)):
						if islemtip=="mesaj":
							self.tox.friend_send_message(int(arkadasno),0,param)
							print arkadasno,self.tox.friend_get_name(int(arkadasno)),"arkadasa metin mesaji gonderildi."
						if islemtip=="komut":
							self.tox.friend_send_message(int(arkadasno),0,param2)
							print arkadasno,self.tox.friend_get_name(int(arkadasno)),"arkadasa komut mesaji gonderildi."
					print com_file,"siliniyor."
					os.remove(com_file)
					print com_file,"tamamlandi."
                
		except KeyboardInterrupt:
			settings.save()
			data = self.tox.get_savedata()
			ProfileHelper.save_profile(data)
			del self.tox
		print "test"
Esempio n. 7
0
 def main(self):
     self.tox = tox_factory(ProfileHelper.open_profile(self.path))
     init_callbacks(self.tox)
     # bootstrap
     for data in node_generator():
         self.tox.bootstrap(*data)
     settings = Settings()
     self.profile = Bot(self.tox)
     print 'Iterate'
     try:
         while not self.stop:
             self.tox.iterate()
             time.sleep(self.tox.iteration_interval() / 1000.0)
     except KeyboardInterrupt:
         settings.save()
         data = self.tox.get_savedata()
         ProfileHelper.save_profile(data)
         del self.tox
Esempio n. 8
0
 def main(self):
     self.tox = tox_factory(ProfileHelper.open_profile(self.path))
     init_callbacks(self.tox)
     # bootstrap
     for data in node_generator():
         self.tox.bootstrap(*data)
     settings = Settings()
     self.profile = Bot(self.tox)
     print 'Iterate'
     try:
         while not self.stop:
             self.tox.iterate()
             time.sleep(self.tox.iteration_interval() / 1000.0)
     except KeyboardInterrupt:
         settings.save()
         data = self.tox.get_savedata()
         ProfileHelper.save_profile(data)
         del self.tox
Esempio n. 9
0
def test_smm_save_state():
    TEST_NAME = b'SmmSaveState'

    enable_trace = True
    ql = Qiling(
        ['./bin/EfiFuzzTests.efi'],
        ".",  # rootfs
        console=True if enable_trace else False,
        stdout=1 if enable_trace else None,
        stderr=1 if enable_trace else None,
        output='debug',
        profile='../smm/smm.ini')

    # NVRAM environment.
    ql.env.update({'TestName': TEST_NAME})

    # Init SMM
    callbacks.init_callbacks(ql)
    smm.init(ql, in_smm=True)

    def validate_smm_read_save_state(ql, address, params):
        assert params['Width'] == 0x4
        assert params['Register'] == EFI_SMM_SAVE_STATE_REGISTER.RAX.value
        assert params['CpuIndex'] == 0x0

        data = int.from_bytes(ql.mem.read(params['Buffer'], params['Width']),
                              'little')
        assert data == 0xbadcafe
        return (address, params)

    # Hook ReadSaveState().
    validate_smm_read_save_state = mockito.spy(validate_smm_read_save_state)
    ql.set_api("SmmReadSaveState", validate_smm_read_save_state,
               QL_INTERCEPT.EXIT)

    # okay, ready to roll.
    ql.os.smm.swsmi_args = {'rax': 0xdeadbeef_0badcafe.to_bytes(8, 'little')}
    ql.run()

    # Make sure that the SMI handler was intercepted once.
    mockito.verify(validate_smm_read_save_state,
                   times=1).__call__(*mockito.ARGS)
def run_server():
    """
    Main function to run the server
    """

    symbol_options = [
        {'label': 'AAPL', 'value': 'AAPL'},
        {'label': 'MSFT', 'value': 'MSFT'},
        {'label': 'AMZN', 'value': 'AMZN'},
        {'label': 'GOOGL', 'value': 'GOOGL'},
        {'label': 'FB', 'value': 'FB'},
        {'label': 'AMD', 'value': 'AMD'},
        {'label': 'ALK', 'value': 'ALK'},
        {'label': 'ALL', 'value': 'ALL'},
        {'label': 'AXP', 'value': 'AXP'},
        {'label': 'CVS', 'value': 'CVS'},
        {'label': 'EBAY', 'value': 'EBAY'},
        {'label': 'INTC', 'value': 'INTC'}
    ]

    app.layout = html.Div([
        html.Div([
            html.H2('LSTM Stock Predictor',
                    style={'display': 'inline',
                           'float': 'left',
                           'font-size': '2.65em',
                           'margin-left': '7px',
                           'font-weight': 'bolder',
                           'font-family': 'Product Sans',
                           'color': "rgba(117, 117, 117, 0.95)",
                           'margin-top': '20px',
                           'margin-bottom': '0'
                           }),
        ]),
        dcc.Dropdown(
            id='stock-symbol-input',
            # options=[{'label': s, 'value': s}
            #          for s in symbols],
            options = symbol_options,
            value='AAPL'
        ),

        # html.Div([
        #     dcc.DatePickerRange(
        #         id='stock-date-picker-range',
        #         min_date_allowed=dt(2000, 1, 1),
        #         max_date_allowed=today,
        #         initial_visible_month=dt(2015, 1, 1),
        #         end_date=today
        #     ),
        #     # html.Div(id='output-container-date-picker-range')
        # ]),

        html.Div([
            dcc.DatePickerSingle(
                id='start-date-picker',
                min_date_allowed=dt(1990, 1, 1),
                max_date_allowed=today,
                initial_visible_month=dt(2000, 1, 1),
                # date=dt(2015, 1, 1)
            ),
            # html.Div(id='start-date-output-container')
        ]),


        html.Div([
            dcc.DatePickerSingle(
                id='end-date-picker',
                min_date_allowed=dt(1990, 1, 1),
                max_date_allowed=today,
                initial_visible_month=dt(2020, 6, 1),
                # date=today
            ),
        ]),

        html.Button('Run Model', id='input_button', n_clicks=0),
        # html.Button('Reset',id='reset_button', n_clicks=0),

        html.Div(id='graph')
    ], className="container")


    # initialize callbacks
    init_callbacks('AAPL')

    # app.run_server(debug=True, port=8080, threaded=False)
    app.run_server(debug=True, port=8080)