Search Google Voice and compile list of all available numbers!

Discussion in 'Mac Programming' started by eshroom, Jan 26, 2011.

  1. eshroom, Jan 26, 2011
    Last edited: Jan 26, 2011

    macrumors 6502

    Joined:
    Oct 18, 2006
    #1
    Here is a simple Perl script enabling you to search through Google and compile a list of numbers (obviously all numbers would take a while, so perhaps choose an area code). Just run through perl in terminal.

    Perhaps someone could do me a favour and compile a list in the 646 area code database, or 415. I am not in the US and it is difficult to do through a VPN (most don't allow automated processes).

    Here's the full version of the script, edited ever so slightly from Will Entriken's creation:

    1. Login to Google Voice

    2. Find numbers


    # prepare
    mkdir GOOGLEVOICE; cd GOOGLEVOICE

    # login
    curl https://www.google.com/accounts/ClientLogin \
    -d Email=YOUREMAIL@gmail.com \
    -d Passwd=YOURPASSWORD \
    -d source=privacylog \
    -d service=grandcentral > token

    AUTH=$(sed -n '/Au/s/A/a/p' token)
    HEADER="Authorization: GoogleLogin $AUTH"
    URL="https://www.google.com/voice/?setup=1#setup/"

    # which area codes does Google Voice support?
    curl --header "$HEADER" "${URL}?ac=[201-999]&start=0" | grep -ho "+1[0-9]\{10\}" | sort -u >> areacodes
    cat areacodes | sed 's/..\(...\)......./\1/' | sort -u
    # answer: 201 202 203 205 207 208 209 210 213 214 215 216 218 219 224 225 229 231 234 240 248 251 252 253 254 256 260 262 267 269 270 276 281 301 302 303 304 305 307 312 313 314 315 316 317 318 319 320 321 323 325 330 331 334 336 337 339 347 352 361 385 386 401 402 404 405 406 407 408 409 410 412 413 414 415 419 423 424 425 430 432 434 435 440 443 469 478 480 484 501 502 503 504 505 507 508 509 510 512 513 515 516 518 520 530 540 541 551 559 561 562 563 567 570 571 573 574 575 585 586 601 602 605 607 608 609 612 614 615 616 617 619 623 626 630 631 636 646 650 651 657 660 661 662 678 682 701 702 703 704 706 707 708 713 714 715 716 717 719 720 724 727 731 732 734 740 747 754 757 760 762 763 765 769 772 773 774 775 779 781 785 786 801 802 803 804 805 806 810 812 813 814 815 816 817 818 828 830 831 832 843 845 847 848 850 856 857 858 859 860 862 863 864 865 870 872 901 903 904 906 908 909 910 913 914 915 916 917 918 919 920 925 928 931 936 937 941 949 951 952 954 956 970 971 972 973 978 980 985 989

    # add a full number from each area code you want to NUMBERS - I'm interested in 707 or 404 or 646 or 215 or 415
    printf "+17070000000\n+14040000000\n" > numbers

    # now we use a BFS on each digit to find all numbers
    # continue at your own peril!


    sed -n 's/+1\(...\).*/\1/p' numbers | sort -u |
    (while read LINE; do curl --header "$HEADER" "${URL}?ac=${LINE:0:3}&q=$LINE[0-9]&start=0"; done) | grep -ho "+1[0-9]\{10\}" | sort -u >> numbers

    sed -n 's/+1\(....\).*/\1/p' numbers | sort -u |
    (while read LINE; do curl --header "$HEADER" "${URL}?ac=${LINE:0:3}&q=$LINE[0-9]&start=0"; done) | grep -ho "+1[0-9]\{10\}" | sort -u >> numbers

    sed -n 's/+1\(.....\).*/\1/p' numbers | sort -u |
    (while read LINE; do curl --header "$HEADER" "${URL}?ac=${LINE:0:3}&q=$LINE[0-9]&start=0"; done) | grep -ho "+1[0-9]\{10\}" | sort -u >> numbers

    sed -n 's/+1\(......\).*/\1/p' numbers | sort -u |
    (while read LINE; do curl --header "$HEADER" "${URL}?ac=${LINE:0:3}&q=$LINE[0-9]&start=0"; done) | grep -ho "+1[0-9]\{10\}" | sort -u >> numbers

    sed -n 's/+1\(.......\).*/\1/p' numbers | sort -u |
    (while read LINE; do curl --header "$HEADER" "${URL}?ac=${LINE:0:3}&q=$LINE[0-9]&start=0"; done) | grep -ho "+1[0-9]\{10\}" | sort -u >> numbers

    sed -n 's/+1\(........\).*/\1/p' numbers | sort -u |
    (while read LINE; do curl --header "$HEADER" "${URL}?ac=${LINE:0:3}&q=$LINE[0-9]&start=0"; done) | grep -ho "+1[0-9]\{10\}" | sort -u >> numbers

    sed -n 's/+1\(.........\).*/\1/p' numbers | sort -u |
    (while read LINE; do curl --header "$HEADER" "${URL}?ac=${LINE:0:3}&q=$LINE[0-9]&start=0"; done) | grep -ho "+1[0-9]\{10\}" | sort -u >> numbers

    sed -n 's/+1\(.........\).*/\1/p' numbers | sort -u |
    (while read LINE; do curl --header "$HEADER" "${URL}?ac=${LINE:0:3}&q=$LINE[0-9]&start=0"; done) | grep -ho "+1[0-9]\{10\}" | sort -u >> numbers

    3. Harvest out your winnings*
    sort -u numbers > sorted; mv sorted numbers


    There's a second part that has code necessary to decipher the numbers and pick good combinations. Of course, it is up to you to decide what number layout you are after, so they may not be useful.

    Thanks
     
  2. macrumors 603

    Joined:
    Aug 9, 2009
    #2
    You could probably sign up for Amazon Web Services, enable the EC2 service, then create an instance running at one of the two US locations. Then ssh in and run your script from the EC2 instance.

    Practically any of the Linux EC2 images would work, since 'perl' is commonly installed by default. If the script runs in less than 1 hour of wall-clock time, it'd probably cost you under 10 cents (US currency).

    I have used a simple EC2 instance to get URLs from other servers outside of EC2. That part works fine.

    I say "probably" only because I'm unsure of what billing requirements would be needed for non-US customers. I'm also not entirely sure what range of IP address the EC2 instance will have, or whether EC2 is blocked by GV. I see no reason for those obstacles, but it would be a good idea to test it with something like 'curl' or 'wget' and hit http://www.whatismyip.com/ .
     
  3. thread starter macrumors 6502

    Joined:
    Oct 18, 2006
    #3
    Thanks, but I wouldn't know where to start. Also, I only need this one thing done. For all my other needs a VPN will suffice.
     
  4. awesomerobot, Jun 2, 2012
    Last edited: Jun 2, 2012

    macrumors newbie

    Joined:
    Oct 29, 2007
    #4
    I hate commenting on a year+ old thread, but this would be really useful to use.

    this wasn't working out of the box for me, but worked when I changed the login bit to this:

    curl https://www.google.com/accounts/ClientLogin \
    --data-urlencode Email=YOUREMAIL@gmail.com --data-urlencode Passwd=YOURPASSWORD \
    -d accountType=GOOGLE \
    -d source=Google-cURL-Example \
    -d service=grandcentral > token
     
  5. macrumors newbie

    Joined:
    Sep 3, 2012
    #5
    PHP Version

    Here's a PHP script I made derived from this post. I'm sharing this as my way of saying thank you.

    to run the script below you need to supply the ac and s parameters like so

    http://localhost/gv.php?ac=121$s=0
    s should be looped and incremented by 5 each time since google will give you 5 numbers each page.

    Also keep in mind that this will only work with a US based IP. If you're outside US, then you can use a proxy to spoof your IP. I use http://www.hotspotshield.com/

    ------------
    <?php

    $ch = curl_init();

    curl_setopt($ch, CURLOPT_URL, "https://www.google.com/accounts/ClientLogin");
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);

    $data = array(
    'accountType' => 'GOOGLE',
    'Email' => 'username@gmail.com',
    'Passwd' => 'password',
    'source'=>'PHI-cUrl-Example',
    'service'=>'grandcentral'
    );

    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $data);

    $msg = curl_exec($ch);

    $cookies = split("\n",$msg);
    //print_r($cookies);

    $ch = curl_init("https://www.google.com/voice/b/0/setup/searchnew/?ac=".$_GET['ac']."&start=". $_GET['s']);

    $header[] = 'Authorization: GoogleLogin ' . $cookies[2];

    curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_HEADER, false);

    $msg = curl_exec($ch);
    curl_close($ch);

    $arr_data = json_decode($msg);
    echo "matches found = " . $arr_data->JSON->num_matches . "<br />";
    foreach($arr_data->JSON->vanity_info as $numbers=>$whatever){
    echo $numbers . "<br/>";
    }

    ?>
    ------------
     
  6. fulldecent, Dec 15, 2012
    Last edited by a moderator: Dec 15, 2012

    macrumors newbie

    Joined:
    Sep 21, 2009
    #6
    Hello, I am the original author, Will Entriken.

    Thank you for your feedback, I use this to improve the script.
     

Share This Page