Posts Tagged ‘Kali’

Kali Linux: history with date & time

Wednesday, August 9th, 2023

In the Linux basic module of OSCP, you’re asked to configure your shell in a way that the history commands always displays the date and the time when the command was run.

Such information is valuable as evidence so this configuration tweak is well worth it.

If you’re the impatient type you might turn to some search engines for some quick results and you will definitely get a lot of hits. None of which work.

Why? All (most, at least) are written for the bash shell.

However, nowadays (2023) the default shell in Kali Linux is zsh.

See for yourself: run ‘echo $SHELL’ in your terminal.

Similar to the bash shell with a ~/.bashrc file, there is a ~/.zshrc file. Open the file with less and search for ‘history’ cat | grep the file and you will that there is an alias defined for history: ‘history 0’ (the numbers modifies the returned history lines).

In many posts, the fc is referenced, including the -E switch – most of the mentioned switches do not work as outlined in the posts.

Finally, I came across the -li switch which not only works (as in ‘does not return “bad option”‘). And this option actually returns the date/time info of commands run in zsh.

What does that mean for you?

Simply add another alias at the end of the .zshrc file:

alias history=’fc -li 0′
(that’s a zero. if you don’t add it, the history command will only return the 16 latest entries in the history file)

Now you can move on to the next task in the OSCP course.

OSCP diary – week 06

Sunday, September 4th, 2022

Hrmpf…. Seems I forgot to write an update on week 05. In that case, I’ll have to summarize two weeks in this post.

I’m still studying buffer overflows, in particular Windows buffer overflows and trying to find my around the debugger that is installed on the offered Win10 virtual machine. I did some additional readings on other websites which explain the theory just as well if not even better.

One thing I can’t help noticing though is that the whole VPN thing is a drag. I get it, VPN is required. But I’m running Kali on Virtualbox, then I have to RDP into a Windows virtual machine. Yes, the recommendation is not to use Wi-Fi, but face it, in some rental places a wired connection might just not be possible.

The format of the OSCP website does not help much either. The notes column on the right side cannot be minimized but it takes up 25% of website’s width.

One problem that’s been bugging me for several weeks now was an update / upgrade problem with apt-get. I got an error message saying “file size is not as expected, mirror sync in progress?”

Looking this up, the solution seemed simple enough – replace the standard repo included in /etc/apt/sources.list with a mirror in your country as listed here:
http://http.kali.org/README.mirrorlist

Now this is where Murphy of Murphy’s Law comes in.

I picked one of the local mirrors, put it in the config files, ran apt-get clean and apt-get update again – but got the same error.

What happens in the background is that the default repo automatically forwards your connection to the fastest local mirror it can find. In my case, the mirror I accidentally put hard-coded into the config file. So, the main repo had a problem and the configured mirror as well. It almost drove me nuts and I was only able to solve by trying yet another mirror, carefully picked – a slower one on purpose. Then, finally apt-get update completed and I was able to catch up with a week’s worth of updates.

Blerg.

Nice to have this off my back, now I can get back to studying…