Giter VIP home page Giter VIP logo

pyobfx's Introduction


PyObfx

Python Obfuscation tool

Features

  • String, Integer, Float and Boolean Obfuscation
  • Variable Name Obfuscation
  • Import Name Obfuscation
  • Packing

Installation

git clone https://github.com/PyObfx/PyObfx.git && cd PyObfx/
pip install -r requirements.txt

Usage

In order to obfuscate a single file:

python3 PyObfx.py <file_name>

To pack the file after obfuscation: (Available packers are bz2, gz and lzma)

python3 PyObfx.py <file_name> -p <packer>

For other options, see:

python3 PyObfx.py -h

License

This project is licensed under the GPL v3 License - see the LICENSE file for details.

pyobfx's People

Contributors

afk avatar kalaycitayfun avatar kondanta avatar orhun avatar qinyaotat avatar samybencherif avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pyobfx's Issues

Task #

[scripts/obfuscator.py] [+] Function Name Obfuscation

Issues with --str-gen breaking code

I am not too sure but when using the --str-gen command it is breaking my code. Is this intentional or am I using the code incorreclty?

user@user-VirtualBox:~/Desktop/PyObfx$ python3 PyObfx.py reverse.py --str-gen ch

user@user-VirtualBox:~/Desktop/obfuscators/PyObfx$ python reverse_obfx.py

File "reverse_obfx.py", line 3
SyntaxError: Non-ASCII character '\xe9' in file reverse_obfx.py on line 3, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details

Task #2 @easyly471 @afk

[scripts/tokenizer.py] Edit tokenizer for reading py file line by line.
[scripts/io.py] + File write func

Task @easyly471

@easyly471
[io.py] Check if file is a .py
[tokenizer.py] Fix tokenizer / return values properly for obfuscation

Task @afk

@afk
[tokenizer.py] Get values for obfuscation
[eg/stringobf.py] Write a func for string obfuscation
[obfuscate.py] Create main obfuscation class in "scripts". import stringobf.
At the end, import this class in main file and demonstrate a string obfuscation

Task @afk

[scripts/obfuscator.py] Create different algorithms for string encryption. Each algorithm should return a string.
[scripts/obfuscator.py] Write a func for numeric values encryption. (int, double etc.).
[scripts/packer.py] Class that responsible for encrypting and compressing file with base64, gzip etc. We don't need it now but we will later.

String decoding failure

I ran
python3 PyObfx.py -f test/test/py
and the resulting script did not run.

I found the issue.

ZyAxHJPhav = lambda n: (n + (2 + 5)) / 1
PrKgsXMFpV = lambda s: ''.join(chr(int(ZyAxHJPhav(ord(c)))) for c in s)
...
if __name__ == PrKgsXMFpV("[[i]ej[["):
    HohxIVAa()

In this case PrKgsXMFpV("[[i]ej[[") evaluates to bbpdlqbb instead of __main__.

When I corrected this manually it appears all strings are be incorrectly represented.

Obfuscation hatası

Kütüphanenizi yeni gördüm, gayet güzel elinize sağlık. Bulduğum birkaç 'bug' durumunu paylaşmak istiyorum. Beta sürümü olması nedeniyle bunlar normal olabilir, ancak bunları bir geri bildirim olarak kabul edin lütfen.

Kütüphaneyi test etmek üzere indirip elimdeki şu script'i kullandım.

import socket
s = socket.socket(socket.AF_INET,socket.SOCK_STREAM)

Obfuscation işlemi sonrası

# Obfuscated with PyObfx #
import socket as JSYswdTziMjk

OSsutnZLha = lambda n: (n + (2 + 2)) / 4
paOQMycZmI = lambda s: ''.join(chr(int(OSsutnZLha(ord(c)))) for c in s)
eV = JSYswdTziMjk.JSYswdTziMjk(JSYswdTziMjk.AF_INET,JSYswdTziMjk.SOCK_STREAM)

Bu durumda, socket modülünün socket fonksiyonu, obfuscation işlemine tabi tutulmaması gerekiyor.

Bir başka import etme şekli

modeule = __import__("socket")
s = module.socket(module.AF_INET,module.SOCK_STREAM)

sonuç

# Obfuscated with PyObfx #

kqpNzUDLvT = lambda n: n - sum([4, 4, 3])
SPHQDyemOf = lambda s: ''.join(chr(int(kqpNzUDLvT(ord(c)))) for c in s)
PJqBVcwOALjXyF = __import__(SPHQDyemOf("~znvp�"))
XB = module.socket(module.AF_INET,module.SOCK_STREAM)

