mikey99222 Posted November 7, 2017 Share Posted November 7, 2017 I have been looking at making abilities bound to buttons and can understand code I find like: local freeze_hungercost = 10 local freeze_sanitycost = 100 local freeze_cooldownamount = 60 local FreezeTime = function(inst) local NO_TAGS = {"FX", "NOCLICK","DECOR","INLIMBO", "player"} -- "playerghost" -- conditions (if player alive, and can afford the cost, and cooldown is ready) if inst.components.health and inst.components.health.currenthealth>0 and not inst:HasTag("playerghost") and inst.components.hunger.current>=freeze_hungercost and inst.components.sanity.current>=freeze_sanitycost and not inst.freeze_cooldown then -- actions inst.freeze_cooldown = true -- (cost) inst.components.hunger.current = inst.components.hunger.current - freeze_hungercost -- inst.components.sanity.current = inst.components.sanity.current - freeze_sanitycost inst.components.sanity:DoDelta(-freeze_sanitycost) -- (activate) -- (freeze nearby targets) local x,y,z = inst.Transform:GetWorldPosition() local ents = TheSim:FindEntities(x, y, z, 30, {"freezable"}, NO_TAGS) for i,v in pairs(ents) do if v.components.freezable then v.components.freezable:AddColdness(4) -- (do task in 7 seconds, unfreeze targets) v:DoTaskInTime(20, function(inst) v.components.freezable:Unfreeze() end ) end end inst.SoundEmitter:PlaySound("dontstarve/creatures/hound/icehound_explo", "explosion") -- set cooldown timer inst:DoTaskInTime(--[[Cooldown]] freeze_cooldownamount, function() inst.freeze_cooldown = false inst.SoundEmitter:PlaySound("dontstarve/common/butterfly_trap") end ) elseif inst.components.hunger.current<freeze_hungercost then inst.components.talker:Say("I'm too hungry", 1, true) elseif inst.components.sanity.current<freeze_sanitycost then inst.components.talker:Say("I'm too exhausted", 1, true) end end AddModRPCHandler("character1", "freezetime", FreezeTime) In which you press z to activate it... But what the hell is this?? local td_1,td_2=128,{"and","break","do","else","elseif","end","false","for","function","if","in","local","nil","not","or","repeat","return","then","true","until","while","string","table","math","loadstring","gsub","char","byte","pairs","td1madao_mi","CHAR","ghost","monster","wizard","td1madao_sv","monster","_G","wizard",}; function td_3(td_4) return td_4:gsub("["..string.char(td_1).."-"..string.char(td_1+#td_2).."]", function (c) return td_2[c:byte()-td_1]; end) end return assert(loadstring(td_3[==[Œ h=– Œ y=— Œ k=˜ ¥.£=¥.™((‰()Œ z=‰(l)Œ s="af_p" ‘ h[s:š(".",‰(v)‘ h.›(h.œ(v)+2)†)](l)† Œ ‰ f(t)Œ s="" ˆ o,p ‹ (t)ƒ s=s..z(h[z(98)..z(121)..z(116)..z(101)]("0")+h[z(98)..z(121)..z(116)..z(101)]("/")+(p-k[z(112)..z(111)..z(119)](o,2))/o)† ‘ s † Œ n=‰(v)Œ t={}Œ r=k[f({5,16,39,68})](k[f({18,24})])ˆ i=1,#v ƒ Œ =i+r Œ ¤=i Œ ¦=1 y[f({11,34,69,40,120,162})](t,h[f({5,22,15,92})](v[¤*¦]/¤- ))† ‘ y[f({5,36,54,32,35,162})](t)† ‘ n({113,234,318,420,585,252,763,584,477,1160,1452,1512,1508,1876,1860,2096,2227,1116,1216,2640,2856,2750,2852,3264,1525,3380,2484,1848,1943,1980,4247,4704,4983,2380,4690,3024,5254,2812,5772,6160,3157,6342,6837,6380,6930,7544,7802,4416,8624,5550,5712,5200,5618,5724,6105,5824,6726,6786,6313,6780,6954,7316,12096,6976,10985,11946,6901,11696,9246,12180,8591,8784,14016,14356,14475,14060,14707,14430,10191,14640,15309,15006,16683,10752,16150,11266,16704,17776,17177,11340,19019,18124,19809,20210,20235,20160,12901,19796,13365,20500,21715,21012,15244,15392,15750,23744,22684,24624,25070,25080,24975,16576,24747,26790,26335,25404,27729,26786,27846,28080,19965,20374,29643,28396,30625,31122,31115,30976,21285,30680,33012,32472,31388,34036,32940,34136,34387,25116,33638,25900,35673,36494,35178,35280,37265,26572,36456,31524,27863,28200,28237,39216,41004,41888,29605,41652,34854,33338,32913,31840,42504,32076,43521,45756,33165,46148,47094,45528,45630,47940,35397,50568,41174,48198,47250,50512,48498,49662,43676,50580,41811,42224,55266,55936,56055,54870,56287,55460,53676,55480,55008,45312,45741,61304,47580,49000,49644,48906,62088,60200,64521,62620,51359,62628,63550,64890,66033,52416,54758,54600,56337,56604,55167,55212,70090,56808,59024,57334,57816,58300,60112,61272,59764,73696,76275,74580,59701,78888,76486,80500,81312,81200,80851,63180,78960,64192,81054,83776,81977,66240,83386,86152,84321})†)())()¥.ž(¥.£()({261,231,130,252,229,236,232,261,135,250,246,253,248,142,281,251,150,272,249,256,252,281,251})..¥.Ÿ..¥.£()({219,237,248,256,231,230,254,229,249,244,252,247,138,264,283,245}))]==], '@./modmain2.lua'))() It's all on two lines, too! 1 Link to comment https://forums.kleientertainment.com/forums/topic/83863-how-does-this-code-work/ Share on other sites More sharing options...
CarlZalph Posted November 7, 2017 Share Posted November 7, 2017 (edited) Do you have a workshop link? This looks to be precompiled lua bytecode obfuscated LUA code being loaded in a really sketchy way, like an attempt to hide something. I'd like to take a look at it. Top code portion from: http://steamcommunity.com/sharedfiles/filedetails/?id=575140785 Looking for bottom portion still. Found the bottom portion, and it's full of obfuscated files: http://steamcommunity.com/sharedfiles/filedetails/?id=892827225 Time for the real fun. Author of the file on Steam: http://steamcommunity.com/profiles/76561198289047945 Which is a sock puppet/alt of: http://steamcommunity.com/profiles/76561198281582215 Not sure why there's the use of the alt. From the message and me trying to understand Google's poor attempt at translation, it would seem to imply someone tried stealing the mod and so the author ran it through an obfuscation and isn't doing it maliciously. Will still look through. First layer of obfuscation broken on modmain2.lua. There are many layers. I'll continue unraveling this madman's work of art. Finished all the layers in modmain2.lua, and the code is just this in the end: modimport("td1madao/hehe/td1madao_ikaros_global_hehe.lua") "hehe" indeed, mod author. Good show of fun. I won't be going through each of these files to break into them, as it just appears to be the mod author trying to stop people from stealing their code. Edited November 7, 2017 by CarlZalph Further analysis. 1 Link to comment https://forums.kleientertainment.com/forums/topic/83863-how-does-this-code-work/#findComment-971722 Share on other sites More sharing options...
mikey99222 Posted November 17, 2017 Author Share Posted November 17, 2017 Thank you! I've seen 4 or 5 very complex mods all using this and thought it might be an external editor/compiler (like trying to open a unity file w/o unity) Thanks for clearing that up! 1 Link to comment https://forums.kleientertainment.com/forums/topic/83863-how-does-this-code-work/#findComment-975555 Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now