Author Topic: [Python] Udemy course extractor  (Read 8542 times)

0 Members and 2 Guests are viewing this topic.

Offline daxda

  • Peasant
  • *
  • Posts: 114
  • Cookies: 112
  • Not the guy you're looking for
    • View Profile
    • Daxda on Github
[Python] Udemy course extractor
« on: July 17, 2014, 08:19:19 pm »
Since Geoff and some other guy posted coupons for udemy.org discounts, I tried to extract all video links from a course.
With this script you are able to extract the "Solid Introduction to Ethical Hacking and Penetration Testing" course from udemy.
The only "limitation" of it, is the fact that you have to buy the courses first (or get access to a valid cookie which have the courses you want,
or 100% off coupon, more 100% off coupons), to be able to extract the links. You need to manually fill out the cookie dict on line L17 and enter the URL,
you want to scrape from, at the bottom of the script on line L115.

I couldn't be bothered to take care of all the various login routines for the site, so you have to do some dirty work.
Unless you want to modify the source that is.



[gist]Daxda/d1b9e535b9aced2450cc[/gist]

Example output:
Code: [Select]
Section 1. Solid Introduction to Ethical Hacking and Penetration Testing

Chapter 1. About the course
File name: Intro.mp4
Link: https://sknowbucket-a.akamaihd.net/2013-10-14_22-29-34-7bf522b269e5ff8cd7e3b0c5200c1254/WebHD_720p.mp4?__gda__=1405633327_ef25fbdfa32f33faa6f5b32a009e80b2&filedownload=attachment%3Bfilename%3Dintromp4.mp4

Chapter 2. Hacking vs Ethical Hacking
File name: hacking_vs_ethical_hacking.mp4
Link: https://sknowbucket-a.akamaihd.net/2013-10-14_22-29-31-54ea765817edd834a9e12d202a3c91fd/WebHD_720p.mp4?__gda__=1405633327_d34925cf2e59c2ad3c166b7c228e6343&filedownload=attachment%3Bfilename%3Dhacking_vs_ethical_hackingmp4.mp4

Chapter 3. Who is a Hacker ?
File name: hacker_def.mp4
Link: https://sknowbucket-a.akamaihd.net/2013-10-14_22-29-35-1ef8ba7ccb507e462b0e2f312a75734b/WebHD_720p.mp4?__gda__=1405633329_f901b01c40d7e1ed8e32dfed7fe1b2b6&filedownload=attachment

Chapter 4. Types of Hackers
File name: types_of_hackers.mp4
Link: https://sknowbucket-a.akamaihd.net/2013-10-14_22-31-38-4473ae9aabc6d12f545c415acc776b38/WebHD_720p.mp4?__gda__=1405633330_968e467f33b34e1d727f8a9e69657292&filedownload=attachment

Chapter 5. Hacktivism
File name: hacktivism.mp4
Link: https://sknowbucket-a.akamaihd.net/2013-10-14_22-29-09-e1ece5d5151c24417daad579e350187e/WebHD_720p.mp4?__gda__=1405633330_e07dde57e3243969ac58e9e45f6b5f4d&filedownload=attachment

Chapter 6. Computer Crimes
File name: computer_crimes.mp4
Link: https://sknowbucket-a.akamaihd.net/2013-10-14_22-30-11-6a371e23b8b06801b071e265ff2a5451/WebHD_720p.mp4?__gda__=1405633331_3ad47c63f467ce5754c0c50c55f6276d&filedownload=attachment

Chapter 7. Important Terms 1
File name: Important Terms 1
Link: https://sknowbucket-a.akamaihd.net/2013-10-17_10-23-52-5dd4eaef148cdfeca88e33f9c64cb1b2/WebHD_720p.mp4?__gda__=1405633327_9aaa81ed7803bdbeca1fbc28c305bcb0&filedownload=attachment%3Bfilename%3Dimportant-terms-1.mp4

Chapter 8. Important Terms 2
File name: Important Terms 2
Link: https://sknowbucket-a.akamaihd.net/2013-10-17_10-27-57-bba20df22f12b4e2c5154f78964ccc9b/WebHD_720p.mp4?__gda__=1405633331_167ae0893ff873e25fa257a7f969709e&filedownload=attachment

Chapter 9. Why Penetration Testing ?
File name: Why Pentest
Link: https://sknowbucket-a.akamaihd.net/2013-10-19_07-42-18-4fde9bf6cd6ff8e0439de030ee05746d/WebHD_720p.mp4?__gda__=1405633327_d1420e1c02e0b162614ddc60e57e03eb&filedownload=attachment%3Bfilename%3Dwhy-pentest.mp4

Chapter 10. Penetration Testing Types
File name: Pentest Types
Link: https://sknowbucket-a.akamaihd.net/2013-10-19_07-46-07-20a37118e33a48e86f961d3a70303f8c/WebHD_720p.mp4?__gda__=1405633332_5c588bb2d5fd8d7b605a30a7e27c2006&filedownload=attachment

Section 2. Real World Information Intelligence Techniques

Chapter 11. Introduction to Information Intelligence Techniques
File name: Module2RealWorldInformationIntelligenceTechniques.mp4
Link: https://sknowbucket-a.akamaihd.net/2013-09-30_07-37-10-0842b3c32f853ff4d63bf34fff815871/WebHD_720p.mp4?__gda__=1405633332_edc5ce7ea852d3a7aaa370e16ee78034&filedownload=attachment

Chapter 12. organizing information during a penetration test
File name: organizinginformationduringapenetrationtest.mp4
Link: https://sknowbucket-a.akamaihd.net/2013-09-30_05-56-41-079e30176fcce1ac705271f61332cf2c/WebHD_720p.mp4?__gda__=1405633333_5677739b53d5347995dbb4684f80abf0&filedownload=attachment

