Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * adf.ly Link Extractor
- *
- * This program used to extract link behind adf.ly advertise link.
- * Still very early release, just for fun coding purpose :)
- * coded by devilzc0der
- *
- * Usage : new adfLyExtract($argv);
- */
- class adfLyExtract
- {
- const V = 0.01; // this is the program version
- var $reqLib = array('curl_init', 'fopen', 'fread', 'get_headers');
- /* Contructor. Check compability, set up arguments, print banner and execute main program. */
- function __construct($opts) {
- $this->checkReqLib();
- $cmd = $this->arguments($opts);
- print $this->banner();
- /* Print help screen then exit if list param is not set */
- if ( !array_key_exists('list', $cmd) )
- exit( $this->usage($cmd['input'][0]) );
- if ( $this->cekFile($cmd['list']) )
- $this->readData($cmd['list']);
- else print $this->crot(" [!] Data is not exist or not wirtable!", 'red') . "\n";
- }
- // check function compability
- function checkReqLib() {
- $ok = 1;
- foreach( $this->reqLib as $func ) {
- if ( !function_exists($func) ) {
- print 'You need function ' . $this->crot($func,'cyan') . " to execute this tool!\n";
- $ok = 0;
- }
- }
- if ( !$ok ) exit;
- }
- /* The cool banner */
- function banner() {
- $msg = " ________________________________________________________\n";
- $msg .= "| mm |\n";
- $msg .= "| /^( )^\ adf.ly Link Extractor " . $this->crot('v' . self::V,'cyan') . " |\n";
- $msg .= "| \,(..),/ This program used to extract link |\n";
- $msg .= "| V~~V behind " . $this->crot('adf.ly', 'red') . " advertise link. |\n";
- $msg .= "| Coded by devilzc0der, just for fun coding purpose. :) |\n";
- $msg .= "|________________________________________________________|\n\n";
- return $msg;
- }
- /* Help Screen */
- function usage($file) {
- $msg = "\nUsage : ";
- $msg .= $file . " --list=[list]\n";
- $msg .= "Example : ";
- $msg .= $file . " --list=/home/dit/linklist.txt -v\n";
- return $msg;
- }
- /**
- * Check list file
- * @return bool. TRUE if file exists and readable.
- */
- function cekFile ($file) {
- if ( !is_file($file) || !is_readable($file) ) return false;
- else return true;
- }
- /* Check adf.ly link */
- function dovalidLink($link) {
- return preg_match("|^http://adf.ly/+([a-z0-9-]+)?$|i", $link);
- }
- /**
- * Read target data
- * @return string.
- */
- function readData ($file) {
- $msg = NULL;
- $read = fopen($file, "r");
- $msg .= fread($read, filesize($file));
- $link = explode("\n", $msg);
- for ($i = 0; $i < count($link); $i++) {
- if ( !empty($link[$i]) ) {
- print " " . $link[$i];
- if ( $this->dovalidLink($link[$i]) )
- $this->con_host($link[$i]);
- else
- print " " . $this->crot('[FAILED]', 'red') . " => Invalid adf.ly Link! \t[SKIP]\n";
- }
- }
- fclose($read);
- return $msg;
- }
- function con_host($host) {
- $ch = curl_init($host);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($ch, CURLOPT_TIMEOUT, 200);
- curl_setopt($ch, CURLOPT_HEADER, 1);
- // curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
- // curl_setopt($ch, CURLOPT_REFERER, "http://devilzc0de.org/");
- curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.9) Gecko/20071025 Firefox/2.0.0.9; Mozilla Firefox');
- $pg = curl_exec($ch);
- if ($pg) {
- if ( preg_match("/http\/1\.1 200 ok/i", $pg) ) {
- preg_match_all('/var url = \'(.*)\';/isU',$pg, $exploit);
- if ( $exploit[1][0] ) {
- $check = get_headers('http://adf.ly' . $exploit[1][0], 1);
- if ( !empty($check) )
- if (preg_match('/301/', $check[0]) || preg_match('/302/', $check[0]) )
- print ' ' . $this->crot('[OK]','cyan') . ' => ' . $this->crot($check['Location'],'l_cyan') . "\n";
- else
- print "\t No repsond from server.\n";
- }
- }
- else
- print " " . $this->crot('[FAILED]','red') . " => Invalid HTTP header respond!\n";
- }
- else
- return false;
- }
- /**
- * Make UNIX like parameter command.
- * This function from losbrutos and modified by earomero. Thankyou. =)
- * @author losbrutos <losbrutos@free.fr>
- * @author earomero <earomero@gmail.com>
- * @param array argv
- * @return array
- */
- function arguments($argv) {
- $_ARG = array();
- foreach ($argv as $arg) {
- if (preg_match('#^-{1,2}([a-zA-Z0-9]*)=?(.*)$#', $arg, $matches)) {
- $key = $matches[1];
- switch ($matches[2]) {
- case '':
- case 'true':
- $arg = true;
- break;
- case 'false':
- $arg = false;
- break;
- default:
- $arg = $matches[2];
- }
- // make unix like -afd == -a -f -d
- if(preg_match("/^-([a-zA-Z0-9]+)/", $matches[0], $match)) {
- $string = $match[1];
- for($i=0; strlen($string) > $i; $i++) {
- $_ARG[$string[$i]] = true;
- }
- } else {
- $_ARG[$key] = $arg;
- }
- } else {
- $_ARG['input'][] = $arg;
- }
- }
- return $_ARG;
- }
- /**
- * Function to print colorful output to terminal.
- * @param string $string String to be colored.
- * @param string $fontColor The available color
- * Available color :
- * black, dark_gray, blue, green, l_green, cyan, l_cyan
- * red, l_red, purple, l_purple, brown, yellow, l_gray,
- * white.
- * @return string
- */
- private function crot($string, $fontColor=NULL) {
- switch ($fontColor) {
- case 'black' : $color = '0;30'; break;
- case 'dark_gray' : $color = '1;30'; break;
- case 'blue' : $color = '0;34'; break;
- case 'l_blue' : $color = '1;34'; break;
- case 'green' : $color = '0;32'; break;
- case 'l_green' : $color = '1;32'; break;
- case 'cyan' : $color = '0;36'; break;
- case 'l_cyan' : $color = '0;36'; break;
- case 'red' : $color = '0;31'; break;
- case 'l_red' : $color = '1;31'; break;
- case 'purple' : $color = '0;35'; break;
- case 'l_purple' : $color = '1;35'; break;
- case 'brown' : $color = '0;33'; break;
- case 'yellow' : $color = '1;33'; break;
- case 'l_gray' : $color = '0;37'; break;
- case 'white' : $color = '1;37'; break;
- }
- $colored_string = "";
- $colored_string .= "\033[" . $color . "m";
- $colored_string .= $string . "\033[0m";
- return $colored_string;
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement