A preserved archive of the Logical Gamers community forums, 2009-2025. The original threads and posts, served read-only. Registration, posting and private messages are gone for good.

[Port] AS2 to AutoIt - QADCA Encryption

1k views · started by Isonyx ·
#1
[Port] AS2 to AutoIt - QADCA Encryption
Was going through some old files and came upon this project.

A while back when I started messing around with Gaiaonline fishing, I came across an encryption known as QADCA.
If I remember correctly it was the encryption Gaiaonline used (or uses) to encrypt and decrypt chat messages over fishing.

At the time I was planning on releasing a fishing bot, but never really got around to it.
After some searching I noticed there did not seem to be a public port of QADCA from Actionscript 2 to any language.

This is the same port The Unintelligible was using when he began work on his fishing bot project as well.

Thought I'd throw it up on Github for anyone too lazy to port it themselves.
I honestly don't even know if this is still relevant or even still utilized by Gaiaonline.

Again, not original code, just a port, but if anyone actually had some documentation on the history of QADCA it'd be neat.

Also I used an IDE known as FlashDevelop, courtesy of The Unintelligible.

Spoiler


#include <Array.au3>

Global $LOOP_MAXIMUM = 100

Global $aStorage[1]

ConsoleWrite("First encryption-decryption test cycle." & @CRLF)
$sEncrypt = _Encrypt(24811251, "Hello World!")
ConsoleWrite("Encrypted: " & $sEncrypt & @CRLF)
$sDecrypt = _Decrypt(24811251, $sEncrypt)
ConsoleWrite("Decrypted: " & $sDecrypt[1] & @CRLF & @CRLF)

ConsoleWrite("Second encryption-decryption test cycle." & @CRLF)
$sEncrypt = _Encrypt(24811251, "Hello World!")
ConsoleWrite("Encrypted: " & $sEncrypt & @CRLF)
$sDecrypt = _Decrypt(24811251, $sEncrypt)
ConsoleWrite("Decrypted: " & $sDecrypt[1] & @CRLF & @CRLF)

Func _Encrypt($iSharedID, $sMessage)
Local $sReturn
$sReturn = _Encrypt1($iSharedID, $sMessage)
$sReturn = _Encrypt2($iSharedID, $sReturn)
$sReturn = _Encrypt3($iSharedID, $sReturn)
Return $sReturn
EndFunc ;==>_Encrypt

Func _Decrypt($iSharedID, $sMessage)
Local $aReturn[1]
If (_IIH($sMessage)) Then
$aReturn[0] = False
Return $aReturn
EndIf
$sMessage = _Decrypt3($iSharedID, $sMessage)
$sMessage = _Decrypt2($iSharedID, $sMessage)
$aReturn = _Decrypt1($iSharedID, $sMessage)
Return $aReturn
EndFunc ;==>_Decrypt

Func _Encrypt1($iSharedID, $sMessage)
Local $sReturn
$sReturn = _EncryptMod($iSharedID) & $sMessage & _EncryptMod($iSharedID)
Return $sReturn
EndFunc ;==>_Encrypt1

Func _EncryptMod($iSharedID)
Local $iReturn
$iReturn = (Mod($iSharedID, 80)) + 19
Return $iReturn
EndFunc ;==>_EncryptMod

Func _Decrypt1($iSharedID, $sMessage)
Local $aSplit, $sPop1, $sPop2, $fBool
$aSplit = StringSplit($sMessage, "", 2)
$sPop1 = _ArrayPop($aSplit)
_ArrayPop($aSplit)
_ArrayReverse($aSplit)
$sPop2 = _ArrayPop($aSplit)
_ArrayPop($aSplit)
$fBool = False
If (($sPop2 & "" & $sPop1) == _EncryptMod($iSharedID)) Then $fBool = True
_ArrayReverse($aSplit)
$aReturn = _ArrayCreate($fBool, _ArrayToString($aSplit, ""))
Return $aReturn
EndFunc ;==>_Decrypt1

