Month: February 2017

  • Pentestit.ru noobs guide

    Pentestit.ru noob guide

    Whilst I’m a “blue teamer” (I specialise in the defensive side of InfoSec), I do enjoy doing Pentesting challenges both for fun and because “know your enemy” & “always think like an attacker” are invaluable bits of advice for any defender.

    One of my favourites is Pentestit.ru Labs which closely mimic real environments you may come across in actual pentests and are designed in such as way that whilst they have a gentle learning curve, they normally require you to have decent IT and security fundamentals, rather than being aimed at people who have installed Kali and are watching “How to be a hacker” YouTube videos.

    However, for the last year or so I’ve been sat in the pentestit.ru Telegram channel and whilst there are and awful lot of very knowledgeable people in the channel (far more knowledgeable than me, many are professional pentesters or prepping for things like OSCP exams) there are also a lot of people who join the channel that are really struggling with the basics. So I thought I’d put together a quick FAQ for those guys.

    Do I need to use Kali Linux?

    No. In fact, I intend to do the next lab entirely from a Windows Box to prove it’s possible (and because I love Powershell). However, if you’re asking that question, I strongly recommend you do as it’s probably the easiest starting platform to attack from.

    Do I need to use PentestIt.ru’s downloadable Kali VM?

    Again, no.  I’d wager almost everyone completing the labs is doing so using a vanilla Kali build. The only difference with the one on the Pentestit.ru website is it come pre-configured with everything you need to connect to their vpn.

    If you’re going to struggle connect to a vpn from Kali when then instructions are on their website, you’d probably be better spending your time reading some linux vpn guides first.

    The vpn is connected and I can ping their gateway machine(s). Now what?

    Start your pentest! Normally these labs only start with one (or possibly two) gateways machines exposed, so don’t expect to be able to access the servers behind the gateway directly. However, usually these labs do have port forwarding set up for some services, so for example hitting port 25 on the gateway machine is likely to be forwarded to port 25 on the “email host” on the internal network.

    You’re normally looking for some way to compromise the gateway machine (or some machine port forwarded to from it) and then pivot to the internal hosts.

    I’m on the vpn, but I get disconnected constantly. Why?

    Check you don’t have more than one vpn connection active to their labs as this will normally cause them to disconnect. Failing that, check out the Pentestit.ru Service channel for service outage notifications.

    I’m on the vpn, but I get disconnected hourly. Why?

    Many of the hosts reset on the hour. so may disconnect you and remove any changes you have made. This in intentional. If you have something running on a host that takes over an hour (i.e. some kind of brute force attack) you are probably approaching the problem in the wrong way.

    I used “<insert tool name>”  and it found nothing. Why?

    One of the great things about these labs is that they are often engineered to make life harder for people using automated tools (especially with the default options) and easier on those actually doing the attacks manually. So, just because sqlmap fails to find an sql injection point, a given password isn’t in the default john the ripper list, nmap doesn’t find an open port on a default scan or a folder isn’t found by dirb doesn’t mean that that approach isn’t going to work. The lab designers know these tools well too and want to give you more of a challenge than “can you run the right tool with the default options”.

    How do I get admin/root?

    I’m sure they’ll prove me wrong at some point, but it’s not likely you ever need admin or root on a host to get the token. This actually makes sense, as with root access you could easily screw over the challenge for other people. However traversing between users with different privs is quite common, often using techniques more commonly associated with escalating to root.

    I’m stuck, now what?

    Try Harder!

    Seriously, that’s probably the first response you’re likely to get in the Telegram channel. Possibly with a link to this

    It’s good advice. Go away, make a coffee, have a smoke, play Hello Kitty Island Adventure … whatever works for you. We’ve all got stuck on a challenge, then come back later with a fresh bunch of ideas.

    But keep trying. These challenges are usually pretty logical and based on real world exploits, so take what you know about the situation and go hit the books (or google) and see if there is something more to learn.

    Seriously, I’ve been trying for days, now what?

    Well, the telegram channel is always there, but most of the people in it try to keep it spoiler free, so the usual etiquette is to ask for somebody to DM you about whatever you are struggling with.

    Also, once the winners of a challenge are announced, people start publishing their solutions, these are great for getting you past you’re current hurdle, however, be very cautious as once you’ve cheated and taken a peek that first time, it becomes much easier to cheat every other time.

    I’ve finished this lab, now what?

    Try this list, or come hang out in the telegram channel and see what others are currently working on.

    Obviously Disclaimer: I’m not part of the pentestit.ru team, just a fan of their work and this does not constitute official pentestit.ru documentation or is in anyway endorsed by them

  • Powershell based Plex “Local Player”

    So, imagine a scenario where you’re trying to give a presentation on a customer’s PC, what you are trying to show is a video on a remote Plex server, but the customer’s PC is so locked down (whitelisted apps only) that whilst vlc will work, a web browser won’t! Seriously!!!

    However, powershell did work and that gave me a way in.

    So, what I thought wouldtake just a few simple lines to download the file from the plex server and play it through vlc, actually became a bit of an epic.

    Therefore, in case anybody ever gets stuck in the same hole or wants some sample code demonstrating to do take “streamed” content and convert it back into something a media player will play locally. The code is now on github at https://github.com/glennpegden/PlexLocalPlayer

    To use it just pass in the URL of the video details page in Plex, your plex username andpassword and the foldername to dump the video into (also optionally the paths to ffmpeg and vlc, or you can redefine these at the top of the script)

    e.g.
    .\PlexLocalPlay.ps1 “http://app.plex.tv/web/app#!/server/01380a5c2c9b4290-9c1136b6882a65c1/details/%2Flibrary%2Fmetadata%2F12345” “user@email.com” “yourplexpasswrd” “G:\Users\Glenn\Downloads”

    Disclaimer: I’ve no idea if interacting with Plex is this way is against their terms and conditions. I’m also not sure any of how I’m doing it is “the right way” because it was reverse engineered by examining how the Plex Web Player works on a laptop rather than from any official documentation. I’m also not responsible for how you use it. My use case was to download marketing material that I was allowed to distribute, I imagine doing this with your family’s blu ray connection may be illegal in many places.

    For anyone writing your own version of this, a few things about the design.

    The convoluted background download. This is to address two problema.

    1. The Plex server seems to time out connections, even if they are happily delivering content. Their own web player gets around this by hitting a “ping” end point as a keep alive, we have to emulate that.
    2. Invoke-Webrequest is nice and simple, but it loads the entire downloaded content into memory and saves it upon completion. Fine for tiny webpages, a disaster waiting to happen for huge files. BITS would normally be my go to alternative (BITS support in powershell is great), but it needs a Content-Length header from the server, which we’re not going to get from a stream.

      So, we have to use .net functions to stream the content into a file, in a background task, so the foreground task can hand the keep alive.

      Potions of the stream downloading code are based on this blog post – https://blogs.msdn.microsoft.com/jasonn/2008/06/13/downloading-files-from-the-internet-in-powershell-with-progress/

    I also added some hokey support for roughly passing back the progress, but as we only know the size of the file on the remote OS and who knows what the transfer/transcode is going to do with it, it’s far from accurate. It also only updates once every 15 seconds (which is how often the keep alive is sent). Really, only consider this as an indicator something is still happening, not a real estimate of progress.

    Obviously simply saving the stream to a file doesn’t generate valid video file, however ffmpeg does a brilliant job or repairing it (or has done in all my tests at least, your mileage may vary).

    Enjoy!

  • Online Anonymity, Privacy and Risk Evaluation

    I got into a conversation the other day about why I, as a massive supporter of the right to online privacy, still tended to use my real name online, in places where a more anonymous handle would be more than acceptable.

    You’d have thought as somebody quite proficient at OSINT (Open Source, Intelligence,  the art of finding information, particularly relating to people, from public information sources), I’d have taken every opportunity to grab a little anonymity, especially as my real name is almost certainly unique in the world.

    It comes down to risk vs reward. Understanding and mitigating the risk is crucial.

    If you know my real name (which is pretty obvious from the domain name of this blog) then there is already loads of freely available information out there on me. I bought domain names in the 90s, back when a real postal address was mandatory (they even sent you a physical certificate of ownership) and I used to run a business out of my house, so it was a legal requirement to have my business address on any formal paperwork, so finding my home address is trivial.  I couldn’t find anywhere leaking my date of birth online but I’d bet there is some site I’ve entered it into (back before I thought to lie about it) which now leaks it publicly. Similarly, I get so many requests for genealogy info that I’m sure somewhere discloses my mothers maiden name. There are also documents I wrote at University on what is now called Cyber Security with my name on that I now wish didn’t exist, that highlight my security “white hat” has been bleached over the years.

    That information is all out there. The genie is out of the bottle, it’s never going back in. So, you’d think that was ever MORE reason to hide my real name online? Not really and it’s all down to understanding and managing that risk.

    If I operate under a pseudonym, I have a new risk. The risk of some detail linking the anonymous me to the real me. I’m going to be in the same physical location as my anonymous self, probably using the same computer, browser and internet connection, I’m going to have similar views, knowledge, understanding, frailties and experiences, the same grammar mistakes, the same typing patterns the same mouse movement patterns.

    As mass tracking and analysis of both data and metadata becomes easier and more prevalent, the chances of me accidentally revealing a link between my real self and my anonymous self increases and once somebody makes that link, there is no point being anonymous at all.

    What’s more, the ability to operate under a pseudonym means I’m more likely to reveal additional information than I normally would under my real identity (even if only subconsciously), increasing the risk even further. The instant all the content you wished to keep anonymous is linked back to your real identity you’re essentially stood there with a big sign saying “this is the stuff I didn’t want you to know was by me”.

    To further evaluate the risk, you also have to understand that data can last forever and who can access this data over time changes. It’s not about who can see your private content now, it’s about who can see it in the future and then associate it back to you.

    Back in 2006, I was in Amsterdam mainly to watch Feyenoord vs Blackburn Rovers, but I also visited the Amsterdam Museum (despite the cliche, not all English football fans in Amsterdam just hang out in De Wallen drinking beer and smoking weed) and read a fascinating but terrifying account of the Nazi occupation of Holland in World War 2. The dutch, quite sensibly, had collected everyone’s religion as part of the census, to ensure that in the case of their funeral being organised by the state, an appropriate ceremony was performed. However, after Nazi occupation, this same list has a whole different purpose.

    The details you put online are no different. Just because you trust a website to responsibly keep your private data private, what if they are sold, hackedpressured by a nation state or have a rogue or sloppy employee?

    I therefore operate under the assumption that EVERYTHING I put online can potentially end up in the wrong hands one day.

    That doesn’t mean that I instantly post everything public, just because one day people might see it anyway, but it’s always a thought in the back of my mind when I post.

    So, I’ve given up on online privacy? Hell No! It’s important to realise anonymity and privacy are not the same thing and the right to privacy is an important right to have, even if I choose to waive it.

    Just because I feel one day, a hack, leak or change of government could see my emails/PMs/Skype calls etc being put in the wrong hands, doesn’t mean that I want to share them with everyone right now.  It’s precisely because anonymity is mere obfuscation that gives people a false sense of security that I think privacy is so very very important.

    For example, my twitter account is public, this is my choice and I know anything I post on there can be seen by the entire world in perpetuity, so it tends to be limited mostly to conversations about tech, football or politics. Facebook however, I have configured to be more private,  that doesn’t mean I’ll post anything incriminating or particularly personal, but it will give you more of an insight into my daily comings and going, my social life and particularly upcoming and current events I’m attending. This includes data that may be of some value ahead of time (i.e. to allow you to break into my house, or scam my friends/bank etc into believing I’m stranded abroad without money) but virtually zero value after the fact. Therefore as long as I can trust Facebook to keep that data private for a short period, the risk is much smaller.

    But privacy in the modern world is tricky. It’s 16 years since of the launch of PGP and almost 3 years since google announced End to End, but there is still no practical way for me to send an email to any non-technical friends with the belief that nobody other than them will ever be able to read it. End to End (E2E) encrypted messengers like Signal, Telegram, WhatsApp and even Facebook Messenger are great, but do I really trust my phone and computer operating systems enough to  be sure the message wasn’t snooped on when it’s decrypted and even if I did, is it reasonable to expect my mum to install a new messenger app, when it’s unlikely I would ever say anything I’d couldn’t be overheard saying to her in the street?

    And what of systems that don’t purport to offer E2E encryption? I love slack, but even if their data is encrypted both in transit and at rest as they claim, they can still be decrypted and subpoenaed. The tech simply isn’t there yet to make privacy EASY and that’s the way both corporations (who sell you data) and government agencies (who use is for surveillance purposes) like it.

    Which brings us back to risk vs reward. In much the same way to only truly secure a computer is unplug it and encase in in concrete, the only way to stay truly private online is to never be online, However, if you want the rewards being online brings, the have to accept the risks. But, when you understand the risks, you can start to mitigate them somewhat.

    There is always a risk and E2E encrypted chat could still be made public, but it’s certainly less risk than some public forum with an unknown operator who may be doing anything with your data to fund their project, even if you are operating under some veil of anonymity. There is a chance the government’s mass surveillance data could be compromised, but it’s much more likely that dodgy service that provides you with free PPV films and sports will have their subscribers details made public. There is chance your slack logs may be subpoenaed, but there is a greater chance you’ll leave your PC or phone unattended and logged into slack.

    Risk vs Reward, but make sure you understand ALL the risks. Not just the immediate ones.

    My advice – Choose your tools and sites wisely, choose what you say online and who you say it to wisely and work with people like the Open Rights Group and EFF to ensure your right to privacy is a legally protected right.