This part deals mostly with the requesting of videos to load. Currently I have set up a Tor Hidden HTTP Service for adding video files to. I then request those videos through Tor/Privoxy Client which connects using PyCURL/CURL. Videos are dynamically managed by passing the filename into a flashvars parameter from my database table where it requests the file from the Tor Hidden HTTP Service.
This is my flash embed code:
<div class="responsive-video">
<section itemscope itemtype="http://schema.org/VideoObject">
<meta itemprop="embedURL" content="http://hidden.cryaboutcrypt.ninja/static/flashplayer/shinobu.swf?video={{=query.filename}}" /><br />
<object width="100%;" height="100%" style="max-width:720px; max-height:406px;" id="videos" align="middle">
<param name="movie" value="{{=URL('static', 'flashplayer/shinobu.swf')}}" />
<param name=FlashVars value="video={{=query.filename}}" />
<!--[if !IE]>-->
<object type="application/x-shockwave-flash" data="{{=URL('static', 'flashplayer/shinobu.swf')}}" width="100%;" height="100%" style="max-width:720px;max-height:406px;">
<param name="movie" value="{{=URL('static', 'flashplayer/shinobu.swf')}}" />
<param name=FlashVars value="video={{=query.filename}}" />
<!--<![endif]-->
<a href="http://www.adobe.com/go/getflash">
<img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" />
</a>
<!--[if !IE]>-->
</object>
<!--<![endif]-->
</object>
</section>
</div>
And the updated Actionscript Code:
package
{
// Media
import flash.display.MovieClip;
import flash.text.TextField;
import flash.text.TextFieldAutoSize;
import flash.text.TextFormat;
import flash.media.Video;
// Network
import flash.net.URLLoader;
import flash.net.URLRequest;
import flash.net.URLLoaderDataFormat;
import flash.net.NetConnection;
import flash.net.NetStream;
import flash.net.NetStreamAppendBytesAction;
// Events
import flash.events.Event;
import flash.events.ProgressEvent;
import flash.events.NetStatusEvent;
import flash.events.IOErrorEvent;
// Data
import flash.utils.ByteArray;
// Security
import flash.system.Security;
public class Main extends MovieClip
{
// Handle For Desktop/Web/Mobile
try
{
// Security Policies
Security.allowDomain('62.75.246.181');
Security.loadPolicyFile('http://hidden.cryaboutcrypt.ninja/strange/static/crossdomain.xml');
}
catch (e)
{};
// Proxy URL
private var videoName:String = stage.loaderInfo.parameters["video"];
private var proxy:String = "http://hidden.cryaboutcrypt.ninja/strange/hidden_request?param1=" + videoName;
// Video Playback
private var netConnection:NetConnection;
private var netStream:NetStream;
private var video:Video;
private var bytes:ByteArray;
private var statusText:TextField;
private var format:TextFormat;
public function Main()
{
statusText = new TextField();
format = new TextFormat();
statusText.text = "";
statusText.autoSize = TextFieldAutoSize.CENTER;
statusText.x = 360;
statusText.y = 203;
format.font = "Verdana";
format.color = 0xFFFFFF;
format.size = 15;
statusText.defaultTextFormat = format;
addChild(statusText);
video = new Video(720, 406);
netConnection = new NetConnection();
netConnection.addEventListener(NetStatusEvent.NET_STATUS, netConnectionStatusHandler);
addChild(video);
var ur:URLRequest = new URLRequest(proxy);
var ul:URLLoader = new URLLoader();
ul.dataFormat = URLLoaderDataFormat.BINARY;
ul.addEventListener(ProgressEvent.PROGRESS, progressLoader);
ul.addEventListener(Event.COMPLETE, function(ev:Event):void
{
bytes = ul.data;
netConnection.connect(null);
});
ul.load(ur);
}
function progressLoader(event:ProgressEvent):void
{
statusText.text = "Network Connection Success. Video is Loading ...";
statusText.autoSize = TextFieldAutoSize.CENTER;
}
public function netConnectionStatusHandler(ev:NetStatusEvent):void
{
switch(ev.info.code)
{
case 'NetConnection.Connect.Success':
netStream = new NetStream(netConnection);
netStream.client = {};
video.attachNetStream(netStream);
netStream.play(null);
netStream.appendBytes(bytes);
break;
}
}
}
}
The source code for the PyCURL request over tor/privoxy to the hidden service using the web2py framework.
def hidden_request():
param1 = str(request.get_vars["param1"])
url = http://oniondomain
param1 = param1.rstrip()
re_url = url + param1
header = StringIO()
buffer = StringIO()
c = pycurl.Curl()
c.setopt(c.URL, re_url)
c.setopt(c.USERAGENT, "Mozilla/5.0 (compatible; MSIE 5.01; Windows NT 5.0)")
c.setopt(c.PROXY, SERVER_IP)
c.setopt(c.PROXYPORT, 8118)
c.setopt(c.PROXYTYPE, c.PROXYTYPE_HTTP)
c.setopt(c.HTTPPROXYTUNNEL, 1)
c.setopt(c.HEADERFUNCTION, header.write)
c.setopt(c.WRITEFUNCTION, buffer.write)
c.perform()
#c.close()
return buffer.getvalue()
Previous articles from bottom(start) to top(end)
http://www.techshinobi.com/index.php/actionscript-pycurl-socks-part-3/
http://www.techshinobi.com/index.php/actionscript-pycurl-socks-part-2/
http://www.techshinobi.com/index.php/actionscript-pycurl-and-socks/
http://www.techshinobi.com/index.php/java-socks-proxy-in-applets-tor/