EG Information

Main Index
EG Manual
Disclaimer
Legal Information
Hall of Fame
Hall of Shame
Member Rankings
Members List
Meet the Staff
Hacker's Home Page

Training Missions

Read Me First
Basic Skills
Realistic Scenarios
Cryptography
Software Cracking
Linux ELF Binary Cracking
Logical Thinking
Programming
Captcha Cracking
Patching
Steganography
Deface This Wall
/dev/null
/dev/urandom
/dev/extra

Knowledge Bank

Discussion Forums
Exploit Database New
PasteBin New
RSS Feeds RSS
Articles / Tutorials
Videos
Online EG MP3 Player Radio
Downloads
Tools

Code Resources

Submit Code
Ajax
ASM
Bash
C
CPP
Csharp
Delphi
Haskell
Java
Javascript
Jython
Lisp
mIRC
MySQL
Perl
PHP
Python
QBASIC
VisualBasic

Pimp Us Out!

Review enigmagroup.org on alexa.com

Has Enigma Group Helped You? Then Help Us By Advertising For Us. Place One Of The Following Images On Your Site And Create A Link Back To Enigma Group.

Enigma Group

Enigma Group

Enigma Group

Enigma Group

 

Affiliates

hackhound.org

suck-o.com

hack.org.za

flyninja.net

 

Enigma Group's Code Bank


Soundcloud mp3 extract0r

