RyukShini

Is it possible to work with Mega.co.nz and AutoIT

5 posts in this topic

#1 ·  Posted (edited)

I was wondering if its possible to make anything like this in AutoIT

 

function toArr(str)
{
    var ret = Array((str.length + 3) >> 2);

    // String to array of 32 bit ints
    for (var i = 0; i < str.length; i += 4)
    {
        // FYI:
        // NaN << x === 0
        // x | NaN === x
        ret[i >> 2] =
            (str.charCodeAt(i  ) << 24) |
            (str.charCodeAt(i+1) << 16) |
            (str.charCodeAt(i+2) <<  8) |
             str.charCodeAt(i+3);
    }
    return ret;
}

function megaKdf(pw)
{
    var pwkey = [0x93c467e3, 0x7db0c7a4, 0xd1be3f81, 0x0152cb56];
    var arrPw = toArr(pw);
    var aes   = Array((arrPw + 3) >> 2);

    // Init aes keys
    for (var i = 0; i < arrPw.length; i += 4)
    {
        aes[i >> 2] = new sjcl.cipher.aes([arrPw[i]|0, arrPw[i+1]|0, arrPw[i+2]|0, arrPw[i+3]|0]);
    }

    // Generate password key
    for (var i = 0; i < 65536; i++)
    {
        for (var j = 0; j < aes.length; j++)
        {
            pwkey = aes[j].encrypt(pwkey);
        }
    }

    return pwkey;
}

function loginHash(pwKey, email)
{
    var aes = new sjcl.cipher.aes(pwKey);
    var arrEmail = toArr(email);
    var hash = [0, 0, 0, 0];

    // Compress email with xor
    for (var i = 0; i < arrEmail.length; i++)
    {
        hash[i & 3] ^= arrEmail[i];
    }

    // Generate hash
    for (var i = 0; i < 16384; i++)
    {
        hash = aes.encrypt(hash);
    }

    return sjcl.codec.base64.fromBits([hash[0], hash[2]], true, true);
}

function badRand32()
{
    return Math.floor(0x100000000 * Math.random());
}

function generateMasterKey()
{
    return [badRand32(), badRand32(), badRand32(), badRand32()];
}

function confirmationLinkHash(pwKey)
{
    var aes = new sjcl.cipher.aes(pwKey);
    return aes.encrypt([badRand32(), 0, 0, badRand32()]);
}

function updateHashes(email, pw)
{
    var pwKey = megaKdf(pw);
    var masterKey = generateMasterKey();
    var clHash = confirmationLinkHash(pwKey, masterKey);
    var lHash = loginHash(pwKey, email);
    var aes = new sjcl.cipher.aes(pwKey);

    return lHash;
}

function htmlentities(str)
{
    return str.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/'/g,"&#39;");
}

