I have 1 computer with 1 network card installed. The network card has 10 IP addresses assigned to it. I have a windows desktop application running there. The application is basically a webbrowser making a call to 1 specific website.
What I want to achieve is for the webbrowser to change its source IP address (round-robin through the IP addresses available on the network card) every time I visit the website, so that the website sees 10 different external IP addresses with each visit.
To add to this, id like to have a scenario were two web browsers run concurrently through different ip addresses
I'm looking to do the application in C#. How do I do it? Or perhaps can anybody point me in the right direction?
There's a lot to this question. If you want the other website to see your address then you need to ensure there is no proxy because proxies by their nature hide your address. Ensure all 10 addresses are public. NAT isn't going to expose 10 different addresses either.
Assuming you are using Berkely sockets, you can loop through the logic to create the sockets and flip out the endpoints in whatever cycle you desire.
while(true)
{
EndPoint ourEP = new IPEndPoint(MyServerIPOne, serverSocketPort);
socket.Bind(MyServerIPOne);
socket.SendTo...etc
}
Example on MSDN displaying how to connect via http.
Related
I have a security course project. It asks to enter a given website and download its information 20 times(site has 20 subpages), then parse etc. I am using c#'s downloadstring to download and parse the page. However, after the fifth time, website finds out that I am doing those downloads as a robot(programmatically).
What I create as a program is successful until the sixth request.
I download the content and parse the desired information. When I reach the sixth subpage, my pc is blocked.
It is not related with time interval. Because, I used random generated timeouts between 6-12 seconds. However, that does not help. It is definitely related with entry counter of the webpage. It is like " not give permission after 5 request in 30 minutes. If it passes the limit then block it for a (or more) day". Since, I have been blocked for many times. I am using my phone's Hotspot.
I find a solution while I am searching on the internet. People are using IP changing methods via netsh etc. However, I think my IP is static (WiFi) and I could not figure out how to change it programmatically in C# Windows Forms App.
Because of that, I would like to hear your thoughts.
Your ISP most likely gives you a single Dynamic IP Address, which is the IP Address of your computer's access point to the Internet (i.e. the WAN). If so, they control the IP and not you. Even if you have a home network with multiple computers all on different local IP Addresses (LAN), you still aren't changing your WAN IP address which is the address that is effectively blocked.
Also, I am not going to judge, but I would say that if this is for an actual course project, then ethically speaking your instructor most likely would not want you to hammer an innocent website any more than the website's owner wishes for you to hammer it, hence the blocking. My suggestion would be to set your sites on another website that does not have the blocking to complete your coursework. Maybe you can do this against Google.com?
If you really need to make a request through a different IP address you could link your application up to several different proxies and switch between them at intervals.
Also, you mention that your IP is static, but there is a difference between your local IP and your external IP address. The IP address given to your WiFi connection is local, but the external IP address which is the one that would be seen by Internet sites is not the same.
If you have a dynamic external IP address one option might be able to programmatically connect to your router and restart it. This is one way to trigger an IP address update if you actually have access to it.
Overall, what you are doing is difficult to achieve for what sounds to be a simple assignment.
Here's a rather involved and eccentric solution that would, however, get around the problem nicely. Create 4 Amazon EC2 t2.micro instances (Windows) and issue 5 requests each from the EC2 instances. You can store the result to S3 buckets. It would take you a lot of work to get this working, but you'd come out the other end also having your first experience of working in the cloud. And each of those instances would have a different IP.
Also if you spin the same instance up and down a few times, it's unlikely to have the same ip in any case, so you could easily get away with one instance.
In a more serious vein: experiment with changing your user agent string and adding a much more hefty amount of time (minutes, hours) between requests. Also, turn your hotspot on and off between every five request, which will likely give you a new IP each time.
There's a similar question ( Can I temporarily override DNS resolution within a .NET application? ) but I just can't figure it out with the meager response there.
Background info
I have a server set up in my home network, an old computer. Our router has the right ports forwarded, the server runs server software for things like http, svn, games, etc. I've got a domain name registered that always points to our external IP address. For all intents and purposes, I've got a typical webserver set up. My friends can game on my server by connecting via the domain name, I can push and pull svn projects, etc.
The only problem is that I also need to use my server when I'm connected to my home network (the same network as the server). Using the domain name results in Windows resolving it to our own IP address, and my router is too retarded to realize it just needs to forward it back into our network to the server as per the usual. I've done some looking around, configuring, telnetting and DNS overriding, but I have it on good authority that our ISP apparently crippled the DNS override feature of their routers to prevent this exact scenario. Apparently they don't like internal loopbacks.
I now basically have to keep 2 configs for each of my server's services: one config that specifies the domain name for when I'm abroad, and a second that specifies the server's internal IP for when I'm at home. It's frustrating because it just isn't always possible.
I want to instantiate a global DNS resolution request/response listener that will do the following: if the requested domain name matches a given string, override the IP in the response with one of my choice.
I've looked things up like easyhook, dllimport, msdn pages, etc, but I still can't figure out where to actually start, which classes I need to get access to, and so on. I basically have no pre-existing code for this particular problem.
I have Visual Studio, years of relatively simple programming experience and a good understanding of unfamiliar code and everything else, just no idea how to start or what to look for.
Many thanks for anything that can get me going.
Couple of pointers, DNS is as you mentioned some server somewhere that knows how to resolve a Domain name to an IP ADDRESS. There are two types of responses 1) Definitive for the domain and 2) Not Definitive for the Domain. Obviously any Definitive response will win.
DNS does not run at TCP/IP layer it runs one layer below using UDP (port 53). As a result DNS is tied into the TCP/IP stack whereby the stack first looks locally to a local host table and sees is the name is there, if it cannot find it the stack will send out the DNS request prior to the session start or SYN packet flying. In order for this to happen, the DNS servers must resolve the address.
I do not fully understand your issue because most Windows servers only have 1 IP Address and one associated Domain name. Unless of course they are using DHCP which just means the server uses multiple address on boot up and DNS server receive updates to what those new address are.
Public vs. Private IP addresses are the responsibility of a router. The router is configured to do NAT (Network Address Translation). This allows a private server to have unroutable addresses like 10.10.1.100 etc. But the router will answer ARPs for the public address making the public network think the router is the public address. So one of your solutions could be to convert your server to a private address and use a "real" router that can perform NAT. Port forwarding is not really routing rather it's a way to "trick" packets destined for one port number to be forwarded to another port dedicated for that application.
My suggestion is to either follow the suggestions above or add the Domain names you want to the local Host table on the server. This will get you what you want. A better solution is to configure your own server to be a DNS server definitive for your domain, that way you get to control everything.
I ended up solving this with (as a few have suggested) the hosts file after all.
I first used ManagedWifi to set a network connection monitor. It detects changes to my connection status and reports the network name.
Then I wrote a console app that stays open (using Hidden Start allows me to hide the window) and safely modifies the hosts file, then flushes the DNS cache. This seems to work in pretty much realtime. :)
I have created a WCF service called MyAppService.
Now, I don't want to host that service on any servers. I would like to host it in my Computer. I know how to host a WCF service in Console/Windows App, as a Windows Service and in IIS.
But I have a problem to host this service in my computer. I mean in short that I want my Computer to Work as server and other computers should be able to consume myAppService from my computer via internet.
So, I would like to ask what is the best hosting option for me and how should I host my service such that other computers can consume myAppService using Internet. 1 more question : If the above problem is solved, then can I use netTcpBinding or I have to use some HttpBinding?
I'm still not 100% certain that I am answering the right question, but I'll give it a shot.
I believe what you are asking is: given that you are hosting a service in IIS on your personal computer, how do you allow others access to it? If my interpretation is incorrect, then please accept my apology in advance.
Note: I'm assuming IPv4 in this answer. IPv6 may be an option, but this answer would not apply.
There are two steps in the solution, and there are a few obstacles that you may or may not be able to overcome.
Get the client's web traffic to your public IP address.
Route incoming traffic to your computer.
Step 1
You can determine your public IP address in many ways, one of which is to ask Google: https://www.google.com/#q=what+is+my+ip
Obstacles are as follows:
Your IP address may change from time to time. The solution is to use a dynamic DNS service such as http://dyn.com/dns/, http://www.thatip.com/, or any of several alternatives that can be found online. These services will provide a URL that routes to your public IP, and they will provide a way to keep your public IP up-to-date so that name resoslution generally works. Keep in mind that DNS does not reliably change in realtime, however, so you should expect some downtime if and when your IP address changes.
Your ISP may block incoming traffic. Whether and how you can get around this is specific to your IP. Specifically, it is common for ISPs to block incoming port 20, 22, 23, 25, 80, and 443. You may be able to work around port blocking by choosing a non-standard port for your service. (This may not affect your WCF and IIS configuration as detailed in step 2.)
Particularly if you are using any kind of shared apartment connection, you may find that you do not have your own public IP address. If that is the case, then there is nothing you can do. If your router's WAN address (or computer's IP addres, if you're not using a router) is something in the 192.168.* or 10.* ranges, then it's time to look into server options.
Step 2
Once a client request has routed through the public internet to your public IP address, it needs to be routed to your computer.
The easiest, though least common these days, scenario is if your computer is directly connected to your cable/DSL modem. In this case, traffic that routes to your public IP is handled by your computer. This is the scenario where your WCF and IIS configuration needs to be listening on the actual port used by the client. For example, if your ISP is blocking port 80, then maybe you could configure your service to listen on port 34323, and that is the port that the client needs to request in the service call.
The most common scenario is that you have a router attached to your cable/DSL modem. In this case, you need to get into the administration control panel on your router and forward a port. For example, if your computer is configured to listen to port 80 for incoming service requests, then you can forward a port (for example, 34323) to port 80 on your local machine. How to forward the port differs by router. You should be able to find it by poking around or by doing an internet search.
The obstacle here is that your local IP address may change. You can overcome this by setting it to a static address outside of your router's DHCP assignment range or by setting up a DHCP reservation within your router. Either way will work. I suggest searching the internet for setting up a static IP or poking around in your router administration settings for DHCP reservations.
If you get all of your settings correct, and if there are no obstacles outside of your control, then a client on the internet can access your WCF service.
Edit:
I missed talking about local Windows firewall concerns. I could go into that, but allow me to link to this how-to guide that covers it pretty well. (Remember, a WCF service is conceptually similar to a website from a hosting standpoint, so much of this applies.) http://www.pcstats.com/articleview.cfm?articleID=1774
Scenario:
Developing an application targeting a Win CE 5.0 powered device. The application is being developed using .NET Compact Framework 3.5 (C#).
Question:
Just like when you connect a computer to a LAN and you can see all the other active computers and their respective IP Address, we would like to implement something similar in our application where only the IP Addresses will be listed.
Considering that it is an existent Windows feature, I guessed it would be possible to easily implement in out application. What's the best approach considering my scenario?
First you will have to define what you mean by active IP Addresses.
A host may block ICMP_ECHO (commonly reffered to as ping) but allow TCP, UDP etc. connections on specific ports.
Depending on what type of service you require of your hosts you could
send ICMP_ECHO requests to all the IP Addresses in your subnet.
- To calculate the IP range of your subnet you may want to use the address space bitmask
- For ICMP request you could also use a broadcast address. But most hosts do not respond to broadcast requests in order to prevend flooding.
attempt to open connections on specific TCP ports (again on the whole ip range)
ask your router to provide you with a list of hosts using it via dns query
send arp requests to an ethernet broad cast address
Essentially there are too many ways to get a list of hosts in a specific ip range or subnet to give a general answer.
First you need to define what you need that host list for.
you can write a function that ping on about 20 or more IPAdresses going from 192.168.1.1 to 192.168.1.20 and call it in different threads with defferent ofssets exmple :
one going from 192.168.1.1
other one going from 192.168.1.21
.......
call them on defferent threads but dont call them a lot it would slow down the CPU and maybe freez the computer
How to build Opera unite like functionality using .NET?
When we run opera browser and enable the opera unite then it shares our desktop on web and we can access it over internet without having a static IP, how does this works?
You need to map your dynamic IP to some static DNS name. One easy to use solution would be a DynDNS service. For these you get a small client program (or good routers already have a dyn dns client already implemented), that simply maps your current ip address to a specfic dns name.
After getting this done it depends on how variable you like it:
- Do you have one master that should be able to look on various client PCs for help?
- Do you like to connect two clients which are both have dynamic ips?
In the first case your master is the one how always ensure to map his current ip address to the dns name. On the router maybe some port forwarding is needed and your clients get a vnc client with reverse mode enabled. This allows everyone to built up a connection to your master and sharing the desktop without any changes on the client site. Only on the master site has something to be done (dynDns and port forwarding).
In the second case it is a little bit more complicated. Now you got two dynamic IPs that like to connect to each other. This is normally be done through some kind of mediator. Means both machine connect to some master (reachable through some DNS name). Now both machines have a bi-directional connection to the master and the master will simply take the data from the first client and forwards it to the second and vice versa. To take all the burden from the master it would be possible that the master in a first step sends the ip address of client A to B and vice versa. Then in a first step both trying to connect to each other directly. This method is known as UDP hole punching and does not always work, which then leads to a fallback to use the master instead.
Two examples that are using the second approach are Skype and join.me.
All these techniques don't have to do anything with .Net. It is pure knowledge about ethernet, TCP/IP, internet, etc. And due to the fact that you have to do a lot of work in this low-level area i would think that C# is not the ideal framework to accomplish this task. Maybe to put the GUI as last step over it all, but for the real work behind the scenes you need some decent network know-how which is mostly independent from the programming language you are using.
You should run your own DNS server. And whenever an user opens the browser and logs in, you should send the current IP address of the user to your server and update in your local DNS. Since you will have only a subdomain (desktop.operaunitecom), whenever someone hit your url it first goes to operaunite DNS server from where it will fetch your IP address. When the user's session closes you should remove the DNS entry. This could be a possible solution.