Monthly Archives: October 2020

Basic code review tools for Ruby

This blog post is to document how to get started analysing a Ruby code base for trivial security vulnerabilities. Particularly in the case, like me, when you have absolutely no ability in Ruby. If you are being asked to do an actual code review then I feel sorry for you dear reader. This will help you get started, but you cannot replace having developed something sizeable within the target language and elbow grease.

The sum total of my Ruby experience was my entirely unpopular module for metasploit a few years ago called “git_enum“. This is a post exploitation module which will seek to rob any stored git passwords or authentication tokens from a user’s home folder. I wanted to merge it into MSF but I am locked in anxiety about how awful that was to write, and assuming it will be laughed out of town if I dared try and contribute it!

I digress. My point was that I am not going to be getting scheduled on any Ruby source code reviews any time soon. The syntax is just alien enough to successfully spurn my interest.

This has been prompted by me having access to source code during an application test. This is a move from a black-box to white-box methodology to aid defence in depth recommendations to be made. There is no assumption that I am reading everything line by line. In saying that, when I have access to source code so I like to leverage automation where possible to maybe point toward weaknesses.

Overview of the process

  1. Obtain the source and save it locally
  2. Identify Static Code analysis tools for the target language
  3. Identify tools to check dependencies for known vulnerabilities

I don’t need to say much about 1. so I will move right on to discussing 2. and 3. below.

Static Code Analysis Tools for Ruby

There is almost always some very expensive commercial tool for doing automated static code analysis. They are probably very good at what they do. However, they always have eye watering license fees and I have never actually had the privilege of using one to find out!

As this is not a full code review you will likely have no budget and so you need to find open source projects that support your target language. A great place to start is this URL from OWASP:

I picked two tools from that list which were open source and which seemed active within the last 2 years of development:

Both were easy to install and use within a Kali host. The other tools may be as good but for me I had two static analysers and that was enough for me.

Brakeman installation and usage

gem install brakeman
brakeman -o brakeman_report.html /path/to/rails/application

Dawnscanner installation and usage

gem install dawnscanner 
dawn --file dawn_report.html --html /path/to/rails/application

Dependency Scanning Tool for Ruby

A dependency is an extension from the core language which has been made by a project and then made available for others to use. Most applications are made using dependencies because they save development time and therefore cost.

The downside of using dependencies is that they are shared by hundreds, thousands, or millions or of other applications. They therefore get scrutinised regularly and a vulnerable dependency can be a bad day for many sites at a single time. One thing you have to stay on top of is the version of dependencies in use and that is why it is an important check to make even if you are not doing a full code review.

The best dependency scanner out there is OWASP’s own Depedenency-check. This tool is getting better every time I use it. It integrates with more dependency management formats all the time. As per the URL below:

This is capable of doing Ruby but to do so it uses “bundler-audit“. For this one I went straight to Bundler-Audit.

Bundler-Audit Installation and Usage

gem install bundler-audit
cd /path/to/rails/application # folder where the Gemile.lock file is.
bundler-audit chec

I would include one vulnerability in my Report for the outdated dependencies which summarises in a table the known vulnerabilities and the CVSS risk rating taken from the CVE references from bundler-audit. If there are hundreds of known vulnerabilities you should prioritise and summarise further.

That is it for this blog post. You have to interpret the results yourselves.

Hope that helps.

In memory of Paul Mason

It is with regret that I am writing this because the world has lost a bright light. This page lists the stories people volunteered about Paul. Mainly from InfoSec Twitter but all sorts of lovely people who knew Mr Mason managed to find me. They are included and very welcome.

If you are reading this and you want to add to the list you can use the comments if you prefer, or I will still take them over Twitter if you have that. The intent is that these will be combined and used to produce a photo album or book for his parents.

There will be an effort to remember Paul at the next Glasgow Defcon on Tuesday 1st of September via Discord/Twitch. As Paul was all about sharing knowledge there will be a talk scheduled and then a virtual “wake” after the event where people can share stories. You are all welcome.

Lisha Sterling/@lishevita

Andy Gill/@ZephyrFish

Robert a.k.a Rab Ray

Spoken poetry for 2 hours.

Paul Ritchie/@cornerpirate

One of the many things that I thank @PMason00 for is the insanely generous gift of a travel guitar that he gave me after work took us away for a ski trip.

