private void doResolveAndConnect0(Channel channel, SocketAddress remoteAddress, SocketAddress localAddress) { EventLoop eventLoop = channel.eventLoop(); AddressResolver <SocketAddress> resolver = _resolver.getResolver((EventExecutor)eventLoop); doConnect(channel, remoteAddress, localAddress); }
public void CreatesEmptyListIfNullIsPassedIn() { var ar = new AddressResolver(new Uri("bolt://virtual.uri:1234"), null); var response = ar.Resolve(ServerAddress.From("virtual.uri", 1234)); response.Should().HaveCount(0); }
public bool LoginWithHashedPassword(string username, string hash) { var user = new User() { UserName = username, PasswordHash = hash }; var client = CommonHelper.GetClient(AddressResolver.GetAddress("KlipperApi", false)); var json = JsonConvert.SerializeObject(user, Formatting.Indented); var httpContent = new StringContent(json, Encoding.UTF8, "application/json"); var response = client.PostAsync("api/auth/login", httpContent).Result; if (response.IsSuccessStatusCode) { Auth.SessionToken = ExtractToken(response); StoreToVault(username, hash); Employee employee = EmployeeService.Instance.GetEmployeeByUserName(username); if (employee != null) { SessionContext.CurrentSubject = employee; } return(true); } return(false); }
/// <summary> /// Loads the results for the current page. /// </summary> private void LoadScanResults() { Snapshot snapshot = SnapshotManagerViewModel.GetInstance().GetSnapshot(SnapshotManagerViewModel.SnapshotRetrievalMode.FromActiveSnapshot); IList <ScanResult> newAddresses = new List <ScanResult>(); if (snapshot != null) { UInt64 startIndex = Math.Min(ScanResultsViewModel.PageSize * this.CurrentPage, snapshot.ElementCount); UInt64 endIndex = Math.Min((ScanResultsViewModel.PageSize * this.CurrentPage) + ScanResultsViewModel.PageSize, snapshot.ElementCount); for (UInt64 index = startIndex; index < endIndex; index++) { SnapshotElementIndexer element = snapshot[index]; String label = element.GetElementLabel() != null?element.GetElementLabel().ToString() : String.Empty; Object currentValue = element.HasCurrentValue() ? element.LoadCurrentValue() : null; Object previousValue = element.HasPreviousValue() ? element.LoadPreviousValue() : null; String moduleName; UInt64 address = AddressResolver.GetInstance().AddressToModule(element.BaseAddress, out moduleName); PointerItem pointerItem = new PointerItem(baseAddress: address.ToIntPtr(), dataType: this.ActiveType, moduleName: moduleName, value: currentValue); newAddresses.Add(new ScanResult(pointerItem, previousValue, label)); } } this.Addresses = new FullyObservableCollection <ScanResult>(newAddresses); // Ensure results are visible this.IsVisible = true; this.IsSelected = true; this.IsActive = true; }
/// <summary> /// Loads the instructions to display. /// </summary> private void LoadInstructions() { Byte[] bytes = EngineCore.GetInstance().VirtualMemory.ReadBytes(this.BaseAddress.ToIntPtr(), 200, out _); if (bytes.IsNullOrEmpty()) { return; } Boolean isProcess32Bit = EngineCore.GetInstance().Processes.IsOpenedProcess32Bit(); // Disassemble instructions IEnumerable <NormalizedInstruction> disassembledInstructions = this.Disassembler.Disassemble(bytes, isProcess32Bit, this.BaseAddress.ToIntPtr()); IList <InstructionItem> instructions = new List <InstructionItem>(); foreach (NormalizedInstruction disassembledInstruction in disassembledInstructions) { String moduleName; UInt64 address = AddressResolver.GetInstance().AddressToModule(disassembledInstruction.Address, out moduleName); instructions.Add(new InstructionItem(address.ToIntPtr(), moduleName, disassembledInstruction.Instruction, disassembledInstruction.Bytes)); } this.Instructions = new FullyObservableCollection <InstructionItem>(instructions); }
/// <summary> /// Resolves the address of an address, pointer, or managed object. /// </summary> /// <returns>The base address of this object.</returns> protected override IntPtr ResolveAddress() { IntPtr pointer = AddressResolver.GetInstance().ResolveModule(this.ModuleName); Boolean successReading = true; pointer = pointer.Add(this.ModuleOffset); if (this.PointerOffsets == null || this.PointerOffsets.Count() == 0) { return(pointer); } foreach (Int32 offset in this.PointerOffsets) { if (EngineCore.GetInstance().Processes.IsOpenedProcess32Bit()) { pointer = EngineCore.GetInstance().VirtualMemory.Read <Int32>(pointer, out successReading).ToIntPtr(); } else { pointer = EngineCore.GetInstance().VirtualMemory.Read <Int64>(pointer, out successReading).ToIntPtr(); } if (pointer == IntPtr.Zero || !successReading) { pointer = IntPtr.Zero; break; } pointer = pointer.Add(offset); } return(pointer); }
/// <summary> /// Starts useful services that run in the background to assist in various operations. /// </summary> private void StartBackgroundServices() { DotNetObjectCollector.GetInstance().Start(); AddressResolver.GetInstance().Start(); AnalyticsService.GetInstance().Start(); AnalyticsService.GetInstance().SendEvent(AnalyticsService.AnalyticsAction.General, "Start"); OutputViewModel.GetInstance().Log(OutputViewModel.LogLevel.Info, "Background services started"); }
/// <summary> /// Starts useful services that run in the background to assist in various operations. /// </summary> private void StartBackgroundServices() { SnapshotPrefilterFactory.GetSnapshotPrefilter(typeof(ChunkLinkedListPrefilter)).BeginPrefilter(); //// PointerCollector.GetInstance().Begin(); DotNetObjectCollector.GetInstance().Begin(); AddressResolver.GetInstance().Begin(); OutputViewModel.GetInstance().Log(OutputViewModel.LogLevel.Info, "Background Services Started"); }
public static IWebHostBuilder CreateWebHostBuilder(string[] args) => WebHost.CreateDefaultBuilder(args) .UseStartup <Startup>() .UseUrls(new string[] { AddressResolver.GetAddress("KlipperApi", true), AddressResolver.GetAddress("KlipperApi", false), }) ;
private EndpointCache GetOrAddEndpoint(Uri endpoint) { // The GetorAdd is followed by a call to .Count which in a ConcurrentDictionary // will acquire all locks for all buckets. This is really expensive. Since the check // there is only to see if we've exceeded the count of endpoints, we can simply // avoid that check altogether if we are not adding any more endpoints. if (this.addressCacheByEndpoint.TryGetValue(endpoint, out EndpointCache existingCache)) { return(existingCache); } EndpointCache endpointCache = this.addressCacheByEndpoint.GetOrAdd( endpoint, (Uri resolvedEndpoint) => { GatewayAddressCache gatewayAddressCache = new GatewayAddressCache( resolvedEndpoint, this.protocol, this.tokenProvider, this.serviceConfigReader, this.httpClient, enableTcpConnectionEndpointRediscovery: this.enableTcpConnectionEndpointRediscovery); string location = this.endpointManager.GetLocation(endpoint); AddressResolver addressResolver = new AddressResolver(null, new NullRequestSigner(), location); addressResolver.InitializeCaches(this.collectionCache, this.routingMapProvider, gatewayAddressCache); return(new EndpointCache() { AddressCache = gatewayAddressCache, AddressResolver = addressResolver, }); }); if (this.addressCacheByEndpoint.Count > this.maxEndpoints) { IEnumerable <Uri> allEndpoints = this.endpointManager.WriteEndpoints.Union(this.endpointManager.ReadEndpoints); Queue <Uri> endpoints = new Queue <Uri>(allEndpoints.Reverse()); while (this.addressCacheByEndpoint.Count > this.maxEndpoints) { if (endpoints.Count > 0) { EndpointCache removedEntry; this.addressCacheByEndpoint.TryRemove(endpoints.Dequeue(), out removedEntry); } else { break; } } } return(endpointCache); }
public void PassesBackCorrectUris() { const string uri1 = "x.acme.com"; const string uri2 = "y.acme.com"; var ar = new AddressResolver("bolt://virtual.uri", new [] { $"bolt://{uri1}", "bolt://" + uri2 }); var response = ar.Resolve(null).ToList(); response.Should().HaveCount(2); response.Any(x => x.Host == uri1).Should().BeTrue(); response.Any(x => x.Host == uri2).Should().BeTrue(); }
public async Task <Employee> GetEmployeeByIdAsync(int employeeId) { var client = CommonHelper.GetClient(AddressResolver.GetAddress("EmployeeApi", false)); var str = "api/employees/" + employeeId.ToString(); HttpResponseMessage response = await client.GetAsync(str); var jsonString = await response.Content.ReadAsStringAsync(); var employee = JsonConvert.DeserializeObject <Employee>(jsonString); return(employee); }
public ChangePackageViewModel(int deliveryId) { _addressResolver = new AddressResolver(); _deliveryRepository = new DeliveryRepository(); _delivery = _deliveryRepository.GetById(deliveryId); RecalculateCostCommand = new Command(RecalculateCost); NewProductLineCommand = new Command(NewProductLine); DeleteProductLineCommand = new Command <ProductLine>(x => x != null, DeleteProductLine); CancelCommand = new Command(() => DialogResult = false); OkCommand = new Command(Save); }
public async Task <Department> GetDepartmentByNameAsync(string departmentName) { var client = CommonHelper.GetClient(AddressResolver.GetAddress("OperationalsApi", false)); var str = "api/departments/ByDepartmentName?departmentName=" + departmentName; HttpResponseMessage response = await client.GetAsync(str); var jsonString = await response.Content.ReadAsStringAsync(); var department = JsonConvert.DeserializeObject <Department>(jsonString); return(department); }
public async Task <IEnumerable <AccessEvent> > GetAttendanceByEmployeeIdAsync(int employeeId) { var client = CommonHelper.GetClient(AddressResolver.GetAddress("AttendanceApi", false)); var str = "api/accessevents/byEmployeeId?employeeId=" + employeeId.ToString(); HttpResponseMessage response = await client.GetAsync(str); var jsonString = await response.Content.ReadAsStringAsync(); var accessEvents = JsonConvert.DeserializeObject <List <AccessEvent> >(jsonString); return(accessEvents); }
/// <summary> /// Resolves the address of an address, pointer, or managed object. /// </summary> /// <returns>The base address of this object.</returns> public IntPtr ResolveAddress() { IntPtr pointer = IntPtr.Zero; Boolean successReading = true; switch (this.ResolveType) { case AddressResolver.ResolveTypeEnum.Module: pointer = AddressResolver.GetInstance().ResolveModule(this.BaseIdentifier); break; case AddressResolver.ResolveTypeEnum.GlobalKeyword: pointer = AddressResolver.GetInstance().ResolveGlobalKeyword(this.BaseIdentifier); break; case AddressResolver.ResolveTypeEnum.DotNet: pointer = AddressResolver.GetInstance().ResolveDotNetObject(this.BaseIdentifier); break; } pointer = pointer.Add(this.BaseAddress); if (this.Offsets == null || this.Offsets.Count() == 0) { return(pointer); } foreach (Int32 offset in this.Offsets) { if (EngineCore.GetInstance().Processes.IsOpenedProcess32Bit()) { pointer = EngineCore.GetInstance().OperatingSystemAdapter.Read <Int32>(pointer, out successReading).ToIntPtr(); } else { pointer = EngineCore.GetInstance().OperatingSystemAdapter.Read <Int64>(pointer, out successReading).ToIntPtr(); } pointer = pointer.Add(offset); if (pointer == IntPtr.Zero || !successReading) { pointer = IntPtr.Zero; break; } } return(pointer); }
static void Main(string[] args) { logger.LogLevel = LogLevel.Error; fileSender.Logger.LogLevel = logger.LogLevel; DisplayCommands(); while (true) { try { string cmd = Console.ReadLine(); if (cmd == "exit") { return; } string[] arguments = cmd.Split(' '); if (arguments.Length > 0 && arguments[0] == "receive") { string path = arguments.Length > 1 ? AssemblePath(arguments, 1, arguments.Length) : Constants.DefaultReceiveFolder; StartReceiving(path, Constants.DefaultPort); logger.Log(LogLevel.Priority, "Saving received files to: \"{0}\"", path); } else if (arguments.Length > 1 && arguments[0] == "send") { destination = AddressResolver.Resolve(arguments[1], Constants.DefaultPort); logger.Log(LogLevel.Priority, "Enter file path to send to " + destination); } else if (destination != null) { Send(cmd.Trim('\"')); } else { logger.Log(LogLevel.Error, "Command not recognized."); DisplayCommands(); } } catch (Exception ex) { logger.Log(LogLevel.Error, ex.Message); } } }
private EndpointCache GetOrAddEndpoint(Uri endpoint) { EndpointCache endpointCache = this.addressCacheByEndpoint.GetOrAdd( endpoint, (Uri resolvedEndpoint) => { GatewayAddressCache gatewayAddressCache = new GatewayAddressCache( resolvedEndpoint, this.protocol, this.tokenProvider, this.userAgentContainer, this.serviceConfigReader, this.requestTimeout, messageHandler: this.messageHandler, apiType: this.apiType, enableTcpConnectionEndpointRediscovery: this.enableTcpConnectionEndpointRediscovery); string location = this.endpointManager.GetLocation(endpoint); AddressResolver addressResolver = new AddressResolver(null, new NullRequestSigner(), location); addressResolver.InitializeCaches(this.collectionCache, this.routingMapProvider, gatewayAddressCache); return(new EndpointCache() { AddressCache = gatewayAddressCache, AddressResolver = addressResolver, }); }); if (this.addressCacheByEndpoint.Count > this.maxEndpoints) { IEnumerable <Uri> allEndpoints = this.endpointManager.WriteEndpoints.Union(this.endpointManager.ReadEndpoints); Queue <Uri> endpoints = new Queue <Uri>(allEndpoints.Reverse()); while (this.addressCacheByEndpoint.Count > this.maxEndpoints) { if (endpoints.Count > 0) { EndpointCache removedEntry; this.addressCacheByEndpoint.TryRemove(endpoints.Dequeue(), out removedEntry); } else { break; } } } return(endpointCache); }
private static void OnServiceResolved(object o, ServiceInfoArgs args) { objects.Remove(o); Console.WriteLine("Service '{0}' at {1}:{2}", args.Service.Name, args.Service.HostName, args.Service.Port); foreach (byte[] bytes in args.Service.Text) { Console.WriteLine("Text: " + Encoding.UTF8.GetString(bytes)); } AddressResolver ar = new AddressResolver(client, args.Service.Address); objects.Add(ar); ar.Found += OnAddressResolved; ar.Failed += OnAddressResolverFailed; }
public Department GetDepartmentById(int departmentId) { var client = CommonHelper.GetClient(AddressResolver.GetAddress("KlipperApi", false), Auth.SessionToken); var str = "api/departments/" + departmentId.ToString(); HttpResponseMessage response = client.GetAsync(str).Result; if (response.IsSuccessStatusCode) { var jsonString = response.Content.ReadAsStringAsync().Result; var department = JsonConvert.DeserializeObject <Department>(jsonString); return(department); } else { return(null); } }
public Employee GetEmployeeById(int employeeId) { var client = CommonHelper.GetClient(AddressResolver.GetAddress("KlipperApi", false), Auth.SessionToken); var str = "api/employees/" + employeeId.ToString(); HttpResponseMessage response = client.GetAsync(str).Result; if (response.IsSuccessStatusCode) { var jsonString = response.Content.ReadAsStringAsync().Result; var employee = JsonConvert.DeserializeObject <Employee>(jsonString); return(employee); } else { return(null); } }
public List <DateTime> GetHolidaysByYear(int year) { var client = CommonHelper.GetClient(AddressResolver.GetAddress("KlipperApi", false), Auth.SessionToken); var str = "api/worktime/holidays/" + year.ToString(); HttpResponseMessage response = client.GetAsync(str).Result; if (response.IsSuccessStatusCode) { var jsonString = response.Content.ReadAsStringAsync().Result; var holidays = JsonConvert.DeserializeObject <List <DateTime> >(jsonString); return(holidays); } else { return(null); } }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { var scopes = typeof(AppConstants.Scopes) .GetFields(BindingFlags.Public | BindingFlags.Static) .Where(f => f.IsLiteral && !f.IsInitOnly && f.FieldType == typeof(string)) .Select(f => (string)f.GetRawConstantValue()) .ToList(); var address = new AddressResolver(Configuration["AuthServer:BaseUrl"]); services.AddSingleton <IAddressResolver>(address); services.AddSingleton <IScopeCollection>(new ScopeCollection(scopes)); ConfigureServicesDatabase(services); ConfigureServicesMvc(services); ConfigureServicesAuth(services, scopes); ConfigureServicesApiExplorer(services, scopes); ConfigureServicesCookieConsent(services); }
public Department GetDepartmentByName(string departmentName) { var client = CommonHelper.GetClient(AddressResolver.GetAddress("KlipperApi", false), Auth.SessionToken); //KK: Please add this action on Employees controller in KlipperAPI var str = "api/departments/ByName?departmentName=" + departmentName; HttpResponseMessage response = client.GetAsync(str).Result; if (response.IsSuccessStatusCode) { var jsonString = response.Content.ReadAsStringAsync().Result; var department = JsonConvert.DeserializeObject <Department>(jsonString); return(department); } else { return(null); } }
public Employee GetEmployeeByUserName(string userName) { var client = CommonHelper.GetClient(AddressResolver.GetAddress("KlipperApi", false), Auth.SessionToken); //KK: Please add this action on Employees controller in KlipperAPI var str = "api/employees/ByUserName?userName=" + userName; HttpResponseMessage response = client.GetAsync(str).Result; if (response.IsSuccessStatusCode) { var jsonString = response.Content.ReadAsStringAsync().Result; var employee = JsonConvert.DeserializeObject <Employee>(jsonString); return(employee); } else { return(null); } }
/// <summary> /// Enumerates the pointers of the specified pointer branch. /// </summary> /// <param name="baseAddress">The current base address.</param> /// <param name="offsets">The offsets leading to this branch.</param> /// <param name="branch">The current branch.</param> /// <param name="pointerIndicies">The indicies at which to return non-null values.</param> /// <returns>The full pointer path to the branch.</returns> private IEnumerable <PointerItem> EnumerateBranches(UInt64 baseAddress, Stack <Int32> offsets, PointerBranch branch, PointerIndicies pointerIndicies) { offsets.Push(branch.Offset); // End index reached if (pointerIndicies.Finished) { yield break; } if (branch.Branches.Count <= 0) { PointerItem pointerItem; // Only create pointer items when in the range of the selection indicies. This is an optimization to prevent creating unneeded objects. if (pointerIndicies.IterateNext()) { String moduleName; UInt64 address = AddressResolver.GetInstance().AddressToModule(baseAddress, out moduleName); pointerItem = new PointerItem(address.ToIntPtr(), DataTypes.Int32, "New Pointer", moduleName, offsets.ToArray().Reverse()); } else { pointerItem = null; } yield return(pointerItem); } else { foreach (PointerBranch childBranch in branch) { foreach (PointerItem pointerItem in this.EnumerateBranches(baseAddress, offsets, childBranch, pointerIndicies)) { yield return(pointerItem); } } } offsets.Pop(); }
public IEnumerable <AccessEvent> GetAccessEvents(int employeeId, DateTime date) { var client = CommonHelper.GetClient(AddressResolver.GetAddress("KlipperApi", false), Auth.SessionToken); var startStr = date.Year.ToString() + "-" + date.Month.ToString() + "-" + date.Day.ToString(); var endStr = startStr; var str = "api/attendance/" + employeeId.ToString() + "/" + startStr + "/" + endStr; HttpResponseMessage response = client.GetAsync(str).Result; if (response.IsSuccessStatusCode) { var jsonString = response.Content.ReadAsStringAsync().Result; var accessEvents = JsonConvert.DeserializeObject <IEnumerable <AccessEvent> >(jsonString); return(accessEvents); } else { return(new List <AccessEvent>()); } }
internal PEAction(FileStream file) { File = file; Reader = new BinaryReader(file); Writer = new BinaryWriter(file); NTHeaderOffset = Reader.ReadStruct <DosHeader>().AddressOfNewExeHeader; File.Seek(NTHeaderOffset, SeekOrigin.Begin); NtHeader = Reader.ReadStruct <NtHeader>(); NtHeader.AssertHealth(); Dirs = new DataDir[16]; for (var i = 0; i < 16; i++) { Dirs[i] = Reader.ReadStruct <DataDir>(); } Resolver = new AddressResolver(NtHeader.FileHeader.NumberOfSections); for (uint i = 0; i < NtHeader.FileHeader.NumberOfSections; i++) { Resolver.Put(Reader.ReadStruct <SectionHeader>()); } }
public async Task <Address> GetAddress([Service] AddressResolver resolver, string id) { return(await resolver.Address(id)); }
protected override IntPtr ResolveAddress() { return(AddressResolver.GetInstance().ResolveModule(this.ModuleName).Add(this.ModuleOffset)); }