Chapter 13. how to locally copying company websites
File name: locallycopyingcompanywebsites.mp4
Link: https://sknowbucket-a.akamaihd.net/2013-09-30_07-34-45-8b90bcc134c59b1c03f7cf738c06668d/WebHD_720p.mp4?__gda__=1405633333_eeb162863162e2acc8bfc697d5f213fc&filedownload=attachment

Chapter 14. newsgroups and list-servers
File name: newsgroupsandlistservers.mp4
Link: https://sknowbucket-a.akamaihd.net/2013-09-30_05-56-18-b6caaca940dfc0df12a0329d3aeab500/WebHD_720p.mp4?__gda__=1405633333_30ce6d72caa84de5697f5ae23b6b4233&filedownload=attachment

Chapter 15. online job listing
File name: onlinejoblisting.mp4
Link: https://sknowbucket-a.akamaihd.net/2013-09-30_08-29-05-6c5d3d5fe49b29e1b5dfca43d17ec3e3/WebHD_720p.mp4?__gda__=1405633334_17df81f31125dd95143d0bf6428ddcf7&filedownload=attachment

Chapter 16. the power of social media websites
File name: thepowerofsocialmediawebsites.mp4
Link: https://sknowbucket-a.akamaihd.net/2013-09-30_05-57-25-eb883a97adc20934bff8ca155d519386/WebHD_720p.mp4?__gda__=1405633334_dc747bed1191767a15ae8bfbbe9b188b&filedownload=attachment

Chapter 17. harvesting a company emails
File name: harvestingacompanyemails.mp4
Link: https://sknowbucket-a.akamaihd.net/2013-09-30_05-57-25-00c33e21a9bdf11f34c0ffb2459981b1/WebHD_720p.mp4?__gda__=1405633335_6d7fc73afe01a392de58247dcc00a529&filedownload=attachment

Chapter 18. how to generate a targeted wordlist for password cracking
File name: generateatargetedwordlistforpasswordcracking.mp4
Link: https://sknowbucket-a.akamaihd.net/2013-09-30_05-57-07-4b3a4ba00c3acb3d69a4d8c4929638c4/WebHD_720p.mp4?__gda__=1405633335_944c4b599b3e6b828205bcec973ca259&filedownload=attachment

Chapter 19. information intelligence with Maltego
File name: informationintelligencewithMaltego.mp4
Link: https://sknowbucket-a.akamaihd.net/2013-09-30_08-40-02-0f6ccec6289b617b08bf1761ab299354/WebHD_720p.mp4?__gda__=1405633336_409dcbffe6982340d8b93a9d625104d9&filedownload=attachment

Chapter 20. Google Search Techniques for penetration testers
File name: GoogleSearchTechniquesforpenetrationtesters.mp4
Link: https://sknowbucket-a.akamaihd.net/2013-09-30_08-46-45-52961f997a4535a7abff091be7a0e9b9/WebHD_720p.mp4?__gda__=1405633336_8590a103a67540396c2fccdbdb3cb782&filedownload=attachment

Chapter 21. other search engines for penetration testers
File name: Othersearchenginesforpenetrationtesters.mp4
Link: https://sknowbucket-a.akamaihd.net/2013-09-30_05-56-26-f73f415bec0dfd8e86a4ab6e65da9498/WebHD_720p.mp4?__gda__=1405633337_06a3de0b51a7ef8caae20270f03999dc&filedownload=attachment

Chapter 22. Enumerating Internal Network From Outside
File name: EnumeratingInternalNetworkFromOutside.mp4
Link: https://sknowbucket-a.akamaihd.net/2013-09-30_05-10-22-1eb47c83fea468299e58000430627783/WebHD_720p.mp4?__gda__=1405633337_2dcb3f682188ab65b1f6092334c3249d&filedownload=attachment

Chapter 23. gather information using WhatWeb, HttpRecon and SSL SCAN
File name: WhatWebHttpReconandSSLSCAN.mp4
Link: https://sknowbucket-a.akamaihd.net/2013-09-30_06-00-54-0f051ced02577053a29fbb525d575653/WebHD_720p.mp4?__gda__=1405633338_7e0542e63718dc58002f1f5a40e31684&filedownload=attachment

Chapter 24. Whois Lookups, finding other Web Sites Hosted on a Web Server
File name: Whoisandotherwebsites.mp4
Link: https://sknowbucket-a.akamaihd.net/2013-09-30_05-58-44-fe1e23878431e05e4be8b3c85b44211e/WebHD_720p.mp4?__gda__=1405633338_c3f49ce95ff57ddb20c5eeac35eb4179&filedownload=attachment

Chapter 25. IP Address Geolocation
File name: IPAddressGeolocation.mp4
Link: https://sknowbucket-a.akamaihd.net/2013-09-30_05-54-19-d1cb3251403bef64225a2da11f930785/WebHD_720p.mp4?__gda__=1405633339_279940e07a17ff9ea0d95000547f5320&filedownload=attachment

Chapter 26. finding subdomains, extracting exif data and finding hidden web dirs
File name: findingsubdomainsexifdataandrobots.mp4
Link: https://sknowbucket-a.akamaihd.net/2013-09-30_05-59-12-3ab312685fa771da694849989975bfdb/WebHD_720p.mp4?__gda__=1405633339_c6ef71c927fc714a87987afd0e60112d&filedownload=attachment

Chapter 27. ShodanHQ for fun and profit
File name: ShodanHQforfunandprofit.mp4
Link: https://sknowbucket-a.akamaihd.net/2013-09-30_05-58-37-b47408d62dca66a53be97b172533a2ff/WebHD_720p.mp4?__gda__=1405633328_b0c686f0249c294962b823208867b43d&filedownload=attachment%3Bfilename%3Dshodanhqforfunandprofitmp4.mp4

