要玩坏啦~用图床传视频 | 垃圾君⑨

要玩坏啦~用图床传视频

有MJJ突发奇想发现图床可以这么用~了解一点m3u8的同学会知道,一大段视频是由很多个小段 .ts文件组成的,那摩如果某个图床接口没能正确过滤文件格式仅是以后缀判断的话,这事情就好办了,你可以将大视频切片成ts——伪装成jpg图片——通过接口上传——包装成M3u8 就可以成功完成整个步骤啦~

粘帖了某大佬写的php代码,完整使用步骤请参考大佬原文 视频完美切片存储方案 附自动化处理脚本

<?php $v_path = $argv[1]; //切片路径 $v_name = $argv[2]; //带切片的视频路径名称 $s = 5; //切片秒 ts 切片必须小于 5MB if (empty($v_path) || empty($v_name)) { echo "请填写完整参数"; exit; } if ($v_path == '/' || $v_path == '\\') { $v_path = ''; } else { mkFolder($v_path); $v_path = $v_path . "/"; } //这是 FFmpeg 处理命令大家自行更改 exec("ffmpeg -i $v_name -c copy -map 0 -f segment -segment_list " . $v_path . "playlist.m3u8 -segment_time $s " . $v_path . "player%03d.ts"); $m = file_get_contents('./' . $v_path . 'playlist.m3u8'); preg_match_all('/player(.*?)\.ts/', $m, $arr); foreach ($arr[1] as $key => $value) {
	echo "处理第" . $value . '个切片' . "\n";
	$ali = upload('./' . $v_path . 'player' . $value . '.ts');
	$m = str_replace('player' . $value . '.ts', $ali, $m);
	file_put_contents('./' . $v_path . 'play.m3u8', $m);
}
 
echo "处理完毕" . "\n";
echo "播放链接为:/" . $v_path . 'play.m3u8';
 
function upload($file) {
	$post['file'] = file_path($file);
	$post['scene'] = 'aeMessageCenterV2ImageRule';
	$post['name'] = 'player.jpg';
	$rel = get_curl('https://kfupload.alibaba.com/mupload', $post, 'iAliexpress/6.22.1 (iPhone; iOS 12.1.2; Scale/2.00)');
	$rel = json_decode($rel, true);
 
	return $rel['url'];
}
 
function get_curl($url, $post = 0, $ua = 0) {
	$ch = curl_init();
	curl_setopt($ch, CURLOPT_URL, $url);
	// 不验证证书
	curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
	curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
	// 最大执行时间
	curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 120);
	curl_setopt($ch, CURLOPT_TIMEOUT, 120);
	$httpheader[] = "Accept:application/json";
	$httpheader[] = "Accept-Encoding:gzip,deflate,sdch";
	$httpheader[] = "Accept-Language:zh-CN,zh;q=0.8";
	$httpheader[] = "Connection:close";
	$ip = mt_rand(48, 140) . "." . mt_rand(10, 240) . "." . mt_rand(10, 240) . "." . mt_rand(10, 240); //随机 ip
	$httpheader[] = 'CLIENT-IP:' . $ip;
	$httpheader[] = 'X-FORWARDED-FOR:' . $ip;
	curl_setopt($ch, CURLOPT_HTTPHEADER, $httpheader);
	if ($post) {
		curl_setopt($ch, CURLOPT_POST, 1);
		curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
	}
 
	if ($ua) {
		curl_setopt($ch, CURLOPT_USERAGENT, $ua);
	} else {
		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");
	}
	curl_setopt($ch, CURLOPT_ENCODING, "gzip");
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
	$ret = curl_exec($ch);
	curl_close($ch);
	return $ret;
}
function mkFolder($path) {
	if (!is_readable($path)) {
		is_file($path) or mkdir($path, 0700);
	}
}
function file_path($file) {
	if (class_exists('CURLFile')) {
		return $post['file'] = new \CURLFile(realpath($file));
	} else {
		return $post['file'] = '@' . realpath($file);
	}
}

