Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

AdityaBhatt3010/From-Hacker-to-Hacked-Reverse-Engineering-Malicious-Python-Script-like-Pro

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

5 Commits

Repository files navigation

From Hacker to Hacked? Reverse Engineering a Malicious Python Script Like Pro🗿

⚠️ Disclaimer: This article is for educational and awareness purposes only.

The code shared below is malicious in nature and has been partially redacted or analyzed to avoid any unethical usage.
Do NOT attempt to run or repurpose any part of the code unless you're in a secure, sandboxed environment for research.
Author does not support or condone malware development or distribution.
Proceed with caution, fellow cyber warriors.🗿


Cover

"Not every .py file is your friend, but every line of code is a story waiting to be cracked."
— Me, after an unexpected midweek malware autopsy session.


📖 The Story: From CTFs to WTFs

So there I was, minding my own business—probably plotting my next CTF conquest or refining some zero-day code—when a buddy of mine dropped a .py file into my inbox like it was a casual meme.
Filename? Instagram_Report_Tool.py
Suspicion Level? Medium-high 🗿
Curiosity Level? Off the charts 🗿🗿

WhatsApp Screenshot

Before you judge, neither he nor I asked for it. The code got passed around like a chain mail from scammer to someone to someone until it landed in my digital lab. And since I happen to be the best coder & hacker in my region, I decided to take it apart.


🔍 First Look: Obfuscation, You Say?

Payload Entry Point:

Tool Code

_ = lambda __ : __import__('base64').b64decode(__[::-1]);exec((_)(b''))

Immediately, I clocked it.

  1. Reverse the string
  2. Base64 decode
  3. Execute

Classic obfuscation. No flags from VirusTotal (0/63). A perfect example of Security Through Obscurity, and I was having none of it 💀

VT


🧪 Deobfuscation: Let’s Crack This Bad Boy

So, I whipped up a simple Python deobfuscator:

Deobfuscator Code

import base64
obfuscated_data = b'' # reversed Base64-encoded payload
# Step 1: Reverse the string
reversed_data = obfuscated_data[::-1]
# Step 2: Base64 Decode
try:
 decoded_bytes = base64.b64decode(reversed_data)
 decoded_text = decoded_bytes.decode('utf-8', errors='replace')
 print(decoded_text)
except Exception as e:
 print(f"[!] Error decoding: {e}")

Obfuscated Output Code

Boom. Out came another layer of exec hell.
Yeah, this malware was nested tighter than a Russian Matryoshka doll.


⏳ Several Layers (and ChatGPT Searches) Later...

After grinding through deobfuscation purgatory for what felt like 1,000 years, the real payload revealed itself.

And oh boy—it was sketchy.


🧠 Actual Malicious Payload Code (for Analysis Only)

Here’s the actual snippet that was revealed after layers of deobfuscation:

Final Code

if file.exists(Secure_initial().tlemne.count):
 return server.single(file, posts, client_id, convers_id)
client_id = tlemne.get(convers_id)
convers_id = tlemne.get(convers_id)
posts = tlemne.get(convers_id)
file = tlemne.get(convers_id)
def actuallypass():
 return download_file(file, posts, client_id, convers_id)
client_id = tlemne.get(convers_id)
convers_id = tlemne.get(convers_id)
posts = tlemne.get(convers_id)
file = tlemne.get(convers_id)
def actuallypass():
 file = open('file.txt')
def actuallypass():
 file = open('file.txt')
def actuallypass():
 if login(file):
 client_id = tlemne.get(convers_id)
 convers_id = tlemne.get(convers_id)
 posts = tlemne.get(convers_id)
def _ready.file():
 mail.args('file', posts)
 login(file)
def actuallypass():
 Download.login.clip(file)
 client_id = tlemne.get(convers_id)
 convers_id = tlemne.get(convers_id)
 posts = tlemne.get(convers_id)
 file = tlemne.get(convers_id)
def _ready.file():
 control(file)
 client_id = tlemne.get(convers_id)
 convers_id = tlemne.get(convers_id)
 posts = tlemne.get(convers_id)
def _ready.file():
 mail.args('file', posts)
 control(file)
def actuallypass():
 licensekey(file)
 client_id = tlemne.get(convers_id)
 convers_id = tlemne.get(convers_id)
 posts = tlemne.get(convers_id)
def _ready.file():
 mail.args('file', posts)
 licensekey(file)
def actuallypass():
 download_file(file)
 convers_id = tlemne.get(convers_id)

⚠️ This code should NEVER be executed unless you're doing malware analysis in a secure, isolated environment (e.g., sandbox VM).
It's designed to silently harvest system data, monitor user activity, and exfiltrate files to a remote C2.
Don’t mess around unless you know exactly what you’re doing.🛡️


