Is there an online compiler?

Propose new features and changes
Bruttosozialprodukt
Posts: 457
Joined: 24 Jan 2014, 22:28

Re: Is there an online compiler?

18 Oct 2017, 05:33

If performance is not an issue, you could use an emulator. QEMU probably being the most popular one on Linux for x86 emulation.
But expect extremely terrible performance. Several hours for the boot wouldn't surprise me at all.

For a translation layer, well on the one side we have the ZenFone which, thanks to its CPU, can translate ARM instructions to x64 instructions without major performance issues.
And software-wise I'm only aware of Wine which can translate Win32 functionality to its Linux equivalents, but only for the same architecture.

About your "solutions":
- Parallels just seems to a a remote access application, similar to OpenVNC or TeamViewer.
- CrossOver on Android seems to heavily rely on Intel's ARM to x64 translation magic and thus would only work on the ZenFone and some ChromeBooks apparently.
User avatar
Reloaded
Posts: 281
Joined: 25 Aug 2017, 08:48

Re: Is there an online compiler?

18 Oct 2017, 07:58

Or you just can use Resource Hacker™ a Perfect Working .exe to .ahk compiler
Bruttosozialprodukt
Posts: 457
Joined: 24 Jan 2014, 22:28

Re: Is there an online compiler?

18 Oct 2017, 08:01

We've been through this. We are talking about actually running AHK code. Besides that, the tool you linked does not look like it would run on either Linux or ARM, not to mention the two combined.
murataygun
Posts: 17
Joined: 07 Aug 2015, 15:53

Re: Is there an online compiler?

10 Jan 2019, 08:24

Bruttosozialprodukt wrote:
20 May 2016, 02:48
An online compiler should be pretty easy to set up if you have a windows server.
In node.js it could be something as simple as that:

Code: Select all

var fs = require('fs');
var express = require('express');
var app = express.createServer();
var bodyParser = require('body-parser');
var execFile = require('child_process').execFile;

app.use(bodyParser.urlencoded({
  extended: true
})); 

app.post('/ahk-online-compiler', function(req, res) {
    fs.writeFile("%temp%/script.ahk", req.body.scriptcode, function(err) {
        if (!err) {
            exexFile("%programfiles%/AutoHotkey/Compiler/Ahk2Exe.exe",  "/in %temp%/script.ahk /out %temp%/script.exe", function(err, stdout, stderr) {
                if (!err) {
                    res.sendFile("temp%/script.exe");
                }
            });
        }
    }); 
});

app.get('/ahk-online-compiler', function(req, res) {
    var htmlCode = `
      <!DOCTYPE html>
      <html>
        <head>
          <title>AHK Online compiler</title>
        </head>
        <body>
          <form action="/ahk-online-compiler" method="post">
            <textarea name="scriptcode"></textarea>
            <input type="submit" value="Compile">
          </form>
        </body>
      </html>
    `;
    res.send(htmlCode);
});
(untested)
Can you give a little more info about this please. Thats what i need right now.
Bruttosozialprodukt
Posts: 457
Joined: 24 Jan 2014, 22:28

Re: Is there an online compiler?

21 Feb 2019, 16:58

Sure, you just need a Windows machine and install autohotkey and node.js on it. Then you create a new folder and put these files in it:

install.bat

Code: Select all

npm i express body-parser
start.bat

Code: Select all

node index.js
index.js

Code: Select all

var fs = require('fs');
var express = require('express');
var app = express();
var bodyParser = require('body-parser');
var execFile = require('child_process').execFile;

app.use(bodyParser.urlencoded({
  extended: true
})); 

app.post('/ahk-online-compiler', function(req, res) {
    console.log(req.body.scriptcode)
    fs.writeFile("%temp%/script.ahk", req.body.scriptcode, function(err) {
        if (!err) {
            exexFile("%programfiles%/AutoHotkey/Compiler/Ahk2Exe.exe",  "/in %temp%/script.ahk /out %temp%/script.exe", function(err, stdout, stderr) {
                if (!err) {
                    res.sendFile("temp%/script.exe");
                } else {
                    res.status(500).send("Compiling the script failed!");
                }
            });
        } else {
            res.status(500).send("Saving the script failed!");
        }
    }); 
});

app.get('/ahk-online-compiler', function(req, res) {
    var htmlCode = `
      <!DOCTYPE html>
      <html>
        <head>
          <title>AHK Online compiler</title>
        </head>
        <body>
          <form action="/ahk-online-compiler" method="post">
            <textarea name="scriptcode" placeholder="Paste your script code here..."></textarea>
            <input type="submit" value="Compile">
          </form>
        </body>
      </html>
    `;
    res.send(htmlCode);
});

app.listen(3000, function () {
  console.log('AhkOnline is listening on port 3000! Try http://localhost:3000/ahk-online-compiler');
});
Then run install.bat to install the dependencies. Then you can start the nodejs server by running the start.bat and check if it works in your browser by opening: http://localhost:3000/ahk-online-compiler
Last edited by Bruttosozialprodukt on 28 Feb 2019, 15:53, edited 1 time in total.
neogna2
Posts: 33
Joined: 15 Sep 2016, 15:44

Re: Is there an online compiler?

22 Feb 2019, 13:46

Let me brainstorm a bit here.

Could an official online compiler be useful in response to the problem of false positives for compiled AutoHotkey scripts?

I'm thinking it would enable an intermediary between
(1) the script developer posts a compiled binary .exe and the user chooses to trust that there is nothing malign in the binary
(2) the script developer posts only the .ahk source and the users have to install AutoHotkey and compile it themselves