更新,又有大佬分.py版本,看来被玩坏已是板上钉钉了 链接点这里

#!/usr/bin/python3
# -*- coding: UTF-8 -*-
 
import requests, os
from urllib3 import encode_multipart_formdata
from concurrent.futures import ThreadPoolExecutor, as_completed
 
def m_upload(filename):
    fakename = os.path.splitext(filename)[0] + '.jpg'
    payload = {'scene':'aeMessageCenterV2ImageRule', 'name':fakename, 'file': (fakename,open(filename,'rb').read())}
    encode_data = encode_multipart_formdata(payload)
    data = encode_data[0]
    headers['Content-Type'] = encode_data[1]
    for _ in range(3):
        try:
            r = requests.post(url, headers=headers, data=data, timeout = 20)
        except:
            print('Failed to upload ' + filename)
            continue
        if r and 'url' in r.text:
            print(filename + " upload")
            return r.json()['url']
        else:
            print('Failed to upload ' + filename)
    return filename + ' ERROR'
 
if __name__ == '__main__':
    for file in os.listdir():
        if '.m3u8' in file:
            m3u8 = open(file)
            break
    new_m3u8 = open('output.m3u8', 'w')
    headers = {'user-agent':'iAliexpress/6.22.1 (iPhone; iOS 12.1.2; Scale/2.00)', 'Accept':'application/json', 'Accept-Encoding':'gzip,deflate,sdch', 'Connection':'close'}
    url = 'https://kfupload.alibaba.com/mupload'
    file_upload = {t.strip():'' for t in m3u8.readlines() if t[0]!='#'}
    m3u8.seek(0)
    executor = ThreadPoolExecutor(max_workers=8)
    futures = {executor.submit(m_upload, filename):filename for filename in file_upload.keys()}
    for future in as_completed(futures):
        file_upload[futures[future]] = future.result()
    for line in m3u8:
        if line[0] != '#':
            new_m3u8.write(file_upload[line.strip()] + '\n')
        else:
            new_m3u8.write(line)
    print("Complete")

题外话,自从大佬公开了滥用步骤,小破站真的该准备迁移全站图片到其他图床了。。。MMP

 
         

记一次服务器改用密钥方式登录ssh过程~

其实这篇文章我不想写的,无奈博主鱼的记忆,这次配置完下次就有可能又忘了,只好写下来以备不需~ 其实配置这个很简单,我以Debian9为例~其中又有点坑需要注...

分享几个可发邮件的临时邮箱

现在临时邮箱快烂大街了,有各位大佬加持下,随便弄个域名,然后解析个IP就行了。可是可以发邮件的临时邮箱就不多了,今天介绍几个可以发邮件的临时邮箱! m...

域名邮箱测试网站mail-tester:来看看你得了几分?

最近听闻mailgun要关闭免费额度,想着自己的小破站的域名邮箱托管到那里,无奈只能抓紧时间撤出来。。。起初我想试试mail.ru家的服务,可是这家可能对域名和d...

使用Flow实现定时发送邮件到指定邮箱

最近为了E5保活问题四处爬文,可惜中文可看的只有推荐使用oneindex...可是谁也不知道微软是如何定义“开发”这个标准的,无奈只能自己想办法。今天分享个利用微...

喜加一!steam平台游戏 丽丽公主 开启限免~

国产解谜类游戏「丽丽公主」开启限免~游戏讲述 男主角君彦是一名年轻的圣骑士,在一次返程归来时,他碰巧路过被恶魔入侵后的爱露村,同时巧遇了被恶魔追赶的...

介绍几个实用WP主题:开源/免费

介绍几个很不错的博客主题,有的专注写作,有的功能很强大~与其四处寻找开心版,不如用开源的主题跟安心些 ZanBlog3 由佚站互联开发,基于 Bootstrap3开发...