精華區beta EZsoft 關於我們 聯絡資訊
既然 coca 都開口了,我就針對 Hinedo 寫一份 hacking guide 希望下次 hinet 改版的時候,各位可以比我先修改好相關程式 然後寄給我 :P 其實這些抓法都是從閱讀網頁原始碼來的,需要略懂 html,我示範一次: 這個範例,是假設你從 hinet 網頁點進 HitFm 聯播網 台中91.5 進去 網址為 http://hichannel.hinet.net/radio/radio.jsp?chid=88 檢視原始碼: 在網頁上可以內嵌影片,需要使用 object 或 embed 這兩個 html 標籤 於是在網頁原始碼中尋找 <object 或 <embed 字樣,可是卻找不到? 這表示,如果那段不是用 javascript 動態產生的,就是用 iframe 從其他網頁引入 果然,原始碼中找到多處 iframe 標籤,而在其中,這行顯然看起來最像是我們的目標 (如果不知道哪個才是,可以一個一個試連,網址開頭 ad.hinet 看就知道是廣告,免試) <iframe width="378" height="338" frameborder="0" scrolling="no" src="../player/player-radio2.jsp?id=88"> src=後面就是播放介面的網址,開頭的 ../ 是相對路徑,表示到目前網址的上一層目錄 也就是 http://hichannel.hinet.net/radio/ 的上一層 所以合起來就是 http://hichannel.hinet.net/player/player-radio2.jsp?id=88 於是,我們再次連到 http://hichannel.hinet.net/player/player-radio2.jsp?id=88 再次進入網頁原始碼 還是找不到 embed 或 object,表示嵌入播放器的不是目前網頁,還要再找 整個檔案並不長,稍微閱讀之後,我們發現機關藏在 javascript 內 play = openPlayer = function() { w = window.open('/player/radio-f1.jsp?id=88','hichannelPlayer', 'width=675,height=530,scrollbars=yes,resizable=no,status=no, toolbar=no,menubar=no,location=no'); try{w.focus()}catch(e){}; return false; } window.open 這個函數,就是會開新的視窗,而第一個參數就是新視窗的網址 也就是 /player/radio-f1.jsp?id=88 剛剛 ../ 是表示上一層,而 / 是表示根目錄,就是所有目錄的最上層 也就是主機網址 + /,就是 http://hichannel.hinet.net/ 所以 /player/radio-f1.jsp?id=88 完整的網址,就是在 http://hichannel.hinet.net/player/radio-f1.jsp?id=88 再次連線到這個網址,果然被我們逮到了! 再看原始碼... 程式有點長,不過,耐心還是找得到... setMovieFile("../api/streamFreeRadio.jsp?id=88&r="+(new Date()). getTime(),playerwidth,1,1); 這個函數看起來就有鬼,主要是從 ?id=88 看出來的,88 是電台代碼 可以注意到剛剛一層一層剝進來的時候,網址都帶著 ?id=88 這個參數 一樣,找出完整的網址: http://hichannel.hinet.net/api/streamFreeRadio.jsp?id=88 後面本來還有用 javascript 依照日期時間,動態產生的參數 r 但是經過測試 Hinet 並沒有檢查這參數,省略照樣可以播放, 看來只是用來混淆視聽的,所以,就拿掉它吧。 連到我們剛找出的網址 http://hichannel.hinet.net/api/streamFreeRadio.jsp?id=88 接著連到這個網址,用瀏覽器有時候沒辦法取得這個頁面的原始碼 原因我並不清楚,我是在 Linux 下用 wget 或是其他工具抓網頁下來的 看原始碼會發現少少的沒幾行,而電台的網址就在一行 HREF="" 的裡面 用 regular expression 很容易就可以抽出來了 詳解 Hinedo 的 Play.vbs Option explicit Dim sh, reg, matches, match, page, url, base '這個網址就是上面我們抓出來的網址 base = "http://hichannel.hinet.net/api/streamFreeRadio.jsp?id=" url = base + WScript.Arguments(0) <<--- 第一個命令列參數為電台代碼 Set sh = CreateObject("WScript.Shell") Function Download( url_to_download ) 用來呼叫主程式下載網頁的函數 Dim o Set o = sh.Exec( """Hinedo.exe"" dl " + url_to_download ) Download = o.StdOut.Readall Set o = Nothing End Function Set reg = New RegExp reg.Global=True reg.IgnoreCase = True 'regular expression 忽略大小寫差異 page = Download( url ) reg.Pattern = "HREF=""([^""]*)"".*>" Set matches = reg.Execute( page ) If matches.Count = 0 Then MsgBox "Error!" WScript.Quit 1 End If url = matches(0).SubMatches(0) page = Download( url ) reg.Pattern = "HREF=""([^""]*)"".*>" Set matches = reg.Execute( page ) If matches.Count = 0 Then MsgBox "Error!" WScript.Quit 1 End If url = matches(0).SubMatches(0) '如果有找到網址,則丟給主程式,否則秀'錯誤' If url <> "" Then sh.Run """Hinedo.exe"" " + url Else MsgBox "Error!" End If -- 個人網頁: http://pcman.sayya.org/ 上面有自畫像及各種聯絡資訊 PCMan 全系列 BBS 連線軟體 http://pcman.ptt.cc/ http://pcmanx.csie.net/ 新酷音輸入法 for Windows http://chewing.csie.net/ IE Tab Firefox plugin/extension http://ietab.mozdev.org/ PCMan 油畫作品集:http://www.wretch.cc/album/album.php?id=pcman&book=1 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 163.29.223.38
hatebus:再推~ 11/24 23:40
mantohu:good ! 11/25 08:08
danial:門外漢問一下, 是用什麼程式語言寫的呢? 11/25 08:21
timyau:visual basic 11/25 08:44
timyau:script .. 11/25 08:44
HZYSoft:VBScript,Windows 內建,好讀好寫,不用裝額外軟體 11/25 08:48
EvilBrave:我以為是用 PERL 寫的 XD 11/25 10:52
JFCC:題外話問一下...我一直找不到電腦不給我執行vbs的原因 11/25 11:10
JFCC:有沒有人有什麼樣的建議@@ 可以讓他復活orz 11/25 11:11
jimshow2001:防毒吧 大大寫的在我的電腦上也跑不順..K牌真機車 11/25 11:54
holanet:我是 Hola,基本上我的 HiRadio 也是跟 HZYSoft 是相同的 11/25 12:09
holanet:不過我有點討厭 Hinet 的方式,要人看廣告也不是這樣搞的 11/25 12:10
JFCC:不是防毒XD 因為他根本就找不到WScript.exe根本就不執行 11/25 12:30
yinjing:搞得好像在做偵探節目 囧 11/26 08:35