美和易思app协议分析及反编译思路解析

获取apk文件

点击下载

反编译apk

  1. apktool.bat;apktool.jar
    作用:最大程度的还原apk中的manifest文件和资源文件 。使用apktool工具反编译apk文件比直接解压同一个apk文件大;还可以将反编译之后的apk重新打包成apk文件,但需要重新签名,才能安装使用。 
  2. classes-dex2.jar
    作用:将APK直接解压后,目录下包含的一个classes.dex文件反编译为
  3. dex2jar
    作用:直接查看classes-dex2jar.jar文件

分析反编译后的包体

查看包体,会得到assets目录,如图


美和易思app协议分析及反编译思路解析
-程序员阿鑫-带你一起秃头!
-第1
张图片

apps目录则是app的核心代码,这里没有经过原生安卓的方法,因为经过分析,此app是使用MUI,用js编写的app,为webview,所有核心代码都在此目录!我们使用HbuilderX打开此目录,则app的工程文件自动显示,接下来,我们可以随意查看代码


美和易思app协议分析及反编译思路解析
-程序员阿鑫-带你一起秃头!
-第2
张图片

分析代码业务逻辑

查看代码后,我们会得到如下信息:
1. app接口: http://api.51moot.cn/api/

  1. 静态资源网址: https://mootimg.oss-cn-beijing.aliyuncs.com/Moot/ 
  2. 核心sign获取接口:http://api.51moot.cn/api/v1/sign

所有请求都会验证sign的正确性,不过可笑的是这个sign是固定的!

分析播放业务逻辑

通过查阅代码,我们可以找到视频播放页面是course_vedio.html,核心代码course_vedio.js文件,以下是播放器初始化代码,可以看出只需要传入我们的用户ID就可以统计时长


美和易思app协议分析及反编译思路解析
-程序员阿鑫-带你一起秃头!
-第3
张图片

通过百度查找polyvObject方法,我们可以得到这是保利威公司的播放器sdk,核心依赖sdk文档->点击查看
至此,我们只需要拼接所需信息即可完成模拟播放,以下是我封装过的接口,使用php语言编写,通过此接口我们可以得到任何想要的信息

更新日志:

