Saturday, 10 October 2020

Trouble logging in:


Check these files for login history & reason for login fails:

Useful guide on setting up an SFTP server

Monday, 23 September 2019

Slicing giant files

Use 'dd' to copy (in this case 3) blocks of data from the giant file to the output:

dd  if=giant.json count=3 of=output.json

trucate could also work.

For JSON jq is a great tool:

Here we are catting json and selecting entries with messages length > 0
cat ~/giant.json  | jq -cn --stream 'fromstream(1|truncate_stream(inputs))' | jq 'select((.messages | length) > 0)

Tuesday, 30 July 2019

Use of * in bash

Bash will parse and expand special args before your commands.

Hence echo * will list files in your dir like ls.

Consider the following interresting case copied from SO. A directory has these contents:
  • test (regular file)
  • test1 (directory)
  • test2 (directory)
  • test3 (directory)
If you then type `mv *` something seemingly weird happens: test3 is there, but the rest is gone. While weird at first, it makes sense once you understand what bash actually passes to `mv`. Because of the asterisk, bash interprets mv * as mv test test1 test2 test3, and when mv gets that list, it'll assume that the last arguement is the destination, which is where all of the files would've been moved.

Thursday, 20 June 2019

Clear up space, remove old ubuntu packages:

Clear up space, remove old ubuntu packages:

sudo apt-get update && sudo apt-get autoclean && sudo apt-get clean && sudo apt-get autoremove

Friday, 28 December 2018

Simple systemd / systemctl

A basic systemd file:




The file /home/andy/test must begin with: 
#!/bin/sh -
The core systemd commands: Not type systemctl not systemd
  • sudo systemctl status test       
  • sudo systemctl restart test
  • sudo systemctl stop test
For when you add something to: /etc/systemd/system
  • sudo systemctl daemon-reload     
Sending logs to syslog from services started by systemd:
Taken from here:
Use the following properties in your systemd service unit file:
SyslogIdentifier= # without any quote
Then, assuming your distribution is using rsyslog to manage syslogs, create a file in /etc/rsyslog.d/.conf with the following content:
if $programname == '' then /path/to/log/file.log
& stop
restart rsyslog (sudo systemctl restart rsyslog)

Monday, 5 March 2018

CTF notes

Notes on doing some CTFs:

How to setup Vbox:

Grab an ubuntu image from
user:  osboxes 

Inside your vmm, Install open ssh on your slave:
sudo apt-get install openssh-server

Open the right ports on host:
VBoxManage modifyvm asdf --natpf1 "ssh,tcp,,3022,,22"
ssh/sftp in:
ssh -p 3022 osboxes@
 sftp -P 3022 osboxes@

How to wget / curl:

curl url

wget posting data and saving/loading data to/from cookie

wget url --post-data="password=ee&user=hr" --save-cookies sc.txt
wget url --load-cookies=sc.txt

Also don't forget simple developer mode and google chrome.

Vulnerabilities check:

File Loading:

* Look for files that load other files or data
* Look for string replacing that can be bypassed


* Check for session state not being cleared properly.

File Execution:

* Check the execution path: Add things to the path.

Disassemble files:

* objdump -d  file > raw
* gdb file
  • r (run)
  • c (contine)
  • b X (breakpoint at function X)
  • si (step one place forwards)
  • info registers (what is in my registers

nginx configuration

server {
        listen 80;
        server_name_in_redirect off;
        root /srv/www/;
        access_log /srv/www/;
        error_log /srv/www/;
        rewrite  ^/$  /andyboot.html  permanent;
        rewrite ^/favicon.ico$ /img/favicon.ico last;
        # Dont expose hidden files to the web
        location ~ /\. {
                return 404;
I want to talk about my old nginx config file.
  • server_name = What urls it should listen to
  • root = where to serve static files from
  • rewrite = These are interesting - if a client asks for X we redirect them to Y instead. - Here it was used in a desperate attempt to get more SEO juice by redirecting / to my name.