By: c0re  -  Date Submitted: 2011-01-19 09:05:43

  1. <?php
  2. /* @name: soundcloud-mp3-extract0r.php
  3.  * @author: c0re <http://enigmagroup.org/>
  4.  * @version: 1.0
  5.  * @copyright: <http://creativecommons.org/licenses/by-nc-sa/3.0/>
  6.  */
  7.  
  8. '------------------------------------------------------
  9. _ _ _
  10. ___ ___ _ _ ___ _| |___| |___ _ _ _| |
  11. |_ -| . | | | | . | _| | . | | | . |
  12. |___|___|___|_|_|___|___|_|___|___|___|
  13. mp3 extract0r
  14.  
  15. by c0re <http://enigmagroup.org/>
  16.  
  17. usage: php '.htmlspecialchars($_SERVER['PHP_SELF']).' <URL> <newName>
  18. ------------------------------------------------------';
  19.  
  20. $url = urldecode(@$argv[1]); //1 parameter is original url
  21. $name = htmlspecialchars(@$argv[2]); //2 parameter is the name of the file
  22. if(empty($url) || empty($name)) {
  23. die("\n[-]ERROR: invalide arguments passed");
  24. }
  25.  
  26. //now we combine all and get our mp3 ;)
  27. downloadMp3(getSource($url),$name);
  28. print("\n\n[DONE] file saved in ".@getcwd()."\\".$name.".mp3\n");
  29. ?>
  30.  
  31. <?php
  32. function getSource($url)
  33. {
  34. //with a strong regex pattern to validate urls copy as you like..
  35. $pattern = '%\b(?:(?:http|https)://|www\.)[\d.a-z-]+\.[a-z]{2,6}(?::\d{1,5}+)?(?:/[!$\'()*+,._a-z-]++){0,10}(?:/[!$\'()*+,._a-z-]+)?(?:\?[!$&\'()*+,.=_a-z-]*)?%i';
  36. //..we check if url is valid
  37. if(!preg_match($pattern, $url)) {
  38. die("\n[-]ERROR: argv[1] doesnt look like an URL");
  39. }
  40. //next check if curl is available
  41. if (!function_exists('curl_init')) {
  42. print("\n\nWARNING: cURL not installed!\ntrying file_get_contents ...\n");
  43. $markup = file_get_contents($url);
  44. if(empty($markup)) {
  45. die("\n[-]ERROR: couldnt get markup");
  46. }
  47. //find anything between streamUrl":" and ",
  48. //( eg: "streamUrl":"http://media.soundcloud.com/stream/3mZyUWW9iikL?stream_token=wK1Cm", )
  49. if(preg_match('/streamUrl\"\:\"(.*?)\"\,/', $markup, $stream)) {
  50. //return the splitted array from the regex
  51. return $stream[1];
  52. }
  53. }
  54. //set a blank + useragent for the header
  55. $referer = "";
  56. $useragent = "Mozilla/5.0 (Windows; U; Windows NT 6.1; de; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13";
  57. //send an header array containing normal looking firefox 3.x.x data
  58. $header = array(
  59. "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
  60. "Accept-Language: en-us;q=0.5,en;q=0.3",
  61. "Accept-Encoding: gzip,deflate",
  62. "Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7",
  63. "Keep-Alive: 115",
  64. "Connection: keep-alive"
  65. );
  66. //initialize the handle
  67. $curl = curl_init();
  68. //stuff it all in an array for curl_setopt
  69. $options = array(
  70. CURLOPT_URL => $url, //set the url
  71. CURLOPT_RETURNTRANSFER => true, //return webpage
  72. CURLOPT_BINARYTRANSFER => true, //return untouch data
  73. CURLOPT_USERAGENT => $useragent, //send custom useragent
  74. CURLOPT_REFERER => $referer, //send custom refferer
  75. CURLOPT_HTTPHEADER => $header, //send custom header
  76. CURLOPT_ENCODING => "", //handle all encodings
  77. CURLOPT_HEADER => false, //dont return headers
  78. CURLOPT_TIMEOUT => 10 //a little break
  79. );
  80. //apply the options array
  81. curl_setopt_array($curl, $options);
  82. //execute the whole thing
  83. $markup = curl_exec($curl);
  84. //get the answer for error code checking
  85. $returncode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
  86. //close handle, free up memory
  87. curl_close($curl);
  88. //check for html error codes
  89. if($returncode != 200 && $returncode != 302 && $returncode != 304) {
  90. die("\n[-]ERROR: this URL seems not alive!");
  91. }
  92. //check if we got html source to search
  93. if(!empty($markup)) {
  94. //find anything between streamUrl":" and ",
  95. //( eg: "streamUrl":"http://media.soundcloud.com/stream/3mZyUWW9iikL?stream_token=wK1Cm", )
  96. if(preg_match('/streamUrl\"\:\"(.*?)\"\,/', $markup, $stream)) {
  97. //return the splitted array from the regex
  98. return $stream[1];
  99. }
  100. else { die("\[-]nERROR: cant find the streamUrl"); }
  101. }
  102. else { die("\n[-]ERROR: couldnt receive html source"); }
  103. }
  104. function downloadMp3($stream,$name)
  105. {
  106. //check if we find any extension in $name
  107. if(stristr($name, '.mp3')) {
  108. die("\n[-]ERROR: argv[2] doesnt need any kind of extension");
  109. }
  110. //just send a blank referer now
  111. $referer = "";
  112. //initialize the handle
  113. $curl = curl_init();
  114. //set the new filename
  115. $filename = dirname(__FILE__).'/'.$name.'.mp3';
  116. //set the filehandle for writing
  117. $handle = fopen($filename,'w');
  118. //stuff it all in an array for curl_setopt
  119. $options = array(
  120. CURLOPT_URL => $stream, //set the url
  121. CURLOPT_FOLLOWLOCATION => true, //follow location headers
  122. /*
  123. PLEASE NOTE: without curlopt_followlocation set this wont
  124. work because soundcloud redirects you to a
  125. random created link
  126. */
  127. CURLOPT_REFERER => $referer, //sent custom refferer
  128. CURLOPT_HEADER => false, //dont return headers
  129. CURLOPT_FILE => $handle, //set the file handle
  130. );
  131. //apply the options array
  132. curl_setopt_array($curl, $options);
  133. //execute it
  134. curl_exec($curl);
  135. //close handle, free up memory
  136. curl_close($curl);
  137. //close the file handle, free up memory
  138. fclose($handle);
  139. }
  140. ?>
  141.  
