pandas, gdb and nvchad

by Joost Agterhoek — on  ,  ,  , 

cover-image

A whole month ain't that bad, right? Right?! Anyway, this post is like the previous post. Jotting down some things I have been doing and points I learned (or easily forget) for posterity.

NvChad and tmux

First things first: I am typing this post from a beautiful NvChad terminal! From the website, 'NvChad is a Lua-based Neovim config that provides solid defaults, a beautiful UI, and a highly customizable configuration'. And it absolutely does! With some fiddling and online soul searching, I got the following things working:

  • Popup terminals for compiling and executing code
  • Language Server Protocol (LSP) servers for Python (pyre) and C (clangd) that autostart and keep me coding on a straight line

And the cherry on top: I have started using tmux, the terminal multiplexer. It helps me with window and tab management, I can use vim motions for terminal output search (great for debugging) and have persistent work spaces. Learning (basic) vim motions before programming (I was using it for report writing and bare HTML website articles) made me hit the floor running when I started with Python. But bare Vim definitely is bare and required too much manual configuration for my knowledge and skill set. NvChad is a bit overwhelming to start out with, but by just configuring some key mappings and installing two LSP servers, I am gradually learning the lua syntax and the Neovim/NvChad approach to customization.

pandas

The data science and spreadsheet carving Python library pandas for me kind of felt like an actual panda: cute from a distance, but it's impossible to get it to move. That's a real problem with pandas, right? Anyway, that's what all my CSV and xlsx code snippets ended up like: a nice idea, some first DataFrame initialization, but when it came to doing someting useful with the data, I got stuck. Again. And. Again. Then, I did what I should have done quite some time ago: I read the documentation! Well, to be clear, I read some 'explain it like I'm 5' blog posts about the documentation. And that finally helped me understand things like:

  • The use of single and double square brackets to return a series or dataframe object, respectively
  • using pd.read_excel with the options sheet_name=None, keep_default_na=False and usecols to ingest data from specific columns across worksheets
  • Stuff all the interesting data into one empty DataFrame with pd.concat
  • Creating a dictionary of DataFrames with tkinter and glob
    • add in some actual code here for later reference

gdb

I actually wrote gcc in the title of this post, go figure. Shows what experience I really have with a debugger. So, talking about g d b, mainly in relation to the book Hacking: The Art of Exploitation. Back when I knew even less about programming, hacking and all that fun stuff, I innocently opened this book and thought 'this will be fun'! Instead, it was pain. But! Now that I'm a little bit more familiar with programming and some light reverse engineering (talk about pain), this book actually provides me the proper foundation to pursue my interest in malware (development and analysis): you learn C and learn to debug i.e. reverse engineer its binary outputs as well! So here are some quick beginner gdb notes I might come back to later on.

single short-hand selectors and display options

  • o - display in octal - display in base 8
  • x - display in hexadecimal - display in base 16
  • u - display in unsigned, standard base 10 decimal
  • t - display in binary
  • b - a single byte
  • h - a halfword which is 2 bytes in size
  • w - a word which is 4 bytes in size
  • g - a giant which is 8 bytes in size

example commands

  • i r eip - info register eip - memory address of EIP (instruction pointer) register
  • x/x $eip - examine one word (four bytes) in the memory the EIP register points to
  • x/1uw $eip - examine one word in the memory the EIP register points to in unsigned decimal notation
  • x/3i $eip - examine three instructions in the EIP register
  • nexti - next instruction
  • x/6cb - examine six bytes in ASCII
  • x/s memory address - display an entire string of ASCII character data Will add more :)