2021-01-07:
(1.)支持学生账户提取试卷及一键答题
2020-10-28:
(1.)修复APP外部与内部进度不同步的问题
2020-09-02:
(1.)修复节点失效
2020-08-17:
(1.)增加一键秒刷
2020-06-03:
(1.)增加pc协议支持
(2.)增加pc cookie提取
(3.)增加pc协议的视频加密信息获取
(4.)网站同时支持falsh和h5内核,播放更加流畅
(5.)优化答题业务逻辑

  1. <?php
  2. namespace SinKingCloud;
  3. class Mstanford
  4. {
  5. private $ApiUrl = array(‘pc’ => ‘https://www.51moot.net/’, ‘mobile’ => ‘http://112.126.118.66/’);
  6. private $sign; //签名
  7. private $UserInfo; //账户信息
  8. public $cookies = null; //pc cookie
  9. /**
  10. *构造参数
  11. */
  12. function __construct($ApiUrl = false, $sign = false)
  13. {
  14. if ($ApiUrl) {
  15. $this->ApiUrl = $ApiUrl;
  16. }
  17. if ($sign) {
  18. $this->sign = $sign;
  19. } else {
  20. $this->sign = $this->get_sign();
  21. }
  22. }
  23. /**
  24. * 获取sign
  25. * @return String 签名
  26. */
  27. private function get_sign()
  28. {
  29. $res = $this->get_curl($this->ApiUrl[‘mobile’] . “/api/v1/sign”);
  30. $arr = json_decode($res, true);
  31. if (!array_key_exists(‘code’, $arr)) {
  32. return false;
  33. }
  34. if ($arr[‘code’] == 0) {
  35. return $arr[‘data’];
  36. } else {
  37. return false;
  38. }
  39. }
  40. /**
  41. * 账户登陆(app协议)
  42. * @param String $user 账户
  43. * @param String $pwd 密码
  44. * @return Array 数据集
  45. */
  46. public function UserLogin($user, $pwd)
  47. {
  48. if (!empty($user) && !empty($pwd)) {
  49. if (empty($this->sign)) {
  50. $this->get_sign();
  51. }
  52. $res = $this->get_curl($this->ApiUrl[‘mobile’] . “/api/v1/web_user?login_name=” . $user . “&login_pass=” . $pwd . “&sign=” . $this->sign);
  53. $arr = json_decode($res, true);
  54. if (!array_key_exists(‘code’, $arr)) {
  55. return false;
  56. }
  57. if ($arr[‘code’] == 0) {
  58. $this->UserInfo = $arr[‘data’];
  59. return $arr[‘data’];
  60. } else {
  61. return false;
  62. }
  63. } else {
  64. return false;
  65. }
  66. }
  67. /**
  68. * 账户登陆(pc协议)
  69. * @param String $user 账户
  70. * @param String $pwd 密码
  71. * @return Array 数据集
  72. */
  73. public function UserPcLogin($user, $pwd)
  74. {
  75. if (!empty($user) && !empty($pwd)) {
  76. if (empty($this->sign)) {
  77. $this->get_sign();
  78. }
  79. $res = $this->get_curl($this->ApiUrl[‘pc’] . “/main/login_validate”, “login_name=” . $user . “&login_pass=” . $pwd . “&auto_login=true”, 0, 0, 1);
  80. $arr = explode(“n”, $res);
  81. $data = json_decode(end($arr), true);
  82. if ($data[‘code’] == ‘success’) {
  83. //取cookie
  84. preg_match_all(‘/Set-Cookie: (.*?);/’, $res, $arr);
  85. $this->cookies = implode(“;”, $arr[1]);
  86. //二次登陆获取用户信息
  87. return $this->UserLogin($user, $pwd);
  88. } else {
  89. return false;
  90. }
  91. } else {
  92. return false;
  93. }
  94. }
  95. /**
  96. * 账户信息查询(app协议)
  97. * @param Int $uid 账户ID
  98. * @return Array 数据集
  99. */
  100. public function UserQuery($uid)
  101. {
  102. if (!empty($uid)) {
  103. if (empty($this->sign)) {
  104. $this->get_sign();
  105. }
  106. $res = $this->get_curl($this->ApiUrl[‘mobile’] . ‘/api/v1/web_user?id=’ . $uid . ‘&sign=’ . $this->sign);
  107. $arr = json_decode($res, true);
  108. if (!array_key_exists(‘code’, $arr)) {
  109. return false;
  110. }
  111. if ($arr[‘code’] == 0) {
  112. $this->UserInfo = $arr[‘data’];
  113. return $arr[‘data’];
  114. } else {
  115. return false;
  116. }
  117. } else {
  118. return false;
  119. }
  120. }
  121. /**
  122. * 课程信息查询(app协议)
  123. * @param Array $id 课程ID
  124. * @return Array 数据集
  125. */
  126. public function CourseQuery($id = array(), $uid = 6518)
  127. {
  128. if (empty($id) || !is_array($id) || empty($this->sign)) {
  129. return false;
  130. } else {
  131. $list = implode(‘,’, $id);
  132. $data = array();
  133. for ($i = 1; $i <= 5; $i++) {
  134. $res = $this->get_curl($this->ApiUrl[‘mobile’] . “/api/v1/course_info?page_index=0&page_size=9999&id_list=” . $list . “&type=1&is_progress=true&user_id=” . $uid . “&assort_id=3&sign=” . $this->sign);
  135. $arr = json_decode($res, true);
  136. if (!array_key_exists(‘code’, $arr)) {
  137. continue;
  138. }
  139. if ($arr[‘code’] == 0) {
  140. foreach ($arr[‘data’][‘rows’] as $key) {
  141. $data[] = $key;
  142. }
  143. } else {
  144. continue;
  145. }
  146. }
  147. return $data;
  148. }
  149. }
  150. /**
  151. * 课程详情(app协议)
  152. * @param Int $id 课程ID
  153. * @return Array
  154. */
  155. public function CourseInfo($id)
  156. {
  157. if (empty($id)) {
  158. return false;
  159. }
  160. if (empty($this->sign)) {
  161. $this->get_sign();
  162. }
  163. $res = $this->get_curl($this->ApiUrl[‘mobile’] . “/api//v1/course_dirctory?course_id=” . $id . “&sign=” . $this->sign);
  164. $arr = json_decode($res, true);
  165. if (!array_key_exists(‘code’, $arr)) {
  166. return false;
  167. }
  168. if ($arr[‘code’] == 0) {
  169. return $arr[‘data’];
  170. } else {
  171. return false;
  172. }
  173. }
  174. /**
  175. * 视频详情(app协议)
  176. * @param Array $id 课程ID
  177. * @return Array 数据集
  178. */
  179. public function DirctoryInfo($id)
  180. {
  181. if (empty($id)) {
  182. return false;
  183. } else {
  184. if (empty($this->sign)) {
  185. $this->get_sign();
  186. }
  187. $res = $this->get_curl($this->ApiUrl[‘mobile’] . “/api/v1/course_dirctory?id=” . $id . “&is_dirctory=true&sign=” . $this->sign);
  188. $arr = json_decode($res, true);
  189. if (!array_key_exists(‘code’, $arr)) {
  190. return false;
  191. }
  192. if ($arr[‘code’] == 0) {
  193. return $arr[‘data’];
  194. } else {
  195. return false;
  196. }
  197. }
  198. }
  199. /**
  200. * 视频详情(pc协议)
  201. * @param Array $id 课程ID
  202. * @return Array 数据集
  203. */
  204. public function DirctoryPcInfo($id)
  205. {
  206. if (empty($id)) {
  207. return false;
  208. } else {
  209. if (empty($this->cookies)) {
  210. return false;
  211. }
  212. $res = $this->get_curl($this->ApiUrl[‘pc’] . “/server_hall_2/server_hall_2/video_play?dir_id=” . $id . “&do=_do”, 0, 0, $this->cookies);
  213. //取视频加密信息
  214. preg_match_all(‘/polyvPlayer([sS]*?);/i’, $res, $arr);
  215. if (isset($arr[0][0])) {
  216. $res = substr(substr($arr[0][0], 12), 0, -2);
  217. $arr = json_decode(str_replace(array(“n”, “t”, “wrap”, “false”, “‘”), array(“”, “”, “‘wrap'”, “‘false'”, ‘”‘), $res), true);
  218. return array(
  219. ‘vid’ => $arr[‘vid’],
  220. ‘ts’ => $arr[‘ts’],
  221. ‘sign’ => $arr[‘sign’],
  222. ‘session_id’ => $arr[‘session_id’],
  223. ‘playsafe’ => $arr[‘playsafe’]
  224. );
  225. } else {
  226. return false;
  227. }
  228. }
  229. }
  230. /**
  231. * 试卷评测(app协议)
  232. * @param Int $id 试卷ID
  233. * @param Int $uid 用户ID
  234. * @param Int $num 错误的个数
  235. * @return Array 数据集
  236. */
  237. public function CourseTest($id, $uid, $num = 0)
  238. {
  239. if (empty($id) || empty($uid)) {
  240. return false;
  241. }
  242. if (empty($this->sign)) {
  243. $this->get_sign();
  244. }
  245. $arr = $this->GetTestInfo($id);
  246. if ($arr) {
  247. $data1 = “api_action=evaluating_check&example_id=” . $id . “&user_id=” . $uid . “&sign=” . $this->sign;
  248. $ids = array();
  249. $ids2 = array();
  250. $errors = array();
  251. for ($i = 0; $i < $num; $i++) {
  252. $errors[] = rand(0, count($arr));
  253. }
  254. $i = 0;
  255. foreach ($arr as $value) {
  256. $ids[] = $value[‘id’];
  257. if (in_array($i, $errors)) {
  258. $value[‘answer_list’] = rand(0, 3);
  259. }
  260. $ids2[] = ‘&answer_list’ . $value[‘id’] . ‘=’ . $value[‘answer_list’];
  261. $i++;
  262. }
  263. $data2 = “&subject_id_list=” . implode(“[{@}]”, $ids);
  264. $data3 = implode(“”, $ids2);
  265. $data = $data1 . $data2 . $data3;
  266. $res2 = $this->put_curl($this->ApiUrl[‘mobile’] . “/api/v1/example_subject”, $data);
  267. $arr2 = json_decode($res2, true);
  268. if ($arr2[‘code’] == 0) {
  269. return $arr2[‘data’];
  270. } else {
  271. return false;
  272. }
  273. } else {
  274. return false;
  275. }
  276. }
  277. /**
  278. * 试卷评测结果(app协议)
  279. * @param Int $id 试卷ID
  280. * @param Int $uid 用户ID
  281. * @return Array 数据集
  282. */
  283. public function GetTestResault($id, $uid)
  284. {
  285. if (empty($id) || empty($uid)) {
  286. return false;
  287. }
  288. if (empty($this->sign)) {
  289. $this->get_sign();
  290. }
  291. $res = $this->get_curl($this->ApiUrl[‘mobile’] . “/api/v1/example_result?example_id=” . $id . “&user_id=” . $uid . “&is_ext=true&sign=” . $this->sign);
  292. $arr = json_decode($res, true);
  293. if (!array_key_exists(‘code’, $arr)) {
  294. return false;
  295. }
  296. return $arr[‘data’];
  297. }
  298. /**
  299. * 试卷详情(app协议)
  300. * @param Int $id 试卷ID
  301. * @return Array 数据集
  302. */
  303. public function GetTestInfo($id)
  304. {
  305. if (empty($this->sign)) {
  306. $this->get_sign();
  307. }
  308. $res = $this->get_curl($this->ApiUrl[‘mobile’] . “/api/v1/example_subject?example_id=” . $id . “&is_random=false&sign=” . $this->sign);
  309. $arr = json_decode($res, true);
  310. if (!array_key_exists(‘code’, $arr)) {
  311. return false;
  312. }
  313. if ($arr[‘code’] == 0) {
  314. return $arr[‘data’];
  315. }
  316. return false;
  317. }
  318. /**
  319. * 用户试卷列表(pc协议)
  320. * @param Boolean 是否为老师
  321. * @return Array 数据集
  322. */
  323. public function GetTestList($admin = false)
  324. {
  325. if (empty($this->cookies)) {
  326. return false;
  327. }
  328. $type = $admin ? “tea” : “stu”;
  329. $res = $this->get_curl($this->ApiUrl[‘pc’] . “/server_hall_2/” . $type . “/examine”, 0, 0, $this->cookies);
  330. preg_match_all(‘/JSON.parse[sS]*?}/i’, $res, $arr);
  331. if ($arr[0]) {
  332. $new = array();
  333. foreach ($arr[0] as $key) {
  334. $txt = htmlspecialchars_decode(str_replace(“JSON.parse(‘”, “”, $key));
  335. $arr2 = json_decode($txt, true);
  336. if (empty($arr2[‘id’]) || empty($arr2[‘title’])) continue;
  337. $new[] = array(
  338. ‘id’ => $arr2[‘id’],
  339. ‘title’ => $arr2[‘title’]
  340. );
  341. }
  342. $tmp_arr = array();
  343. foreach ($new as $k => $v) {
  344. if (in_array($v[‘id’], $tmp_arr)) {
  345. unset($new[$k]);
  346. } else {
  347. $tmp_arr[$k] = $v[‘id’];
  348. }
  349. }
  350. return $new;
  351. } else {
  352. return false;
  353. }
  354. }
  355. /**
  356. * 观看视频
  357. * @param Int $user_id 用户id
  358. * @param String $video_id 视频id值
  359. * @param Int $times 观看秒数
  360. * @param Int $id 视频id
  361. * @return Boolean 执行结果
  362. */
  363. public function LookVideo($user_id, $video_id, $times, $id)
  364. {
  365. $pid = time() . rand(100, 999) . ‘X’ . rand(100000, 999999);
  366. $vid = $video_id;
  367. $uid = substr($vid, 0, 10);
  368. $flow = 0;
  369. $ts = time() . “886”;
  370. $href = ‘https://www.51moot.net/server_hall_2/server_hall_2/video_play?dir_id=’ . $id . ‘&do=_do’;
  371. $duration = $times;
  372. $cts = $times;
  373. $pd = $times;
  374. $sd = 10;
  375. $param2 = base64_encode($user_id);
  376. $pn = ‘HTML5’;
  377. $pv = ‘v1.15.1’;
  378. $cataid = “1480326650851”;
  379. $sign = md5(“rtas.net” . $pid . $vid . ‘0’ . $pd . $cts);
  380. $url = ‘https://prtas.videocc.net/v2/view?pid=’ . $pid . ‘&vid=’ . $vid . ‘&uid=’ . $uid . ‘&flow=’ . $flow . ‘&ts=’ . $ts . ‘&href=’ . base64_encode($href) . ‘&duration=’ . $duration . ‘&cts=’ . $cts . ‘&sign=’ . $sign . ‘&sd=’ . $sd . ‘&pd=’ . $pd . ‘&pn=’ . $pn . ‘&pv=’ . $pv . ‘&param2=’ . $param2 . ‘&cataid=’ . $cataid . ‘&ute=bop’;
  381. return $this->get_curl($url) == “1”;
  382. }
  383. /**
  384. * Curl get post请求
  385. * @param String $url 网址
  386. * @param String $post POST参数
  387. * @param String $referer refer地址
  388. * @param String $cookie 携带COOKIE
  389. * @param String $header 请求头
  390. * @param String $ua User-agent
  391. * @param String $nobaody 重定向
  392. * @return String 数据
  393. */
  394. private function get_curl($url, $post = 0, $referer = 0, $cookie = 0, $header = 0, $ua = 0, $nobaody = 0)
  395. {
  396. $ch = curl_init();
  397. curl_setopt($ch, CURLOPT_URL, $url);
  398. curl_setopt($ch, CURLOPT_TIMEOUT, 60);
  399. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  400. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
  401. $clwl[] = “Accept:*/*”;
  402. $clwl[] = “Accept-Encoding:gzip,deflate,sdch”;
  403. $clwl[] = “Accept-Language:zh-CN,zh;q=0.8”;
  404. curl_setopt($ch, CURLOPT_HTTPHEADER, $clwl);
  405. if ($post) {
  406. curl_setopt($ch, CURLOPT_POST, 1);
  407. curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
  408. }
  409. if ($header) {
  410. curl_setopt($ch, CURLOPT_HEADER, TRUE);
  411. }
  412. if ($cookie) {
  413. curl_setopt($ch, CURLOPT_COOKIE, $cookie);
  414. }
  415. if ($referer) {
  416. if ($referer == 1) {
  417. curl_setopt($ch, CURLOPT_REFERER, $this->ApiUrl . $url);
  418. } else {
  419. curl_setopt($ch, CURLOPT_REFERER, $referer);
  420. }
  421. }
  422. if ($ua) {
  423. curl_setopt($ch, CURLOPT_USERAGENT, $ua);
  424. } else {
  425. curl_setopt($ch, CURLOPT_USERAGENT, ‘Mozilla/5.0 (Linux; U; Android 4.0.4; es-mx; HTC_One_X Build/IMM76D) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0’);
  426. }
  427. if ($nobaody) {
  428. curl_setopt($ch, CURLOPT_NOBODY, 1);
  429. //主要头部
  430. curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); //跟随重定向
  431. }
  432. curl_setopt($ch, CURLOPT_ENCODING, “gzip”);
  433. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  434. $ret = curl_exec($ch);
  435. curl_close($ch);
  436. return $ret;
  437. }
  438. /**
  439. * Curl PUT请求
  440. * @param String $url 网址
  441. * @param String $data 参数
  442. * @param Array $header 请求头
  443. * @return String 数据
  444. */
  445. private function put_curl($url, $data = “”, $header = array())
  446. {
  447. $ch = curl_init();
  448. $header[] = “Content-type:application/x-www-form-urlencoded”;
  449. curl_setopt($ch, CURLOPT_URL, $url);
  450. curl_setopt($ch, CURLOPT_CUSTOMREQUEST, “PUT”);
  451. curl_setopt($ch, CURLOPT_HEADER, 0);
  452. curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
  453. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  454. curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
  455. $res = curl_exec($ch);
  456. curl_close($ch);
  457. return $res;
  458. }
  459. }

    总体功能实现

    封装完接口,我们可以得到想要功能,我们可以实现多视频同时播放来实现,以下是实现效果

© 版权声明
THE END
危笑云联盟交个朋友,喜欢就支持一下吧
点赞0 分享
评论 抢沙发
头像
欢迎您留下宝贵的见解!
提交
头像

昵称

取消
昵称表情图片

    暂无评论内容