Chapter 28. Web Application Firewall Detection, HTTP and DNS load balancer detection
File name: WAFandLoadBalancersDetection.mp4
Link: https://sknowbucket-a.akamaihd.net/2013-09-30_07-36-09-7a48ff856ed417db45cd1613f8a043da/WebHD_720p.mp4?__gda__=1405633340_0ac879dc2d450864830ce43ef6e1bee6&filedownload=attachment

Chapter 29. DNS Enumerating for penetration testers
File name: DNSEnumerating.mp4
Link: https://sknowbucket-a.akamaihd.net/2013-09-30_05-12-16-bf772604b02808cd5caa593ad478c5cc/WebHD_720p.mp4?__gda__=1405633340_b37f86ce2dfb7c95a1857a28d66aafab&filedownload=attachment

Chapter 30. Mail Server Enumeration for penetration testers
File name: EnumeratingMailServer.mp4
Link: https://sknowbucket-a.akamaihd.net/2013-09-30_08-53-20-f87eb1767e1c349976fc40a6d935927e/WebHD_720p.mp4?__gda__=1405633341_622c08463f9678183c8acea827907eb6&filedownload=attachment

Chapter 31. Intel Gathering Methodology for penetration testers
File name: IntelGatheringMethodology.mp4
Link: https://sknowbucket-a.akamaihd.net/2013-09-30_08-38-06-27b8159caa30b8a1cb10068c01f3f1f9/WebHD_720p.mp4?__gda__=1405633341_f3744acec514ce11a23fed8bf88736ff&filedownload=attachment

Section 3. Scanning and vulnerability Assessment

Chapter 32. packet Crafting and Manipulating with Scapy
File name: PacketCraftingandManipulatingwithScapy.mp4
Link: https://sknowbucket-a.akamaihd.net/2013-09-30_05-59-12-cf21674c636b66676c0ec24f745ea699/WebHD_720p.mp4?__gda__=1405633342_0f8b0922524d3da9472df81ac18a6bd1&filedownload=attachment

Chapter 33. port scanning with scapy
File name: portscanningwithscapy.mp4
Link: https://sknowbucket-a.akamaihd.net/2013-09-30_05-56-28-cdb4fdafeedb2d33b0050d418cbee043/WebHD_720p.mp4?__gda__=1405633328_362c9cf7ac8bc6784a4509b4c11fa280&filedownload=attachment%3Bfilename%3Dportscanningwithscapymp4.mp4

Chapter 34. Network Enumeration and Mapping Techniques
File name: NetworkEnumerationandMapping.mp4
Link: https://sknowbucket-a.akamaihd.net/2013-09-30_08-38-28-5b869517c7aae103de2e3e609e260ad7/WebHD_720p.mp4?__gda__=1405633342_fedb0325fb6f1db5bd7c8b2e64a0d108&filedownload=attachment

Chapter 35. Network scanning techniques
File name: networkscaning.mp4
Link: https://sknowbucket-a.akamaihd.net/2013-09-30_06-04-36-d13cea9d2d62e7f46c39c3ad63610692/WebHD_720p.mp4?__gda__=1405633343_038ef25df0f5429d972c83e2883911d9&filedownload=attachment

Chapter 36. Vulnerability Identification and Assessment techniques
File name: VulnerabilityIdentificationandAssessment.mp4
Link: https://sknowbucket-a.akamaihd.net/2013-09-30_07-37-04-6cd5ac881a3927401a9732d9db284cc6/WebHD_720p.mp4?__gda__=1405633343_d59b4f4deea4acaa994ab56476bce28d&filedownload=attachment

Chapter 37. Practical Evasion and avoidance Techniques
File name: EvasionandavoidanceTechniques.mp4
Link: https://sknowbucket-a.akamaihd.net/2013-09-30_05-11-28-8c6fabb19a5f8ac85672786f8b306c6b/WebHD_720p.mp4?__gda__=1405633343_980c45c2bde1af1ccc3b62e262ecb3e2&filedownload=attachment

Section 4. Network Attacking Techniques

Chapter 38. Password cracking, MITM, Sniffing SSL and RDP Attacks
File name: module4.mp4
Link: https://sknowbucket-a.akamaihd.net/2013-09-30_06-04-56-393b234b3a01e61bfb72f91031b1db86/WebHD_720p.mp4?__gda__=1405633344_b63233fbafc86c1ececa8a4f6377a8e2&filedownload=attachment

Section 5. Windows and Linux Attacking Techniques

Chapter 39. Windows Security Overview for Penetration Testers
File name: WindowsSecurityOverviewforPenetrationTesters.mp4
Link: https://sknowbucket-a.akamaihd.net/2013-09-30_08-54-10-7f5f4262bce22d65479122a05f5aefbb/WebHD_720p.mp4?__gda__=1405633344_8338e8398d551c219feff06e8f8faab6&filedownload=attachment

Chapter 40. Linux Security Overview for Penetration Testers
File name: UnixSecurityOverviewforPenetrationTesters.mp4
Link: https://sknowbucket-a.akamaihd.net/2013-09-30_08-48-55-ee6ffd440246ae961aaae83b81438e67/WebHD_720p.mp4?__gda__=1405633346_a5fc5c07eec9133c52202475872efb46&filedownload=attachment

Chapter 41. Attacking and Hacking Windows
File name: AttackingWindows.mp4
Link: https://sknowbucket-a.akamaihd.net/2013-09-30_05-14-25-a76aa25fa37624873f4b32ef8dfc29ff/WebHD_720p.mp4?__gda__=1405633346_8828abdce7a9db7ea94b0cdef8319397&filedownload=attachment

Chapter 42. Attacking and Hacking Linux
File name: AttackingUnix.mp4
Link: https://sknowbucket-a.akamaihd.net/2013-09-30_05-11-27-4e9b6ae0f4831efd8cde29901a2a57f3/WebHD_720p.mp4?__gda__=1405633347_a0293cddef422a7b699d43185ad4e08a&filedownload=attachment

