📜 ⬆️ ⬇️

Turing machine restored from compressed code

A day ago, Turing’s birthday was celebrated, and there was a doodle on the Google site with a Turing javascript script machine . It is not the first time that the search engine shows non-trivial and interesting scripts, which then, after a day of celebration, disappear into non-existence. It is strange that there are few words about them on the page of all the doodles, but there are no working models, such as, for example, the Turing machine under consideration ( UPD4 (06/26/2012, 5:20) - a live script appeared on this link , you can play; but obfuscated even stronger than it was on the page). Perhaps they are somewhere there, but a search on the Internet did not lead to a result. Such self-willed behavior of the elements of the Internet began to bother, so yesterday I, without much effort and effort, but decided to extract the working code and try to control it.

To do this, it was necessary to deobfuse the Google codes of the search page (which you cannot even call a search, judging by the mass of scripts) and unlink the engine from the parent site. It turned out to run the algorithm of the counter, which is sewn into the engine by default, but the mechanism for passing logical tasks does not work, which, judging by the code, it contains, but does not start by clicking on the button with a triangle. Nevertheless, 20 percent of the work was done, and I would not like it to disappear. Perhaps in other free time I will take care of it, and perhaps someone will pick up and make a fork with a request, and he (or we together) will manage to start the tasks.

I spread everything pulled out on Gitkhab , already with deobfuscation. If the authors express dissatisfaction and demand removal - we’ll think of something to get away from the author’s materials (a lot of the code from the doodle itself, the animation of sprites is not necessary to perform there), but for now the project is considered as educational. After all, the task of reengineering a toy does not have a different goal, how to learn the techniques of reengineering and deobfuscation, as well as acquaintance with the kitchen of excessively overgrown scripts of such a simple first site. Therefore, I put in the repository not only the typewriter script itself, but all the scripts present on the page — the bar, the footer, and something else. This can be useful both for acquaintance and for restoring the functions of a toy (Turing machine), because it somehow distinguishes 2 user states — the first-time visitor and the first 6 levels (according to the number of letters “Google”).

Ultimately, the whole game is enclosed in a single file turing12.3.js and in 2 pictures of sprites (turing12-hp-deferredsprite.png, turing12-hp-sprite.png). Everything else for the main task is irrelevant.
')
Next, the launch of the game itself is generated (manually) in the gTuring01.htm file (the built-in binary counter starts working on the machine), and the launch of the search page to familiarize yourself with the shell and all other rs.js files, ssl_gb.js , but the game itself is not running in the last file, only on the first one. extern_chrome_ca.js - a file from the Canadian Google, it is not known what it does, it does not apply to the game. If you need compressed source - they are, but should not be needed, it is deobfuscated normally by this service .

Found Turing machine simulator (JS) with modifications in 2012.
Open-Turing-Project / OpenTuring (C language)



UPD : rrock in the comments told how to start the game further and start to pass the levels. Although this is not a complete solution, but there is a continuation!

UPD2 (06/26/2012, 1:30 am): before committing to GitHab (not done yet) - dig a little further.

A review of the turing12.3.js code shows that var T = function (a) { ... (line approximately 3638) contains tasks and programs for the machine to each of them. The first task ( U = [{ ... z: "", p: "",) is, apparently, the program of the counter, which is started by default.

Further, why it was possible to launch from the search page and failed from the artificially created one - because the click event is hung on an object external to the gameplay - a block with id = "hplogo". The first task starts from it, apparently, through the line " if ((Y = document.getElementById (" hplogo ")) && " ... the only place where id is encountered.

Also, it is easy to guess and assume that all U [...] is the choice of rules for the level of the task, and U [0] and the place is " m.aa (U [0] .a.Va, e); " is the start of the counter by default, Ab () and “a.onload = Ab ” is the default launch function. (However, the substitution of U [1] does not lead to the launch of level 1, although the behavior changes. The context is important.)

The goal of the diggers now is to create a link that launches the 1st level of the game from the page gTuring01.htm .

UPD3 (06/26/2012, 3:30): commit is made. The target at% 75 has been reached - both HTM files are launched and play in several levels. Details of the behavior and memory states are not investigated. The main thing is - work.
Option rrock - github.com/rrockru/GoogleTuring .

UPD4 (06/26/2012, 5:20): and, however, we were in vain worried that they would not revive this script - in the evening there was a picture, and now there is a working script! www.google.com/doodles/alan-turings-100th-birthday . But! There he is buried even deeper in obfuscation (how do you like it? Src = "/ doodles / js / doodle_javascript.js"), and here it is readable and open.

UPD5 (06/26/2012, 6:00 AM): working example here: spmbt.kodingen.com/gTuringMachine/index.htm

Source: https://habr.com/ru/post/146444/


All Articles