I got it out and have given it a bash here it sounds great for a wee guitar.

Neither of us wanted to ski. So we had planned a bunch of things to do ranging from lock picking to rocking the hotel to its core.

He handed me this wee travel guitar at Glasgow airport and I think he had some other instrument with him I honestly forget what. We go to check-in and the extremely low budget airline was kicking off about instruments and bags. He frankly charmed the pants off the lady behind the desk.

Said we were a band and had been booked to play a hotel. They had booked our flight and, stupidly, forgot we would need instruments! Then bosh we were checked-in without paying a penny both with an instrument case over the allowance. Witchcraft I tell you. Witchcraft. 

The rest of the company were off skiing. But we were sharing a room. For us it was two days of absolute chillaxing. Up for breakfast, back for a snooze.

Then afternoons were spent passing this guitar around playing songs and talking about all kinds of things. To set this in time we stopped to watch Trump’s inauguration on CNN at one point. 

I tried to hand the guitar back to him at Glasgow airport. He said something like:

“No man you keep her. Take care of her she seems to like you”.

He stubbed out a cigarette and was off in a taxi while I tried to process the insane generosity of that action.

I installed it as the office guitar. Which @longjonsouza said “brought the promise of music” to us.

I was going in two days a week back then and I made sure I was in early to belt out songs before 8:30am. If I was stressed I would break it out. I would also infamously play it during job interviews from that point on. I think @__shabab__ was the only one to survive the new more rigorous application process.

Look if you cannot crack a password while someone plays the Mario theme badly at you are you even a hacker? This guitar has now survived my house move and it sits in my new dedicated office room right next to me.

Part of moving to a house with a garden came with a picture in my head of me and Paul sitting out there playing songs and relaxing as the summer sun toddles off to the west.

Instead as I stood out there for the first time as the owner of the place I got the call from his father breaking the sad news. While I won’t be out there with him. I will be playing his beaten and much loved travel guitar.

Don’t worry Paul I am taking good care of her.

Love you. 

Clare Cavanagh/@Clarecav01

Stefano Sesia/@StefanoSesia

Lewis Binnie/@LewisBinnie1

Daniel Dresner/@DanielGDresner


Campbell Murray/@zyx2k

James Hemmings/@MrJamesHemmings


Josh Fraser/@jishf

Steve Porter/@SteveDPorter


Miguel Marques/@z0mbi3


“Paul and I were colleagues. Even though we parted ways, I’ll always remember him for the little time we shared together. How he showed up at a customer meeting once wearing just everyday clothes, proudly stating (and I quote) ‘he would never wear a suit again because he has been a teacher and had had enough of that’. And then he brought to the table the most amazing and interesting stories and managed to “connect” with people and just made everything great while showing the same customer a degree of knowledge, professional attitude and passion that I’ve seldom seen elsewhere. Immediately, no matter who they were, no matter their background or language or stance in life, he just made friends.

When he talked – and he could talk a lot! – he absolutely captivated the audience like no one. Even in a crowd of hundreds, you could always feel he was talking to you and to you alone.

He helped – always, at any time, without asking too many questions when questions were a nuisance. He was always there. Always. He just .. gave freely and never, ever asked for anything back. He showed me what it means to enjoy a conversation, to be proud of what you do and find the fun side in everything. He made me laugh to the point of crying, even though English isn’t my first language. He talked about his family at times, especially his dad, about his life and achievements and funny stories and I wish we could have had that famous beer and listen to more.

I’ll always remember him. In some small but meaningful ways he changed my life when I switched careers and moved onto the cyber security side of things. He believed in me so much, and I think I made him a little bit proud.

I’m pouring myself a whisky now, and my thoughts are for all the people whose life he steered in better directions. I’m sure there’s more than he could imagine; I hope others will reach out to you to show how proud you should be of him.

My sincerest condolences.”

Youri Van Der Zwar/@yourniz

Paul Fennell/@Digit4lbytes

John A Ferguson/@jafwords

I’ve known him for 15 years. I loved his take on the world and loved his wisdom. We taught together and as much as he left that world of secondary teaching behind him I know that he made a massive difference.

The children that Paul taught loved him. He was a phenomenal English teacher and helped shape the lives of so many young people. The pupils looked up to him and respected him. He was forward thinking and helped shape some of the ways we teach that many will just take for granted now.

