Writeups

Stapler

Index ## [stapler](/Gajabaar.io/stapler.html) 1. [Summary](#summary) 2. [Reconnaissance](#reconnaissance) 3. [Vulnerability Analysis](#vulnerability-analysis) 4. [Exploitation](#exploitation) 5. [Password Attacks](#password-attacks) 6. [Post-Exploitation](#post-exploitation)

Summary

Enumeration led us to vulnerable wordpress plugins which led to the initial foothold to the machine. Also, vulnerable version of OS led us to escalate our privileges to root.

Reconnaissance

nmap

Initial nmap scan with top 100 ports:

nmap -Pn stapler -oN nmap/initial which is:

Starting Nmap 7.92 ( https://nmap.org ) at 2022-07-07 21:46 +0545
Nmap scan report for stapler (192.168.67.148)
Host is up (0.17s latency).
Not shown: 992 filtered tcp ports (no-response)
PORT     STATE  SERVICE
20/tcp   closed ftp-data
21/tcp   open   ftp
22/tcp   open   ssh
53/tcp   open   domain
80/tcp   open   http
139/tcp  open   netbios-ssn
666/tcp  open   doom
3306/tcp open   mysql

Nmap done: 1 IP address (1 host up) scanned in 20.08 seconds

Since port 80 was open but didn’t respond to ping, So I assumed that the server had disabled ping response.

Getting all port scan done, meanwhile further recon into the found open ports.

nmap scan with default nmap script, Version detection and OS detection:

sudo nmap -sC -sV -O -Pn -p20,21,22,80,139,666,3306 -oA nmap/all

Starting Nmap 7.92 ( https://nmap.org ) at 2022-07-07 21:49 +0545
Nmap scan report for stapler (192.168.67.148)
Host is up (0.17s latency).

PORT     STATE  SERVICE     VERSION
20/tcp   closed ftp-data
21/tcp   open   ftp         vsftpd 2.0.8 or later
| ftp-anon: Anonymous FTP login allowed (FTP code 230)
|_Can't get directory listing: PASV failed: 550 Permission denied.
| ftp-syst: 
|   STAT: 
| FTP server status:
|      Connected to 192.168.49.67
|      Logged in as ftp
|      TYPE: ASCII
|      No session bandwidth limit
|      Session timeout in seconds is 300
|      Control connection is plain text
|      Data connections will be plain text
|      At session startup, client count was 1
|      vsFTPd 3.0.3 - secure, fast, stable
|_End of status
22/tcp   open   ssh         OpenSSH 7.2p2 Ubuntu 4 (Ubuntu Linux; protocol 2.0)
| ssh-hostkey: 
|   2048 81:21:ce:a1:1a:05:b1:69:4f:4d:ed:80:28:e8:99:05 (RSA)
|   256 5b:a5:bb:67:91:1a:51:c2:d3:21:da:c0:ca:f0:db:9e (ECDSA)
|_  256 6d:01:b7:73:ac:b0:93:6f:fa:b9:89:e6:ae:3c:ab:d3 (ED25519)
53/tcp   open   tcpwrapped
80/tcp   open   http        PHP cli server 5.5 or later
|_http-title: 404 Not Found
139/tcp  open   netbios-ssn Samba smbd 4.3.9-Ubuntu (workgroup: WORKGROUP)
666/tcp  open   doom?
| fingerprint-strings: 
|   NULL: 
|     message2.jpgUT 
|     QWux
|     "DL[E
|     #;3[
|     \xf6
|     u([r
|     qYQq
|     Y_?n2
|     3&M~{
|     9-a)T
|     L}AJ
|_    .npy.9
3306/tcp open   mysql       MySQL 5.7.12-0ubuntu1
| mysql-info: 
|   Protocol: 10
|   Version: 5.7.12-0ubuntu1
|   Thread ID: 11
|   Capabilities flags: 63487
|   Some Capabilities: InteractiveClient, IgnoreSigpipes, Speaks41ProtocolOld, FoundRows, ODBCClient, Support41Auth, SupportsCompression, LongPassword, DontAllowDatabaseTableColumn, SupportsLoadDataLocal, Speaks41ProtocolNew, IgnoreSpaceBeforeParenthesis, ConnectWithDatabase, SupportsTransactions, LongColumnFlag, SupportsMultipleResults, SupportsMultipleStatments, SupportsAuthPlugins
|   Status: Autocommit
|   Salt: <VlJUArMLX:~\x19m02?;
| W
|_  Auth Plugin Name: mysql_native_password
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-Port666-TCP:V=7.92%I=7%D=7/7%Time=62C70407%P=x86_64-pc-linux-gnu%r(NULL
SF:,2D58,"PK\x03\x04\x14\0\x02\0\x08\0d\x80\xc3Hp\xdf\x15\x81\xaa,\0\0\x15
SF:2\0\0\x0c\0\x1c\0message2\.jpgUT\t\0\x03\+\x9cQWJ\x9cQWux\x0b\0\x01\x04
SF:\xf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8e}\xac\x15\xf6~\xc4R\x8e`wT\x96\xa8KT\x1cam\xdb\x99f\xfb\n\xbc\xbc
SF:L}AJ\xe5H\x912\x88\(O\0k\xc9\xa9\x1a\x93\xb8\x84\x8fdN\xbf\x17\xf5\xf0\
SF:.npy\.9\x04\xcf\x14\x1d\x89Rr9\xe4\xd2\xae\x91#\xfbOg\xed\xf6\x15\x04\x
SF:f6~\xf1\]V\xdcBGu\xeb\xaa=\x8e\xef\xa4HU\x1e\x8f\x9f\x9bI\xf4\xb6GTQ\xf
SF:3\xe9\xe5\x8e\x0b\x14L\xb2\xda\x92\x12\xf3\x95\xa2\x1c\xb3\x13\*P\x11\?
SF:\xfb\xf3\xda\xcaDfv\x89`\xa9\xe4k\xc4S\x0e\xd6P0");
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.92%E=4%D=7/7%OT=21%CT=20%CU=36884%PV=Y%DS=2%DC=I%G=Y%TM=62C7044
OS:4%P=x86_64-pc-linux-gnu)SEQ(SP=FF%GCD=1%ISR=10C%TI=Z%TS=8)OPS(O1=M54EST1
OS:1NW7%O2=M54EST11NW7%O3=M54ENNT11NW7%O4=M54EST11NW7%O5=M54EST11NW7%O6=M54
OS:EST11)WIN(W1=7120%W2=7120%W3=7120%W4=7120%W5=7120%W6=7120)ECN(R=Y%DF=Y%T
OS:=40%W=7210%O=M54ENNSNW7%CC=Y%Q=)T1(R=Y%DF=Y%T=40%S=O%A=S+%F=AS%RD=0%Q=)T
OS:2(R=N)T3(R=N)T4(R=N)T5(R=Y%DF=Y%T=40%W=0%S=Z%A=S+%F=AR%O=%RD=0%Q=)T6(R=N
OS:)T7(R=N)U1(R=Y%DF=N%T=40%IPL=164%UN=0%RIPL=G%RID=G%RIPCK=G%RUCK=G%RUD=G)
OS:IE(R=N)

Network Distance: 2 hops
Service Info: Host: RED; OS: Linux; CPE: cpe:/o:linux:linux_kernel

Host script results:
|_clock-skew: mean: -19m58s, deviation: 34m37s, median: 0s
| smb2-time: 
|   date: 2022-07-07T16:04:53
|_  start_date: N/A
|_nbstat: NetBIOS name: RED, NetBIOS user: <unknown>, NetBIOS MAC: <unknown> (unknown)
| smb-security-mode: 
|   account_used: guest
|   authentication_level: user
|   challenge_response: supported
|_  message_signing: disabled (dangerous, but default)
| smb2-security-mode: 
|   3.1.1: 
|_    Message signing enabled but not required
| smb-os-discovery: 
|   OS: Windows 6.1 (Samba 4.3.9-Ubuntu)
|   Computer name: red
|   NetBIOS computer name: RED\x00
|   Domain name: \x00
|   FQDN: red
|_  System time: 2022-07-07T17:04:53+01:00

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 62.42 seconds

There was a ftp server open with anonyomous login enabled, port 80 with phpCli, 3306 with mysql which looked suspicious.

FTP:

So, there was nothing that we could do about the ftp server, but got three usernames which is Elly,John and Harry.

The full port scan results came as: Command: nmap -vvv -Pn -p- stapler -oA nmap/all

# Nmap 7.92 scan initiated Thu Jul  7 21:47:39 2022 as: nmap -vvv -Pn -p- -oA nmap/all stapler
Nmap scan report for stapler (192.168.67.148)
Host is up, received user-set (0.17s latency).
Scanned at 2022-07-07 21:47:39 +0545 for 541s
Not shown: 65524 filtered tcp ports (no-response)
PORT      STATE  SERVICE     REASON
20/tcp    closed ftp-data    conn-refused
21/tcp    open   ftp         syn-ack
22/tcp    open   ssh         syn-ack
53/tcp    open   domain      syn-ack
80/tcp    open   http        syn-ack
123/tcp   closed ntp         conn-refused
137/tcp   closed netbios-ns  conn-refused
139/tcp   open   netbios-ssn syn-ack
666/tcp   open   doom        syn-ack
3306/tcp  open   mysql       syn-ack
12380/tcp open   unknown     syn-ack

Read data files from: /usr/bin/../share/nmap
# Nmap done at Thu Jul  7 21:56:40 2022 -- 1 IP address (1 host up) scanned in 540.48 seconds

which showed that port 12380 was open.

Aggressive nmap scan into port 12380: Command: nmap -Pn -p12380 -A stapler -oN nmap/port12380

Starting Nmap 7.92 ( https://nmap.org ) at 2022-07-07 22:05 +0545
Nmap scan report for stapler (192.168.67.148)
Host is up (0.29s latency).

PORT      STATE SERVICE VERSION
12380/tcp open  http    Apache httpd 2.4.18 ((Ubuntu))
|_http-server-header: Apache/2.4.18 (Ubuntu)
|_http-title: Site doesn't have a title (text/html).

Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
Nmap done: 1 IP address (1 host up) scanned in 27.41 seconds

Vulnerability Analysis

curl stapler:12380 gave some garbage value so using curl stapler:12380 | html2text which gave:

****** Coming Soon ******
*** Sorry guys, BSides happened too quick! Didn't have enough time to finish
the website. ***
** Try again next year. **
Made with  by Creative_Tim. Free download here.

Trying curl stapler:12380/robots.txt | html2text gave the same results.

Getting into the web-browser and looking at http://stapler:12380/blogblog gave nothing so tried https://stapler:12380/blogblog and finally got a wordpress site.

In https://stapler:12380/blogblog/wp-content/, found a directory with lising of plugins, themes and uploads.

GET /blogblog/wp-content/plugins gave:

****** Index of /blogblog/wp-content/plugins ******
[[ICO]]       Name                        Last_modified    Size Description
===========================================================================
[[PARENTDIR]] Parent_Directory                               -  
[[DIR]]       advanced-video-embed-embed- 2015-10-14 13:52    -  
              videos-or-playlists/
[[   ]]       hello.php                   2016-06-03 23:40 2.2K  
[[DIR]]       shortcode-ui/               2015-11-12 17:07    -  
[[DIR]]       two-factor/                 2016-04-12 22:56    -  
===========================================================================
     Apache/2.4.18 (Ubuntu) Server at stapler Port 12380

Looking for plugin advanced-video-embed-embed-videos-or-playlists/ on exploit-db, found a LFI vuln with a exploit code.

Exploitation

downloaded the python script from vulnhub, modified it according to the need and ran the script to get the shell access.

Downloaded the file compromised which had:

<?php
/**
 * The base configurations of the WordPress.
 *
 * This file has the following configurations: MySQL settings, Table Prefix,
 * Secret Keys, and ABSPATH. You can find more information by visiting
 * {@link https://codex.wordpress.org/Editing_wp-config.php Editing wp-config.php}
 * Codex page. You can get the MySQL settings from your web host.
 *
 * This file is used by the wp-config.php creation script during the
 * installation. You don't have to use the web site, you can just copy this file
 * to "wp-config.php" and fill in the values.
 *
 * @package WordPress
 */

// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define('DB_NAME', 'wordpress');

/** MySQL database username */
define('DB_USER', 'root');

/** MySQL database password */
define('DB_PASSWORD', 'plbkac');

/** MySQL hostname */
define('DB_HOST', 'localhost');

/** Database Charset to use in creating database tables. */
define('DB_CHARSET', 'utf8mb4');

/** The Database Collate type. Don't change this if in doubt. */
define('DB_COLLATE', '');

/**#@+
 * Authentication Unique Keys and Salts.
 *
 * Change these to different unique phrases!
 * You can generate these using the {@link https://api.wordpress.org/secret-key/1.1/salt/ WordPress.org secret-key service}
 * You can change these at any point in time to invalidate all existing cookies. This will force all users to have to log in again.
 *
 * @since 2.6.0
 */
define('AUTH_KEY',         'V 5p=[.Vds8~SX;>t)++Tt57U6{Xe`T|oW^eQ!mHr }]>9RX07W<sZ,I~`6Y5-T:');
define('SECURE_AUTH_KEY',  'vJZq=p.Ug,]:<-P#A|k-+:;JzV8*pZ|K/U*J][Nyvs+}&!/#>4#K7eFP5-av`n)2');
define('LOGGED_IN_KEY',    'ql-Vfg[?v6{ZR*+O)|Hf OpPWYfKX0Jmpl8zU<cr.wm?|jqZH:YMv;zu@tM7P:4o');
define('NONCE_KEY',        'j|V8J.~n}R2,mlU%?C8o2[~6Vo1{Gt+4mykbYH;HDAIj9TE?QQI!VW]]D`3i73xO');
define('AUTH_SALT',        'I{gDlDs`Z@.+/AdyzYw4%+<WsO-LDBHT}>}!||Xrf@1E6jJNV={p1?yMKYec*OI$');
define('SECURE_AUTH_SALT', '.HJmx^zb];5P}hM-uJ%^+9=0SBQEh[[*>#z+p>nVi10`XOUq (Zml~op3SG4OG_D');
define('LOGGED_IN_SALT',   '[Zz!)%R7/w37+:9L#.=hL:cyeMM2kTx&_nP4{D}n=y=FQt%zJw>c[a+;ppCzIkt;');
define('NONCE_SALT',       'tb(}BfgB7l!rhDVm{eK6^MSN-|o]S]]axl4TE_y+Fi5I-RxN/9xeTsK]#ga_9:hJ');

/**#@-*/

/**
 * WordPress Database Table prefix.
 *
 * You can have multiple installations in one database if you give each a unique
 * prefix. Only numbers, letters, and underscores please!
 */
$table_prefix  = 'wp_';

/**
 * For developers: WordPress debugging mode.
 *
 * Change this to true to enable the display of notices during development.
 * It is strongly recommended that plugin and theme developers use WP_DEBUG
 * in their development environments.
 */
define('WP_DEBUG', false);

/* That's all, stop editing! Happy blogging. */

/** Absolute path to the WordPress directory. */
if ( !defined('ABSPATH') )
        define('ABSPATH', dirname(__FILE__) . '/');

/** Sets up WordPress vars and included files. */
require_once(ABSPATH . 'wp-settings.php');

define('WP_HTTP_BLOCK_EXTERNAL', true);

The database user and password is compromised, and thus can be accessed from phpmyadmin: user:root pass:plbkac

used mysql -u root -p -h stapler to access the mysql database.

show databases;

use wordpress;

show tables;

select * from wp_users;

MySQL [wordpress]> select * from wp_users;
+----+------------+------------------------------------+---------------+-----------------------+------------------+---------------------+---------------------+-------------+-----------------+
| ID | user_login | user_pass                          | user_nicename | user_email            | user_url         | user_registered     | user_activation_key | user_status | display_name    |
+----+------------+------------------------------------+---------------+-----------------------+------------------+---------------------+---------------------+-------------+-----------------+
|  1 | John       | $P$B7889EMq/erHIuZapMB8GEizebcIy9. | john          | [email protected]    | http://localhost | 2016-06-03 23:18:47 |                     |           0 | John Smith      |
|  2 | Elly       | $P$BlumbJRRBit7y50Y17.UPJ/xEgv4my0 | elly          | [email protected]    |                  | 2016-06-05 16:11:33 |                     |           0 | Elly Jones      |
|  3 | Peter      | $P$BTzoYuAFiBA5ixX2njL0XcLzu67sGD0 | peter         | [email protected]   |                  | 2016-06-05 16:13:16 |                     |           0 | Peter Parker    |
|  4 | barry      | $P$BIp1ND3G70AnRAkRY41vpVypsTfZhk0 | barry         | [email protected]   |                  | 2016-06-05 16:14:26 |                     |           0 | Barry Atkins    |
|  5 | heather    | $P$Bwd0VpK8hX4aN.rZ14WDdhEIGeJgf10 | heather       | [email protected] |                  | 2016-06-05 16:18:04 |                     |           0 | Heather Neville |
|  6 | garry      | $P$BzjfKAHd6N4cHKiugLX.4aLes8PxnZ1 | garry         | [email protected]   |                  | 2016-06-05 16:18:23 |                     |           0 | garry           |
|  7 | harry      | $P$BqV.SQ6OtKhVV7k7h1wqESkMh41buR0 | harry         | [email protected]   |                  | 2016-06-05 16:18:41 |                     |           0 | harry           |
|  8 | scott      | $P$BFmSPiDX1fChKRsytp1yp8Jo7RdHeI1 | scott         | [email protected]   |                  | 2016-06-05 16:18:59 |                     |           0 | scott           |
|  9 | kathy      | $P$BZlxAMnC6ON.PYaurLGrhfBi6TjtcA0 | kathy         | [email protected]   |                  | 2016-06-05 16:19:14 |                     |           0 | kathy           |
| 10 | tim        | $P$BXDR7dLIJczwfuExJdpQqRsNf.9ueN0 | tim           | [email protected]     |                  | 2016-06-05 16:19:29 |                     |           0 | tim             |
| 11 | ZOE        | $P$B.gMMKRP11QOdT5m1s9mstAUEDjagu1 | zoe           | [email protected]     |                  | 2016-06-05 16:19:50 |                     |           0 | ZOE             |
| 12 | Dave       | $P$Bl7/V9Lqvu37jJT.6t4KWmY.v907Hy. | dave          | [email protected]    |                  | 2016-06-05 16:20:09 |                     |           0 | Dave            |
| 13 | Simon      | $P$BLxdiNNRP008kOQ.jE44CjSK/7tEcz0 | simon         | [email protected]   |                  | 2016-06-05 16:20:35 |                     |           0 | Simon           |
| 14 | Abby       | $P$ByZg5mTBpKiLZ5KxhhRe/uqR.48ofs. | abby          | [email protected]    |                  | 2016-06-05 16:20:53 |                     |           0 | Abby            |
| 15 | Vicki      | $P$B85lqQ1Wwl2SqcPOuKDvxaSwodTY131 | vicki         | [email protected]   |                  | 2016-06-05 16:21:14 |                     |           0 | Vicki           |
| 16 | Pam        | $P$BuLagypsIJdEuzMkf20XyS5bRm00dQ0 | pam           | [email protected]     |                  | 2016-06-05 16:42:23 |                     |           0 | Pam             |
+----+------------+------------------------------------+---------------+-----------------------+------------------+---------------------+---------------------+-------------+-----------------+
16 rows in set (0.003 sec)

Extracted the hashes and used hashcat to crack into the hashes.

Password Attacks

hashcat -m 400 -a 0 hashes /etc/share/wordlists/rockyou.txt to crack the hash. Finally found the password of the user john which is incorrect. Finally uploaded a php reverse shell into the server using the wordpress plugin and gained an initial foothold into the system.

Post-Exploitation

After getting foothold into the server, got into /tmp, downloaded linpeas.sh and ran the script.

Found:

OS: Linux version 4.4.0-21-generic (buildd@lgw01-06) (gcc version 5.3.1 20160413 (Ubuntu 5.3.1-14ubuntu2) ) #37-Ubuntu SMP Mon Apr 18 18:34:49 UTC 2016                                                                                     
User & Groups: uid=33(www-data) gid=33(www-data) groups=33(www-data)
Hostname: red.initech
Writable folder: /dev/shm

which pointed toward the OS version. Searched it in exploit-db and found that this particular version is having an issue of incorrect use of dynamic memory during program operation which can lead to local privilege escalation, by using the pointer to that memory.

After some looking into google, found the CVE number was CVE-2016-4557 and found an exploit to it.Finally, used the UAF(Use-After-Free) vulnerability to escalate the privileges to root.