Showing posts with label php. Show all posts
Showing posts with label php. Show all posts

Tuesday, December 20, 2011

Email Harvesting with PHP and Javascript

We can scrape emails using the prototype library and php.. like so..

1:  <script src="prototype.js"></script>  
2:  <script>  
3:       function scrapeEmails(url)  
4:       {  
5:            var notice = $('notice');  
6:            var url = 'proxy.php?url=' + encodeURIComponent(url);  
7:            new Ajax.Request(url,  
8:            {  
9:                 method: 'get',  
10:                 onSuccess: function(transport)  
11:                 {  
12:                      var markdown = transport.responseText;  
13:                      markdown.gsub(/\w+@\w+[.]\w+/g, function(matches)  
14:                      {  
15:                           //var emails = matches.split(',');  
16:                           for(i=0;i<matches.length;i++)  
17:                           {  
18:                                notice.insert(matches[i] + "<br/>");  
19:                           }  
20:                      });  
21:                 },  
22:                 onFailure: function(transport)  
23:                 {  
24:                      notice.update(transport.responseText);  
25:                 }  
26:            });  
27:       }  
28:  </script>  

And the proxy.php ifile (while vulnerable to file inclusion at this point, please secure your own scripts and stop bitching at me)

1:  <?php  
2:  $url = $_GET['url'];  
3:  $content = file_get_contents($url);  
4:  header('Content-type: text/xml');  
5:  echo $content;  
6:  ?>  

And use it like this..

1:  <body>  
2:       <input type="text" value="http://www.dotfart.com/quiz/emails.txt" size="80" id="url">  
3:       <input type="button" value="do it" onclick="scrapeEmails(document.getElementById('url').value);">  
4:       <hr/>  
5:       <div id="notice"></div>  
6:  </body>