VanGans

Untitled

Feb 11th, 2019
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.84 KB | None | 0 0
  1. <title>Adf.ly decoder</title>
  2. <?php
  3.  
  4. function request( $url ) {
  5. $ua = 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1712.4 Safari/537.36';
  6. if ( !preg_match( '/^[a-zA-Z0-9\/]+$/', $url ) )
  7. return false;
  8.  
  9. $ch = curl_init();
  10. curl_setopt_array( $ch, array(
  11. CURLOPT_FAILONERROR => true,
  12. CURLOPT_FOLLOWLOCATION => false,
  13. CURLOPT_RETURNTRANSFER => true,
  14. CURLOPT_TIMEOUT => 10,
  15. CURLOPT_USERAGENT => $ua,
  16. CURLOPT_URL => 'http://adf.ly/' . $url
  17. ) );
  18. $data = curl_exec( $ch );
  19. curl_close( $ch );
  20.  
  21. if ( preg_match( "#var ysmm = '([a-zA-Z0-9+/=]+)'#", $data, $matches ) ) {
  22. $final = $url = decode( $matches[1] );
  23. // check for redirects
  24. $ch = curl_init();
  25. curl_setopt_array( $ch, array(
  26. CURLOPT_FAILONERROR => true,
  27. CURLOPT_FOLLOWLOCATION => true,
  28. CURLOPT_RETURNTRANSFER => true,
  29. CURLOPT_HEADER => true,
  30. CURLOPT_NOBODY => true,
  31. CURLOPT_TIMEOUT => 10,
  32. CURLOPT_USERAGENT => $ua,
  33. CURLOPT_URL => $url
  34. ) );
  35. $data = curl_exec( $ch );
  36. if ( preg_match_all( '/Location:\s*(.+)\s*$/im', $data, $matches, PREG_SET_ORDER ) ) {
  37. $last = array_pop( $matches );
  38. $final = trim( $last[1] );
  39. }
  40.  
  41. return array( $url, $final );
  42. }
  43.  
  44. return false;
  45. }
  46.  
  47. function decode( $ysmm ) {
  48. $left = '';
  49. $right = '';
  50. for ( $i = 0; $i < strlen( $ysmm ); $i++ ) {
  51. if ( $i % 2 == 0 ) {
  52. $left .= $ysmm[$i];
  53. } else {
  54. $right = $ysmm[$i] . $right;
  55. }
  56. }
  57. return substr( base64_decode( $left . $right ), 2 );
  58. }
  59.  
  60. if ( isset( $_GET['url'] ) && $_GET['url'] ) {
  61. // strip out beginning (everything up to last slash)
  62. $stripped = '';
  63. $slashes = explode( '/', $_GET['url'] );
  64. $stripped = array_pop( $slashes );
  65.  
  66. list( $url, $final ) = request( $stripped );
  67. if ( $url ) {
  68. echo '<p>Your URL is <a href="' . $url . '">' . $url . '</a>';
  69. if ( $url != $final ) {
  70. echo ' (<a href="' . $final . '">' . $final . '</a>)';
  71. }
  72. echo '</p>';
  73. } else {
  74. // try 2 parts
  75. $stripped = array_pop( $slashes ) . '/' . $stripped;
  76. list( $url, $final ) = request( $stripped );
  77. if ( $url ) {
  78. echo '<p>Your URL is <a href="' . $url . '">' . $url . '</a>';
  79. if ( $url != $final ) {
  80. echo ' (<a href="' . $final . '">' . $final . '</a>)';
  81. }
  82. echo '</p>';
  83. } else {
  84. echo '<p>Adf.ly URL not found</p>';
  85. }
  86. }
  87. }
  88. ?>
  89. <form method="GET">
  90. Adf.ly URL to decode: <input type="text" name="url" /> <input type="submit" value="Go" />
  91. </form>
Add Comment
Please, Sign In to add comment