Return to php category list

Who Visited EnigmaGroup Today?

1387 Guests, 227 Users (216 Spiders)
terrorbyte, Pabz, Nightraven, cat1vo, lolzsec, interspirehost, lamb, tgm001, plex, Edika, TheCheeseDemon, rockcraft, recoveryToolbox, saraf, soufiaane, sickmind, mjneat, famous0123, Galagatron, dark_void, CJ_Omaha, junaid_junaid59, JohnJohnJohn, ssmaslov, psychomarine, Dregoon, Patrickk, Aska, Beat_Slayer, M0rdak, Ausome1, Imre, Vreality2007, mmndglxuwn, m0rt, unholyblood, iterrumzz, VurbTrurb, Mayonoula, MAMWOURBROR, mutabor, gobinda, cossyDrybrich, Razin, zaCruBumas8, hunja, johny34, pantoufle, bagy, arctica, hackarchives, UsedDeteKef, Peculator, Fadhilat606, TheTrueMonarch, Pascall01, hackaday, Tjm, arndevil, flairvelocity, lol, alphbond, kdivanov, elizbethallis6, Rik, bn11, BorgBot, SHASHANK101hello, 4poc4lyptic, ksajxai, nbmorri1, electro-technic, شمالي عرعر, AutobotPrime, Underleaf, The End, tomtombomb, killobyte, snowgirlx, so_saucey, zerolife, Althor, Cramps, Hekser, Hyperborn, cyber-guard, jhgrunn, cobra, Partisan, MAZI_, cyborg, GenbreedX, moel77, cliptoX, pwnpwnlolz, letshavepie, Mrwormz, yshiau, mirmo, roozyoppomo, soft_devil, cls777, scoobywan, Reiversed, joshua, st3alth, Afrika, PaiffDryday, venter, Anthony12796, sh3llcod3, 8FIGURE, Rannim, Evil1, maloaboy, BACanON, SlayingDragons, Repuhlsive, IvanDimitriev, 1RiB, mzungudo, Micro_Geek, iMaxx, aciboummamymn, k0unterkulcher, somebody777, m14m16, GoododotAlcob, negasora, Rastii, UninueMem, Swifsolja, ad.conquest, ngolatkar, Infinity8, Jigoku, thesupervisor, p0is0n5ting, kernel_mod, AKL, GothicLogic, themastersinner, dnatrixene135, ChewBigRed, kalak55, sejem, cve916, pollolololo, triecturn, Violatedsmurf, Ops, jmp, xsiemich, generalisimo, strudels, ga3ttpom, KingOfBritains, epoch_qwert, suten, FriskyKat, Ryuske, Adonis Achilles, ubqbcdzzhf, 3vil, US£RNAM£, Weindittewcon, Batesheelocot, GSmyrlis, MaxMeier, Elite.America, rabbidmind, Psiber_Syn, phoenix22, imittyerrotte, peewster, cyberturtle, ctb, dexgeda, sdw, Pizza, White_widdow, devarian, finesse, Nature112091777, Danc7171, Alphadragon, Estadagause, 53QR10U5, Xargos, Alkomage, hardlock, Barry Gonzoles, MineDweller, Gkjt, N4g4c3N, [I]nfectedbug, wimsteege, aqr5zdcw, xin214, Bugshuppy, SnoopSky, Hessesian, voodooKobra, sKcarr, IROverRated, W1F1G3NJU75U, Baddy, ziadmosaan, gamble86, realzs, CruelDemon, Shinju, aVoid, aquiredanonymity, kukumumu, web_request, callmeneon, KissMyDAFFODIL, Feld Grau, Abhinav2107, prabhataditya, mbuyiselo, shumer, phenom216, princennamdi, huskyboiza, ninety-nine
 
Enigma Group