Answer the question
In order to leave comments, you need to log in
What encryption algorithm is used?
Hello.
I decided to write a chat bot in PHP, I found a site - iii.ru I
started monitoring the network, here's what happened:
(send method - POST, host: iii.ru/api/2.0/json/Chat.request)
Host: iii.ru
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:60.0) Gecko/20100101 Firefox/60.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: ru-RU,ru;q=0.8,en-US;q=0.5,en;q=0.3
Accept-Encoding: gzip, deflate
Cookie: iiiszf2prd=ab1n9je0281j9b889epsq7l000; __utma=59720757.928596652.1528507335.1528507335.1528507335.1; __utmb=59720757.5.10.1528507335; __utmc=59720757; __utmz=59720757.1528507335.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); _ym_uid=1528507335526390865; _ym_isad=2; __utmt=1; mrc=app_id%3D475256%26connectPartner%3D0%26is_app_user%3D0%26window_id%3DCometName_218933313d5cbcd3edddbec043850e28%26sig%3D37456b98ebc7c923fe2defb4ef0f5275
Connection: keep-alive
Referer: http://iii.ru/static/Vishnu3.swf?v=3
Content-type: application/x-www-form-urlencoded
Content-length: 108
POST: JBYnDm4xNEI0ajsSPxAQFiIUBBE/ICACIA1xAzAZOV0sDRELIy16AzUERQE4DjsGbVExCD4iLyUIBjBXVDkKR0QjdDUdAiVSQikvW2kfRE8=
RmhZbkhIb3VLME1iWlNjTVBSZFRCUXNwTVJRWE56dGZDeDVxUlRBakVGNHZKMmxYSnhWWVh5SXFmQlF2TWhGZmJTYzVHenczRzBVb05pSmFQUmtkRVRrcmNSNGtKUkVDS2kwN0EyNDNKUVV4SmpKWFBDRTlCVDA3TUJrNkpUa1JOeVltVnljcVBRVThMWFVZS0dRbkdDb2hOQlVpSVcwSE95eFhGVGtsT0I0Z0kzSUhPU1l5QWk4ak5Bb3JKemdTYmpJckhqQnJEbFEvUFhGY0lqZ2ZFVDR3STFralZsaEdKREE1RlRzaVdGQWpQWEZlSWdKVlhTd3dPQlI2SlJCUVB5VXlEajhrQ3hFcE1UUmFPandVRFNVbExGVVdMU01kYnhvK0VRMDZKaEEvTVNJUkFTY2tYamtiSWdvTE9qSVFKRnc1Q2dBeFlWOHJXamNTT3k4WlV5RWhjVUEvS1I5RExDazhFeU1oV0Ywc0tqWVBMREVkUWo0clBCOTZJQjFETkdrblZUOFZXRjBpS2paYVBqY3pIU2NoV0VZa01EbGZMekpZVUNNOWNWNGlBbFZkTERBNEZIb3dLZ0lXTlNKRUt6WTFRd0FoSkJBNksyNEhEVEluVlQ4Zk9CZEVKelZDSnlvdFF4WXhNVUlvUVRjTkVEVTFXU0pjSlVNTk9qSlpLUjkxR2k5SkFRZ29MamNSTlQxTEdUMEZKZ0VvQXlOWk56OXlYUUlYTGtNc0wxVUFPZ0lyRUVFaFZCb2RhaG9URUJCcFdnMEFNVk1STndVQURBcG1SUWdqREFjUk0wd1hEQkJwV0EwQWV4OEROeDRIUkNSUkV5ZzJWeDBxSDBZUkJqSWRHVGdzYWhRekpTOVRPdzh2SFVZaVNVOD0=
Answer the question
In order to leave comments, you need to log in
Everything is quite simple
IiiEncryptionXor class:
package primary.utils
{
import flash.utils.ByteArray;
public class IiiEncryptionXor
{
public function IiiEncryptionXor()
{
super();
}
public static function encrypt(string:String, key:String) : String
{
var barr:ByteArray = new ByteArray();
barr.writeUTFBytes(Base64.encode(string));
var xstr:String = xorr(barr,key);
return Base64.encode(xstr);
}
public static function decrypt(string:String, key:String) : String
{
var barr:ByteArray = Base64.decodeToByteArray(string);
var xstr:String = xorr(barr,key);
return Base64.decode(xstr);
}
private static function xorr(barr:ByteArray, key:String) : String
{
var keypos:Number = NaN;
var keyByteArr:ByteArray = new ByteArray();
keyByteArr.writeUTFBytes(key);
var keylen:int = keyByteArr.length;
var barrlen:int = barr.length;
var barrNew:ByteArray = new ByteArray();
for(var i:int = 0; i < barrlen; i++)
{
keypos = i % keylen;
barrNew[i] = barr[i] ^ keyByteArr[keypos];
}
return barrNew.toString();
}
}
}
package primary.utils
{
import flash.utils.ByteArray;
public class Base64
{
private static const BASE64_CHARS:String = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
public static const version:String = "1.1.0";
public function Base64()
{
super();
throw new Error("Base64 class is static container only");
}
public static function encode(data:String) : String
{
var bytes:ByteArray = new ByteArray();
bytes.writeUTFBytes(data);
return encodeByteArray(bytes);
}
public static function encodeByteArray(data:ByteArray) : String
{
var dataBuffer:Array = null;
var i:uint = 0;
var j:uint = 0;
var k:uint = 0;
var output:String = "";
var outputBuffer:Array = new Array(4);
data.position = 0;
while(data.bytesAvailable > 0)
{
dataBuffer = new Array();
i = 0;
while(i < 3 && data.bytesAvailable > 0)
{
dataBuffer[i] = data.readUnsignedByte();
i++;
}
outputBuffer[0] = (dataBuffer[0] & 252) >> 2;
outputBuffer[1] = (dataBuffer[0] & 3) << 4 | dataBuffer[1] >> 4;
outputBuffer[2] = (dataBuffer[1] & 15) << 2 | dataBuffer[2] >> 6;
outputBuffer[3] = dataBuffer[2] & 63;
for(j = dataBuffer.length; j < 3; j++)
{
outputBuffer[j + 1] = 64;
}
for(k = 0; k < outputBuffer.length; k++)
{
output = output + BASE64_CHARS.charAt(outputBuffer[k]);
}
}
return output;
}
public static function decode(data:String) : String
{
var bytes:ByteArray = decodeToByteArray(data);
return bytes.readUTFBytes(bytes.length);
}
public static function decodeToByteArray(data:String) : ByteArray
{
var j:uint = 0;
var k:uint = 0;
var output:ByteArray = new ByteArray();
var dataBuffer:Array = new Array(4);
var outputBuffer:Array = new Array(3);
for(var i:uint = 0; i < data.length; i = i + 4)
{
j = 0;
while(j < 4 && i + j < data.length)
{
dataBuffer[j] = BASE64_CHARS.indexOf(data.charAt(i + j));
while(dataBuffer[j] < 0 && i < data.length)
{
i++;
dataBuffer[j] = BASE64_CHARS.indexOf(data.charAt(i + j));
}
j++;
}
outputBuffer[0] = (dataBuffer[0] << 2) + ((dataBuffer[1] & 48) >> 4);
outputBuffer[1] = ((dataBuffer[1] & 15) << 4) + ((dataBuffer[2] & 60) >> 2);
outputBuffer[2] = ((dataBuffer[2] & 3) << 6) + dataBuffer[3];
for(k = 0; k < outputBuffer.length; k++)
{
if(dataBuffer[k + 1] == 64)
{
break;
}
output.writeByte(outputBuffer[k]);
}
}
output.position = 0;
return output;
}
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question