Section 6. Windows and Linux Post-Exploitation Techniques

Chapter 43. Windows post exploitation techniques
File name: TacticalPostExploitationTechniquesWindows.mp4
Link: https://sknowbucket-a.akamaihd.net/2013-09-30_09-03-47-2558a5d56bba644970d47cbc9318ec38/WebHD_720p.mp4?__gda__=1405633347_291748ffc0dd36de038527aa41379284&filedownload=attachment

Chapter 44. Linux post exploitation techniques
File name: TacticalPostExploitationTechniquesUnix.mp4
Link: https://sknowbucket-a.akamaihd.net/2013-09-30_09-04-12-48e6a374c4e53da5a6dcaab4e40f9400/WebHD_720p.mp4?__gda__=1405633348_370453631dbe32d6a22e96b71f744557&filedownload=attachment

Chapter 45. Data mining techniques
File name: datamining.mp4
Link: https://sknowbucket-a.akamaihd.net/2013-09-30_05-08-57-c312b7ae53c9c1788f674e5fc5a138ca/WebHD_720p.mp4?__gda__=1405633348_5e444c134fe053701a717a88d4cb9571&filedownload=attachment

Section 7. Web Exploitation Techniques

Chapter 46. Web Application Primer
File name: WebApplicationPrimer.mp4
Link: https://sknowbucket-a.akamaihd.net/2013-09-30_08-55-58-9eb5009c123e14ba51b427c4b4a38054/WebHD_720p.mp4?__gda__=1405633349_245ebaa07a433bf60b5088ff808f18b0&filedownload=attachment

Chapter 47. Web Application Scanning and Mapping
File name: WebApplicationScanningandMapping.mp4
Link: https://sknowbucket-a.akamaihd.net/2013-09-30_08-56-29-8d0c95a1bf1984a73ea72acfe6a91bfe/WebHD_720p.mp4?__gda__=1405633349_2fcd584e340bba87c5bd3fbd5d89c603&filedownload=attachment

Chapter 48. Exploiting SQL Injection to Full System Access (MYSQL)
File name: ExploitingSQLInjectionMYSQLtoFullSystemAccess.mp4
Link: https://sknowbucket-a.akamaihd.net/2013-09-30_06-07-33-94075a6fc2b93fd1b1577eacdb7abe0d/WebHD_720p.mp4?__gda__=1405633328_944fda129506961408913c40a5722904&filedownload=attachment%3Bfilename%3Dexploitingsqlinjectionmysqltofullsystemaccessmp4.mp4

Chapter 49. Exploiting SQL Injection to Full System Access (MSSQL)
File name: ExploitingSQLInjectionMSSQLtoFullSystemAccess.mp4
Link: https://sknowbucket-a.akamaihd.net/2013-09-30_08-53-16-3b0cfd0318044e9de46627f2790747cd/WebHD_720p.mp4?__gda__=1405633350_9e2f1bd840ce7b134fd9619a08294914&filedownload=attachment

Chapter 50. Exploiting Blind SQL Injection to Full System Access (MYSQL)
File name: ExploitingBlindSQLInjectionMYSQLtoFullSystemAccess.mp4
Link: https://sknowbucket-a.akamaihd.net/2013-09-30_05-11-14-ce7b8cfa132b7383777e17c8a70fd3c5/WebHD_720p.mp4?__gda__=1405633350_2bc7f694db243c7f181ac0df507278b5&filedownload=attachment

Chapter 51. Exploiting Blind SQL Injection to Full System Access (MSSQL)
File name: ExploitingBlindSQLInjectionMSSQLtoFullSystemAccess.mp4
Link: https://sknowbucket-a.akamaihd.net/2013-09-30_09-03-07-a9c430be43d02e6323e2a1765ce857c6/WebHD_720p.mp4?__gda__=1405633351_31fd04fbdeaafcb5f7a75693e41a1d8c&filedownload=attachment

Chapter 52. Exploiting RFI, Local File include, File Uploads and RCE
File name: ExploitingFilehandlingandcmdexecvulns.mp4
Link: https://sknowbucket-a.akamaihd.net/2013-09-30_05-12-16-9313125c96f240a67e8748ef74773c8c/WebHD_720p.mp4?__gda__=1405633351_2089972431bf6d72ac1a655bb8e88ec0&filedownload=attachment

Chapter 53. Exploiting XSS ( Reflected and Stored ) and CSRF to Full System Access
File name: ExploitingXSSandCSRF.mp4
Link: https://sknowbucket-a.akamaihd.net/2013-09-30_09-02-49-75f95af78854dbb70ba1b74b9a30d6f5/WebHD_720p.mp4?__gda__=1405633352_1cc4380ca2e57d8e68d82a838f9ad632&filedownload=attachment

Section 8. Windows Exploit Development

Chapter 54. Using Immunity Debugger and Metasploit to develop a windows exploit
File name: Module8Windowsexploitdevelopment.mp4
Link: https://sknowbucket-a.akamaihd.net/2013-09-30_09-08-20-7af8d95e3f18436d5ad97d80a6b2a8d8/WebHD_720p.mp4?__gda__=1405633352_2f5b774ad9431ae7caf5914fa4a6a2d6&filedownload=attachment

Section 9. The end but it is not the end :)

Chapter 55. The end
File name: Final
Link: https://sknowbucket-a.akamaihd.net/2013-10-01_15-57-44-b9b8ee680f7b084642adbac6bc559580/WebHD_720p.mp4?__gda__=1405633353_433c9d6a9c17d49ae6c4f1b9989ca9fe&filedownload=attachment
« Last Edit: July 18, 2014, 07:22:51 pm by daxda »