Func _Encrypt2($iSharedID, $sMessage)
Local $aTemporary[1]
Local $aSplit, $iCounter, $sReturn
$aSplit = StringSplit($sMessage, "", 2)
$iCounter = 0
While ($iCounter < StringLen($sMessage))
If (Mod($iCounter, 3) == Mod($iSharedID, 3)) Then _
_ArrayAdd($aTemporary, Chr(Round(Random() * 200) + 33))
_ArrayAdd($aTemporary, $aSplit[$iCounter])
$iCounter += 1
WEnd
$sReturn = _ArrayToString($aTemporary, "")
Return $sReturn
EndFunc ;==>_Encrypt2

Func _Decrypt2($iSharedID, $sMessage)
Local $aTemporary[1]
Local $aCounter[2] = [0, 0]
Local $aSplit
$aSplit = StringSplit($sMessage, "", 2)
While ($aCounter[0] < StringLen($sMessage))
If (Mod($aCounter[0], 3) == Mod($iSharedID, 3)) Then
If (($aCounter[0] + $aCounter[1]) >= StringLen($sMessage)) Then
_ArrayAdd($aSplit, "")
Else
$aSplit[$aCounter[0] + $aCounter[1]] = ""
EndIf
$aCounter[1] += 1
EndIf
$aCounter[0] += 1
WEnd
$aCounter[0] = 0
While ($aCounter[0] < StringLen($sMessage))
If ($aSplit[$aCounter[0]] <> "") Then _
_ArrayAdd($aTemporary, $aSplit[$aCounter[0]])
$aCounter[0] += 1
WEnd
$sReturn = _ArrayToString($aTemporary, "")
Return $sReturn
EndFunc ;==>_Decrypt2

Func _Encrypt3($iSharedID, $sMessage)
Local $aSplit, $iCounter, $iCalculation
$aSplit = StringSplit($sMessage, "", 2)
$iCounter = 0
While ($iCounter < UBound($aSplit))
$iCalculation = (Asc($aSplit[$iCounter])) - (Mod($iSharedID, 10) + 10)
$aSplit[$iCounter] = Chr($iCalculation)
$iCounter += 1
WEnd
$aReturn = _ArrayToString($aSplit, "")
Return $aReturn
EndFunc ;==>_Encrypt3

Func _Decrypt3($iSharedID, $sMessage)
Local $aSplit, $iCounter, $iCalculation, $aReturn
$aSplit = StringSplit($sMessage, "", 2)
$iCounter = 0
While ($iCounter < UBound($aSplit))
$iCalculation = (Asc($aSplit[$iCounter])) + (Mod($iSharedID, 10) + 10)
$aSplit[$iCounter] = Chr($iCalculation)
$iCounter += 1
WEnd
$aReturn = _ArrayToString($aSplit, "")
Return $aReturn
EndFunc ;==>_Decrypt3

Func _IIH($sMessage)
Local $fBool, $iCounter
$fBool = False
$iCounter = 0
If UBound($aStorage) >= 2 Then
While ($iCounter < $LOOP_MAXIMUM)
If ($aStorage[$iCounter] == $sMessage) Then $fBool = True
$iCounter += 1
WEnd
EndIf
$aStorage[Mod(0, $LOOP_MAXIMUM)] = $sMessage
Return $fBool
EndFunc ;==>_IIH
[/0][/0][/0][/0][/0][/0][/1][/1][/0][/1][/0][/0][/0][/2][/1][/1][/0][/1][/1][/1][/1]



The original AS2 source code I worked off of is hosted on my Github, as well as some AS2 code for debugging it in FlashDevelop.
#2
Good work. Code looks pretty clean and polished since I last looked at it a while ago.

The thread you referenced is pretty old and ramblish though. And looking at it in retrospect, I never actually got around to the lot of those, l0l. Oh well.

Nice post either way. Could be useful to those still dabbling into Gaia and things of the sort.
#3
Didn't know any parts of Gaia even still used QADCA. We actually made a port almost 6-7 years back I think in AutoIt.
#4
Tree wrote:
Didn't know any parts of Gaia even still used QADCA. We actually made a port almost 6-7 years back I think in AutoIt.


Yeah, I remember hearing about that. I think I even asked you for advice at some point.

Good work. Code looks pretty clean and polished since I last looked at it a while ago.

The thread you referenced is pretty old and ramblish though. And looking at it in retrospect, I never actually got around to the lot of those, l0l. Oh well.

Nice post either way. Could be useful to those still dabbling into Gaia and things of the sort.


Thanks. If you decided to pick up any of those projects again I still think your development of a Firewall would be very interesting.