Our Feeds

Thursday 4 October 2012

Ajith KP

Remote Command 'N Code Execution with Examples

Guyzzz welcome to _TERMINAL_CODERS_ Here I would like to explain Remote Command and Remote Code Execution attacks with examples.      We can execute remote commands with two different methods.
  • Exec : We can execute commands in remote machine. But the string result or the steps with string cannot able to see. But command will executed there.
  • Passthru : we can execute command and also the result is enable to see.

Remote Command Execution  

Remote Command Execution attack is a type of attack which attacker can execute "System Commands" in Remote Machine.
An example of remote command execution with Exec method is LFI [Local File Inclusion]. Lets start LFI with examples. LFI vulnerability arises when programmer includes further pages or data without properly sanitizing it.
Create a PHP file withbellow code,
Code: 
 


Save the above code as "index.php".

Next create another PHP file with bellow code,

Code:


Save the bellow as "contact.php".

Next create another PHP page with bellow code,

Code:


Save this as "file.php".

The file "file.php" havent declared the file perfectly.

So lets open "index.php" in your browser.


 


















The file.php have started with index.php Now change the URL to "http://localhost/LFI/file.php?file=contact.php"



















Now it have opened contact.php It is the vulnerability of LFI. Read Hack with LFI Vulnerabily Devil'sCafe


Next remote command execution with "passthru" method.

Create a PHP File with bellow code,

Code:


Save the code as "cmd.php".

Open it in browser. But you cannot see anything here.
Change the URL to "http://localhost/cmd/cmd.php?cmd=dir"
 [I'm using Windows OS. So I use Windows System Command].

You will get result as bellow image.



















Remote Code Execution  

Unlike Remote Command Execution, Remote Code Execution is an attack with execution of PHP command in Remote Machine. An example of Remote Code Execution is "RFI"[Remote File Inclusion].

Copy the bellow code,

Code:


Save it as "page.php"

Open it in your browser. You can see head "_TERMINAL_CODERS_"

Now cange the URL to,
"http://localhost/RFI/page.php?page=http://www.terminalcoders.blogspot.in"



















Guyzzz I have spend about half an hour to create this tutor...
Please spend your 30 seconds to add your comments...

1 comments :

Write comments