Python Forum
Identifying if the program I have is python and then decompiling
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Identifying if the program I have is python and then decompiling
#1
My wife befriended someone online and he said he could write a program to help her with some data input on her web site. He wrote a 9mb executable for her Mac which runs from within terminal. The program does in fact do what she wanted, but I'm skeptical about the program and hope it it doesnt contain any type of malware, back-doors, etc.

The Mac just identifies the program as a "Unix Executable" and the file has no extension. The contents of the file appear to be compiled (most of the contents are not human readable). Looking through the file with a hex editor I do see some references to py and python in it which is why I started in this forum.

Are there any terminal commands or other ways to find out more about the program?
Anything I can look for in the program to confirm that is python?

Ultimately I would like to "de-compile" the program (not really sure that it is truly compiled, or why I can read the code) and see what it does.

Any help about the next steps to take in any part of this mess would be welcome.
Thanks in advance
Reply
#2
How about obtaining the source code? Might have to pay, but more ethical than decompiling.
Also, use viral scanning and malware software - you should be using anyway.
ndc85430 likes this post
Reply
#3
I suggest erasing the program and using an open-source one instead.
ndc85430 likes this post
Reply
#4
(Jun-01-2022, 02:53 PM)jefsummers Wrote: How about obtaining the source code? Might have to pay, but more ethical than decompiling.
Also, use viral scanning and malware software - you should be using anyway.

I'm concerned that it may contain some kind of malware and obviously he wouldn't provide that part.
I'm not concerned with the actual code that does what she wants, I just want to make sure nothing is hidden in it.

I have already scanned it with malwarebytes and Avast and installed LittleSnitch firewall on a test machine. All came up clean but to be 100% sure I would like to make sure nothing sneaky is going on
Reply
#5
(Jun-01-2022, 03:45 PM)Gribouillis Wrote: I suggest erasing the program and using an open-source one instead.

It's more about if there was a payload or back-door opened then program itself. I want o make sure that nothing was compromised.
How can I confirm that the executable is indeed python and then possibly decompile?
Reply
#6
Get the source code and run that in Python. If you are sure he would not include anything malicious in the source, you will be safe. And, you will be sure it is in Python, solves your problem.
Reply
#7
First try, if the program was written with Python and packed with PyInstaller: https://github.com/extremecoders-re/pyinstxtractor

Decompiler for pyc-files:

Python >3.7: https://github.com/rocky/python-decompile3
Python all : https://pypi.org/project/uncompyle6/

Tool to analyze Binary files: https://ghidra-sre.org/


I guess he has taken the easy way. Program written with Python and packed as distribution with PyInstaller.
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
Reply
#8
(Jun-01-2022, 07:41 PM)DeaD_EyE Wrote: First try, if the program was written with Python and packed with PyInstaller: https://github.com/extremecoders-re/pyinstxtractor

Decompiler for pyc-files:

Python >3.7: https://github.com/rocky/python-decompile3
Python all : https://pypi.org/project/uncompyle6/

Tool to analyze Binary files: https://ghidra-sre.org/


I guess he has taken the easy way. Program written with Python and packed as distribution with PyInstaller.

(Jun-01-2022, 07:41 PM)DeaD_EyE Wrote: First try, if the program was written with Python and packed with PyInstaller: https://github.com/extremecoders-re/pyinstxtractor

Decompiler for pyc-files:

Python >3.7: https://github.com/rocky/python-decompile3
Python all : https://pypi.org/project/uncompyle6/

Tool to analyze Binary files: https://ghidra-sre.org/


I guess he has taken the easy way. Program written with Python and packed as distribution with PyInstaller.

Thanks for your reply. I was hopeful from your post I might be getting somewhere with this. I ran into some snags and Ill relate them to you, maybe something will be of some more help.

First, as I originally mentioned the program in question was written for a Mac. I tried pyinstxtractor but couldn't get it to run on the Mac (I suspect I need to install a full python install, not just use the built in OS version).

So I installed python on a Win10 box. The first thing I noticed is that the program I trying to decompile wouldn't run on the Win10 machine. I assume the packer makes an executable that is platform specific.

after adding an extension .pyo to the file I tried pyinstxtractor again. This is the output

Output:
C:\Users\David>D:\pyinstxtractor.py d:\SA.pyo [+] Processing d:\SA.pyo [+] Pyinstaller version: 2.0 [+] Python version: 309 [+] Length of package: 9419143 bytes Traceback (most recent call last): File "D:\pyinstxtractor.py", line 423, in <module> main() File "D:\pyinstxtractor.py", line 411, in main arch.parseTOC() File "D:\pyinstxtractor.py", line 235, in parseTOC struct.unpack( \ struct.error: unpack requires a buffer of 6906162 bytes
I also tried decompyle3 d:\SA.pyo
Output:
Unknown magic number 64207 in D:\SA.pyo
I installed the Java SDK and ran ghidra-sre. I havent figured out how to use the program but it looks like it is trying to load a project file not a python file. Maybe I'm missing something.

Couldn't figure ut how to install uncompyle6 but I'm pretty fried. Will look at it again tomorrow.

Does any of this information help or give you any more clues?

Thanks
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Identifying keywords in text drchips 6 96,123 Mar-29-2022, 12:32 PM
Last Post: snippsat
  trying to put a a filter on identifying a straight CompleteNewb 1 1,664 Dec-01-2021, 11:11 PM
Last Post: CompleteNewb
  Identifying string success flag graham23s 4 3,125 Aug-14-2019, 09:27 PM
Last Post: graham23s
  identifying a dictionary with an attribute? Skaperen 7 3,797 Oct-04-2018, 05:48 AM
Last Post: Skaperen
  Identifying only specific words in a string GilbyScarChest 2 2,707 Aug-08-2018, 03:22 AM
Last Post: GilbyScarChest
  Identifying the value of all adjacent elements in an array JoeB 2 8,645 Nov-23-2017, 05:10 PM
Last Post: JoeB
  Identifying object types microphone_head 5 4,474 Oct-01-2017, 02:04 PM
Last Post: buran

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020