Useful links

I refile computer tips here (and other links) from my bookmarks.

Organizing Notes With Refile   emacs

To refile to a top-level heading use this trick

(setq org-refile-use-outline-path 'file)

captured on: [2018-07-24 Tue 20:29]

Mount qcow2 image   linux kvm qemu

This is a quick guide to mounting a qcow2 disk images on your host server. This is useful to reset passwords, edit files, or recover something without the virtual machine running.

#Step 1 - Enable NBD on the Host

modprobe nbd max_part=8

#Step 2 - Connect the QCOW2 as network block device

qemu-nbd --connect=/dev/nbd0 /var/lib/vz/images/100/vm-100-disk-1.qcow2

#Step 3 - Find The Virtual Machine Partitions

fdisk /dev/nbd0 -l

#Step 4 - Mount the partition from the VM

mount /dev/nbd0p1 /mnt/somepoint/

#Step 5 - After you done, unmount and disconnect

umount /mnt/somepoint/
qemu-nbd --disconnect /dev/nbd0
rmmod nbd

#In my case partition didn't receive its own, Fixed by running

partx -a /dev/nbd0

captured on: [2018-06-20 Wed 18:29]

Download lain 8bit tone   lain

ffmpeg -i Serial\ Experiments\ Lain\ \ Opening\ -\ Duvet\ \(8bit\)-N6Jn98ktFw0.mkv -ss 19 -vn -strict -2 -codec:a vorbis lain.ogg

captured on: [2017-12-25 Mon 15:28]

Evaluating Emacs commands in Common lisp   emacs lisp

So I can eval emacs commands and functions from common lisp using the swank function eval-in-emacs


This can be very helpful. Like getting the current emms track.

captured on: [2018-01-05 Fri 19:11]

Linux disable ip class 6   linux net

sudo sysctl -w net.ipv6.conf.all.disable_ipv6=1

captured on: [2018-01-07 Sun 21:15]

docker remove stopped containers   linux docker

docker rm $(docker ps -a -q) 

captured on: [2018-01-18 Thu 12:59]

change the background color   linux x

xsetroot -solid "#222222"

file:///home/vsts/.xinitrc#%20xsetroot%20-solid%20"#222222" captured on: [2018-01-19 Fri 16:38]

Apache docker fix sigwinch issue   apache docker

Just remove the -it option (interactive and pseudo tty). and this will work. captured on: [2018-01-21 Sun 14:37]

docker remove none images (with no name)   docker linux

docker rmi -f $(docker images -a|grep "<none>"|awk '$1=="<none>" {print $3}')

captured on: [2018-01-21 Sun 17:16]

Archive mailing lists from   linux emacs gnu wget

wget -N -nH -m

captured on: [2018-01-24 Wed 14:41]

mb2md on mailings lists from   emacs eshell

Welcome to the Emacs shell

~/work/1/s $ for file in emacs-devel/* {mb2md -s ~/archives/$file -d ~/Maildir/emacs-devel}

captured on: [2018-01-24 Wed 15:34]

Play pinknoise & brownnoise   sleep linux

This needs sox installed.

play -n synth brownnoise synth pinknoise mix synth sine amod 0.3 20

captured on: [2018-01-26 Fri 15:33]

Emacs org mode make tangled file executable with 755 file permissions   org emacs

:tangle-mode (identity #o755)

captured on: [2018-01-26 Fri 15:56]

Protect against arp poisoning attacks   linux networking

This protects against netcut and other tools like this

sudo arpon -i wlp3s0 -D

captured on: [2018-01-27 Sat 20:10]

Print certain pages from pdf using lp and pdftk   linux

pdftk 1501129577488.pdf cat 278-282 output /dev/stdout |lp -d "Canon_MP140_series"

captured on: [2018-02-01 Thu 10:04]

org mode change image width   org emacs

Have to reload inline images display for this to take place.

(setq org-image-actual-width 1100)

captured on: [2018-02-07 Wed 07:09]

python split string every nth character   python

[line[i:i+n] for i in range(0, len(line), n)]

captured on: [2018-02-11 Sun 18:05]

Stream audio using ncat and ffmpeg   linux stream ffmpeg

for i in Music/theLeSigh/*.mp3; do ffmpeg -hide_banner -loglevel panic  -re -i  "$i" -vn -c:a mp3 -f mp3 - < /dev/null; done |ncat -lk -p 8089

captured on: [2018-03-21 Wed 22:41]

man page number meanings   linux

    The standard sections of the manual include:

    1      User Commands
    2      System Calls
    3      C Library Functions
    4      Devices and Special Files
    5      File Formats and Conventions
    6      Games et. al.
    7      Miscellanea
    8      System Administration tools and Daemons

    Distributions customize the manual section to their specifics,
    which often include additional sections.

captured on: [2018-05-24 Thu 23:18]

P2P application using (E, Xor) as a metric set   toread

Emacs Lisp to automatically add, commit, and push when files change   emacs git

captured on: [2018-07-24 Tue 20:42]

Are makefiles Turing complete? - Stack Overflow   programming math

  • Note taken on [2018-07-01 Sun 12:42]
    so it turns out make files are turing complete, any language that can express a lambda function is turing complete, with Y-combinator you can make recursion.

captured on: [2018-07-01 Sun 12:42]

Yes, see this. Once you have lambda, it's all downhill from there.

Here is a plagiarized Fibonacci example

This should be enough to build a foundation for more generality (I've got to get back to work, or I'd play more.)

dec = $(patsubst .%,%,$1)

not = $(if $1,,.)

lteq = $(if $1,$(if $(findstring $1,$2),.,),.)
gteq = $(if $2,$(if $(findstring $2,$1),.,),.)
eq = $(and $(call lteq,$1,$2),$(call gteq,$1,$2))
lt = $(and $(call lteq,$1,$2),$(call not,$(call gteq,$1,$2)))

add = $1$2
sub = $(if $(call not,$2),$1,$(call sub,$(call dec,$1),$(call dec,$2)))
mul = $(if $(call not,$2),$2,$(call add,$1,$(call mul,$1,$(call dec,$2))))
fibo = $(if $(call lt,$1,..),$1,$(call add,$(call fibo,$(call dec,$1)),$(call fibo,$(call sub,$1,..))))
fact = $(if $(call lt,$1,..),.,$(call mul,$1,$(call fact,$(call dec,$1))))

numeral = $(words $(subst .,. ,$1))

go = $(or $(info $(call numeral,$(call mul,$1,$1)) $(call numeral,$(call fibo,$1)) $(call numeral,$(call fact,$1)) ),$(call go,.$1))

_ := $(call go,)

This prints out squares, fibonacci numbers and factorials. There appears to be a 16 bit limit on number sizes. Bummer.

bash - How to toggle xinput device prop - Ask Ubuntu   linux

captured on: [2018-02-01 Thu 06:46]

Toggle xinput device on or off with following bash script.


state=`xinput list-props "$device" | grep "Device Enabled" | grep -o "[01]$"`

if [ $state == '1' ];then
  xinput --disable $device
  xinput --enable $device

How to enable IP Forwarding in Linux - MDLog:/sysadmin   linux hacking networking

captured on: [2018-01-27 Sat 14:25]

sysctl -w net.ipv4.ip_forward=1

parameters - Skip download if files exist in wget? - Stack Overflow   linux wget

captured on: [2018-01-24 Wed 14:33]

The -nc, --no-clobber option isn't the best solution as newer files will not be downloaded. One should use -N instead which will download and overwrite the file only if the server has a newer version, so the correct answer is:

wget -N

Then running Wget with -N, with or without -r or -p, the decision as to whether or not to download a newer copy of a file depends on the local and remote timestamp and size of the file. -nc may not be specified at the same time as =-=N.

-N, --timestamping: Turn on time-stamping.

linux - How do I mirror a directory with wget without creating parent directories? - Stack Overflow   linux wget

captured on: [2018-01-24 Wed 14:30]

mirror without parent directory

For a path like:

-nH would download all files to the directory a/b/c/d in the current directory, and -nH --cut-dirs=3 would download all files to the directory d in the current directory.

Timeout a command in bash without unnecessary delay - Stack Overflow   linux

captured on: [2018-01-15 Mon 23:57]

( your\_command ) & pid=$! 
( sleep $TIMEOUT && kill -HUP $pid ) 2>/dev/null & watcher=$! 
wait $pid 2>/dev/null && pkill -HUP -P $watcher

antivirus - CLAMAV not working - Ask Ubuntu   linux

captured on: [2018-01-12 Fri 19:49]

The error message tells the tale: LibClamAV Error: cli_loaddbdir(): No supported database files found in /var/lib/clamav and Known viruses: 0

You need

clamav-freshclam - anti-virus utility for Unix - virus database update utility

Also ensure that user running the scan has read access to /var/lib/clamav.

mount - What is the fastest way to extract an ISO? - Unix & Linux Stack Exchange   linux

captured on: [2018-01-12 Fri 19:46]

you can do this by 7zip software:

sudo apt-get install p7zip-full

7z x iso_file.iso

on Fedora:

7za x iso_file.iso

Is IceCat that secure that I don't need the Tor Browser anymore? | Trisquel GNU/Linux - Run free!   privacy

captured on: [2017-12-21 Thu 23:36]

Q: is icecat replacement to tor browser ?

A: Allow to clarify.
RMS said he uses IceCat and Tor. Many people think that makes it OK. Well, maybe in a freedom perspective (one can argue that IceCat is more free than Firefox or Tor Browser, but from a user point of view they are the same). However from a security and privacy perspective, it is totally wrong.

Consider this: Tor hides your identity by making every user look the same. So, if you use a different browser (and there are many ways to know which browser you are using) you make yourself unique, and therefore easy to track and follow. I had already said that in another comment here in the forum.

Consider also this: the Tor Project has a team working on the Tor Browser everyday, to make it safe to use. You think they would spend resources like that if it was THAT easy? It's not. Browser fingerprint is a though subject and the Tor Browser has a lot of patches to make sure that you don't seem too unique. IceCat for example has LibreJS or whatever that is called. It is a MAJOR fingerprint issue. Maybe if everyone used it it would be ok, but as of right now I think not a lot of people do that.

Also consider this: Tor Browser has been aligning its releases with Firefox security releases to make sure that there are no open bugs an attacker might exploit. I don't know about IceCat release cycle, but check if they are fast enough putting out security updates.

Finally, I will have to advise everyone NOT to use IceCat with Tor, at least not if you need STRONG anonimity. If its just a matter of not wanting your ISP to know that you see funny cats online, that's ok. But the websites where you see funny cats have a good chance of knowing that its you. Well, at least knowing its the same person, even if they can't know who it is…

CPU frequency scaling - ArchWiki   linux

captured on: [2017-12-05 Tue 20:26]

How to scale, and what are scaling governors

Scaling governors

Governors (see table below) are power schemes for the CPU. Only one may be active at a time. For details, see the kernel documentation in the kernel source.

Governor Description
performance Run the CPU at the maximum frequency.
powersave Run the CPU at the minimum frequency.
userspace Run the CPU at user specified frequencies. p
ondemand Scales the frequency dynamically according to current load. Jumps to the highest frequency and then possibly back off as the idle time increases.
conservative Scales the frequency dynamically according to current load. Scales the begifrequency more gradually than ondemand.
schedutil Scheduler-driven CPU frequency selection,

Depending on the scaling driver, one of these governors will be loaded by default:

  • ondemand for AMD and older Intel CPU.
  • powersave for Intel CPUs using the intel_pstate driver (Sandy Bridge and newer).

Note: The intel_pstate driver supports only the performance and powersave governors, but they both provide dynamic scaling. The performance governor should give better power saving functionality than the old ondemand governor.

Warning: Use CPU monitoring tools (for temperatures, voltage, etc.) when changing the default governor.

To activate a particular governor, run:

# cpupower frequency-set -g governor


  • To adjust for only a single CPU core, append -c core_number to the command above.
  • Activating a governor requires that specific kernel module (named cpufreq_governor) is loaded. As of kernel 3.4, these modules are loaded automatically.

Alternatively, you can activate a governor on every available CPU manually:

# echo governor | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor >/dev/null

Tip: To monitor cpu speed in real time, run:

$ watch grep \"cpu MHz\" /proc/cpuinfo

Tuning the ondemand governor

See the kernel documentation for details.

Switching threshold

To set the threshold for stepping up to another frequency:

# echo -n percent > /sys/devices/system/cpu/cpufreq/<governor>/up_threshold

To set the threshold for stepping down to another frequency:

# echo -n percent > /sys/devices/system/cpu/cpufreq/<governor>/down_threshold

disable emacs asking following git symbolink   emacs

captured on: [2018-07-24 Tue 20:53]

Compile and link 32 program on 64 bit processor   programming lowlevel

This is the program from the PGU book:


.section .data

.section .text

.globl _start


        pushl $3
        pushl $2

        call power
        addl $8, %esp

        movl %eax, %ebx
        movl $1, %eax
        int $0x80

                pushl %ebp
                movl %esp, %ebp

                subl $4, %esp
                movl 8(%ebp), %ebx
                movl 12(%ebp), %ecx

                movl %ebx, -4(%ebp)

                        cmpl $1, %ecx
                        je end_power

                        movl -4(%ebp), %eax
                        imull %ebx, %eax
                        movl %eax, -4(%ebp)

                        decl %ecx

                        jmp power_loop_start

                        movl -4(%ebp), %eax
                        movl %ebp, %esp
                        popl %ebp

This will compile and link it

as --32 power.s -o power.o && ld -melf_i386 power.o -o power

captured on: [2018-07-27 Fri 18:23]

DONE The Jury Is In: Monolithic OS Design Is Flawed   toread

Stream ffmpeg using dash   linux

ffmpeg \
        -re \
        -loglevel error \
        -stream_loop -1 \
        -f concat \
        -safe 0 \
        -i /tmp/playlist \
        -vf "drawtext=\
                        text='%{gmtime\:%Y-%m-%d %T} UTC':\
                        fontsize=48" \
        -codec:v libx264 \
        -profile:v baseline \
        -pix_fmt yuv420p \
        -level 4 \
        -preset veryfast \
        -codec:a aac \
        -tune zerolatency \
        -f dash \
        -window_size 5 \
        -remove_at_exit 1 \

How to make a self-hosted video livestream | Drew DeVault’s Blog captured on: [2018-08-26 Sun 19:31]

Download phrack zines   linux

wget -r -np
find . -name "*.tar.gz" -exec sh -c 'mkdir $(basename {}|cut -d . -f 1); tar xvf {} -C $(basename {}|cut -d . -f 1)' \;

networking - How can I capture network traffic of a single process? - Ask Ubuntu   linux

captured on: [2019-01-02 Wed 15:31]

create a test network namespace:

ip netns add test

create a pair of virtual network interfaces (veth-a and veth-b):

ip link add veth-a type veth peer name veth-b

change the active namespace of the veth-a interface:

ip link set veth-a netns test

configure the IP addresses of the virtual interfaces:

ip netns exec test ifconfig veth-a up netmask
ifconfig veth-b up netmask

configure the routing in the test namespace:

ip netns exec test route add default gw dev veth-a

activate ip\forward and establish a NAT rule to forward the traffic coming in from the namespace you created (you have to adjust the network interface and SNAT ip address):

echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -t nat -A POSTROUTING -s -o <your internet interface, e.g. eth0> -j SNAT --to-source <your ip address>

(You can also use the MASQUERADE rule if you prefer)

finally, you can run the process you want to analyze in the new namespace, and wireshark too:

ip netns exec test thebinarytotest
ip netns exec test wireshark

You'll have to monitor the veth-a interface.

How to Resize a qcow2 Image and Filesystem with Virt-Resize : FATMIN   linux qemu

captured on: [2018-12-24 Mon 19:39]

Binary Hacking Course - LiveOverflow   hacking

captured on: [2018-12-27 Thu 15:02]

Crackmes   hacking

captured on: [2018-12-26 Wed 11:08]   crypto

captured on: [2018-12-25 Tue 22:56]

FactHacks: Introduction   crypto

captured on: [2018-12-25 Tue 22:53]

Convert Word to PDF. Documents DOC to PDF   COMPUTER

captured on: [2018-12-25 Tue 16:49]

OverTheWire: Wargames   hacking

captured on: [2018-12-25 Tue 14:42]

SE-Niveau Ingénieur - Lilia SFAXI - Enseignement   study

captured on: [2018-12-24 Mon 13:00]

Stefan Hajnoczi: QEMU Internals: How guest physical RAM works   qemu linux

captured on: [2018-12-24 Mon 12:58]

stack probing | The Infinite Loop   hacking linux

captured on: [2018-12-21 Fri 22:38]

Designing Lispy DSLs, part 1: SCSS | More magic   lisp programming

captured on: [2018-10-31 Wed 23:37]

Speculative execution - Wikipedia   study

captured on: [2018-10-25 Thu 23:02]

Michael Orlitzky { Fixing KVM (QEMU) keymaps }   emacs qemu

captured on: [2018-09-17 Mon 20:58]

Why adding bugs to software can make it safer - MIT Technology Review   hacking

captured on: [2018-09-09 Sun 14:29]


captured on: [2018-09-05 Wed 14:02] - Everything you want to know about x86 microcode, but might have been afraid to ask   hacking

captured on: [2018-09-04 Tue 23:53]

How to read from an EEPROM | Pen Test Partners   hacking

captured on: [2018-09-04 Tue 23:19]

TODO A military technique for falling asleep in two minutes   toread

Gödel's Lost Letter and P=NP | a personal view of the theory of computation   programming math toread crime

captured on: [2018-09-03 Mon 08:12]

How do I set up X11 forwarding?   linux x11

X11 forwarding on windows machines using ssh captured on: [2018-07-18 Wed 16:02]

Why your programmers just want to code – Maker to Manager – Medium

ichbins/ichbins.scm at master · darius/ichbins

Why the GPL sucks | Sealed Abstract


Learn Lisp The Hard Way : lisp

QEMU Escape — vmescape from 0CTF 2017 Finals Writeup - Eadom's Blog

How to Solve Any Dynamic Programming Problem – Pramp

Literate programming: Knuth is doing it wrong

0x5f3759df | Hummus and Magnets

Nietzsche and Capitalism : philosophy

Play my snes music   linux

needs ffmpeg compiled with libgme

find /part2/Down/spcsets/ -regex "^.*\.spc$" |shuf |while read line; do mpv "$line"; done;

captured on: [2019-01-05 Sat 20:12]

PHP Filters read source code of file   web hacking php


captured on: [2019-02-05 Tue 10:46]

php filters RFI   hacking


captured on: [2019-02-05 Tue 11:22]

Regenerate certificates for   linux

docker run -it -v $(pwd)/certs:/etc/letsencrypt -v $(pwd)/certs-data:/var/lib/letsencrypt deliverous/certbot certonly --webroot --webroot-path=/var/lib/letsencrypt -d -d

captured on: [2019-02-16 Sat 17:53]

DONE Newark Academy CTF 2019 Super Duper AES team hackstreetboys   toread

  • The permutation and substitution functions will always be reversible for block ciphers especially if they are known.
  • The vulnerability lies with the lack of key passed during encryption.
    • The number of rounds used during encryption would be irrelevant since the ciphertext produced without a key wouldn’t really be “random” enough.

DONE CTFZone 2019 Quals OCB2 team zero cost abstractions   toread

DONE CTFZone 2019 Quals Windows Secrets team !soBad   toread

DONE m0leCon CTF 2019 OOP Admin Panel team BullSoc   toread

DONE CTFZone 2019 Quals Classifier9000 team p4   toread

DONE The C language is purely functional (2009)   toread software

DONE Debugging Firmware with GDB   toread hacking

DONE Creating and Using a Custom Linux Kernel on Guix System   toread linux

Author: Mohamed Aziz Knani

Date: 2020-05-19 Tue 03:11

Emacs 25.2.2 (Org mode 9.3.6)


hacker emblem