function analyzeLink(link, pw)
{
    var linkHex      = "N/A";
    var masterKey    = "N/A";
    var encMasterKey = "N/A";
    var pwHash       = "N/A";
    var unknown      = "N/A";
    var email        = "N/A";
    var spacer       = "N/A";
    var name         = "N/A";
    var unknown2     = "N/A";

    if (link.substr(0, 27) == "https://mega.co.nz/#confirm")
    {
        link = link.substr(27);
    }
    if (link.substr(0, 19) == "mega.co.nz/#confirm")
    {
        link = link.substr(19);
    }
    if (link.substr(0, 8) == "#confirm")
    {
        link = link.substr(8);
    }
    if (link.search(/^[0-9A-Za-z\-_]*$/) == 0)
    {
        link = sjcl.codec.hex.fromBits(sjcl.codec.base64.toBits(link, true));

        var pos;
        for (pos = 94; pos < link.length; pos += 2)
        {
            if (link.substr(pos, 2) == "09")
            {
                break;
            }
        }
        if (pos < link.length)
        {
            var pwKey = megaKdf(pw);
            var aes = new sjcl.cipher.aes(pwKey);
            var linkHash = aes.decrypt(sjcl.codec.hex.toBits(link.substr(32, 32)));
            if (linkHash[1] == 0 && linkHash[2] == 0)
            {
                masterKey = (new sjcl.cipher.aes(pwKey)).decrypt(sjcl.codec.hex.toBits(link.substr(0, 32)));
                masterKey = 'Base64: <span style="color:#f00; font-family:monospace;">' + sjcl.codec.base64.fromBits(masterKey, true, true) + '</span> (hex: <span style="color:#f00; font-family:monospace;">' + sjcl.codec.hex.fromBits(masterKey) + '</span>)';
            }
            else if (pw != "")
            {
                masterKey = "Wrong password";
            }
            encMasterKey = '<span style="color:#f00; font-family:monospace;">' + link.substr( 0, 32) + '</span>';
            pwHash       = '<span style="color:#080; font-family:monospace;">' + link.substr(32, 32) + '</span>';
            unknown      = '<span style="color:#00f; font-family:monospace;">' + link.substr(64, 30) + '</span>';
            email        = link.substr(94, pos - 94);
            spacer       = '<span style="color:#0cc; font-family:monospace;">09</span>';
            name         = link.substr(pos + 2, link.length - 16 - pos - 2);
            unknown2     = '<span style="color:#000; font-family:monospace;">' + link.substr(link.length - 16) + '</span>';
            linkHex = '<span style="font-family:monospace;">' + encMasterKey + " " + pwHash + " " + unknown +
                ' <span style="color:#888; font-family:monospace;">' + email + '</span> ' + spacer +
                ' <span style="color:#f0f; font-family:monospace;">' + name + '</span> ' + unknown2 + '</span>';
            email = htmlentities(sjcl.codec.utf8String.fromBits(sjcl.codec.hex.toBits(email))) + ' (<span style="color:#888; font-family:monospace;">' + email + '</span>)';
            name  = htmlentities(sjcl.codec.utf8String.fromBits(sjcl.codec.hex.toBits(name)))  + ' (<span style="color:#f0f; font-family:monospace;">' + name  + '</span>)';
        }
    }
    ge("linkHex").innerHTML          = linkHex;
    ge("linkMasterKey").innerHTML    = masterKey;
    ge("linkEncMasterKey").innerHTML = encMasterKey;
    ge("linkPwHash").innerHTML       = pwHash;
    ge("linkUnknown").innerHTML      = unknown;
    ge("linkEmail").innerHTML        = email;
    ge("linkSpacer").innerHTML       = spacer;
    ge("linkName").innerHTML         = name;
    ge("linkUnknown2").innerHTML     = unknown2;
}

 

Edited by RyukShini

Share this post


Link to post
Share on other sites



Anyone who has a clue??
Thanks in advance

Share this post


Link to post
Share on other sites

Yes. or in any other programing lenguage.

 

Saludos

Share this post


Link to post
Share on other sites

Not being too familiar with the Javascript language reference, I don't know what some of the functions are doing (like how the comma separated values are handled/fed to the AES func...but it looks plausible.  As far as the HTML rendering, you'd have to embed some sort of browser/renderer unless you can afford to use other UI means/elements.

Share this post


Link to post
Share on other sites

@RyukShini,

it would be wiser not to try to translate the code, but to describe the task, and then try to implement it in AutoIt. then, if you need help with your AutoIt script, you can ask the forum.

