What's new

[PYTHON] Simple Base64 Encode/Decode for Python Scripts

B0NNiE

B0NNiE

Enthusiast
Messages
124
Reaction score
42
Points
85
Sin$
0
I felt the need to play with encoding my python scripts, or variables in base64. So i wrote this, cause i can.

So i can use it inside things like this encoded python statement
foo = "cHJpbnQgJyBpIGFtIGEgZ29kIG9mIGFsbGxsbGwn"
exec(base64.b64decode(foo))
or for just text lol


So here it is :tongue:
be3ba700997f8c3e7aeb9e7d52e506f3.png


Encode :biggrin:

1f654802a20c34cdd5b37f45da9137d9.png


Decode :3

695745738bf0728269b4d20451384809.png



SOURCE:

Code:
#!/usr/bin/env python
# this script is for encoding anything in base64 for python use
#
################
import os
import sys
import base64
import zlib
import platform
plat =  platform.system().lower()
################
##############
  ###########
 
 
 
def clearscreen():
        if plat =="linux" or "mac":
            os.system('clear')
        elif plat =="windows":
            os.system('cls')
        else:
            print "your missing a platform...? how is this possible"
            sys.exit(0)
def main():
    clearscreen()
    print '''
    ###########################
###########################
#######    #####  #########
######  ##  ####  #########
###### ######## # #########
###### #  ### ## #########
######  ##  ## ## #########
###### #### # ### #########
###### #### #      ########
######  ##  ##### #########
#######    ###### #########
###########################\nBase64 encoder/decoder for internal python scripts\n\n\n[*] Type /d for decoder\n[*] Type /q to quit\n\n\n'''
    string =  raw_input('\n\n\n[ > ] Paste stuff to be encoded here:        \n\n')
    if string == "/d":
        clearscreen()
        print '\n\n\n\n[!]Decoder'
        dstring = raw_input('\n\n[ > ] Paste encoded stuff here:        \n\n')
        denc = base64.b64decode(dstring)
        print '\nResult:\n\n',denc,'\n'
        raw_input('\n\n\nPress enter to continue')
        clearscreen()
        main()
    elif string == "/q":
        sys.exit(0)
    else:
        enc = base64.b64encode(string)
        print '\nResult:\n\n',enc,'\n'
        raw_input('\n\n\nPress enter to continue')
        clearscreen()
        main()
if __name__ == "__main__":
    main()

Can make an .exe if y'all want
 
Top Bottom
Login
Register