Jump to content

Encrypting file ---> python


GoogleMe

Recommended Posts

I wanted to know if there is someway to Encrypt a file (python file) with from ex: AES and make the file run within encryption...

for example: 

Making a calculator encrypt it  when you open Idle,Pycharm  the output is strange symbols and characters ... 

and that's how no one can see your code and only u can decrypt it if u remember the parameters...

is that possible???

 

thankx anyway

Link to comment
Share on other sites

Okay, I will bite.  Yes you can.  Powersploit has a module to do it for Powershell as well.

For python, there is  cool function called exec() that will run a string as python code.  Of course it has to be valid python code.  Similar to the "invoke-expression" for Powershell.

So, what works in Posh, works in Pyth.  You can encrypt your code with a key and convert it to base 64 string.  That string will be what you put in a new python function as an assignment to a variable..hard coded assignment.  Now, your new function takes the key as an input parameter and when ran the reverse happens.  Your code is unbase64, decrypted with key back to a string and then ran with exec(). 

 

Link to comment
Share on other sites

  • 5 weeks later...

Thank u i was woundering why some files ive been looking up look like

gshshjskaggisis

gibrish when i try to edit them. You answered the question.

Link to comment
Share on other sites

  • 10 months later...

There are two terms you should look up. The first is packers / cryptors. These take some code, hide it in some way, and wrap it in something that decodes and runs it when the application is ran. A very simple example -

eval(bytes.fromhex('7072696e74282768656c6c6f20776f726c642729'))

Now it would be pretty easy to recover the original script in this case. You can just copy out the stuff being passed to the eval, run it, and see the result. That's where the next concept comes in, obfuscation. This makes the code more difficult to understand. This can mean changes in variable names, control flow, using lesser known features (could we maybe move some functionality into decorators?).

These can almost always be broken, but the simple idea is there, and they will generally slow someone down when analyzing your software.

Link to comment
Share on other sites

  • 1 month later...
On 3/3/2020 at 7:16 AM, CYBERING said:

There are two terms you should look up. The first is packers / cryptors. These take some code, hide it in some way, and wrap it in something that decodes and runs it when the application is ran. A very simple example -


eval(bytes.fromhex('7072696e74282768656c6c6f20776f726c642729'))

Now it would be pretty easy to recover the original script in this case. You can just copy out the stuff being passed to the eval, run it, and see the result. That's where the next concept comes in, obfuscation. This makes the code more difficult to understand. This can mean changes in variable names, control flow, using lesser known features (could we maybe move some functionality into decorators?).

These can almost always be broken, but the simple idea is there, and they will generally slow someone down when analyzing your software.

Well said,thank you.

Link to comment
Share on other sites

  • 1 year later...

why need try hide python script. is there something to hide lol.

you can allways encrypt any file.

openssl aes-256-cbc -a -salt -pbkdf2 -in backdoor.py -out facebookhack.py.enc

and then decrypt it and pipe to python

openssl aes-256-cbc -d -a -pbkdf2 -in facebookhack.py.enc | python -

LOL you got point right xD

in reality not work. you need pass phraise decrypth it and your victim not run your code

without checking it. they will do

openssl aes-256-cbc -d -a -pbkdf2 -in facebookhack.py.enc -out really.py

nano really.py

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...