He was a champion of interdisciplinary learning, allowing pupils to see the link between all of the subject areas found in school.

What cyber security gained, we definitely lost in education and it was a huge loss. The pupils who had Paul as a teacher will remember him fondly, and his friends who taught with him will miss him deeply.




Giovanni Interi

I first met Paul at a company meeting where he delivered a fantastic talk about education and IT security I was impressed at his vast knowledge both technical and human.

We worked in the same company for a while, not on same projects however, and had opportunities to exchange very interesting conversations. What was transpiring always from being in contact with Paul was … his BIG HEART. Even when he wasn’t happy with someone or some situation. He really had time for everyone, would discuss any subject and would respect different views, and choices. When he expressed his, Paul was always able to explain clearly and unequivocally.

On one of the ski trip mentioned in these memories he was so attentive to the trip companions and also to the other passengers on the plane close to us. I remember he started talking to a Jewish passenger (distinguishable by his traditional clothing and looks) with a genuine interest of their life and faith and showed a solid historical and contemporary knowledge of their lifestyle and traditions. That particular chat impressed me particularly as it highlighted his openness and respect of all walks of life.

One particular moment of that trip was snapped in a β€˜friendly’ snooze in the smoking room of the Hotel where we were staying:

A pile of Paul’s (Paul Mason, Paul Johnstone)

Thank you Paul! Rest in peace!


Persistent SSH Sessions

If you win the lottery and start a job working as a penetration tester the chances are you will need to learn a couple of vital lessons sharpish. One that I like to drill into people is about SSH sessions that persist even if your client connection dies. A complete rookie mistake – that we all make – is to lose data when our SSH connection dies. Maybe the Wi-Fi disconnects or you close your laptop to go for lunch? Who knows.

Don’t blame yourself. The chances are you partly educated yourself and you were using either a Linux base machine or a VM. In that scenario your terminal lives as long as you want it to with no questions asked.

Now that you are on someone’s payroll the chances are you have a fancy “penetration testing lab” that you have to send connections through for legal reasons. While I like that I won’t lose my liberty it does introduce this complexity into our lives.


I am a relative noob to Tmux but it really seems to be worth the investment of time.

If I had a time machine I would get future me who understands Tmux completely to come and teach me. Maybe in a fancy silver car with a… I am gonna say it… *pffft*. Ok ok, calm down. In a fancy silver car with a tmux-capacitor! I know some of you liked that pun and that means you are as bad as me.

The absolute basics are these three commands:

tmux new -s <session_name>    # used to establish a new session.
tmux new -s customerA         # I name a session after the project for ease.
tmux ls                       # list the sessions that exist
tmux attach -t <session_name> # used to attach to your previous session
tmux attach -t customerA      # attaching back to the session created last time.

If you create a new session you can then kill your client SSH connection by disconnecting from Wi-Fi or whatever. On reconnecting when back online you attach to that and you have lost nothing (assuming the server has remained online and the issue was client side only).

For the purposes of this tutorial you have done all you need to do to prevent yourself losing work. Go you.

However, Tmux is capable of lots more things such as splitting an SSH session horizontally and/or vertically when you want to show two processes at once in a screenshot. Or what about having multiple “windows” in a single SSH session and a relatively easy way to move between those windows? Instead of having additional instances of Putty on windows or tabs in “MTPutty” you can do everything over a single SSH session inside of Tmux.

There is a full cheat sheet here.

Totally worth the learning curve.

Captain’s Log: September 2020

The Good

  • 10k Daily Steps Challenge + **New Goal** – Still rumbling along with this nicely. I upped my game to now add a sub task to aim for 22 active minutes a day. That means having the heart rate properly elevated. This is going to take a while to get habitual but I have made a decent start and lowered my resting heart rate a couple of beats at the same time. The month went well until the final 2 days where I had a beast of a cold and sore throat. I managed the 10k but it took a lot of effort. I whinged on twitter about a possible chainbreaker while being sick and @TIA568B reminded me to keep going so voila:
