1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

can i ban a whole city from visiting my website?

Discussion in 'BlackHat Lounge' started by IAMAZEME, Apr 23, 2013.

  1. IAMAZEME

    IAMAZEME Jr. VIP Jr. VIP Premium Member

    Joined:
    Oct 1, 2008
    Messages:
    661
    Likes Received:
    354
    I want to run a particular campaign but do not want a particular city to access my page. How would i go about accomplishing that
     
  2. imageek

    imageek Newbie

    Joined:
    Apr 14, 2013
    Messages:
    15
    Likes Received:
    4
    Occupation:
    Self Employed Software Developer and Marketer
    Location:
    United Kingdom
    You can use Geo Targeting. Check out Max Mind they have a free database. They also have more accurate paid databases, although the free one works fine the majority of the time.

    Setting it up is pretty simple. They have examples on the site, and there are plenty of tutorials online about using the Max Mind databases.
     
  3. RMX

    RMX Power Member

    Joined:
    Nov 16, 2009
    Messages:
    726
    Likes Received:
    389
    Occupation:
    Network Security Admin
    Location:
    London, UK
    Home Page:
    There are no IP ranges for a particular city defined anywhere, so no easy way about it. If you know the providers operating in that city, you can block their ranges, but that would include their clients from other cities as well.

    Method described by the poster above may work, but even then it will not be 100% accurate.
     
  4. DarkPixel

    DarkPixel Jr. VIP Jr. VIP Premium Member

    Joined:
    Oct 4, 2011
    Messages:
    1,328
    Likes Received:
    1,239
    Location:
    ↓↓↓↓
    Home Page:
    Maxmind is the tool you need. I don't have the time to do it now but with simple PHP, you can redirect visitors from your selected city, to another site, thus block them.
     
  5. innozemec

    innozemec Jr. VIP Jr. VIP

    Joined:
    Aug 19, 2011
    Messages:
    5,289
    Likes Received:
    1,799
    Location:
    www.Indexification.com
    Home Page:
    Maxmind exactly will do the work.

    Ofcourse it can't be 100% accurate as RMX explained already, but definitely will do the work you need :)
     
  6. imageek

    imageek Newbie

    Joined:
    Apr 14, 2013
    Messages:
    15
    Likes Received:
    4
    Occupation:
    Self Employed Software Developer and Marketer
    Location:
    United Kingdom
    If you do need help setting it up I'd be more than happy to help. I won't charge you as this is a relatively simple task. Just PM me with some contact info as I can't respond to PM's atm.
     
  7. crazyflx

    crazyflx Elite Member

    Joined:
    Nov 9, 2009
    Messages:
    1,674
    Likes Received:
    4,825
    Location:
    http://CRAZYFLX.COM
    Home Page:
    You're going to need to setup a geotargeting script, as everyone else above has stated. Here is a tutorial I wrote here on BHW on how to do that (I wrote it almost two years ago, but the information is still correct):

    http://www.blackhatworld.com/blackh...-how-set-up-your-own-geotargeting-script.html

    Then you can just use some simple logic like:

    Code:
    $VisitorCity = "the city the script determined they live in";
    $BlockCity = "the city of people you want to block";
    
    if ($VisitorCity == $BlockCity ) {
    //send blocked visitor to a different website or page
    header('Location: http://BlockedVisitorPage.com/');
    } else {
    //allow visitor to see regular content, as they are not blocked because they aren't in the city you want to block
    header('Location: http://RegularContent.com');
    }
     
    • Thanks Thanks x 2
  8. lancis

    lancis Elite Member

    Joined:
    Jul 31, 2010
    Messages:
    1,632
    Likes Received:
    2,384
    Occupation:
    Entrepreneur
    Location:
    Milky Way
    Home Page:
    Its next to impossible, even with GeoIP. For example, when I use the cell phone my IP is identified as being from another city.
     
  9. IAMAZEME

    IAMAZEME Jr. VIP Jr. VIP Premium Member

    Joined:
    Oct 1, 2008
    Messages:
    661
    Likes Received:
    354
    what if i wanted to block all roadrunner ip ranges from that city? Could this be done more effectively?


     
  10. natsirtdm

    natsirtdm Junior Member

    Joined:
    Jun 5, 2012
    Messages:
    121
    Likes Received:
    44
    check out wordpress traffic tools, has the maxmind implemented and re-directions are really simple.
     
  11. IAMAZEME

    IAMAZEME Jr. VIP Jr. VIP Premium Member

    Joined:
    Oct 1, 2008
    Messages:
    661
    Likes Received:
    354
    what if the site is not word press and what if i wanted to block all roadrunner ip ranges from that city? Could this be done more effectively?


     
  12. crazyflx

    crazyflx Elite Member

    Joined:
    Nov 9, 2009
    Messages:
    1,674
    Likes Received:
    4,825
    Location:
    http://CRAZYFLX.COM
    Home Page:
    Assuming RoadRunner is an ISP, you could determine if they're using a roadrunner IP address using something like what is posted on this StackOverflow question:

    Code:
    http://stackoverflow.com/questions/855967/how-do-i-retrieve-the-visitors-isp-through-php
    Or, depending on the number of queries you need, you can implement this using MaxMinds GeoIP Web Services ($20 for 200,000 requests) and it returns the information listed on this page:
    Code:
    http://dev.maxmind.com/geoip/web-services
    Once you have that information you can filter out the traffic and send it wherever you want based on the information returned.
     
  13. Inception_AC

    Inception_AC Jr. Executive VIP Jr. VIP Premium Member

    Joined:
    Feb 16, 2011
    Messages:
    1,620
    Likes Received:
    1,131
    im looking something similar to this

    Im looking for users of France to goto one site, sweden another, belgium another and holland the other

    any idea how this is done? i tried maximind but it completly tore my head to bits and didnt work like i wanted :(
     
    Last edited: Apr 23, 2013
  14. crazyflx

    crazyflx Elite Member

    Joined:
    Nov 9, 2009
    Messages:
    1,674
    Likes Received:
    4,825
    Location:
    http://CRAZYFLX.COM
    Home Page:
    It's very easy if you don't mind paying to use MaxMind ($20 for 200,000 queries or you can get more of course).

    If you're paying to use their web service, you'd use something like this (PHP):

    Code:
    $VisitorIP = $_SERVER["REMOTE_ADDR"];
    $VisitorCountryCode = file_get_contents('http://geoip.maxmind.com/a?l={YOUR MAXMIND LICENSE KEY}q&i=' . $VisitorIP);
    
    if ($VisitorCountryCode == 'FR') {
    //visitor is from france, send them to website for french visitors
    header('Location: http://FrenchContent.com');
    exit;
    } else if ($VisitorCountryCode == 'SE') {
    //visitor is from Sweden, send them to website for swedish visitors
    header('Location: http://SwedishContent.com');
    exit; }
    and so on
    If you don't want to pay to use their services, then you'll need to install their free "lite" version on your own server. I've written a guide on how to do that and provided the link a few posts up.
     
    Last edited: Apr 24, 2013
  15. The Scarlet Pimp

    The Scarlet Pimp Jr. VIP Jr. VIP Premium Member

    Joined:
    Apr 2, 2008
    Messages:
    788
    Likes Received:
    3,127
    Occupation:
    Chair moistener.
    Location:
    Cyberspace
  16. Ptrick125

    Ptrick125 Regular Member

    Joined:
    Mar 4, 2013
    Messages:
    428
    Likes Received:
    113
    Occupation:
    Going To School
    Location:
    Near Austin, Texas
    Home Page:
    Why would you want to exclude a certain city in the first place?
     
  17. Jonny Quick

    Jonny Quick BANNED BANNED

    Joined:
    Aug 26, 2010
    Messages:
    231
    Likes Received:
    340
    The first rule about fight club is that you don't talk about fight club.
     
  18. The Scarlet Pimp

    The Scarlet Pimp Jr. VIP Jr. VIP Premium Member

    Joined:
    Apr 2, 2008
    Messages:
    788
    Likes Received:
    3,127
    Occupation:
    Chair moistener.
    Location:
    Cyberspace
    that should have been the first rule of the "cookie stuffing" club... :D
     
  19. tonymu

    tonymu Junior Member

    Joined:
    Feb 12, 2013
    Messages:
    121
    Likes Received:
    15
    bookmarked