I'd like to programmatically be able to block outgoing packets to some IPs. Nevermind the application, I would like to be able to do it.
I have Windows 7 x64 Professional so it comes with WindowsFirewall with Advanced Security which has an outbound filter capability.
Currently I'm manually adding rules to block an IP, but there has got to be a better way.
I read this: Any way to turn the "internet off" in windows using c#? and http://msdn.microsoft.com/en-us/library/bb945065.aspx so I know it's possible to write such applications.
I'm a java programmer, and I couldn't find an jni to interface with firewall.dll. I don't know anything about C# to write one myself.
I'm asking if there a - there's a tool out there that can do this, please let me know about it. I've Googled and Googled, but alas - nothing. If there isn't please get me started on how to write it myself.
In case you're feeling generous, you could write one for me s.t. you could block outbound traffic to an IP and unblock it.
Thank you all very much.
The most straightforward way would be just to run netsh, here's an article on how to do it
A modern alternative to netsh is powershell. The commands Enable-NetFirewallRule and Disable-NetFirewallRule allow you to turn rules on/off from a powershell script. The command Set-NetFirewallRule allows you to edit an existing firewall rule, for if you want to change the ip address a rule is affecting. You could even add new rules using New-NetFirewallRule as well if needed.
Related
I really don't know how to look for what I am trying to achieve. I will add two images to show you in a better way what I am doing here.
As you can see I have added a blocking rule in firewall which will block a range of addresses(first rule on the second image) of a specific application.
Is there a way to do something similar on windows phone?
I am not looking for some code or anything. Just for some guidance. Where should I look? What should I look for? Windows phone don't have firewall and I don't want to use any external firewall app's if there is one...
There is nothing like a firewall for Windows Phone. You don't have such a deep access to the network layer. Compared to desktop PC operating systems users and developers are much more restricted in the things they are allowed to do. That leads to less vulnerable systems.
The good side of a restricted system is that it's much harder (or almost implossible) to create a virus, trojaner etc. for it.
On the other hand you are not able to control the system in its depth since there is no API an anti virus software or firewall would need to consume.
In short: It's not possible to block IP addresses for specific applications.
You can't do it with the public API (no such API is available), however you still able to achieve your goal on the interop unlocked handset.
Please refer to this forum about unlocking your phone, and this thread about blocking some sites (i.e. it's an old trick with the editing of \windows\system32\drivers\etc\hosts file).
I'm pretty sure, you can also add a real firewall rule ('cause firewall service is up and running on the WP8.1 & up OS'es) to the registry but this require more investigation.
If I need to post this elsewhere let me know.
We have some old software thats being re-written, that uses a printerdriver to a propriatery printer.
I need to rewrite the software bypassing the print driver and go directly to the printer. I do have the specs for the printer communication, thats fine, but what Id like to do is monitor the communications to the printer to view its contents (from the existing software that Im re-writing) and compare it to the specs, and what I will be sending it for validation.
I have to make sure Im not missing anything.
Any ideas on how I might be able to accomplish this?
Thanks
To capture the traffic you have to basic options.
1. Use software
If you are using ethernet, you can use a program like WireShark or USBTrace to capture the packets that are being sent out. There are similar programs for USB.
2. Use hardware
Another option would be to use an external logic analyzer. It's basically a box that sits in-between the computer and the printer that captures all the data, then uses software to decode it. There are some inexpensive options available (USBEE, Bus Pirate, and Total Phase Beagle.
I own a USBEE and I've used it to debug a simple USB device. It works well enough for that. The software is a little clunky though.
I was wondering if anyone knows how (or even if it is possible) to monitor and trigger an action when a computer running windows (7-8) starts reciving a file transfer from over the network onto one of its drives.
Bonus points if I can find out how big the file is that the other guy is placing on my machine and how much is done etc...
I want to know if there is any API in windows, or snippit of code, or some other API that provides any of this functionality.
I still want to be able to recive files, I just want to manage them better. I am on a network with over 90 computers and this software that I wish to write would be running on most of them.
Of course you can (after all it's what an Antivirus program does) but it's NOT easy and probably you'll see it's more comfortable to do in C than in C#. I'm sure there's a .NET porting of WinPCap anyway you can always P/Invoke.
Start reading about Network Monitor SDK on MSDN. It's not an easy task, you have to capture a specific set of frames, you may use a Network Packet Monitor to inspect the content and the type of the packets you have to capture and parse.
I'm not sure but you may take a look to QoS API (start reading this article), it should provide something you can use.
How to prevent terminal (Windows-CE) from shut-down after 5 minutes
the terminal is Motorola MC3190 (Windows-CE) and if i dont touch the screen for 5 minutes
the terminal shut-down. how to prevent this ?
i need the solution in C# code.
thanks in advance
I initially voted to close, but have been thinking more about this, and I think the question you've asked may have been missing an important piece of information.
I think what you need to look at are the Windows CE Power Management functions, specifically SetPowerRequirement. This allows you to indicate that your application is using some device within the system. If not, it's unclear why your application, absent some device interactions, wants to prevent power management from doing its job.
No code needed for this. Go to Start->Settings->Power and uncheck the box next to "Turn off screen if device not used for".
If you tried to do this programmatically, you would be draining the battery power faster than the user intends. That will probably irritate your user.
If your heart is set on doing this, then you can modify the value in [HKLM]\System\CurrentControlSet\Control\Power\Timeouts
I also gave this answer on the MSDN forums
-PaulH
I dont know Windows-CE and i Dont know C#, but I found you an answer on google. Here you go. And now I want to try programing something for some station. Would be great home control device.
Is your Motorola MC3190 configured to Turn Off if it is running on Battery Power? Will it ever turn off if on External Power?
NOTE: I had to post as answer to show image, but this isn't really an answer.
EDIT: If this is what you are interested in, consider reading the device's SystemState property. There are many members to SystemState, and one of them just may be what you are after.
There is no easy technique for what you are wanting to do, because the devices are designed to power down when not in use. If the battery goes dead, the devices have to be completely reset. Make sure this is what you want to do, because there is a reason it is hard to get around.
You'll likely have to register for a BatteryStrength changed event (like >> THIS <<), then try to trick it somehow ...maybe by popping up a dialog box or simulating a key press.
You'll most likely need to P/Invoke some of the lower level coredll.dll functionality (examples >> HERE <<) to get what you want, as this stuff doesn't come wrapped up in the standard WinMobile SDK.
EDIT 2: Here's a Great example that someone wrote to read and control as much of the Power State as possible: techlicity blog I liked it so much I've copied the code to a class in my Mobile Project!
I have an .exe that runs on my computer. How can I connect to it from c#?
For example notepad.exe is running. I would like to write in notepad from windows form app or console app form. How can I do that?
Two suggestions:
either start the process using Process.Start()
http://msdn.microsoft.com/en-us/library/system.diagnostics.process.start.aspx
or use SendKeys from Windows Script Host
http://msdn.microsoft.com/en-us/library/8c6yea83(VS.85).aspx
It depends on exactly what you want to do. Using SendKeys is the simplest solution but it's crude and limited in functionality. You can do more and better with SendMessage, but this will be harder to code.
Have a look at this tutorial. As far as I can tell, it does exactly what you are looking for. I realize it's in German, so just look at the source code.
Reading from another process in windows is problematic to say the least. We did some work on this a while ago and it involved hooking into the low-level Win32 API using assembly language. Essentially, it's really not pleasant and if you can avoid doing this you'll have a lot more hair on your head.
Using SendMessage would work if the application you are sending to understands the message you are trying to send to it. I suspect that you start to get into security problems with this on later Windows versions (Vista + Win7) and would have to run your application with elevated privileges.
Why do you want to do this?