From 58275c061edd5454f5e6ccf7006ce1d33da0cfbf Mon Sep 17 00:00:00 2001 From: Master Jumblespeed Date: Sun, 23 Aug 2015 18:04:26 -0400 Subject: [PATCH] nirai: aes --> xor for byte obfuscation, add toon takeover command, change prefix to stride-beta --- build/make.py | 13 +++++--- build/nirai/src | 2 +- build/src/stride.cxx | 23 ++++--------- deployment/deploy.json | 2 +- toontown/toon/DistributedToonAI.py | 52 ++++++++++++++++++++++++++++-- 5 files changed, 68 insertions(+), 24 deletions(-) diff --git a/build/make.py b/build/make.py index 11d0b6e0..d4248b41 100644 --- a/build/make.py +++ b/build/make.py @@ -29,10 +29,15 @@ def niraicall_obfuscate(code): # Reverse code = code[::-1] - # AES - key = ''.join(chr((i ^ (9 * i + 81)) % ((i + 193) * 11)) for i in xrange(16)) - iv = ''.join(chr((i ^ (5 * i + 170)) % ((i + 38) * 7)) for i in xrange(16)) - code = aes.encrypt(code, key, iv) + # XOR + key = ['B', 'A', 'Q', 'J', 'R', 'P', 'Z', 'P', 'A', 'H', 'U', 'T'] + output = [] + + for i in range(len(code)): + xor_num = ord(code[i]) ^ ord(key[i % len(key)]) + output.append(chr(xor_num)) + + code = ''.join(output) return True, code diff --git a/build/nirai/src b/build/nirai/src index 3d29188a..f1b859ed 160000 --- a/build/nirai/src +++ b/build/nirai/src @@ -1 +1 @@ -Subproject commit 3d29188a91b658f61cd2c3b3b8ada23050d4f230 +Subproject commit f1b859ed19c77f14ccdab22f3cd7ce82de2acede diff --git a/build/src/stride.cxx b/build/src/stride.cxx index 9b91f840..7db6fa41 100644 --- a/build/src/stride.cxx +++ b/build/src/stride.cxx @@ -145,21 +145,12 @@ extern "C" PyObject* niraicall_deobfuscate(char* code, Py_ssize_t size) { std::string codestr(code, size); - // AES - unsigned char* aes_decrypted = new unsigned char[size]; - unsigned char key[16]; - unsigned char iv[16]; - - for (int i = 0; i < 16; ++i) - key[i] = (i ^ (9 * i + 81)) % ((i + 193) * 11); - - for (int i = 0; i < 16; ++i) - iv[i] = (i ^ (5 * i + 170)) % ((i + 38) * 7); - - int decsize = AES_decrypt((unsigned char*)code, size, key, iv, aes_decrypted); - - std::string output((char*)aes_decrypted, decsize); + char key[12] = {'B', 'A', 'Q', 'J', 'R', 'P', 'Z', 'P', 'A', 'H', 'U', 'T'}; + std::string output = codestr; + + for (int i = 0; i < codestr.size(); i++) + output[i] = codestr[i] ^ key[i % (sizeof(key) / sizeof(char))]; + std::reverse(output.begin(), output.end()); - delete[] aes_decrypted; - return PyString_FromStringAndSize(output.data(), decsize); + return PyString_FromStringAndSize(output.data(), size); } diff --git a/deployment/deploy.json b/deployment/deploy.json index 3f5305da..675325ca 100644 --- a/deployment/deploy.json +++ b/deployment/deploy.json @@ -3,6 +3,6 @@ "astron": "6b769e6", "panda3d": "b924139", "libpandadna": "a0047ce", - "version-prefix": "tts-beta-", + "version-prefix": "stride-beta-", "server-resources": ["pdna", "txt", "dat", "bam", "ttf"] } diff --git a/toontown/toon/DistributedToonAI.py b/toontown/toon/DistributedToonAI.py index a01ee415..67f648c8 100755 --- a/toontown/toon/DistributedToonAI.py +++ b/toontown/toon/DistributedToonAI.py @@ -3126,6 +3126,24 @@ class DistributedToonAI(DistributedPlayerAI.DistributedPlayerAI, DistributedSmoo self.zoneId)) return ['success', suitIndex, building.doId] + def doToonBuildingTakeover(self): + streetId = ZoneUtil.getBranchZone(self.zoneId) + if streetId not in self.air.suitPlanners: + self.notify.warning('Street %d is not known.' % streetId) + return ['badlocation', 'notknownstreet', 0] + sp = self.air.suitPlanners[streetId] + bm = sp.buildingMgr + building = self.findClosestSuitDoor() + if building == None: + return ['badlocation', 'nobuilding', 0] + if building.isToonBlock(): + return ['badlocation', 'toonblock', 0] + building.toonTakeOver() + self.notify.warning('toonTakeOverFromStreet %s %d' % (building.block, + self.zoneId)) + + return ['success', building.doId] + def doCogdoTakeOver(self, suitIndex): if suitIndex >= len(SuitDNA.suitHeadTypes): self.notify.warning('Bad suit index: %s' % suitIndex) @@ -3298,6 +3316,31 @@ class DistributedToonAI(DistributedPlayerAI.DistributedPlayerAI, DistributedSmoo return None + def findClosestSuitDoor(self): + zoneId = self.zoneId + streetId = ZoneUtil.getBranchZone(zoneId) + sp = self.air.suitPlanners[streetId] + if not sp: + return None + bm = sp.buildingMgr + if not bm: + return None + zones = [zoneId, + zoneId - 1, + zoneId + 1, + zoneId - 2, + zoneId + 2] + for zone in zones: + for i in bm.getSuitBlocks(): + building = bm.getBuilding(i) + extZoneId, intZoneId = building.getExteriorAndInteriorZoneId() + if not NPCToons.isZoneProtected(intZoneId): + if hasattr(building, 'elevator'): + if building.elevator.zoneId == zone: + return building + + return None + def b_setGardenTrophies(self, trophyList): self.setGardenTrophies(trophyList) self.d_setGardenTrophies(trophyList) @@ -4925,8 +4968,8 @@ def track(command, track, value=None): return 'Set the experience of the %s track to: %d!' % (track, value) return 'Invalid command.' -@magicWord(category=CATEGORY_PROGRAMMER, types=[str, str]) -def suit(command, suitName): +@magicWord(category=CATEGORY_ADMINISTRATOR, types=[str, str]) +def suit(command, suitName = 'unset'): invoker = spellbook.getInvoker() command = command.lower() if suitName not in SuitDNA.suitHeadTypes: @@ -4942,6 +4985,11 @@ def suit(command, suitName): if returnCode[0] == 'success': return 'Successfully spawned a Cog building with: ' + suitFullName return "Couldn't spawn a Cog building with: " + suitFullName + elif command == 'nobuilding': + returnCode = invoker.doToonBuildingTakeover() + if returnCode[0] == 'success': + return 'Toons took over the cog building!' + return "Couldn't allow toons to take over cog building because " + returnCode[1] else: return 'Invalid command.'