⚠️ What This Malware Was Actually Doing

Think of it as a stealthy digital parasite that quietly sips on your data cappuccino while you’re chilling.

🔍 1. Sensitive Data Collection

client_id = tlemne.get(convers_id)

Grabbing identifiers like:

  • client_id, convers_id = Unique user/system/session IDs
  • posts, file = Could be clipboard data or documents

📁 2. Accessing Local Files

file = open('file.txt')
  • Could be a placeholder for sensitive file access (tokens, credentials, session info)

🕵️‍♂️ 3. Clipboard & Key Data Monitoring

Download.login.clip(file)
  • Potentially capturing clipboard content (wallet addresses? Passwords? Who knows.)

📡 4. Backdoor Behavior & C2 Communication

if file.exists(Secure_initial().tlemne.count)
server.single(file, posts, client_id, convers_id)
  • Contacting a Command and Control server (C2)
  • Sending/receiving payloads
  • Possibly downloading new malware, triggering keyloggers, or even taking screenshots

🧩 Technical Breakdown

Component Purpose
client_id, convers_id Device fingerprinting
file = open('file.txt') Access local files
Download.login.clip(file) Clipboard monitoring
download_file(...) Data exfiltration
server.single(...) Remote command execution
Secure_initial() Persistence check

🔐 What You Should Do Immediately (If You Fell for This Trap)

✅ 1. Disconnect From the Internet

# CMD (Admin)
netsh interface set interface "Wi-Fi" admin=disable
netsh interface set interface "Ethernet" admin=disable

✅ 2. Check Running Scripts

Option A: Task Manager

  • python.exe, cmd.exe, powershell.exe with unknown sources

Option B: PowerShell

Get-Process | Where-Object { $_.Path -like "*python*" -or $_.Path -like "*.ps1" }

✅ 3. Check Persistence Mechanisms

  • Startup Folder
dir "$env:APPDATA\Microsoft\Windows\Start Menu\Programs\Startup"
  • Registry Keys
reg query "HKCU\Software\Microsoft\Windows\CurrentVersion\Run"
  • Scheduled Tasks
schtasks /query /fo LIST /v
  • WMI Subscriptions
Get-WmiObject -Namespace root\subscription -Class __EventFilter

✅ 4. Run Deep Scans

  • Windows Defender Offline
Start-MpWDOScan
  • Malwarebytes – Full System Scan

  • Autoruns (Sysinternals) – For deep autostart entries


🔐 Reset These Passwords Immediately

Priority Platform
🔒 High Email, Banking, Social Media
🧠 Critical Password Manager, GitHub, AWS
🧼 Clean Device Required Do NOT use the infected machine

🛠️ Bonus: Malware Hunting Commands

Recent Suspicious Scripts

Get-ChildItem -Path C:\ -Include *.py,*.ps1,*.bat,*.vbs -Recurse |
Where-Object { $_.CreationTime -gt (Get-Date).AddDays(-7) }

Check Clipboard

Get-Clipboard

📌 Final Thoughts: Don’t Get Played by Pretty .py Files

So yeah—this was a legit reverse engineering session born from curiosity.

Let this serve as a reminder:

  • 🧠 Think before you run.
  • 🔒 Verify before you trust.
  • 🛡️ Scan before you execute.

Because even if you're the best hacker in your region, there's always malware trying to one-up you in the shadows.


🚨 Final Reminder: Ethics > Egos

This wasn't just a mid-week reverse engineering joyride—it's a real case of social engineering via code sharing. It could've hit anyone, and that's why stories like these need to be told responsibly.

If you’re in cybersecurity, ethical hacking, or just curious about malware—knowledge is power, but ethics is your shield.

⚠️ Final Legal Notice & Reminder:

This breakdown is for educational awareness only.
The included code has been posted purely for analytical and academic purposes.
Misuse of such information for unauthorized access, data theft, or cybercrime is illegal and punishable under laws such as the IT Act 2000 (India) and the Computer Fraud and Abuse Act (CFAA) (USA).
Stay legal, stay ethical.🛡️🗿


✌️Peace, Packets, and Payloads

Until next time...
Keep your ports closed, your mind open,
and never stop reversing the world—one script at a time.

Stay Curious. Stay Relentless. Stay Safe.
- Aditya Bhatt 🗿🤖💻


About

A reverse engineering deep dive into a seemingly harmless Instagram tool that turned out to be a stealthy obfuscated Python malware

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

AltStyle によって変換されたページ (->オリジナル) /