I've been playing around with a little python game from SANS called pyWars. It's a python based CTF game that has various python challenges. It came with the SEC 573 course I took earlier in the year and I am just now finally getting some time to play with it.
While playing, I decided to make every answer to each challenge a function then call the function to submit the answer. In doing this I realized that when you're writing functions over and over it can become tedious to type out the entire function definition over and over.
After some mild complaining in Slack, one of my buddy epi mentioned User Snippets and gave me an example of one for a Python function, which I am going to share with you today. I had not heard of these wonderful things until today. I this would be great to share this as my first actual post on hashnode.
Open VSCode and navigate -> Preferences -> User Snippets
Once you click User Snippets you'll see a command pallet style window pop up. VSCode allows you to make these user snippet definitions for a variety of languages.
This will open a familiar text editor window and allow you to configure your user snippet.
Here is a solid reference for creating your first user snippet for VSCode. We're just going to create a basic one to assist with Python function definitions.
Now lets test! Once we return to our script we are going to call the user snippet with
space and type out
That is going to drop the template for the function that we just created into the script and this is where it gets pretty awesome. As you fill in the portions of your script you can move through the different sections with the tab key. This makes it super fast to knock out the template for a function.
And there we have it, a quick user snippet that might save you a little bit of time when you're writing your script. These can be used in any language supported by VSCode.
Additional Reading: epi's blog
Credit for the Cover: Here
I enjoy computers and computer security. I have set a goal for myself to focus more on software development and engineering. I am planning on blogging about DFIR, Security and Python development.