but when you are asking AutoIt forum members to read and understand an enigmatic and lengthy piece of code written in another language, it is not surprising you have not yet got any help.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now

  • Similar Content

    • Miliardsto
      By Miliardsto
      Hello I got these tabs
       
      Global $TabMain = GUICtrlCreateTabItem("Main") Global $Action = GUICtrlCreateTabItem("Actions") Global $TabThings = GUICtrlCreateTabItem("Things") As we know to change tab we have to click with mouse on tab name like here it looks like below.
      Is there possibility to change tab without click on the tab but change by click on button for example?

    • sree161
      By sree161
      Hi,
      i have a code which generates two numeric outputs.i have to save them in excel.
      Is there any way to export them to specific cells in excel???
    • TotalAuto
      By TotalAuto
      Howdy All
      I've gone around and around in circles wasting hours trying to fix this problem to no avail so I thought I would try posting for help given there are some real smart people in this forum.
      Background
      I have 5 separate .au3 scripts that all do different basic tasks. For example:
      1.au3 = opens Chrome browser to obtain information from a specific website then closes
      2.au3 = opens an Excel workbook to run a macro then saves and closes
      3.au3 = Open two seperate workbooks and transfers data from one to the other then saves and closes
      4.au3 = .......etc
      5.au3 = .......etc
      These 5 separate scripts, doing completely different tasks, need to each run once per day at 5 different designated times within a day and then close. For example:
      1.au3 = 10am
      2.au3 = 12pm
      3.au3 = 2pm
      4.au3 = 4pm
      5.au3 = 5pm
      Problem
      I can not get these different scripts to reliably run at their designated times. When I manually run these scripts individually by using 'Go F5' they work perfectly. If I convert these scripts to an .exe and manually run each one they work about 98% of time.
      How can I schedule these different .au3 files or associated .exe files to reliably run each day at different times?
      Attempts To Fix The Issue
      1. I have tried converting each .au3 script into their own .exe file and use Window's Task Scheduler to run these .exe files at their designated time but the success rate  of running each .exe in full, to completion, without error is very low at about 30%. Things that commonly go wrong include a browser not opening but movement still continues on the desk top. Other times things just do not happen at all.
      2. I have Windows 7 64 bit and have tried creating and running both (x86) and (x64) .exe files but again reliability problems exist;
      3. I have also tried moving each .exe file to the My Documents folder as I read someone that keeping your files on your desktop ties your files to individual Windows user profiles which can cause AutoIt operating errors. Not sure if this is correct but thought I would try it anyway. It did not fix my issue.
      4. I installed a program called AlwaysUp which supposedly always reliably runs in the background and will reliably execute your AutoIt script or .exe files. Still have significant reliability issues.
      Therefore, can someone please provide advice on how I can get my 5 different .au3 files to run at 5 designated times through the day, every day, without fail? Overtime I will be creating more and more different .au3 files to run certain tasks throughout the day and do not want to create one large AutoIt file that continually runs and attempts to do all the different tasks itself.
      Any help is very appreciated.
      Thanks
      Dan
       
       
    • hugomito
      By hugomito
      Hi all,
      I built an AutoIt application that interacts with several other applications/software. Now, it's turn to interfact with Visual Studio Team Services (VSTS).
      Does anyone has a blog, demo, script to share?
      Thanks!
    • WiorDi37
      By WiorDi37
      Hello, Everyone!
      I want when clicking the exit button the window will close. If content changes upon exit the program will automatically choose not save.
      Look forward to the help, thanks.
      #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <AutoItConstants.au3> $GUI = GUICreate("Form1", 220, 119, 192, 124, $WS_SYSMENU) GUISetFont(10, 400, 0, "Tahoma") GUICtrlCreateGroup("Chuẩn bị trình chiếu", 16, 16, 185, 65) $ok_Button = GUICtrlCreateButton("Ok", 32, 48, 75, 25) $exit_Button = GUICtrlCreateButton("Exit", 112, 48, 75, 25) GUICtrlCreateGroup("", -99, -99, 1, 1) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $ok_Button ShellExecute(@MyDocumentsDir&'\Dich-thuat\Short-Document.pdf', "", "", Default, @SW_MAXIMIZE) WinWaitActive("Data and Computer Communications (Eighth Edition) - Google Chrome") ShellExecute(@MyDocumentsDir&'\Dich-thuat\Document.rtf', "", "", Default, @SW_MAXIMIZE) WinWaitActive("Document.rtf [Compatibility Mode] - Word") ShellExecute(@MyDocumentsDir&'\Dich-thuat\Presentation1.pptx', "", "", Default, @SW_MAXIMIZE) WinWaitActive("Presentation1.pptx - PowerPoint") MouseClick("left", 1381, 886, 1) Sleep(2000) MsgBox(64, "Thông báo", "Đã chuẩn bị xong") Case $exit_Button WinClose("Presentation1.pptx - PowerPoint") ;I need help handling this place Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd