Jump to content

Actionscript to Autoit.


 Share

Recommended Posts

#include <Array.au3>

Func Qadca()
    
EndFunc

#cs
    function Qadca()
    {
    } // End of the function
#ce

Func e0($id, $s)
    $_loc1 = e1($id, $s)
    $_loc1 = e2($id, $_loc1)
    $_loc1 = e3($id, $_loc1)
    $_loc1 = e4($id, $_loc1)
    Return $_loc1
EndFunc

#cs
static function e0(id, s)
   {
       var _loc1;
       _loc1 = Qadca.e1(id, s);
       _loc1 = Qadca.e2(id, _loc1);
       _loc1 = Qadca.e3(id, _loc1);
       _loc1 = Qadca.e4(id, _loc1);
       return (_loc1);
   } // End of the function
#ce

Func d0($id, $s)
    Dim $_loc2[1]
    If (iih($s)) Then
        $_loc2[0] = False ;0 = b
        Return $_loc2
    EndIf
    $s = d4($id, $s)
    $s = d3($id, $s)
    $s = d2($id, $s)
    $_loc2 = d1($id, $s)
    Return $_loc2
EndFunc

#cs
static function d0(id, s)
   {
      var _loc2 = new Object();
      if (Qadca.iih(s))
      {
          _loc2.b = false;
           return (_loc2);
       } // end if
       s = Qadca.d4(id, s);
       s = Qadca.d3(id, s);
      s = Qadca.d2(id, s);
       _loc2 = Qadca.d1(id, s);
       return (_loc2);
   } // End of the function
#ce

Func e1($id, $s)
    $_loc1 = e1iMod($id)
    $_loc2 = $_loc1 + $s + $_loc1
    Return $_loc2
EndFunc

#cs
    static function e1(id, s)
    {
        var _loc1 = Qadca.e1iMod(id);
        var _loc2 = _loc1 + s + _loc1;
        return (_loc2);
    } // End of the function
#ce

Func e1iMod($id)
    $_loc1 = Mod($id, 80)
    $_loc1 = $_loc1 + 19
    Return $_loc1
EndFunc

#cs
    static function e1iMod(id)
    {
        var _loc1 = id % 80;
        _loc1 = _loc1 + 19;
        return (_loc1);
    } // End of the function
#ce

Func d1($id, $s)
    $_loc1 = StringSplit($s, "")
    $_loc5 = _ArrayPop($_loc1)
    $_loc1 = _ArrayPop($_loc1)
    $_loc1 = _ArrayReverse($_loc1)
    $_loc6 = _ArrayPop($_loc1)
    $_loc1 = _ArrayPop($_loc1)
    $_loc4 = $_loc6 & "" & $_loc5 ; + +
    $_loc8 = e1iMod($id)
    $_loc3 = False
    If ($_loc4 == $_loc8) Then
        $_loc3 = True
    EndIf
    $_loc1 = _ArrayReverse($_loc1)
    $_loc7 = _ArrayToString($_loc1, "")
    Dim $_loc2[2]
    $_loc2[0] = $_loc3 ;0 = b
    $_loc2[1] = $_loc7 ;1 = s
    Return $_loc2
EndFunc

#cs
    static function d1(id, s)
    {
        var _loc1 = s.split("");
        var _loc5 = _loc1.pop();
        _loc1.pop();
        _loc1.reverse();
        var _loc6 = _loc1.pop();
        _loc1.pop();
        var _loc4 = _loc6 + "" + _loc5;
        var _loc8 = Qadca.e1iMod(id);
        var _loc3 = false;
        if (_loc4 == _loc8)
        {
            _loc3 = true;
        } // end if
        _loc1.reverse();
        var _loc7 = _loc1.join("");
        var _loc2 = new Object();
        _loc2.b = _loc3;
        _loc2.s = _loc7;
        return (_loc2);
    } // End of the function
#ce

Func e2($id, $s)
    $_loc4 = StringSplit($s, "")
    $_loc3 = _ArrayCreate("")
    $_loc5 = Mod($id, 3)
    $_loc1 = 0
    While $_loc1 < StringLen($s)
        $_loc1 += 1
        If (Mod($_loc1, 3) == $_loc5) Then
            $_loc2 = Chr(Round(Random() * 200) + 33)
            _ArrayPush($_loc3, $_loc2)
        EndIf
        _ArrayPush($_loc3, $_loc4[$_loc1])
    WEnd
    $_loc7 = _ArrayToString($_loc3, "")
    Return $_loc7
EndFunc

#cs
    static function e2(id, s)
    {
        var _loc4 = s.split("");
        var _loc3 = new Array();
        var _loc5 = id % 3;
        for (var _loc1 = 0; _loc1 < s.length; ++_loc1)
        {
            if (_loc1 % 3 == _loc5)
            {
                var _loc2 = chr(Math.round(Math.random() * 200) + 33);
                _loc3.push(_loc2);
            } // end if
            _loc3.push(_loc4[_loc1]);
        } // end of for
        var _loc7 = _loc3.join("");
        return (_loc7);
    } // End of the function
#ce

Func d2($id, $s)
    $_loc2 = StringSplit($s, "")
    $_loc5 = _ArrayCreate("")
    $_loc6 = Mod($id, 3)
    $_loc3 = 0
    $_loc8 = 0
    $_loc1 = 0
    While $_loc1 < StringLen($s)
        If Mod($_loc1, 3) == $_loc6 Then
            $_loc2[$_loc1 + $_loc3] = $awesome
            $_loc3 += 1
        EndIf
        $_loc1 += 1
    WEnd
    $_loc1 = 0
    While $_loc1 < StringLen($s)
        If $_loc2[$_loc1] <> $awesome Then
            _ArrayPush($_loc5, $_loc2[$_loc1])
        EndIf
        $_loc1 += 1
    WEnd
    $_loc7 = _ArrayToString($_loc5, "")
    Return $_loc7
EndFunc

#cs
    static function d2(id, s)
    {
        var _loc2 = s.split("");
        var _loc5 = new Array();
        var _loc6 = id % 3;
        var _loc3 = 0;
        var _loc8 = 0;
        for (var _loc1 = 0; _loc1 < s.length; ++_loc1)
        {
            if (_loc1 % 3 == _loc6)
            {
                _loc2[_loc1 + _loc3] = Qadca.awesome;
                ++_loc3;
            } // end if
        } // end of for
        for (var _loc1 = 0; _loc1 < s.length; ++_loc1)
        {
            if (_loc2[_loc1] != Qadca.awesome)
            {
                _loc5.push(_loc2[_loc1]);
            } // end if
        } // end of for
        var _loc7 = _loc5.join("");
        return (_loc7);
    } // End of the function
#ce

Func e3($id, $s)
    $_loc3 = StringSplit($s, "")
    $id += 1
    $_loc1 = 0
    While 1
        $_loc2 = Asc($_loc3[$_loc1])
        $_loc4 = Mod($id, 10) + 10
        $_loc2 = $_loc2 - $_loc4
        $_loc3[$_loc1] = Chr($_loc2)
        If $_loc1 >= StringLen($_loc3) Then ExitLoop
        $_loc1 += 1
    WEnd
    $_loc6 = _ArrayToString($_loc3, "")
    Return $_loc6
EndFunc

#cs
    static function e3(id, s)
    {
        var _loc3 = s.split("");
        ++id;
        for (var _loc1 = 0; _loc1 < _loc3.length; ++_loc1)
        {
            var _loc2 = ord(_loc3[_loc1]);
            var _loc4 = id % 10 + 10;
            _loc2 = _loc2 - _loc4;
            _loc3[_loc1] = chr(_loc2);
        } // end of for
        var _loc6 = _loc3.join("");
        return (_loc6);
    } // End of the function
#ce

Func d3($id, $s)
    
EndFunc

#cs
    static function d3(id, s)
    {
        var _loc3 = s.split("");
        ++id;
        for (var _loc1 = 0; _loc1 < _loc3.length; ++_loc1)
        {
            var _loc2 = ord(_loc3[_loc1]);
            var _loc4 = id % 10 + 10;
            _loc2 = _loc2 + _loc4;
            trace(_loc2);
            _loc3[_loc1] = chr(_loc2);
        } // end of for
        var _loc6 = _loc3.join("");
        return (_loc6);
    } // End of the function
#ce

Func e4($id, $s)
    tracee("encode4( " & $id & ", " & $s & " )")
    $_loc2 = StringSplit($s, "")
    $_loc3 = _ArrayCreate("")
    tracee(" a1 = " & $_loc2)
    $_loc1 = 0
    While 1
        $_loc3[$_loc1] = $_loc2[$_loc1 + 1]
        $_loc3[$_loc1 + 1] = $_loc2[$_loc1]
        If $_loc1 >= (StringLen($_loc2[0]) - 1) Then ExitLoop
        $_loc1 += 2
    WEnd
    $_loc3[StringLen($_loc2[0]) - 1] = $_loc2[StringLen($_loc2) - 1]
    tracee(" a2 = " & $_loc3)
    $_loc4 = _ArrayToString($_loc3, "")
    tracee(" rs = " & $_loc4)
    Return $_loc4
EndFunc

#cs
    static function e4(id, s)
    {
        Qadca.tracee("encode4( " + id + ", " + s + " )");
        var _loc2 = s.split("");
        var _loc3 = new Array();
        Qadca.tracee("  a1  = " + _loc2);
        for (var _loc1 = 0; _loc1 < _loc2.length - 1; _loc1 = _loc1 + 2)
        {
            _loc3[_loc1] = _loc2[_loc1 + 1];
            _loc3[_loc1 + 1] = _loc2[_loc1];
        } // end of for
        _loc3[_loc2.length - 1] = _loc2[_loc2.length - 1];
        Qadca.tracee("  a2  = " + _loc3);
        var _loc4 = _loc3.join("");
        Qadca.tracee("  rs = " + _loc4);
        return (_loc4);
    } // End of the function
#ce

Func d4($id, $s)
    tracee("decode4( " & $id & ", " & $s & " )")
    Return e4($id, $s)
EndFunc

#cs
    static function d4(id, s)
    {
        Qadca.tracee("decode4( " + id + ", " + s + " )");
        return (Qadca.e4(id, s));
    } // End of the function
#ce

Func e5($id, $s)
    tracee("encode5( " & $id & ", " & $s & " )")
    $_loc3 = StringSplit($s, "")
    $_loc4 = _ArrayCreate("")
    $_loc5 = Mod($id, (StringLen($s) - 3)) + 1
    tracee(" a1 = " & $_loc3[0])
    tracee(" sh = " & $_loc5)
    tracee(" a1.length = " & StringLen($_loc3))
    $_loc2 = 0
    While 1
        $_loc1 = $_loc2 + $_loc5
        If $_loc1 >= StringLen($_loc3[0]) Then
            $_loc1 = $_loc1 - StringLen($_loc3[0])
        EndIf
        $_loc4[$_loc2] = $_loc3[$_loc1]
        If $_loc2 >= StringLen($_loc3[0]) Then ExitLoop
        $_loc2 += 1
    WEnd
    tracee(" a2 = " & $_loc4)
    $_loc6 = _ArrayToString($_loc4, "")
    tracee(" rs = " & $_loc6)
    Return $_loc6
EndFunc

#cs
    static function e5(id, s)
    {
        Qadca.tracee("encode5( " + id + ", " + s + " )");
        var _loc3 = s.split("");
        var _loc4 = new Array();
        var _loc5 = id % (s.length - 3) + 1;
        Qadca.tracee("  a1  = " + _loc3);
        Qadca.tracee("  sh  = " + _loc5);
        Qadca.tracee("  a1.length = " + _loc3.length);
        for (var _loc2 = 0; _loc2 < _loc3.length; ++_loc2)
        {
            var _loc1 = _loc2 + _loc5;
            if (_loc1 >= _loc3.length)
            {
                _loc1 = _loc1 - _loc3.length;
            } // end if
            _loc4[_loc2] = _loc3[_loc1];
        } // end of for
        Qadca.tracee("  a2  = " + _loc4);
        var _loc6 = _loc4.join("");
        Qadca.tracee("  rs = " + _loc6);
        return (_loc6);
    } // End of the function
#ce

Func d5($id, $s)
    tracee("decode5( " & $id & ", " & $s & " )")
    $_loc3 = StringSplit($s, "")
    $_loc4 = _ArrayCreate("")
    $_loc5 = Mod($id, (StringLen($s) - 3)) + 1
    $_loc2 = 0
    While 1
        $_loc1 = $_loc2 - $_loc5
        If $_loc1 < 0 Then
            $_loc1 = $_loc1 + StringLen($_loc3)
        EndIf
        $_loc4[$_loc2] = $_loc3[$_loc1]
        If $_loc2 >= StringLen($_loc3) Then ExitLoop
        $_loc2 += 1
    WEnd
    tracee(" a2 = " & $_loc4)
    $_loc6 = _ArrayToString($_loc4, "")
    tracee(" rs = " & $_loc6)
    Return $_loc6
EndFunc

#cs
    static function d5(id, s)
    {
        Qadca.tracee("decode5( " + id + ", " + s + " )");
        var _loc3 = s.split("");
        var _loc4 = new Array();
        var _loc5 = id % (s.length - 3) + 1;
        Qadca.tracee("  a1  = " + _loc3);
        Qadca.tracee("  sh  = " + _loc5);
        for (var _loc2 = 0; _loc2 < _loc3.length; ++_loc2)
        {
            var _loc1 = _loc2 - _loc5;
            if (_loc1 < 0)
            {
                _loc1 = _loc1 + _loc3.length;
            } // end if
            _loc4[_loc2] = _loc3[_loc1];
        } // end of for
        Qadca.tracee("  a2  = " + _loc4);
        var _loc6 = _loc4.join("");
        Qadca.tracee("  rs = " + _loc6);
        return (_loc6);
    } // End of the function
#ce

Func iih($s)
    $_loc2 = False
    $_loc1 = 0
    While $_loc1 < $bolmax
        If $bol[$_loc1] == $s Then $_loc2 = True
        $_loc1 += 1
    WEnd
    $bolc += 1
    $bol[Mod($bolc, $bolmax)] = $s
    Return $_loc2
EndFunc

#cs
    static function iih(s)
    {
        var _loc2 = false;
        for (var _loc1 = 0; _loc1 < Qadca.bolmax; ++_loc1)
        {
            if (Qadca.bol[_loc1] == s)
            {
                _loc2 = true;
            } // end if
        } // end of for
        bolc = ++Qadca.bolc;
        Qadca.bol[Qadca.bolc % Qadca.bolmax] = s;
        return (_loc2);
    } // End of the function
#ce

Func tracee($s)
    
EndFunc

#cs
    static function tracee(s)
    {
    } // End of the function
#ce

$awesome = ""
$bol = _ArrayCreate("")
$bolmax = 100
$bolc = 0

MsgBox(0, "", d0(944712, "S")) ;encode?
;MsgBox(0, "", d4(944712, "S")) ;decode?

#cs
    static var awesome = null;
    static var bol = new Array();
    static var bolmax = 100;
    static var bolc = 0;
} // End of Class
#ce

The commented code is the actionscript.

I tried converted it line by line, or as close as I could, Naturally I ran into errors.

What the code is supposed to do, (I think?) is encode/decode $s based on $id.

Reason im trying to get this working?

I want to make a chat client, but about a year ago, they encrypted the "chat" part of the packets.

I think that, it uses the id, to encode/decode the text. I have no idea if thats right or not, But I dont see how else.

If I go into the chat with two different accounts, and check the packets, the encryption is different. So that would explain it.

Anyone mind helping out? See any errors in the script? Bah, I hate converting stuff. D<

# MY LOVE FOR YOU... IS LIKE A TRUCK- #
Link to comment
Share on other sites

Heres what the "encoded" packets look like, And im the parts highlighted, are the parts im guessing are $id and $s

Posted Image

# MY LOVE FOR YOU... IS LIKE A TRUCK- #
Link to comment
Share on other sites

  • Moderators

You'll need to read the file in binary mode.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

  • Moderators

What file?

I assumed it was a file AzKay... you never stated other wise (at least I didn't read where you did).

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

K, So, what im doing is:

This is originally flash based, With avatars and bugs, etc.

What im trying to do, is to make it into a text based chat.

The "chat" packets, are encoded, so when im receiving the packets, they come out like that, the actionscript above, is the code that encodes/decodes those packets back to their original text

For example; In the flash app, I say;

Hello

The packet would come out as X.XXXXXX.X.XXXXXX.<This part is the encoded text>

Im trying to decode the encoded text, back to "Hello".

In all the functions, it uses $id and $s, And I think $id would be the

X.<HERE>.X.XXXXXX.

And the $s would be the message. The, "Hello", If it was being encoded, or the encoded text, to be decoded.

Basically, Im making an alternate text based version in autoit, as opposed to the flash one.

# MY LOVE FOR YOU... IS LIKE A TRUCK- #
Link to comment
Share on other sites

  • 2 weeks later...

Well the actionscript contained within the code looks like it is written by a robot, there are no comments or distinguishable variable names.

I can't tell how the packets are captured, are they retrieved using the TCP functions or are you reading in a log file?

Does the Actionscript code still work? You say they made changes. Can you post a sample packet so we can try to decode it?

Edited by weaponx
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...