IP or winsock interception? - c#

We have a terminal emulator (its more then just this, but for the question it best describe what it it...) Sometime ago instead of rewriting it a port proxy was introduced. the proxy listens to 127.0.0.1 loopback and takes the connection and encrypts it using SSL.
What I need to do is get the data from the local machine before it goes in to the proxy so we can check it and stop or change it. I can't change the configuration of the current setup so I need to find a way to get the data before its sent. can this be done using winsock? any other approaches?
thanks

A Layered Service Provider should do it (one is presumbably inside fiddler, so if that works for you, that's going to be quicker

You could possibly try using fiddler to listen in to 127.0.0.1

You should use some Win32 API Hook library.
Maybe EasyHook or Microsoft Detours.

Related

I can't call API from another PC at the same network

I connected two laptops together with a wi-fi modem.
Laptop1 got the IP 192.168.0.20
Laptop2 got the IP 192.168.0.21
I launched an ASP.Net Core web application on Laptop2 on port 44382.
I turned off both laptops' firewalls.
The result of ping 192.168.0.20 from laptop2
The result of ping 192.168.0.21 from laptop1
When I call my API from the laptop2(localhost) there is no problem and I see the result
The problem is when I call API from laptop1(another laptop), after a long time I see this
I can't find what my problem is.
You're most likely using IIS Express, which doesn't automatically bind everything the way you need for remote access. This answer breaks down what you'll need to accomplish that fairly well, but you may just want to look at installing IIS.
Make sure door 44382 is open in the firewall.
Create new rule in/out for port here (advanced configs of firewall)

Load Testing TCP with IP spoofing

I'm trying to come up with a way to Load Test the following architecture:
We have an Application Server that recieves data from multiple servers with data-collecting agents on them.
However, our testing environment only has ONE server with an agent, and we wish to emulate multiple (100) connections from the same server outgoing to the Application Server.
I have a wide-open range of IPs I have already assigned to the NIS card on the agent machine, but I am unable to find a way to make each outgoing connection from the machine to the app server use a different IP and thus open a new connection.
I know that web tests on HTTP protocols can use Virtual Users and IP Spoofing tools easily when facing thi sproblem, but since the agent-server connection uses TCP - I cannot find ANY tool that is capable of fulfilling this function.
I also thought about possibly editing each packet by code and replacing it's header with a different IP each time - but this method seems both too convuluted and impractical as it would delay each request for too long to make the load testing relevant.
Any ideas and solutions are welcome!
thanks in advance :)
You can set the IP adress by using Socket.Bind before connecting to the server.
It's described here: http://msdn.microsoft.com/en-us/library/system.net.sockets.socket.localendpoint(v=vs.100).aspx
You can use winpcap or its .net wrapper pcap.Net (http://pcapdotnet.codeplex.com/) to get complete control over the IP/TCP packets sent.

SSL for dummies

I want to add some security to a client(iPhone) - server(c#) application I'm working on, mainly to encrypt messages sent between client and server.
I know i should use SSL but not really sure what the steps i need to do in both client and server to implement it.
Can someone please give me some guidance?
I don't use HTTP protocol, i use my own textual protocol, but any way with HTTP or my own protocol how do i add ssl support? i know that in c# there is SSLStream instead of regular Stream. And on ios there is some stream settings i need to configure, i just don't know how to do it.
Host the application using SSL in IIS, then use HTTPS as the service point. [edit] Don't forget you'll need a cert.
Take the easy approach, which is allowed to go on the App Store without having to go through all the encryption law stuff. Simply use a HTTP server and a client.
C# runs the HTTP server (maybe use IIS to handle that? Maybe C# has its own software for that) and the iPhone simply uses NSURLRequest.
Easy to implement and safe, since you'll benefit from patches from Apple and Microsoft.
Update for the updated question: I did some quick research and this kept popping up: kCFStreamPropertySSLSettings - maybe it helps you. It's apparently something for NSStream that allows it to create SSL connections, or something. I'm afraid I can't help you more than that.

Is there a difference between connect PPC to WS through ActiveSync and IP cradle?

i build C# program on Windows-Mobile that connect to WebService through cradle
and work with ActiveSync.
the customer want me to change the program that the connection will be through IP cradle.
is it require me any code change ?
how to do it ?
thank's in advance
It shouldn't require any code change. If you can get Internet Explorer on your device to display your web service page (asmx), then your application should be able to connect to the web service as well.
I don't think so, web requests should use connection manager which will automatically use the ip connection that is already there.
It's probably worth noting here that the ActiveSync pass-through is not a full-up network bridge. For example, ICMP packets don't pass through it. For a Web Service call using port 80 HTTP commands, however, you should be fine.

Whats the best way to send an event to all workstations

I hope someone can guide me as I'm stuck... I need to write an emergency broadcast system that notifies workstations of an emergency and pops up a little message at the bottom of the user's screen. This seems simple enough but there are about 4000 workstations over multiple subnets. The system needs to be almost realtime, lightweight and easy to deploy as a windows service.
The problem started when I discovered that the routers do not forward UDP broadcast packets x.x.x.255. Later I made a simple test hook in VB6 to catch net send messages but even those didn't pass the routers. I also wrote a simple packet sniffer to filter packets only to find that the network packets never reached the intended destination.
Then I took a look and explored using MSMQ over HTTP, but this required IIS to be installed on the target workstation. Since there are so many workstations it would be a major security concern.
Right now I've finished a web service with asynchronous callback that sends an event to subscribers. It works perfectly on a small scale but once there are more than 15 subscribers performance degrades considerably. Polling a server isn't really an option because of the load it will generate on the server (plus I've tried it too)
I need your help to guide me as to what technology to use. has anyone used the comet way with so many clients or should I look at WCF?
I'm using Visual C# 2005. Please help me out of this predicament.
Thanks
Consider using WCF callbacks mechanism and events. There is good introduction by Juval Lowy.
Another pattern is to implement blocking web-service calls. This is how GMail chat works, for example. However, you will have to deal with sessions and timeouts here. It works when clients are behind NATs and Firewalls and not reachable directly. But it may be too complicated for simple alert within intranet.
This is exactly what Multicast was designed for.
A normal network broadcast (by definition) stays on the local subnet, and will not be forwarded through routers.
Multicast transmissions on the other hand can have various scopes, ranging from subnet local, through site local, even to global. All you need is for the various routers connecting your subnets together to be multicast aware.
This problem i think is best solved with socket.
Open a connection to the server, and keep it open.
Could you have a slave server in each subnet that was responsible for distributing the messages to all the clients in the subnet?
Then you could have just the slaves attached to the central server where the messages are initiated.
I think some of you are vastly overthinking this. There is already a service built into every version of Windows that provides this exact functionality! It is called the Messenger service. All you have to do is ensure that this service is enabled and running on all clients.
(Although you didn't specify in the question, I'm assuming from your choices of technology that the client population of this network is all Windows).
You can send messages using this facility from the command line using something like this:
NET SEND computername "This is a test message"
The NET SEND command also has options to send by Windows domain, or to specific users by name regardless of where they are logged in, or to every system that is connected to a particular Windows server. Those options should let you easily avoid the subnet issue, particularly if you use domain-based security on your network. (You may need the "Alerter" service enabled on certain servers if you are sending messages through the server and not directly to the clients).
The programmatic version of this is an API called NetMessageBufferSend() which is pretty straightforward. A quick scan of P/Invoke.net finds a page for this API that supplies not only the definitions you need to call out to the API, but also a C# sample program!
You shouldn't need to write any client-side code at all. Probably the most involved thing will be figuring out the best set of calls to this API that will get complete coverage of the network in your configuration.
ETA: I just noticed that the Messenger service and this API are completely gone in Windows Vista. Very odd of Microsoft to completely remove functionality like this. It appears that this vendor has a compatible replacement for Vista.

Categories