Proje oldukça iyi, geliştikçe sorunların çözüleceğine inanıyorum. İyi çalışmalar 👍

PyObfx Obfuscates builtin names but fails to give definitions

Describe the bug
PyObfx obfuscates the Python builtin "exec" as a random variable name but fails to set it. For example, exec(myfunction) is replaced by aashcdhs(acdbchdc) with no definition of aashcdhs.

To Reproduce
Steps to reproduce the behavior:

  1. Create a sample script that uses exec (I am making a remote code execution malware program for fun)
  2. Run PyObfx on the script
  3. Execute and see the error

Expected behavior
There should be a definition that maps the random name to the exec statement

Screenshots
None

Desktop (please complete the following information):

  • OS: Windows 10
  • Browser Chrome
  • Version Latest version of PyObfx (git cloned it yesterday)

issue with classes (magic methods)

Obfuscator obfuscates magic methods too. It's a big problem for class based programs, obfuscator should ignore them.

#!/usr/bin/env python3
# coding: utf-8

class TestClass(object):
    def __init__(self, *args, **kwargs):
        for k, v in kwargs.items():
            setattr(self, k, v)

    def __str__(self):
        return '< TestClass >'

    def __repr__(self):
        return self.__str__()

    def sum_args(self, *args):
        return sum(args)
λ lain ~ python3 PyObfx.py -f test.py && ipython3 -i test_obfx.py
#!/usr/bin/env python3
# coding: utf-8
# Obfuscated with PyObfx #

bLgfUPEJdI = lambda n: (n + 3) / (2 + 4)
cvXuBCWNly = lambda s: ''.join(chr(int(bLgfUPEJdI(ord(c)))) for c in s)

class TestClass(object):
    def vOsKmjwhGfMSbHNo(self, *jxamLITo, **kwargs):
        for aUTZ, boAj in kwargs.items():
            setattr(self, aUTZ, boAj)

    def juzMvIHfBtbynx(self):
        return cvXuBCWNly("Ĩ�ƠǵȻɀŋȘǡȻȻ�IJ")

    def MnwVKChmBiATtFlo(self):
        return self.juzMvIHfBtbynx()

    def VzXdRhlBNjHECxum(self, *jxamLITo):
        return sum(jxamLITo)


In [1]: obj = TestClass(test='test')
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-1-9fc139a23731> in <module>()
----> 1 obj = TestClass(test='test')

TypeError: TestClass() takes no arguments

Task @afk

[scripts/obfuscator.py] [+] Variable Value Obfuscation

Task @emperorfederico

[scripts/strgen.py] Write a function for random string generation.
Params will be the string type (unicode)[boolean], language[chinese/japanese for instance] and string length.
At the end, import this class and demonstrate a random generation with random length.

"import as" fails

Describe the bug

Obfuscation of import <library-name> as <short-name> produces unusable results.

To Reproduce
Steps to reproduce the behavior:

  1. create a filen called test.py with content
import pandas as pd 

df = pd.DataFrame()

print(type(df))
  1. run > python test.py. It will print to stdout: <class 'pandas.core.frame.DataFrame'>

  2. Obfuscate with > python PyObfx.py -f test.py

  3. the resulting test_obfx.py looks like:

# Obfuscated with PyObfx #
import pandas OnUVvJaBoxpz

TROhSgWpkL = lambda n: n - sum([5, 4, 1])
vVtdzETYyL = lambda s: ''.join(chr(int(TROhSgWpkL(ord(c)))) for c in s)
rXkhlFus = pd.DataFrame()

print(type(rXkhlFus))
  1. run > python test_obfx.py. The error you get is:
File "test_obfx.py", line 2
    import pandas OnUVvJaBoxpz
                             ^
SyntaxError: invalid syntax

Expected behavior
It should be on the lines of;

# Obfuscated with PyObfx #
import pandas as OnUVvJaBoxpz

TROhSgWpkL = lambda n: n - sum([5, 4, 1])
vVtdzETYyL = lambda s: ''.join(chr(int(TROhSgWpkL(ord(c)))) for c in s)
rXkhlFus = OnUVvJaBoxpz.DataFrame()

print(type(rXkhlFus))

Desktop (please complete the following information):

  • OS: Windows 10
  • Python Version: 3.6.8

Additional context

import pandas as pd or import numpy as np are a common convention used widely in python programming for data science/machine learning.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.