Some days this is what success looks like
  • Blog Posts – I got an actual technical blog post out the door getting re(started) with iOS app testing. I prefer this blog maintaining its technical edge but I was never prolific with that stuff with at most 8 a year. The commitment to track my 2020 with the Captain’s Log series has drowned out the few technical posts.
  • Audio Books – Absolutely still devouring the Rama series of books by Arthur C Clarke. I am on to “Rama Revealed” which is the final book. The first book was a wonderful and relatively short story but the later instalments have been much longer listens with this one being 20 hours. Very much worth watching.
  • Youtube Channel – I have been watching Kurzegesagt with my kids. It is probably a bit beyond them but my eldest is getting all kinds of joy out of the existential and space series. I keep regularly having “mind blown!!” reactions to these videos. Honestly they are amazingly well put together. Delve into the series on ants… Pro tip.
  • Sleep – The youngest has started to sleep through the night! Hopefully this continues. So I relocated myself from sleeping on their floor to an actual bed. Like a real person I have slept on a bed! As I write this on the 7th of September for 4 consecutive nights. Long may this continue. *update.. It continued :D*. This is the real shift as it enabled the new exercise goal. If you don’t get sleep you cannot recover from exercise and so it was of limited value without this.
  • Games – XCOM: Chimera Squad. I had no idea that this had been released! I am a long time lover of the XCOM series. Over the years they have tried multiple different game modes including flight simulator, FPS etc. This is an interesting twist which is close to old school final fantasy game dynamics. Each mission is a series of breach and clear engagements. Upgrade kit to make more breach possibilities occur i.e. a brute force device to defeat doors locked with keypads, or explosives to make entries in walls. It has been interesting and a different direction for the series.
  • Weekends – We managed to get to the park most weekends for outside activities. Getting this done early in the weekend sets us up for a happier time over the weekend. Even ventured out to the forest for a roam about in nature. The kids were mainly asking where the slides were until they discovered a massive pile of rocks to climb.
  • CENSIS Talk – I was asked to speak at an event for CENSIS. Work were all for it, and gave me time in the busy schedule. The talk was around security practices in the IoT ecosystem space. While I tell everyone I am not the expert in this area I do slowly improve my understanding of it. The real positive about this was that we had agreed to do a live hacking demo. No bother when the event was face2face, but I needed to record it. The process of recording and editing was enjoyable and I really get a kick out of making little films.

AWS Snafu Finally Solved!

In April I bought a book called “AWS Pentesting with Kali”. I had decided to fire into some cloud skills as I am increasingly back on customer engagements again and it is always nice to learn new things. Sadly I have not even opened the book yet. But I did develop a tool (still not released) to enable data in and data out of restricted environments.

Data in via typing, and data out via QR codes which are both established techniques already but I like to make my own tools for these things sometimes.

Anywho, I needed a Windows server over an Internet connection and RDP to get the right feel for speed. So I went with opening an AWS account, woohoo! I would spin up a new instance each time I worked on the tool and then crush it as I went to bed using my free-tier allowance like a boss.

Unfortunately ever since May I have been sent an email every month warning my of my free-tier allowance being at 85%. But.. but.. I have nothing running? I log in to the dashboard and see nothing even paused. As the months roll on I eventually tweeted about it:

Enter the heroes I needed: @JGMSoftware, @UK_Daniel_Card, and @joe_jag who all deftly informed me I know nothing about AWS because I had assumed that dashboard showed me everything when it is indeed tied by region. I have honestly no idea why the server was spun up once in Ohio when I seem to default to Virginia on the dashboard.

Lesson very well learned and THAT is why I bothered opening an AWS account in the first place. Now that my test server is properly wiped I can now crack that AWS book open in the dead of winter and not incur costs immediately as I will have my free-tier amount back.

To the helpers. I salute thee. Keep being beautiful.

The Bad

  • Stress – I had a very stressful couple of weeks over the end of August and start of September. Some times are tough but this one was pretty up there. On being positive about it something good should come of it mid October unless there are delays or catastrophe. Fortunately the uptick in weekends being relaxing and sleep came just as it ended. Nicely timed.
    • I would like to caveat this with the fact that, after the initial rocky start, the increase in sleep quality and duration by sleeping on an actual bed made it vanish.

Highlight of the month

Work took me to places where I needed to record multiple videos for different audiences. Some for internal training, and then this one which I can share with you.

This is notable because it was made for a non-security audience. That meant doing some background theory in risk analysis and threat modelling before going into a live hacking demo to help contextualise what was happening.

Research it is not. But a reasonable demo against a vulnerable spoofed IoT ecosystem which was fun to put together.