Moin,
habe leider nicht mehr die Zeit und Lust das System hier vollständig zu testen, sollte aber soweit funktionieren.
Was habe ich hier gemacht? Alle Python files im root Packverzeichnis werden mit der Bitte melden Sie sich an, um diesen Link zu sehen. verschlüsselt. Ich nutze dazu AES im CBC Mode mit einem 32 Byte langen Schlüssel und zusätzlich einem 16 Byte langen Initialization Vector.
Nachdem der Plaintext verschlüsselt wurde codiere ich den Dateiinhalt zusätzlich noch in das base16 Format. Dieses nutzt das Alphabet "0123456789ABCDEF".
Verschlüsselte Dateien sehen wie folgt aus:
- 0949D8CA6F52B7AFFF3014286D6D0EBB16877FD557BE2FF4CAD94A45F72C8FBDEE5EEDF69D98B99A14FB5AAD07F983AE598EA5AC87C6ED954F7BD88461A5D6D0F0B6699A48C3ABFFEFB178262CE7575BFEAF8B08FBD34DE97B87C3CD2BE83AB552DE5B5A1A45AA01D454AA6C696C6C5B091FA1DBD157A8AC23CC203CDFDC278F9C71F0E1BCF5ABCE4D26CE2CFE285B0D81B64E6B42E121B89932E50EFE8CE6DDA29310376C76D9B63E8F963AB9C016451FCAC4B6DE070312C2435B8A10FBE3B24CF5394C41B7B0D2CBD440D7042BBCCCE154B74E9345F28A469174C66E34B44F903104D1B2BC94D69527E022B8030380D673449EE03591539142E6C3CFA36FE2916AB75A53332ECC0D3C0108E034ABE1DAB1A8227F9EFB9EDC4B03771233435677CB8F0DB542D904620DD88BBA57E00C25586E37F8ECBFA5EF67CD30556E2605DFDF292C6F6C3C227539BA2E925B60A75A6A00340A16B7A885181C653A4DA46CD9C709AA4CEF4AEF0768B01B7106A6797AFDB1FE69BDDFB415378AAA9EB53689AAEDB46B46CE176A8074115E1167D45514A9EA41BD4E5E52CC2B4A7BF2FE927E725DF16293892EDA65CD347CB3CA8C136637BC41A7612B4B531CB311F54B4AFA55D646B3853808E56360730E1C6FF4016A98DCE801E50E0D7D2B1D646363EEA984D96EC3F6375DC96C4F0A2BE26460A2322BF1D432A77B72ADE88B758AB8752439BAC5AE4F5840AEB00AAB508CA3FD8E14C4757759C0B51B6B59BF0EE51FF0741867B86862EB9A0533FA0A835BFBDF08FCA2FC114325767D42214522EA83180B64EB49532AE3953EE1F231DA00B8F73E42A0C00AA8721CD7AB2666282B487623F1AC817DAB1F79A8439B2CAD55F17BEEE78E172F9D7426FF6993886603915AB8FC5F65C1356F0B197BA500E12B42583B71CD7A558C1F79E7F6CC92733003E2F32A2A4CAB90133A53FF02F2544DF0172F47D827F76FB2EDD0DF9B8DEAD70F7491D1DA98F3323B4FE808362F85083BED7F7D11E1A37DEF410A869C7B101B776C584C74CAF0617BC11C92CD1E951DEA89E30D373DC42BDAA822FDF15B96AB2E161DDA17947CC1A1B1D4927E04FD1F28DCF48EFF22AAD8330EA0F976EFBEB64EC4646B1A9F01EBFA032563E564F2348D40152FCD797907F275F62878A4D7D6416435AB2839504BE09D4877AA8DCC9684D1F1D90FD1814D2F95861F3CD199525C495156E969F161932F75B02F97DACEA2E159DFBF8E4F6D8F9209CFCA1B1F64E6B9AF2CACFCE5FC677207B701CFC0AABC94E42E9251FDAEE856EC42909E7C666489E0B432B6B2686263ECF1D553C78B494EF0831B53DFDF0293CA82769441881A1E9EA19C1D063E33D27894C42E3D698E825E6E2421813D3AEED74DE1535BB64FD49B4CAFC652A1E4805CCEB3A30CF28423DEFC6F9EE6662F52A3723594E4184FF7BF8253D86E5008F92710A43C539C5C7E311EF7EA0F83520E0D0B636AC879B9546E4180056E958FF2F23C3D2415A649CB1B1730C4E893CC180811233999779A4A78430B7C5561E176652F660A91780EE588DF8644A86C9A2C83BB686A5975BB1DAA92808325AFA1C3CCD09EA251D397A9DF91144B0715DCE7C069CD105E0F32D9CDDC8184E8C11DA2EC6ED7CC8C7844665EA6B744FCC40856C5FFC391F92963B90C88FE621CC9717F0B52809AB261D5EE822134CC45F48D981FD7EBFB080632D53AF7884CE69E881E0F68101A74E125310D0FF02BED3DCEB2AFB20C1B8B6BBF345CCC2A724A48E5DDC9354B19899E43C418A700E10A8B729D6AC1D84B78E6EADBD781C27C99269D3655ACC99BC6C3DC0EFA37919138CCC87D4A83AF3EE93BC024395AB37467E4A9F55D6B8B9DE80D383D075D8D934CC211F8771D9E34751BF03903DC6F7CEBE542BE9BE2D01A80F5B466389EF87EC859B6DEE94F76DC511E7C2DB5E920D6AF2BDD435EE56A2F0882712B5FF85836C489E6B4D28E5C14CFD128B7FCFC0C84DD78A45CF0E17E170C44C68B03B943D966E62E13717C0A1C3824C6A12F541B25C2B80586C89EE4B6196708DB2FEBB02E43F19FA5F9F6C24FAF505BC3091493B220ABD986EF48B56B365171AB7F17FC77374928FDF2F8EE1F394CD0B1913F07E63E8A017EDDCB60EF3BCA4F987B0EFB4DBCA6658156AF7AABFC2168E2861F1ADF88312E6C2C17C70A46D583E9AF65F2A71A49BDF8546AB33906882262053E1FA166E8E29F82447ABCB83F7066185383790A89C3E29C453A8B19881CA7220C8BF6681401B3C0B3F86459968578C0CAE32C9E9D4023A461B6E1E07B1FCDD7700F2EA88DE0A170329CEAE297520E969061B5D02BFE9A92FC5BF9A7470E8A77B82886621DAEAC23D155359051AD6A03560F098A903A7DF05314730B801E4858CCB5EACC56EF344ABA13B000158255FFBEA748E80CBE6504F1961186738FCA96B5BF73D263DC96BF43775E07549FAD934EC4A9B93E5892C5C190681515F0C23357CD37DFD0F7A944489BDD9B9BA7958AF8CA772F72BFB1C1213175AD8CFA52DCF35D98493A4217DE7AE12F202AA1EAD1AF4925EB5E4E690E2823026838A4E0FB004E18D69DD4E05E6A010A81B66DE11FD724F8864163647BB42A6E969971C83FADA6627F3A25E5DE099712D91891F137C7F0C6E53FDC15DFB676D815435E1F5E6F9973309D3FAAD622AB66A0A449F6C324878B9AC61477B1F3D04DAAAD9EE5DF70F2E3DBA391F0014BEA7A1B34A723F400A72D5590ABDF91FE8BC6034C87C63C70D0BB0AC0A0E8205FE3DB9B861CFA57353EBF3264F2D090F0FE4B0B71E95A3A0CBCE3E71EFD9858AE7ECD4A6B8B0230C3F2AA941D426CE80685C871F98E51B4D29FA97F519DD8003C574DA0600CA3584850341DF9E15F0853B7B4BF15369230EDAB43CDE0FA4DA96FF246B47486BD95A58323D4CE9719294F61AE578728633D4C5E7CC6A423C75C87E1EB288E3AED7A09B79481905A566071DEE5792421EF9FA2B94D1CA9B9FC90C3C43C5D7711E6260542E68386A886031656C3D28FD08F7DC6D0A03E2414492F77D63FBAE5AD38214AA4BD9BBDCD9117B8E24DF1B665702849839E98CB8F12080C6F998EEC3D7FA0E71DCFF42BDD14BB7335EEF1FC6080B396C0842C73E35527733D278BC0F3FD65D3CA6936B8C5EBFB89E3CD92195CBD57D4BF9C4A7B4C6F4386BAFE4D67D89691CF6A155EF21B9D23C891D332C74F22A388A546AFDA6C58D9442D08D864CAAC32C923662581F37C5B9C7AFE9635BA98C343C00F56D5207FB31FC7F7FBFDD0D1BE8D1239BD8E4F1826F85081BECC7B75C2542D9A8D730B3E3489D89DA78C80898CDDC2CD8E44C9AEF9D9FFC362D0354818E9111469FBD5B141A20DD470010F6945D016909CCF4137FB299F6DA0A8D8DE6911B2F55BED5C2233F46EC2EE69156411739467373B6359D1AFCFE1BA60612D507B91E6768D7F96DD1942031914BC7098F894CA403FC78FC1205229E9B90BDB01598BADC33B17ADA1B58010D1F9575D31787C3754EC78EF2A0898023EB757D83D52FD1D1596CF1213AF154F83384557455C7E1DB074E016D48AE40CD44DAA99DD1C42234196614D77CCAEF9692065D0759578CC74E3C68DE572F04D3726A18D002C9BE76DBCBFB8315BE228B3257919EF5969B51763643E3C59B13C3CE7A83F3A5C3BA3B9C0E8679C5BE5B85E781735F07027A55B58DEB7F665EC1534269D31963840E9BECEEE66D4D74767E0B26FC45CE6D8E02564203C876EB09C58C60F0D38652E8D976E289A15FC1E47197E546A294A27496CAB0F7356F1B97C05A0F8FD94290C92CA79C1CDFE6656222588EDF469A3D73928481FD827D14E168CE33CD74F78995744E02E255EFA33D2DE5C7F2203B2683B980FEA6C3083455830F45F91E39402A4566E73C6CAAEB5C80693EA1CF170C79240F805578F2AE3E96CB07684E4D6152FAAC2DA5EAEB03C603C5876509D873AC9E8B9F902DEF62C00365C634F291AE1ED97AA7F36C5BC92A8A3694755FCD22B9417C46FC15B532157F63ED1787C737489C6E03764174731D268927D0CA5229F908C2868E6B594E2070C8CF64E949136F359935D67A3826AF47CEC91DA486D627C00BA3B8E5856A7804ACA7C0D6BC460F32A43312251610E99AA9235A53C168E2B6643E7E7DCA7C1C2D9E06E5269F5FBBE1130E955F1EA46BCF4E6E2103F2A0A0DC2FB4F3CAE1137D52313A0C27756978DCFD8D17FD25A7D85A68908DD16B3399AEE62D0A44163D8522A0B98C974DFC7203B3222702F2B675B569DCB545910A2C2357B618993418FB9D2E88B31F9A1F7DF2834DA04303A0F90F2A2D8279D3C9A942776469FB0B7D27DE9DCB63F2F0BFACC9261AEFEEA16FDE0ADB5291BE6B46611B183D65B188135E0805064B7AC14F9B8F8B4ACEAF7C7FE5DD50E63B343D2030F8C98DE9AC7A64342595694A5C110AD430615A068C0AA140AA49FBE6164A7AF94905332B9C313867D972583D6E664C4930E20442A92FC39AB4076599F3BA2CC203B6CB882AA7146A7AB192034AB93E96EAC735CB56D52498E4BC076D973ACAD846628A377A65D003EB9D18A7A58E9349B4F79202ACB988D57C031C03FE745B8F91AB2C695174EFB8D0660E99F33ABE7E7ED274069D56157A1BA4D94121EF194B85BD34D14D0D9D1624AB0E69050C06443D382B1CEB94ACC659F32AEF82A212BC56C0F9260C36064F476F22AFDFFA7FAC60F365E52333B2064C0DAD0A9D7355876E2E4A6A5AD12661BA250FFBAA2AA9DE8D5B7A36A1DE243B761879D0D77367702C1DE1AE85B34B1D7DB82FFDE797F082022B1F6160BEA09CD821281B9D53F021F639DF1DE84217D7921E8D0E38E12EC03E40EFF5C91BEC56F0F3243887A092A471A927CF995A2EAFE9957E949365293E315E2B587E20C23223B9DA6BDD7DBA95AC7AB49478DD87D1FACE18C237B45691F076519F70F299D029598FD4C45C80073F7D224CB9A9DAFF25A477F42EDCAD55DDD24E28D40EF8CCB118D8F49FAFFDC14D54EC0EF386DC17D8A23D8D883DBABAD94CF3942DE277D253099B704B747CDD3344DFB1E53855658DD0E3F7B931AF571F1DCF6AAD2646687E0E5C91EEAA1BE7DA84C6966B9DF6561A390F6FBAA38DED8DA06B835FEFCF29BC7B91BD8282F3DD1B946225B0E7908B43D94BF04E2BF51E82FE96DD365D181572175E4D1518A62D9B6444A93BEB901F40D67A5AFFE602B0B9D7F653E66B6D313810F652723C7D08FCB533975E587D29E89AFC32BC6D5061F534F753237304A8CF61A738242DBC3E7E2B5AAAC1FC3D38468D4EB82CA2DE59ED702F2049646A6F72EF96CE413F427108624F8AF9C3683E184A8CA7C8369AC30A238BC05F00955222922C8B6CAC66D02D7A37D024E7BAE1D3B4DB079A2306C7AD9B1B700D0D8A6B8829AC355D2C2DC18FE555E27E8CF2AF420981DE9D1EDE3F37E9E4E27A8ECC8EA221DB153B4FBA1985F9FAC9290F8738C3FE00CC44094F725BDAF42D50B23E439961EF0671DA00B93CB12EC3124E3A3072A66E6D3347C36684403403F2FE079C45183D349365D0D4D859F571BDB046FB9039A923402EABDB5E4F5AA79D772AD277159016DF9B5306B5A18BB5A4E47D66B650AD4760FC6ABA1394B26471209FB082DF0B982BD415631ECE0D84A75860118C59CC9A48CA18843C10C5BFD84E64D4700379601E2E1D834D070666A0881FF0B3222F12A9D76E623C0BE387D44FF847C7795CB41EF6BC35763FF3096826E5916AAE9CC3BD8B3167D3AB7D32B03A66BE3671C43F42F729231DFFC64751E5538553A38977165ED5272D588DC3DD981755EE63D193AF30AE1221B1AB7150CF406B833B19DDC3B9F32605787201703A1E4FEC267CA542AD3E0D9A182FE979D1298AABD900E4B8BB76248903E408A319F0F31109A590EB724387ADC58673DB1FB586C61135A0EA5A4628808B7A84A41E21B9247D11BF9B811F9FBD43D13539B3085331E4B1DF05CBB7BC4F925571C7C4D361F00A0FF6C2D4A5AED702692CDC12F596BB9E237DAC08F827F1E824810CAE0A139D150A92FE99C04F3A5FFB99D12242EB442E7F7FC92655345E4B8DC0C07FFF2B652B04DC97E00DE24B1D3F09A85051987A98DB5775E7FEC7A3B835DAE9EC9FD1FC339C3D90CC9631B4F1EA5264611C524B6A65A4F68D8E8C648FB51B0A0EDB4A7A9D325CB5935370A05482A26BBDF8DFE01061121400D05908D18CE4400D7D1794F0FE98B8B88C0990D0112AE5FED39F9CFD13BF1B0635CACEE14E992A5EFEDD9711BCD861B867BB0732F61D7A06816AFC340EB78E7A994D6A1D30AB321EDCF53AD08CB14E7330F33C048AEF8582D737B72C2A3671E369B7D8A1313615B6599BD94E111EEF7146284F730099916F264FD3A681D1C898DB716AE841619DC537E4371193C3D6D655601642B64611DB36060156C53CA9C41DEBE778EC19B63BB828878905C452E2DABF690F4A2973BA398730DAFE5E9F705E96EEDA8629C72B3E6AA306FE1DFC38DD7A6FC7922DD3052D69FC39455DB69A3EF2FCB7C58DDA6713C9DAF106F27DCFEAD7E8D1A16969DBDBB1F827B649572483704BA40137C67C888A8F9DE2871EAB268A7D41FA1EF19015CDA498B7FCBCF706C478EF635C57E869BFD9D384C60D9D0CD4A93DDFBE7BCC37CE7AB3131B27AA2C71A32E078960E99006FAA5F7BC9B327D68EED554C39B8B04C49E2AD93200F4C1CAE662BB87BC7129587991E1E5592113FDB891991F45F0E7A347B39EF50DD180020D68AB54F0F3237B11DD4C9B12D9C1554930928C0A781DEEB135DFB9251B2E2B1A1D35614AC885EEAC223E7DE121711221125E112787747406AAC41DE02528947950C625860A7A0E45B5911CA1F07ACD95FECD6F07D968540D6DFF6707F6C1BFBDEC2356842FFEE6A012D1514F99EF86A879B539CEBB72B7FF9C0E03C36422C36ECCC4F6E8D7152FB0E343E8CD72B581E47783C678D86130BF7EC56C245F562723CEC6C5EF78E6875B531C96BD915331B12FD936EA5ED011B4067AD4BBB062D2F418616587A6E44DF838AF51EE5845DE705F77F82A90B66CB32D8B22CBEB5D17209F64525AE5DD076B4D37A583904C34CC7A2B49446B07CDA821043E94EE6453C3FEC4052790F0D41A14A1DA7334CAEA43FC62EAA5C0B19231DE2B624670D12748CEEF31CAEF6B14F364BCFEB8AFF97B803BAC2A9E16610CED1845444E478C2C8488678935C59A65757F413114DEB49F71815E79FB81A300E5AF1D5FEC3EFBDC877D8EE3D2BDFBB72791E8721703C7532CA959BBD3D92E96EBAC92D8D1DE359444EF5F007798A0D241517411C0C9EB81D56A16F1522A4BB307A2D15481F9D810A8F147649626CB76DEF5C9BA3C7A5BCEA9DC8C2FF3151AF1F016FA837E3EC7240C6BA9847B75E76E6D3D072841777367908AD29C8D64004D8F19678793EBCF19A22516A28FB0B213D91459747AFCE3459BA045FAF371E4A5579DA77A254F7FB6B63EEC08F3CB753A0CDEC8C70A6B25BBD286116D10E73888806A72A8A24673AEEE95A2D288AA56D6F239DE87EA89B54805AE0DA6BA56DB74C307010BD4C7B903EF2674CE5B0C2A42E3A74348B24169E3A0144F874F65DB63D1CAABDF650CE5180E2A847E470FC6C7B924A96B591DC16D1CB52788B6EDA4A623D41DA9541F0D4E326DD37E83DD6FDF110A376A8A58AB4AFB66FC312C7BD67F5B5F27C5694ADD29B13A7169114F66C3C8A7D4EB05AB27C31B5AAF0A8BBB9B72935774719C8E6E170EFF8BB684249087C9DB090D165CCDF0FB9D8DF5DD2EE2D86EA1A5768AC130ED76F925F4AE395AA5E7AEFA01CA436232C676CB21029D1907A158760E1A17267F406D6A1B64040EB1649FDA49A9B6ED7C00C26BF1617E2F8E977B4E91FBCD9258532C68693F8DBBA95C2C8733A4C47A432C182AB4C19121618B288E779CFAE3DA83FE3E696CF9948B1720796BE90D52B3B775136DA82059BACB19C1EBFAD82EC4CA69D9F4EA18638E8C3A057C63CB61C5098C97813ACCF85918092C6752FEDB2B89A3C6E99940D2B34B7B735D6B3C8E1E8E70CB7785552B8F2049325B8C3EB1AC6751272753101F27DBBA079350ABFA61AF0E60F88E8FD8C78AE27D22B6EB866DD5A94C0C1277C0F773FE4F239D8F27FC62801B02680C2D3FE64AAE50D8534D737E12796158ECF144DC678DEF1794EFFBAC0A1EF2346A27AA9DCC388D073ED2BF9987A11D5B240AB1FBF43E00FE10AA4097CC130091D78D0D56767BE4D6C51E76C5EC2DF2085D0EB975D2ECDE1125DF6E4AA808A3BE6CE3EA8F5C7B017177C8937164DB7DABD35A440513519C6464C72BB93634096057365ED90954F82E5EE3C83DEB0D83E42982B716FBA6A9A3A12274EAE5F64D7639FCB55E71E8C4E6E24DA17F4CD1B29A7400D13A064150BA8C2942037F24F7BFAA523DB56C8BE24E66B3E3AAF65C052CC3ABC3EE486A6BA72F59BD7E85EFE1529702AA0917002CDCF1E822850970A84A78783EB795427A149CFD4C297D6756108E33EF68CD88731B89B5A31F548F6363EA09B956778101412FF4DB16920CFC0B7790896E4F7259BED9ACF133C15E34007CD85044E07D13BBA59E14E3DFC630B2C66718C01308AC046DF688EC8F611A4F7D36B88B0FBD5E3477F7AF77761A9E8B4619B988220C518F4
Im M2 Client werden die Python files in dieser verschlüsselten Form im Speicher abgelegt und dann bei Bedarf, wenn das Script aufgerufen wird z.B., wieder entschlüsselt.
Zur Verschlüsselung der Dateien habe ich eine Konsolenanwendung, welche nach dem erfolgreichen Verschlüsseln den generierten Schlüssel und IV fertig für Copy/Paste ausgibt.
Die beiden Strings müssen dann im EterPackManager Header ausgetauscht werden. Siehe dazu den Client Source.
Die Anwendung zum Verschlüsseln Bitte melden Sie sich an, um diesen Link zu sehen. Beachtet die Readme Datei.
Für die Entschlüsselung lasse ich euch den Code hier im Spoiler.
- //Search: bool GetFromPack(CMappedFile & rMappedFile, const char * c_szFileName, LPCVOID * pData);
- //Add after:
- #ifdef ROOT_AES256_ENCRYPT
- std::string DecyptPythonFile(const char* fileName, UINT uFileSize, const VOID* c_pvFileData);
- bool IsInRootPack(const char* c_szName);
- std::string base16Key = "9CA85EEEA15E285B616ADB04113F5040E547CAED6AE482B15E1691F8EE78C1D0";
- std::string base16IV = "E1C0A4DC027A40982318841F8E2E05D8";
- std::string GetKey() { return base16Key; }
- std::string GetIV() { return base16IV; }
- #endif
- //Add new includes
- #ifdef ROOT_AES256_ENCRYPT
- #include "cryptopp/aes.h"
- #include "cryptopp/modes.h"
- #include "cryptopp/filters.h"
- #include "cryptopp/secblock.h"
- #include "cryptopp/hkdf.h"
- #include "cryptopp/sha.h"
- #include "cryptopp/cryptlib.h"
- #include "cryptopp/hex.h"
- #endif
- //Search function bool CEterPackManager::GetFromPack(CMappedFile & rMappedFile, const char * c_szFileName, LPCVOID * pData)
- //After the function, add:
- #ifdef ROOT_AES256_ENCRYPT
- string CEterPackManager::DecyptPythonFile(const char* fileName, UINT uFileSize, const VOID* c_pvFileData)
- {
- const CHAR* c_pcFileData = (const CHAR*)c_pvFileData;
- std::string stConvFileData;
- if (CEterPackManager::instance().IsInRootPack(fileName))
- {
- std::string cipherText;
- std::string encFileData;
- for (UINT i = 0; i <= uFileSize; ++i)
- {
- cipherText += c_pcFileData[i];
- }
- //Decode IV
- unsigned char iv[CryptoPP::AES::BLOCKSIZE] = {};
- CryptoPP::HexDecoder decoder;
- decoder.Put((unsigned char*)base16IV.data(), base64IV.size());
- decoder.MessageEnd();
- decoder.Get(iv, sizeof(iv));
- //Decode key
- unsigned char key[CryptoPP::AES::MAX_KEYLENGTH];
- {
- CryptoPP::HexDecoder decoder2;
- decoder2.Put((unsigned char*)base16Key.data(), base64Key.size());
- decoder2.MessageEnd();
- decoder2.Get(key, sizeof(key));
- }
- try
- {
- //decode content
- string content_decoded;
- {
- CryptoPP::HexDecoder decoder;
- decoder.Put((unsigned char*)cipherText.data(), cipherText.size());
- decoder.MessageEnd();
- long long size = decoder.MaxRetrievable();
- content_decoded.resize(size);
- decoder.Get((unsigned char*)content_decoded.data(), content_decoded.size());
- stConvFileData.reserve(size);
- }
- CryptoPP::CBC_Mode<CryptoPP::AES>::Decryption d;
- d.SetKeyWithIV(key, sizeof(key), iv);
- CryptoPP::StringSource s(content_decoded, true,
- new CryptoPP::StreamTransformationFilter(d,
- new CryptoPP::StringSink(encFileData),
- CryptoPP::StreamTransformationFilter::PKCS_PADDING
- )
- );
- stConvFileData += encFileData;
- }
- catch (const CryptoPP::Exception& e)
- {
- Tracef("Crypto++ error in EterPackManager: %s in file %s\n", e.what(), fileName);
- }
- }
- else
- {
- // ConvertPythonTextFormat
- {
- for (UINT i = 0; i < uFileSize; ++i)
- {
- if (c_pcFileData[i] != 13)
- stConvFileData += c_pcFileData[i];
- }
- }
- }
- return stConvFileData;
- }
- #endif
- //Search function bool CEterPackManager::RegisterPackWhenPackMaking(const char * c_szName, const char * c_szDirectory, CEterPack* pPack)
- //Add after the function:
- #ifdef ROOT_AES256_ENCRYPT
- bool CEterPackManager::IsInRootPack(const char* c_szName)
- {
- return m_RootPack.IsExist(c_szName);
- }
- #endif
- //Search in function PyObject * packGet(PyObject * poSelf, PyObject * poArgs):
- if (CEterPackManager::Instance().Get(file,strFileName,&pData))
- return Py_BuildValue("s#",pData, file.Size());
- //replace the code with:
- #ifdef ROOT_AES256_ENCRYPT
- DWORD dwBufSize = 0;
- char* acBufData = NULL;
- string content = "";
- if (CEterPackManager::Instance().Get(file, strFileName, &pData))
- {
- dwBufSize = file.Size();
- acBufData = new char[dwBufSize];
- memcpy(acBufData, pData, dwBufSize);
- content = CEterPackManager::Instance().DecyptPythonFile(strFileName, dwBufSize, acBufData);
- delete[] acBufData;
- dwBufSize = content.size();
- return Py_BuildValue("s#", content.c_str(), dwBufSize);
- }
- #else
- if (CEterPackManager::Instance().Get(file,strFileName,&pData))
- return Py_BuildValue("s#",pData, file.Size());
- #endif
- //Add new includes
- #ifdef ROOT_AES256_ENCRYPT
- #include "cryptopp/aes.h"
- #include "cryptopp/modes.h"
- #include "cryptopp/filters.h"
- #include "cryptopp/secblock.h"
- #include "cryptopp/hkdf.h"
- #include "cryptopp/sha.h"
- #include "cryptopp/cryptlib.h"
- #include "cryptopp/hex.h"
- #endif
- //Search function bool CPythonLauncher::RunMemoryTextFile(const char* c_szFileName, UINT uFileSize, const VOID* c_pvFileData)
- //replace the whole function:
- bool CPythonLauncher::RunMemoryTextFile(const char* c_szFileName, UINT uFileSize, const VOID* c_pvFileData)
- {
- NANOBEGIN
- const CHAR* c_pcFileData=(const CHAR*)c_pvFileData;
- std::string stConvFileData;
- stConvFileData.reserve(uFileSize);
- stConvFileData += "exec(compile('''";
- #ifdef ROOT_AES256_ENCRYPT
- if (CEterPackManager::instance().IsInRootPack(c_szFileName))
- {
- std::string cipherText;
- std::string encFileData;
- std::string st_key = CEterPackManager::instance().GetKey();
- std::string st_iv = CEterPackManager::instance().GetIV();
- for (UINT i = 0; i <= uFileSize; ++i)
- {
- cipherText += c_pcFileData[i];
- }
- //Decode IV
- byte iv[CryptoPP::AES::BLOCKSIZE] = {};
- CryptoPP::HexDecoder decoder;
- decoder.Put((byte*)st_iv.data(), st_iv.size());
- decoder.MessageEnd();
- decoder.Get(iv, sizeof(iv));
- //Decode key
- byte key[CryptoPP::AES::MAX_KEYLENGTH];
- {
- CryptoPP::HexDecoder decoder2;
- decoder2.Put((byte*)st_key.data(), st_key.size());
- decoder2.MessageEnd();
- decoder2.Get(key, sizeof(key));
- }
- try
- {
- //decode content
- string content_decoded;
- {
- CryptoPP::HexDecoder decoder;
- decoder.Put((unsigned char*)cipherText.data(), cipherText.size());
- decoder.MessageEnd();
- long long size = decoder.MaxRetrievable();
- content_decoded.resize(size);
- decoder.Get((unsigned char*)content_decoded.data(), content_decoded.size());
- stConvFileData.reserve(size);
- }
- CryptoPP::CBC_Mode<CryptoPP::AES>::Decryption d;
- d.SetKeyWithIV(key, sizeof(key), iv);
- CryptoPP::StringSource s(content_decoded, true,
- new CryptoPP::StreamTransformationFilter(d,
- new CryptoPP::StringSink(encFileData),
- CryptoPP::StreamTransformationFilter::PKCS_PADDING
- )
- );
- stConvFileData += encFileData;
- }
- catch (const CryptoPP::Exception& e)
- {
- Tracef("Crypto++ error: %s in file %s\n", e.what(), c_szFileName);
- }
- }
- else
- {
- // ConvertPythonTextFormat
- {
- for (UINT i = 0; i < uFileSize; ++i)
- {
- if (c_pcFileData[i] != 13)
- stConvFileData += c_pcFileData[i];
- }
- }
- }
- #else
- // ConvertPythonTextFormat
- {
- for (UINT i = 0; i < uFileSize; ++i)
- {
- if (c_pcFileData[i] != 13)
- stConvFileData += c_pcFileData[i];
- }
- }
- #endif
- stConvFileData+= "''', ";
- stConvFileData+= "'";
- stConvFileData+= c_szFileName;
- stConvFileData+= "', ";
- stConvFileData+= "'exec'))";
- const CHAR* c_pcConvFileData=stConvFileData.c_str();
- NANOEND
- return RunLine(c_pcConvFileData);
- }
Wenn es noch Fragen/Probleme gibt schreibt hier gerne. Wie gesagt, es sind nicht alle Prozesse im Client durchgetestet, aber das was ich mir angesehen habe funktioniert.