Is it also possible to create deterministic binaries with AutoHotkey? I mean binaries that are identical given the same .ahk input and given the same version of AutoHotkey regardless of what PC and what Windows version they're compiled on. If possible then an official online compiler might help even more with the false positives problem. Since everyone, including the anti-malware vendors, could then check if a script binary is compiled from the .ahk source and AutoHotkey version that it is claimed to be compiled from by running the .ahk code through the online compiler and then compare hashes for the binaries.

It might also be possible to create some automatic build service for AutoHotkey scripts on GitHub and GitLab. Developers could then push .ahk code updates and binaries would be automatically created using the trusted official online compiler.
Bruttosozialprodukt
Posts: 457
Joined: 24 Jan 2014, 22:28

Re: Is there an online compiler?

28 Feb 2019, 12:49

Having a trusted source that compiles the script for you would indeed be a nice thing to have. For source code that compiles on Linux, TravisCI and GitLab CI are very commonly used.

The AHK compiler essentially just makes a copy of autohotkey.exe and adds the script as a resource to it. So yes, builds are reproducible as long as the AHK version is the same.

Since you can probably compile AHK scripts on Linux using Wine, you could create a GitHub or GitLab repository and set it up with TravisCI/GitLab CI + a Wine docker image with AHK installed and make it automatically compile your code + release the binaries every time you commit code changes to the repository.
It would be pretty trivial to set something like that up, but everyone would have to set up their own repositories.

If anyone would like to see that, I might be willing to give it a shot.


edit:
I think it would actually be possible to set up a website that compiles AHK scripts using client-sided JavaScript with https://developer.mozilla.org/en-US/docs/Web/API/FileReader
This way you wouldn't waste server resources.
neogna2
Posts: 33
Joined: 15 Sep 2016, 15:44

Re: Is there an online compiler?

03 Mar 2019, 16:23

Bruttosozialprodukt wrote:
28 Feb 2019, 12:49
The AHK compiler essentially just makes a copy of autohotkey.exe and adds the script as a resource to it. So yes, builds are reproducible as long as the AHK version is the same.
Good. I assume that in addition to AutoHotkey version differences the exe would also vary with the file encoding of the .ahk source file. Still useful.
Bruttosozialprodukt wrote:
28 Feb 2019, 12:49
Since you can probably compile AHK scripts on Linux using Wine, you could create a GitHub or GitLab repository and set it up with TravisCI/GitLab CI + a Wine docker image with AHK installed and make it automatically compile your code + release the binaries every time you commit code changes to the repository.
It would be pretty trivial to set something like that up, but everyone would have to set up their own repositories.
I don't think setting something like that up indvidually would help much with the false positives issue, since it is only a shifts from "blindly trust my binary" to "blindly trust my personal online compiler". To do better there'd need to be one single online compiler set up transparently and by some trusted party. Another approach is to have a single trusted online de-compiler/analyzer. It would take compiled AHK scripts as input and unpack them, hash verify that the autohotkey.exe component is not tampered with and output the source .ahk file and any other unpacked files. Developers could then compile and host binaries themselves but also submit/link each new compiled version to the de-compiler and get a "test results" page there to link back to.
Bruttosozialprodukt
Posts: 457
Joined: 24 Jan 2014, 22:28

Re: Is there an online compiler?

04 Mar 2019, 02:55

I don't think that a different script name would change the result. There are however other properties that you can add when compiling the script that would cause a different output.

I wouldn't be blindly trusting your compiler. I would only blindly trust the TravisCI or GitLab server. The exact commands that are used to compile the script are transparent.
And I would trust both of these.
neogna2
Posts: 33
Joined: 15 Sep 2016, 15:44

Re: Is there an online compiler?

08 Mar 2019, 03:16

Bruttosozialprodukt wrote:
04 Mar 2019, 02:55
I don't think that a different script name would change the result. There are however other properties that you can add when compiling the script that would cause a different output.
I didn't mean filename but file encoding. Even though UTF-8 BOM is strongly adviced in the AutoHotkey FAQ some .ahk files online have other encodings. For example IIRC .ahk pasted into github using the web interface default to UTF-8 encoding (without BOM) when later downloaded.
Bruttosozialprodukt wrote:
04 Mar 2019, 02:55
I wouldn't be blindly trusting your compiler. I would only blindly trust the TravisCI or GitLab server. The exact commands that are used to compile the script are transparent. And I would trust both of these.
I see. I don't know much about TravisCI. Do you know if it can be set to show the hashes for the binary compiler and all other files thare are used? Otherwise I imagine a weak point would be that a malignant actor could modify the AutoHotkey binaries before uploading them to their TravisCI system. If on the other hand the hashes are shown then there would be a way to verify the integry of the compiler, especially if autohotkey.com also began posting file hashes for each release.
Bruttosozialprodukt
Posts: 457
Joined: 24 Jan 2014, 22:28

Re: Is there an online compiler?

09 Mar 2019, 05:03

Yes it can be set up to execute anything that can be executed from the commandline in Linux.
And you don't upload the autohotkey.exe, you write a script that tells the CI how to download it from the official website.

Also, if you upload your file to github the normal way, the encoding would not change. You should avoid the webinterface to modify your files. Just install git on your computer and run:

Code: Select all

git add myscript.ahk
git commit -m "my commit msg..."
git push -u origin master
to upload your file or changes the repository.

Return to “Wish List”

Who is online

Users browsing this forum: No registered users and 6 guests