This forum is in archive mode. You will not be able to post new content.

Author Topic: Hiding Files The Python Way  (Read 3955 times)

0 Members and 3 Guests are viewing this topic.

Offline techb

  • Soy Sauce Feeler
  • Global Moderator
  • King
  • *
  • Posts: 2350
  • Cookies: 345
  • Aliens do in fact wear hats.
    • View Profile
    • github
Hiding Files The Python Way
« on: March 28, 2012, 12:30:11 AM »
In my blog I posted a quick script that will hide archives in jpeg images.


Well here I am going to show you how to abuse the NTFS and hide files alongside an executable. As the file system and binary implies, this is Windows based.


The feature we will be abusing is the Alternate Data Stream (ADS). ADS was created back in the Windows NT 3.1 days so the file system could communicate with Apple Hierarchical File System (HFS).


This comes in handy for us in several ways. We can store DLL's we want to inject in the binary itself, use it to store txt data for backdoor redirects, create a encoder/decoder to hid files in itself for better protection and transportation, etc.


We do this almost like you would in the blog post about hiding archives in jpeg's. We will open both files, and append the read file.


Code: [Select]
#Include file extensions
hide = raw_input("File to hide: ")
visible = raw_input("Visible file: ")


file_to_hide = open( hide_file, "rb")

file_content = file_to_hide.read()
file_to_hide.close()


print "File size: %d"  % len(file_content)


visible_file = open("%s:%s" % (visible, hide), "wb")
visible_file.write(file_content)
visible_file.close()


As you can see, about the only difference is the ":" when opening the binary. We do this to flag the file system so that the read file will be along side the binary.


I learned this technique in "Grey Hat Python", great book.
>>>import this
-----------------------------

Offline lucid

  • #Underground
  • Titan
  • **
  • Posts: 2683
  • Cookies: 243
  • psychonaut
    • View Profile
Re: Hiding Files The Python Way
« Reply #1 on: March 28, 2012, 05:12:36 AM »
Do you have an upload link for that book? That would be swell
"Hacking is at least as much about ideas as about computers and technology. We use our skills to open doors that should never have been shut. We open these doors not only for our own benefit but for the benefit of others, too." - Brian the Hacker

Quote
15:04  @Phage : I'm bored of Python

Offline Kulverstukas

  • Administrator
  • Zeus
  • *
  • Posts: 6627
  • Cookies: 542
  • Fascist dictator
    • View Profile
    • My blog
Re: Hiding Files The Python Way
« Reply #2 on: March 28, 2012, 01:51:58 PM »
I have a copy of it in my library :P
Here ya go: http://upload.evilzone.org/download.php?id=1905756&type=zip

Offline lucid

  • #Underground
  • Titan
  • **
  • Posts: 2683
  • Cookies: 243
  • psychonaut
    • View Profile
Re: Hiding Files The Python Way
« Reply #3 on: March 28, 2012, 05:56:34 PM »
Thanks admin  ;D
"Hacking is at least as much about ideas as about computers and technology. We use our skills to open doors that should never have been shut. We open these doors not only for our own benefit but for the benefit of others, too." - Brian the Hacker

Quote
15:04  @Phage : I'm bored of Python

Offline techb

  • Soy Sauce Feeler
  • Global Moderator
  • King
  • *
  • Posts: 2350
  • Cookies: 345
  • Aliens do in fact wear hats.
    • View Profile
    • github
Re: Hiding Files The Python Way
« Reply #4 on: March 28, 2012, 06:03:11 PM »
You guys always beat me to it lol.


Here's at least the code that the book goes over.
>>>import this
-----------------------------

 



Want to be here? Contact Ande, Factionwars or Kulverstukas on the forum or at IRC.