Linux CLI tricks

Send a string to an IP/port telnet 80 (echo hello; sleep 1) | telnet 80 echo hello > /dev/tcp/ References uptime The three load average values are 1, 5 and 15 minutes. $ uptime 15:29:28 up 20:23, 0 users, load average: 5.08, 1.49, 0.51 stress Stress your system in different ways. $ stress --cpu 8 Number of processors $ make -j $(nproc) Synonyms for localhost localhost 127. [Read More]

Resetting a forgotten Windows password

When you’ve misplaced the password to a local Windows account. Seen to work on Windows 2000, 7 and 10. Prerequisites: a 4GB USB stick and a machine capable of creating a USB boot disk (Ubuntu is good). Time to complete: half an hour to download Kali and create the stick and a few minutes to reset a password. Download the latest Kali Linux ISO and create a USB boot disk on another machine. [Read More]

Network analysis

On the Linux command line

For the purposes of this exercise we’re not employing any nefarious means to gain access to packets. Generally Ethernet switches attempt to intelligently direct packets to only the intended host so an ordinary machine sat on a subnet will only receive its own packets and broadcasts. But unsolicited broadcasts will at least show you some other active IPs on the network. You want to get “in the way” of as much data as possible so if you can run these tests on the router then even better. [Read More]

Create a Twitter bot

Using twurl and Google Cloud

Prerequisites: a Twitter account, moderate command line and Google Cloud experience. Time to complete: a couple of hours. Alternatively you might consider GitLab hosting. Developer account Apply for a Twitter dev account, create an app and make a note of the two API keys. Keep them to yourself. Google Cloud hosting Create the smallest (and cheapest) Linux instance on Google Cloud. Installation Connect to your instance and install the essentials. [Read More]

Generate a network topology

From a hosts file

tracehost is a bash script that parses a standard hosts files and generates an SVG. The script accepts a standard system hosts file format but actually it only cares about the first host or IP on a line. In fact any line format may be used as long as each line begins with something that can be pinged. localhost # for local people - google # Zero waste The image below is generated as a daily GitLab cron job. [Read More]

Turbo charge your bash prompt

Bash prompt variables The escape characters that can appear in the bash prompt are well-documented so let’s not cover that in any detail. But a good starting point is the “user@host:dir” combo, which conveniently is also the scp syntax. PS1="\u@\h:\w $ " root@kali:/tmp $ Variables described in the bash documentation: PS1 - The primary prompt string. The default value is ‘\s-\v\$ ’. PS0 - The value of this parameter is expanded like PS1 and displayed by interactive shells after reading a command and before the command is executed. [Read More]

Parsing WAV files

In alternative languages

What does a WAV header look like? Inspect the hex with xxd, a WAV header is 42 bytes and is then followed by the sample data. xxd example.wav | head -10 00000000: 5249 4646 2400 0080 5741 5645 666d 7420 RIFF$...WAVEfmt 00000010: 1000 0000 0100 0100 d007 0000 a00f 0000 ................ 00000020: 0100 1000 6461 7461 0000 0080 0000 4582 00000030: e2d0 126c 9e57 c4b4 308c d41f be7f 0a10 . [Read More]