Offline diga123

  • NULL
  • Posts: 1
  • Cookies: -2
    • View Profile
Re: [Python] Udemy course extractor
« Reply #1 on: September 10, 2014, 10:55:02 am »
how i can work with it
can u explain plz
because i have the error in the line 2
with Import Requests

Offline RedBullAddicted

  • Moderator
  • Sir
  • *
  • Posts: 519
  • Cookies: 189
    • View Profile
Re: [Python] Udemy course extractor
« Reply #2 on: September 10, 2014, 11:35:35 am »
Please provide the complete error message you get next time. I guess you do not have the third party library requests installed. Install it and try again

Code: [Select]
http://docs.python-requests.org/en/latest/user/install/

Cheers,
RBA
Deep into that darkness peering, long I stood there, wondering, fearing, doubting, dreaming dreams no mortal ever dared to dream before. - Edgar Allan Poe

Offline iTpHo3NiX

  • EZ's Pirate Captain
  • Administrator
  • Titan
  • *
  • Posts: 2920
  • Cookies: 328
    • View Profile
    • EvilZone
Re: [Python] Udemy course extractor
« Reply #3 on: August 26, 2015, 03:33:29 am »
Necro!!! (Btw I don't know how people miss the giant block of red text when gravediggin... probably on tapatalk...)

Anyways, does anyone know of a udemy course extractor that I can just log in to and download the courses, would be pretty damn useful so I can share the few purchased courses I have, mainly all android and mobile app development. This is too much for me to do..
« Last Edit: August 26, 2015, 03:34:28 am by DeepCopy »
[09:27] (+lenoch) iTpHo3NiX can even manipulate me to suck dick
[09:27] (+lenoch) oh no that's voluntary
[09:27] (+lenoch) sorry

Offline hondo

  • NULL
  • Posts: 2
  • Cookies: 0
    • View Profile
Re: [Python] Udemy course extractor
« Reply #4 on: October 07, 2015, 04:44:46 am »
how i can work with it
can u explain plz
because i have the error in the line 2
with Import Requests

pip install requests

Offline overflow

  • Serf
  • *
  • Posts: 21
  • Cookies: 5
    • View Profile
Re: [Python] Udemy course extractor
« Reply #5 on: January 18, 2016, 10:26:18 pm »
Necro!!! (Btw I don't know how people miss the giant block of red text when gravediggin... probably on tapatalk...)

Anyways, does anyone know of a udemy course extractor that I can just log in to and download the courses, would be pretty damn useful so I can share the few purchased courses I have, mainly all android and mobile app development. This is too much for me to do..

For windows:

Code: [Select]
udemy-dl -u username -p password https://www.udemy.com/course_name
Code: (python) [Select]
#!/usr/bin/env python
# -*- coding: utf8 -*-

import requests
import requests.sessions
import argparse
import getpass
import sys
import re
import os
import json
import wget
import subprocess

# Version
__version__ = '2.0.1'

# User Agent String
useragent = 'Mozilla/5.0 (Windows NT 6.3; rv:36.0) Gecko/20100101 Firefox/36.0'

class DLException(Exception):
    """Raise if some lectured failed to download."""
    pass

def download(link, filename):
    """Download files to given destination file-name."""
    try:
        if 'pdf' in link:
            filename = filename.rstrip('mp4')+'pdf'
        elif 'mp3' in link:
            filename = filename.rstrip('mp4')+'mp3'

        if 'youtube.com' in link:
            youtube_dl(link, filename)
        else:
            try:
            aria2c_dl(link, filename)
            except OSError:
            if not os.path.exists(filename):
                try:
                curl_dl(link, filename)
                except OSError:
                if not os.path.exists(filename):
                wget.download(link, filename)
                else:
                raise DLException('Failed to download this lecture')
    except TypeError:
        print("Skipped. Url wasn't parsed properly.")


def curl_dl(link, filename):
    """Use curl as the downloader."""
    command = ['curl', '-C', '-', link, '-o', filename]

    cert_path = requests.certs.where()
    if cert_path:
        command.extend(['--cacert', cert_path])
    else:
        command.extend(['--insecure'])
    subprocess.call(command)


def dl_progress(num_blocks, block_size, total_size):
    """Show a decent download progress indication."""
    progress = num_blocks * block_size * 100 / total_size
    if num_blocks != 0:
        sys.stdout.write(4 * '\b')
    sys.stdout.write('{0:3d}%'.format((progress)))


def youtube_dl(link, filename):
    """Use youtube-dl as the downloader if videos are in youtube.com."""
    try:
        subprocess.call(['youtube-dl', '-o', filename, link])
    except OSError:
        raise DLException('Install youtube-dl to download this lecture')

def curl_dl(link, filename):
    """Use curl as the downloader."""
    command = ['curl', '-C', '-', link, '-o', filename]

    cert_path = requests.certs.where()
    if cert_path:
        command.extend(['--cacert', cert_path])
    else:
        command.extend(['--insecure'])
    subprocess.call(command)

def aria2c_dl(link, filename):
"""Use aria2c as the downloader."""
command = ['aria2c', '--continue', '--file-allocation=none', '-U', useragent, link, '-o', filename]
try:
subprocess.call(command)
except OSError:
curl_dl(link, filename)


class Session:
    """Starting session with proper headers to access udemy site"""
    headers = {'User-Agent': useragent,
               'X-Requested-With': 'XMLHttpRequest',
               'Host': 'www.udemy.com',
               'Referer': 'https://www.udemy.com/join/login-popup'}

    def __init__(self):
        self.session = requests.sessions.Session()
       
    def set_auth_headers(self, access_token, client_id):
        """ Setting up authentication headers. """
        self.headers['X-Udemy-Bearer-Token'] = access_token
        self.headers['X-Udemy-Client-Id'] = client_id
        self.headers['Authorization'] = "Bearer " + access_token
        self.headers['X-Udemy-Authorization'] = "Bearer " + access_token

    def get(self, url):
        """ Retreiving content of a given url. """
        return self.session.get(url, headers=self.headers)

    def post(self, url, data):
        """ HTTP post given data with requests object. """
        return self.session.post(url, data, headers=self.headers)


session = Session()


def get_csrf_token():
    """ Extractig CSRF Token from login page """
    response = session.get('https://www.udemy.com/join/login-popup')
    match = re.search("name=\'csrfmiddlewaretoken\' value=\'(.*)\'", response.text)
    return match.group(1)

def login(username, password):
    """ Login with popu-page. """
    login_url = 'https://www.udemy.com/join/login-popup/?displayType=ajax&display_type=popup&showSkipButton=1&returnUrlAfterLogin=https%3A%2F%2Fwww.udemy.com%2F&next=https%3A%2F%2Fwww.udemy.com%2F&locale=en_US'
    csrf_token = get_csrf_token()
    payload = {'isSubmitted': 1, 'email': username, 'password': password,
               'displayType': 'ajax', 'csrfmiddlewaretoken': csrf_token}
    response = session.post(login_url, payload)

    access_token = response.cookies.get('access_token')
    client_id = response.cookies.get('client_id')
    if access_token is None:
        print("Error: Couldn\'t fetch token !")
        sys.exit(1)
    session.set_auth_headers(access_token, client_id)

    response = response.text
    if 'error' in response:
        print(response)
        sys.exit(1)


def get_course_id(course_link):
    """ Retreiving course ID """
    response = session.get(course_link)
    matches = re.search('data-course-id="(\d+)"', response.text, re.IGNORECASE)
    return matches.groups()[0] if matches else None


def parse_video_url(course_id, lecture_id):
    """ Extracting video URLS. """
    get_url = 'https://www.udemy.com/api-2.0/users/me/subscribed-courses/{0}/lectures/{1}?video_only=&auto_play=&fields[lecture]=asset,embed_url&fields[asset]=asset_type,download_urls,title&instructorPreviewMode=False'.format(course_id, lecture_id)
    json_source = session.get(get_url).json()
   
    try:
        if json_source['asset']['download_urls']['Video']:
            list_videos = [item_ for item_ in json_source['asset']['download_urls']['Video']]
            list_videos = sorted(list_videos,key=lambda item_: int(item_['label']),reverse=True)
            for element in list_videos:
                if element['label'] == '1080':
                    return element['file']
                elif element['label'] == '720':
                    return element['file']
                elif element['label'] == '480':
                    return element['file']
                elif element['label'] == '360':
                    return element['file']
                else:
                    print('Skipped. Couldn\'t fetch video')
                    return None
    except KeyError:
        try:
            if json_source['asset']['download_urls']['E-Book']:
                for element in json_source['asset']['download_urls']['E-Book']:
                    if element['label'] == 'download':
                        return element['file']
                    else:
                        print('Skipped. Couldn\'t fetch e-book')
                        return None
        except KeyError:
            if json_source['asset']['download_urls']['Audio']:
                for element in json_source['asset']['download_urls']['Audio']:
                    if element['label'] == 'download':
                        return element['file']
                    else:
                        print('Skipped. Couldn\'t fetch audio')
                        return None
    else:
        print('Skipped. Something unexpected')
        return None


def get_video_links(course_id, lecture_start, lecture_end):
    """ Getting video links from api 1.1. """
    course_url = 'https://www.udemy.com/api-1.1/courses/{0}/curriculum?fields[lecture]=@min,completionRatio,progressStatus&fields[quiz]=@min,completionRatio'.format(course_id)
    course_data = session.get(course_url).json()

    chapter = None
    video_list = []

    lecture_number = 1
    chapter_number = 0
    # A udemy course has chapters, each having one or more lectures
    for item in course_data:
        if item['__class'] == 'chapter':
            chapter = item['title']
            chapter_number += 1

        elif item['__class'] == 'lecture' and (item['assetType'] == 'Video' or item['assetType'] == 'E-Book' or item['assetType'] == 'VideoMashup' or item['assetType'] == 'Audio'):
            lecture = item['title']
            if valid_lecture(lecture_number, lecture_start, lecture_end):
                try:
                    lecture_id = item['id']
                    video_url = parse_video_url(course_id, lecture_id)
                    video_list.append({'chapter': chapter,
                                       'lecture': lecture,
                                       'video_url': video_url,
                                       'lecture_number': lecture_number,
                                       'chapter_number': chapter_number})
                except Exception as e:
                    print('Cannot download lecture "{0!s}"'.format((lecture)))
            lecture_number += 1
    return video_list


def valid_lecture(lecture_number, lecture_start, lecture_end):
    """ Testing if the given lecture number is valid and exisit. """
    if lecture_start and lecture_end:
        return lecture_start <= lecture_number <= lecture_end
    elif lecture_start:
        return lecture_start <= lecture_number
    else:
        return lecture_number <= lecture_end


def sanitize_path(s):
    """ Cleaning up path for saving files. """
    return "".join([c for c in s if c.isalpha() or c.isdigit() or c in ' .-_,']).rstrip()


def mkdir(directory):
    """ Creating output directory structure, if not exisit. """
    if not os.path.exists(directory):
        os.makedirs(directory)


def get_video(directory, filename, link):
    """ Get video content. """
    print('Downloading {0!s}  '.format((filename.encode('utf-8'))))
    previous_dir = os.getcwd()
    mkdir(directory)
    os.chdir(directory)
    try:
        download(link, filename)
    except DLException as e:
        print('Couldn\'t download this lecture: {0}'.format(e))
    os.chdir(previous_dir)
    print('\n'),


def save_link(url):
    """save links to a file named links.txt"""
    url_str = str(url)
    with open('links.txt', 'a') as sv_file:
        sv_file.write(url_str + '\n')
        sv_file.close()


def udemy_dl(username, password, course_link, lecture_start, lecture_end, dest_dir="", save_links = None):
    """ Login into udemy and do all magic. """

    login(username, password)

    course_id = get_course_id(course_link)
    if not course_id:
        print('Failed to get course ID')
        return

    for video in get_video_links(course_id, lecture_start, lecture_end):
        if save_links:
            save_link(video['video_url'])
        else:
            directory = '{0:02d} {1!s}'.format(video['chapter_number'], video['chapter'].encode('utf-8'))
            directory = sanitize_path(directory)

            if dest_dir:
                directory = os.path.join(dest_dir, directory)

            filename = '{0:03d} {1!s}.mp4'.format(video['lecture_number'], video['lecture'].encode('utf-8'))
            filename = sanitize_path(filename)

            get_video(directory, filename, video['video_url'])
           
    if os.path.exists('links.txt'):
        print('links saved to file successfully.')

    session.get('http://www.udemy.com/user/logout')


def is_integer(p):
    """ Check if given value is an intiger. """
    try:
        int(p)
        return True
    except ValueError:
        return False

def main():
    """ Accepting arguments and preparing """
    parser = argparse.ArgumentParser(description='Fetch all the videos for a udemy course')
    parser.add_argument('link', help='Link for udemy course', action='store')
    parser.add_argument('-u', '--username', help='Username/Email', default=None, action='store')
    parser.add_argument('-p', '--password', help='Password', default=None, action='store')
    parser.add_argument('--lecture-start', help='Lecture to start at (default is 1)', default=1, action='store')
    parser.add_argument('--lecture-end', help='Lecture to end at (default is last)', default=None, action='store')
    parser.add_argument('-o', '--output-dir', help='Output directory', default=None, action='store')
    parser.add_argument('-s', '--save-links', help='Do not download but save links to a file', action='store_const', const=True, default=None)
    parser.add_argument('-v', '--version', help='Display the version of udemy-dl and exit', action='version', version='%(prog)s {version}'.format(version=__version__))

    args = vars(parser.parse_args())

    username = args['username']
    password = args['password']
    link_args = args['link']
    link = re.search( r'(https://www.udemy.com/.*?)/', link_args+'/').group(1)
    lecture_start = args['lecture_start']
    lecture_end = args['lecture_end']
    save_links = args['save_links']

    if lecture_start is not None:
        if not is_integer(lecture_start) or int(lecture_start) <= 0:
            print('--lecture_start requires natural number argument')
            sys.exit(1)
        lecture_start = int(lecture_start)
    if lecture_end is not None:
        if not is_integer(lecture_end) or int(lecture_end) <= 0:
            print('--lecture_end requires natural number argument')
            sys.exit(1)
        lecture_end = int(lecture_end)
   
    if args['output_dir']:
        # Normalize the output path if specified
        output_dir = os.path.normpath(args['output_dir'])
    else:
        # Get output dir name from the URL
        output_dir = os.path.join(".", link.rsplit('/', 1)[1])

    if not username:
        try:
            username = raw_input("Username/Email: ")  # Python 2
        except NameError:
            username = input("Username/Email: ")  # Python 3

    if not password:
        password = getpass.getpass(prompt='Password: ')

    print('Downloading to: {0!s}\n'.format((os.path.abspath(output_dir))))

    udemy_dl(username, password, link, lecture_start, lecture_end, output_dir, save_links)


if __name__ == '__main__':
    main()
"Personally, I make it a habit to avoid habits."

Offline MadJack

  • NULL
  • Posts: 3
  • Cookies: -29
    • View Profile
Re: [Python] Udemy course extractor
« Reply #6 on: January 25, 2016, 10:27:31 pm »
Thanks a lot for the scripts. Can someone add the captions download feature please? I really need them. I also bought the "Udemy Paid Course Downloader" exploit from 0day.today (150$) but it doesn't work so I decided to leak and publish the script here:
Code: [Select]
This Tool Bypasses any Paid Udemy Course and Download it Without Paying a Single Peny.
Requirments: Full Course URL
Example: https://www.udemy.com/become-an-android-developer-from-scratch/
ONLY.
Usage info:
This Tools is Coded in Python So You'll Need to Have Python Installed and Some Python Libraries on Your PC.
Then all You Got To Do is to Run The Tool and Feed it The Course URL.


Secret Code:
#!/usr/bin/env python
# -*- coding: utf8 -*-
'''
Before You Run The Tool You Must Have Those Libraries Installed
BeautifulSoup , Fake-Factory , requests



Download Links:
requests: https://pypi.python.org/packages/source/r/requests/requests-2.3.0.tar.gz
BeautifulSoup: https://pypi.python.org/packages/source/b/beautifulsoup4/beautifulsoup4-4.3.2.tar.gz
Fake-Factory: https://pypi.python.org/packages/source/f/fake-factory/fake-factory-0.4.0.tar.gz

How To Install:
Extract Each Folder Separatedly , Open cmd , cd into New Directories , finally execute "python setup.py build&python setup.py install" if on windows ... and if on linux execute "python setup.py build;python setup.py install"

For any Error Report @ http://fb.me/eve.dized
'''
import requests, urllib, sys, re, os, json, urllib2, cookielib
from bs4 import BeautifulSoup
from faker import Factory
try:
    from urllib import urlretrieve
except:
    from urllib.request import urlretrieve


class Session:
    headers = {'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64; rv:18.0) Gecko/20100101 Firefox/18.0',
               'X-Requested-With': 'XMLHttpRequest',
               'Referer': ' http://www.udemy.com/'}

    def __init__(self):
        self.session = requests.Session()

    def get(self, url):
        return self.session.get(url, headers=self.headers)

    def post(self, url, data):
        return self.session.post(url, data, headers=self.headers)


session = Session()


def get_csrf_token(url):
    response = session.get(url)
    soup = BeautifulSoup(response.text)
    return soup.find_all('input', {'name': 'csrf'})[0]['value']


def register():
cj = cookielib.CookieJar()
httper = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
httper.addheaders.append(('User-Agent','Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Firefox/31.0'))
csrf_grabber = httper.open('https://www.udemy.com/join/signup-submit/')
csrf_value = re.findall('csrf: \'(.*)\'',csrf_grabber.read())[0]
fake = Factory.create()
fake_name = fake.name()
fake_email = fake.email()
fake_password = fake_email
register_request = httper.open('https://www.udemy.com/join/signup-submit/','locale=en_US&isSubmitted=1&csrf='+csrf_value+'&fullName='+urllib.quote_plus(fake_name)+'&email='+urllib.quote_plus(fake_email)+'&password='+urllib.quote_plus(fake_password)+'&timeZone=Africa%2FHarare&displayType=json')
register_json_response = json.loads(register_request.read())['returnUrl']

if register_json_response=='https://www.udemy.com/user/complete-signup/':
print "[+] Fake Auth Generated & Registered Successfully: name="+fake_name+"; email="+fake_email+"; password="+fake_password+";"
return fake_email
else:
print "[-] Could Not Register New User ... Try Again"


def login(username, password):
    login_url = 'https://www.udemy.com/join/login-submit'
    csrf_token = get_csrf_token('https://www.udemy.com/join/login-popup')
    payload = {'isSubmitted': 1, 'email': username, 'password': password,
               'displayType': 'json', 'csrf': csrf_token}
    response = session.post(login_url, payload).json()
    if 'error' in response:
        print(response['error']['message'])
        sys.exit(1)


def get_course_id(course_link):
    response = session.get(course_link)
    matches = re.search('data-course-id="(\d+)"', response.text)
    return matches.groups()[0]


def parse_video_url(lecture_id):
    embed_url = 'https://www.udemy.com/embed/{0}'.format(lecture_id)
    html = session.get(embed_url).text

    data = re.search(r'\$\("#player"\).jwplayer\((.*?)\);.*</script>', html,
                     re.MULTILINE | re.DOTALL).group(1)
    video = json.loads(data)

    if 'playlist' in video and 'sources' in video['playlist'][0]:
        source = video['playlist'][0]['sources'][0]
        return source['file']
    else:
        return None


def get_video_links(course_id):
    course_url = 'https://www.udemy.com/api-1.1/courses/{0}/curriculum?fields[lecture]=@min,completionRatio,progressStatus&fields[quiz]=@min,completionRatio'.format(course_id)
    course_data = session.get(course_url).json()

    chapter = None
    video_list = []

    lecture_number = 0
    chapter_number = 0
    session.get('https://www.udemy.com/course/preview-subscribe/?courseId='+course_id)
    for item in course_data:
        if item['__class'] == 'chapter':
            chapter = item['title']
            chapter_number += 1
            lecture_number = 1
        elif item['__class'] == 'lecture' and item['assetType'] == 'Video':
            lecture = item['title']
            try:
                lecture_id = item['id']
                video_url = parse_video_url(lecture_id)
                video_list.append({'chapter': chapter,
                                   'lecture': lecture,
                                   'video_url': video_url,
                                   'lecture_number': lecture_number,
                                   'chapter_number': chapter_number})
            except:
                print('Cannot download lecture "%s"' % (lecture))
            lecture_number += 1
    return video_list


def sanitize_path(s):
    return "".join([c for c in s if c.isalpha() or c.isdigit() or c in ' .-_,']).rstrip()


def mkdir(directory):
    if not os.path.exists(directory):
        os.makedirs(directory)


def dl_progress(num_blocks, block_size, total_size):
    progress = num_blocks * block_size * 100 / total_size
    if num_blocks != 0:
        sys.stdout.write(4 * '\b')
    sys.stdout.write('%3d%%' % (progress))


def get_video(directory, filename, link):
    print('[+] %s  <======> ' % (filename)),
    mkdir(directory)
    os.chdir(directory)
    if not os.path.exists(filename):
        urlretrieve(link, filename, reporthook=dl_progress)
    os.chdir('..')
    print ' Finished'


def udemy_dl(username, password, course_link):
    login(username, password)
    course_id = get_course_id(course_link)

    for video in get_video_links(course_id):
        directory = '%02d %s' % (video['chapter_number'], video['chapter'])
        filename = '%03d %s.mp4' % (video['lecture_number'], video['lecture'])

        directory = sanitize_path(directory)
        filename = sanitize_path(filename)

        get_video(directory, filename, video['video_url'])

    session.get('http://www.udemy.com/user/logout')


def main():
    link = raw_input("[+] Udemy Course Url: ")
    login = register()
    udemy_dl(login, login, link)


if __name__ == '__main__':
    main()

If somebody is able to fix and update the exploit please PM me! :P I want to download all the courses and release them for free.

Offline TeamVega

  • Serf
  • *
  • Posts: 32
  • Cookies: -2
    • View Profile
Re: [Python] Udemy course extractor
« Reply #7 on: January 26, 2016, 03:41:22 pm »
Why dont you use
https://github.com/nishad/udemy-dl-windows

register on udemy using a fake email, click on start Free Preview and then run the utility, it will download in the background all the videos.

Offline MadJack

  • NULL
  • Posts: 3
  • Cookies: -29
    • View Profile
Re: [Python] Udemy course extractor
« Reply #8 on: January 26, 2016, 07:23:35 pm »
register on udemy using a fake email, click on start Free Preview and then run the utility, it will download in the background all the videos.

Thanks a lot man. This technique works (tested with udemy-dl Linux version)!