I've been searching the internet for C# tutorials on how to implement a windows service that sits on a windows machine that logs all URLs visited from any browser on that machine. In the most simple sense i literally want to Log the URL and DateTime to a text file.
All the posts I've found are around or over 10 years old so i'm not sure if they are still viable and many include using 3rd party libraries such as winPcap,Pcap, FiddlerCore which seem over kill for what i'm after.
In the simplest sense, I don't want to monitor all my network traffic, i don't want to intercept and manipulate packets or install some underlying proxy server and i don't care about request times and packet sizes.
Is the above possible without have to use a third party library like winPcap? Is there some kind event listener available the can be subscribed too?
I looked at querying the browsers local database to retrieve the users history but this doesn't store incognito data so this is no longer viable and i don't really want to go down this route and have different implementations for different browsers.
Any help, direction or examples would be greatly appreciated.
Related
I would like to know if there is a technique or solution for the follow problem.
I have a software application that is currently running inside of a Microsoft RDP session. I have some help resources built into it in which some of them open up on a webbrowser. Some of them are YouTube videos. The problem is taht through organisational policies, they cannot open YouTube clips within the RDP which connects to a interstate server.
What I would like to do is instead open up a webpage outside of that RDP connection on the local host computer instead, which does not have any restrictions like opening up YouTube webpage to play video clips.
Can you please suggest a technique, utility or solution to this problem?
Thanks,
Colin.
The nicest way to do this would probably be to create a dynamic virtual channel plugin for RDP: https://msdn.microsoft.com/en-us/library/bb540859(v=vs.85).aspx
You would have a server-side component registered to handle the protocols (http/https, I assume) you want to redirect back to the client, possibly with some filtering logic if you still want a few to run server-side (such as intranet sites); then a client-side mstsc plugin whose only job is to call ShellExecute on the URLs you pass back.
Piggybacking on clipboard redirection might be less code, but it obviously has side-effects - e.g it obliterates anything else the user might have had on the clipboard.
I have three applications running in three separate app pools. One of the applications is an administrative app that few people have privileged access to. One of the function the administrative app allows is creating downtime notices. So when a user goes into the administrative app and creates a downtime notice the other two apps are supposed to pick up on there being a new notice and display it on the login page.
The problem is that these notices are cached and being that each app is in a separate app pool the administrative app doesn't have any way to clear the downtime notices cache in the other two applications.
I'm trying to figure out a way around this. The only thing I can think of is to insert a record in the DB that denotes the cache needs to be cleared and the other two apps will check the DB when loading the login page. Does anyone have another approach that might work a little cleaner?
*Side note, this is more widespread than just the downtime notices, but I just used this as an example.
EDIT
Restarting the app pools is not feasible as it will most likely kill background threads.
If I understand correctly, you're basically trying to send a message from the administrative app to other apps. Maybe you should consider creating WCF service on these apps that could be called from the administrative application. That is a standard way to communicate between different apps if you don't want to use e.g. shared medium such a database and it doesn't force you to use polling model.
Another way to look at this is that this is basically an inter-application messaging problem, which has a number of libraries already out there that could help you solve it. RabbitMQ comes to mind for this. It has a C# client all ready to go. MSMQ is another potential technology, and one that already comes with Windows - you just need to install it.
If it's database information you're caching, you might try your luck at setting up and SqlCacheDependency.
Otherwise, I would recommend not using the ASP.NET cache, and either find a 3rd party solution that uses a distributed caching scheme, that way all applications are using one cache, instead of 3 separate ones.
I'm not saying this is the best answer or even the right answer, its just what I did.
I have a series of ecommerce websites on separate servers and data centers that rely on pulling catalog data from a central backoffice website location and then caches them locally. In my first iteration of this I simply used GET requests that the central location could ping the corresponding consuming website to initiate its own cache refresh routine. I used SSL on each of the eCommerce servers as I already had that setup and could then have the backoffice web app send credentials via SSL GET to initiate the refresh securely.
At a later stage, we found it more efficient to use sockets instead on the backoffice where each consuming website would be a client and listen for changes in the data. The backoffice website could then communicate to its corresponding website when a particular account change and then communicate this very specifically. This approach is much more granular and we could update in small bits as needed as opposed to a large chunked update but this was definitely more complicated than our first try.
Overview
C# File - Users PC
PHP Server - Hosts Webpages for application
Server and Users PC on local network
I have a c# file that reads weight from a USB scale. How would I trigger this file to run so it feeds into my program. The problem is I am using PHP to host our webpage/application so its not running client side and the scale is not hooked up to the server but to the clients PC.
The C# script would have to be on the clients in order to read the scale so how would I trigger this to happen?
Is this even possible and if not what would be a better way?
Important Edit
I was able to run the Scale Script (C#) when I wanted by having PHP and C# use TCP sockets.
The C# would listen for PHP to send something and when it did it would read the scale and send this information back to PHP becuase PHP was listening for a response. Mixed in with a little Ajax and it updates in the web browser.
Gave Chris Credit because he was the most helpful with answering my questions
It sounds like what you really want is for the client application to submit the data to the website itself, and the most suitable approach is probably to expose a web service from your server.
This service should accept weight data, along with some sort of customer key or whatever, to correlate the records correctly on the server side. I've never created a web service in PHP personally, so I can't give any advice on the implementation of that, but it is fairly trivial to hook a C# client app up to a web service once you've exposed its metadata (assuming you use SOAP).
you can't start C# application from a web page in a way that'll work in every browser every time. BUT, you can have some workarounds:
Use ActiveX component that read the data in the client and upload it to the server. the biggest cons is that it'll only work in Internet Explorer
use Silverlight client application that runs on elevated mode (v4) and upload the data to your server.
refer your clients to download application (the C# application you wrote about) and run it - this application will upload the data to your server.
hope this helps.
C# isn't a scripting language, it's a language that compiles into executable binaries or libraries. You won't be able to execute C# code on the client's computer via a website because C# code needs to be compiled before it can run.
Presumably what you really want is for your compiled C# binary to be executed on the client's machine via your website. You won't be able to easily do that. There are a lot of security measures in place to prevent browsers from running programs on your computer. There may be ways to hack around these security measures by using plugins (such as ActiveX), but it's not something that will be a one-liner.
Edit: I think you need to step back and think about what you're trying to do in a broad sense. You're trying to create a website that can read information from a user's USB port. This is the type of thing that browsers are designed to prevent, and for good reason. I wouldn't want random websites to be able to access peripheral hardware without my explicit permission. If you want this website to function the way you're expecting, you're going to have to seriously think about the security implications. You'll need some kind of client-side code (ActiveX, Silverlight, ...), and the user will need to explicitly give permission to for this all to happen. It won't be easy, and it won't be automatic. And I'm damn glad that's true.
I have a school project with a friend of mine and we are developing a software product (in C#) that reads a value from a hardware sensor through serial com (from arduino). Depending on that value we want to be able to blacklist certain ips and domains and re-route them to a htmlfile that informs the user that that webpage has been blocked.
What methods are there? The only thing we come to think about so far is just use simple filehandling and edit the .hosts file, but thats not flexiable at all really. Is there maybe an api for the windows firewall or something like that can be used?
Thanks in advance
Controlling the windows filewall can easily be done through COM: http://www.shafqatahmed.com/2008/01/controlling-win.html
However that isnt going to get you to redirect to a certain page.
If you want to redirect to a page you would have to intercept all traffic. I assume HTTP. So you can either put an application that listens on port 80 and redirects, or use sockets.
More information sniffing packets can be found here: http://www.techpowerup.com/forums/showthread.php?t=61792
basically, I am needing to execute a program on the viewers computer through a website. This program must be capable of talking to device drivers however, which makes it an unlikely candidate for activex. The website will only be used by clients(as in, it's not a public site) so having to change security settings isn't too big of a deal.
Also, we could possibly have them install an application on their computer, and then when they click a button on the website this activex control just executes the application they already installed to avoid device driver problems..
Does anyone have any ideas on how to do this well? I have a feeling activex won't just let you arbitrarily execute local applications. Also, it is preferred to be possible to do without certificates and signing(though it will eventually be over https)
(it's only tagged C# because that's the programming language to be used on both the client and server)
If you only need to tell the application to simply launch or launch with certain data, you can look into registering a protocol handler and create links, that the user can click, similar to myapp://the/data/you/need/to/send.
It sounds like you will have control over the client and server sides, so why not use WCF and set up the client application to connect to the server via a duplexed communication. On the server side keep a list of the clients that have connected to it and then when you need to trigger the client side code it will iterate over the list of clients and send the message to execute the code. And when the client disconnects it will be unregistered from the server.
See this link for more information on the duplex services.
Also, we could possibly have them install an application on their computer, and then when they click a button on the website this activex control just executes the application they already installed to avoid device driver problems..
Ding ding. That's pretty much what you'll have to do.