Simpliest method for sniffing network activity - c#

I have used packed inspection program such as WireShark and others and I have observed that most of them relay on the pcap driver.
Recently I stumbled over a source code written in C# witch intercepted traffic in a few lines of code. My questions are:
Is pcap driver or something similar included in .NET ?
Is possible to realize the same sniffing using traditional Windows API ?
If yes what are the drawbacks and why installing pcap is preferred ?
Thank you

Is possible to realize the same sniffing using traditional Windows API ?
Yes you can use the WFP call-out driver
If yes what are the drawbacks and why installing pcap is preferred ?
pcap installs the driver and corresponding user mode dll's , it is easy to use.
Otherwise you have to write ur own filter driver and corresponding user mode code.

Related

PHP (HTML5) based Windows Software

Is it possible to make from a HTML5-APP (PHP,SQLITE,HTML,CSS,JS) a installable Windows Software in c#?
The software must start PHP (5.4), and must just load the document-root in the webbrowser object.
In theory it should work without problems. But what about protecting this code? Is it possible to protect at least the PHP part? Will ioncube or zend-guard work on PHP 5.4's embeded server? And is it possible to hide the shell window, which will open everytime, when i start the PHP Webserver via cmd?
Or do you know an alternate, how i can make a software from a HTML-5 (with PHP) App?
Your choosing the wrong language. PHP, HTML, JS, CSS and SQLLite are separate technologies.
I'd suggest writing the app in another language capable of producing an executable like C / C++ (and one that can plug into to SQLITE fairly easy).
If you want to create a installer out of HTML5-APP (PHP,SQLITE,HTML,CSS,JS) , take a look at bitnami package, it may solve your problem, if you have any explicit reason to use C#, and then you have see its library or namespace which may give you installer capability. However your question is unclear, can be be more clear?
You can embed a Chrome browser in C# using the CefSharp project. You would also need to embed some webserver (php built-in webserver might work, but it's single threaded so it might be an issue).
If it doesn't necessarily need to be C#, then take a look at the PHP Desktop project that is using C++ to embed a Chrome engine, a multithreaded webserver Mongoose and a PHP interpreter. Sources can be protected using many available php encoders, see the KnowledgeBase wiki page on the project site for details.

Windows 8 upload file via FTP [duplicate]

I'm trying to create an FTP Application in Metro and C# but the FTP class in System.Net has been removed and now I can't figure out how to do this. I've looked into the BackgroundUploader but can't understand how I can bring back directory structures etc.
Does anyone have any experience doing this, I know it is achievable since there is an app already available on the Windows Store.
Thanks
I haven't checked it yet, since I just started to look for it. In this article they're sharing an FTP sample in C#.
http://code.msdn.microsoft.com/windowsapps/CSWindowsStoreAppFTPDownloa-88a90bd9
Regards,
Herb
Take a look at http://www.dreamincode.net/forums/topic/35902-create-an-ftp-class-library-in-c%23/. It's a C# implementation of a FTP client using sockets, unless you have advanced requirements this may be sufficient for you.
And if you need more you could Always expand on his example!
Please have a look at this sample below. The difference from the Microsoft sample is the use of sockets:
- Windows 8.1 Sockets: Ftp Client Sample in C#

Write/Read file in my iPhone app Shared File

I wrote an app on my iPhone. It's a more portable and smaller version of my pc software. I activated the File Sharing feature on my app so now I can transfer files through iTunes. But I want my pc software to be able to read or write files to that shared folder on my iPhone without having to do it manually through iTunes.
I have big constraints:
I can't use a Jailbroken iPhone/iPod/iPad
The vast majority of my customers don't have Internet access (It's a farm management software so even cellular are not available in some area)... :(
I heard there is a way using Manzana and MobileDevice.dll (itunesmobiledevice.dll). I don't really know how to use these dll. I tried to use Manzana a little but I can't access my folder since it's not a jailbroken iPhone.. Can someone help me with a little bit of code example?
Or is there other ways to make my iPhone app communicate with my C# application using the USB cable without internet access or Wifi?
mobiledevice.codeplex.com. This project should let you send and retrieve files from the phone
I'd suggest seeing if you can use the iTunes scripting interface. Add the COM reference iTunes 1.1 Type Library to a project and you can control many parts of itunes automatically. I can't find the documentation for it, but you can play around with the library and see if there is something to access the file sharing section.
Here's a decent introduction to using it:
http://www.codeproject.com/Articles/7723/Controlling-iTunes-through-COM

Limiting Bandwidth of your PC using c#

i have check IPv4InterfaceStatistics Class of C# and its seems it display all Information of your Network, from bandwidth download / upload, Packet Sent / Rcvd, and Speed of your LAN,
Upon checking the properties, i have found out that all of the properties are GET only.
Is there a way for us to set / limit the bandwidth of download / upload?
thanks in advance.
PS : I need to create an application that will limit the bandwidth of a PC. Thanks
To do that you will need to create a driver, which is not possible to do in C# (or any other managed language). So at least part of your application will need to be written in C or C++.
Maybe TcpDump
will solve you're issue ,learn how to use it than maybe you can control it from C# as a process ,if Tcpdump can't do that ,that give a try with Wireshark i think Wireshark can be implemented within C#

How can I install a printer using .NET?

I have an .INF for a virtual printer that I need to install from a .NET Application. I have done this before using batch scripts, but I am looking for a snippet of code to do this in the .NET Framework.
There's nothing particular about the printer .INF, so any code that installs a printer from an INF in C# or VB.NET will work.
I believe this is possible via interop to native win32 APIs, but I've found its much, much easier just to use a System.Diagnostics.Process() to call into printui.dll via:
rundll32.exe printui.dll,PrintUIEntry /?
Perhaps you're already using that in the mentioned batch script, but if not the parameters are documented here: PrintUI.DLL User's Guide and Reference
Just be sure to test it against all operation systems you need to support. Some options either do not exist in all Windows releases or have been renamed (although I think they're the more esoteric options - installing an .INF will likely work across the board).
You are going to want to look at the WMI objects available. These give you a finer control of the local machine settings. Take a look at the WMI code creator from Microsoft, I believe this will generate some example code you can leverage to solve your problem.
Administering Printer Settings in C# for Flexible Printing
see this article, it uses an MS Platform SDK DLL called PRNADMIN to manage printers, printer-drivers, printer-ports, ...etc.
I personally use it in a commercial project to install a printer driver and change the printer port to local port to intercept the Postscript. and it works like a Charm.
Alternatively you can use some pre-installed vbscripts that come with windows in C:\Windows\system32\Printing_Admin_Scripts and here is a an articles for them:
http://technet.microsoft.com/en-us/library/cc771846.aspx
This is not the ideal solution, but if nobody else answers, you can create a temp batch file and invoke that through C#/VB.NET.
Someone else will probably know a more natural way to do this.
You will need to wrap the setup APIs using PINVOKE or a native COM object.

Categories

Resources