From the original article(s) found here http://www.techshinobi.com/index.php/actionscript-pycurl-and-socks/ I have rewritten the code a bit to play a video file (flv) on a mobile device from a Tor (Onion Network) Hidden Service.
Here is the actionscript code (and below the web2py/pycurl function), enjoy!
package
{
// Media
import flash.display.Sprite;
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.NetStatusEvent;
import flash.events.ProgressEvent;
import flash.events.IOErrorEvent;
// Data
import flash.utils.ByteArray;
// Security
import flash.system.Security;
public class Main extends Sprite
{
// Handle For Desktop/Web/Mobile
try
{
// Security Policies
Security.allowDomain('xx.xx.xxx.xxx');
Security.loadPolicyFile('http://xx.xx.xxx.xxx/strange/static/crossdomain.xml');
}
catch (e)
{};
// Proxy URL
public var proxy:String = "http://xx.xx.xxx.xxx/strange/re_quest?param1=static¶m2=demo.flv";
// Video Playback
private var netConnection:NetConnection;
private var netStream:NetStream;
private var video:Video;
private var bytes:ByteArray;
public function Main()
{
video = new Video(320, 240);
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(Event.COMPLETE, function(ev:Event):void
{
bytes = ul.data;
netConnection.connect(null);
});
ul.load(ur);
}
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 code on the web server hosting the Privoxy and Tor client.
import pycurl
from StringIO import StringIO
def re_quest():
url = "http://eoshdbe77ah552wy.onion/hetodjabdloekio/"
param1 = str(request.get_vars["param1"])
param2 = str(request.get_vars["param2"])
param1 = param1.rstrip()
param2 = param2.rstrip()
re_url = url + param1 + "/" + param2
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, "xx.xx.xxx.xxx")
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()
return buffer.getvalue()
All 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/