Pages

Tuesday, February 23, 2016

How to Hide Files in Windows System Using ADS(Altanate Data Stream)

How to Hide File Using Python 

Alternate Data stream is a substructure of a NTFS file system.Alternate Data Stream(ADS) can not  detect by common software or tools and it is attach with normal file or folder in hidden layer.

File Data and Attributes <--> Default Data Stream <-->Altanate Data Stream

so first create folder and inside that folder create python file name hide.py and also create text file hello.txt and also add image file photo.jpg we are going to hide this photo.jpg file inside the hello.txt file

What things we need to hide file using python
[+]install python 2.7 to your windows computer
[+]install pyADS 
open command prompt and type 
pip install pyADS


then it will install pyADS for you 
ok now open hide.py file in text editor or python IDE.i use pycharm

then type
import argparse
from pyads import ADS
we use argparse to get user input in command prompt

then create our main function
 def Main():
and create variable name parse and then it take input from argparse method
parser=argparse.ArgumentParser()
then we can get user input to scan for ADS files
Add file to ADS
Remove file from ADS
Extract ADS file

parser.add_argument("file",help="Specify File or Directory")
parser.add_argument("-o","--output",help="Print output to terminal",action="store_true")
parser.add_argument("-a","--add",help="Add stream to <file>",type=str)
parser.add_argument("-e","--extract",help="Extract All",action="store_true")
parser.add_argument("-r","--remove",help="Remove All",action="store_true")
 
Whole Program
import argparse
from pyads import ADS


def Main():
    parser=argparse.ArgumentParser()
    parser.add_argument("file",help="Specify File or Directory")
    parser.add_argument("-o","--output",help="Print output to terminal",action="store_true")
    parser.add_argument("-a","--add",help="Add stream to <file>",type=str)
    parser.add_argument("-e","--extract",help="Extract All",action="store_true")
    parser.add_argument("-r","--remove",help="Remove All",action="store_true")

    args=parser.parse_args()
    if args.file:
        handler=ADS(args.file)

        if args.add:
            handler.addStream(args.add)
        if handler.containStreams():
            for stream in handler.getStreams()[:]:
                if args.output:
                    print(args.file+":"+stream)
                if args.extract:
                    fh=open(stream,"wb")
                    fh.write(handler.getStreamContent(stream))
                    fh.close()
                if args.remove:
                    handler.removeStream(stream)
    else:
        print(parser.usage)



Main()
Lets try it
hide file inside
see text file size is 0byte


 open folder and type cmd then it will open Command prompt from there
so type python hide.py hello.txt -a photo.jpg 


now it will combine the photo inside the text file we can check it using python hello.txt -o to scan the ads file see now photo is inside the text file.

now we can check the text file size it is still 0byte

so we can delete the photo.jpg 

now let's recover our hidden photo from text file
python hide.py hello.txt -e


this will extract photo.jpg from hello.txt file 

i hope you would enjoy this tutorial.if you are like this post please share with your friends.

Commands

python hide.py hello.txt -o  To check is there any ADS files
python hide.py hello.txt -a photo.jpg to hide photo inside text file
python hide.py hello.txt -e to extract photo from text file
python hide.py hello.txt -r to remove photo from text file
if you have face error add pyads file to same folder
download






No comments:

Post a Comment