HOWTO
commandline misc
- backup imap with offlineimap:
[general] accounts = Test [Account Test] localrepository = LocalExample remoterepository = RemoteExample [Repository LocalExample] type = Maildir localfolders = ~/Test [Repository RemoteExample] type = IMAP remotehost = xxxxx.co.uk ssl = yes remoteuser = xxxxx@xxxxx.co.uk
-
beep
beep mute is in alsamixer
-
WPA
wpa_passphrase essid passphrase > /etc/wpa_supplicant.conf
wpa_supplicant -B -c/etc/wpa_supplicant.conf -iwlan0
-
text to pdf
e2ps -nh diana.txt > diana.ps
ps2pdf diana.ps
very small, landscape:
e2ps -nh -l -size 1 diana.txt > diana.ps
-
grep in binary file (treat binary as ascii)
grep -a purl
-
most recent// and head
ls -t Wiki/images | head
-
use of watch as in:
watch --no-title --interval=5 "curl -Is slashdot.org | egrep '^X-(F|B)' | cut -d - -f 2"
watch tail /var/log/messages
-
redirection of STDERR = 2> :
./stego -e -t ~/projects/steganographia/island.txt ~/projects/steganographia/island.txt testout 2> tttt
for file in `ls *`; do cat $file | text2wave -o $file ; done
wget -c // to resume
gpsbabel -t -i garmin -f /dev/ttyUSB0 -o gpx -F gpsfile.gpx
rsync -av --delete /root/ /media/rsync
-
git:
git pull
git checkout -f master ;; to overwrite all local changes
git diff
./readrng -d /dev/ttyUSB0 -q 512 :: to fill entropy buffer for /dev/random
gocr cuc1.png > cucumber_screen6 OCR
modprobe snd-pcm-oss
lsof -r 1 -i :22 // who is there?
xawtv-remote snap jpeg 320x240 xxx.jpeg
echo "sensor_fps:30" > /proc/cpia/video0
network/data forensics
kismet -c wlan0
tcpdump -s 0 -A
-
tcpreplay and driftnet
airdecap-ng Kismet-Sep-25-2009-12.pcapdump
tcpreplay -t -i lo Kismet-Sep-25-2009-12.pcapdump-dec
driftnet -i lo
-
raw sniff in scapy
pkts = sniff(prn=lambda x:sys.stdout.write(str(x)))
tcpdump -s 0 -w - | devdisplay 240 100 1 // raw packets
tcpdump -s 0 -w - | tee pipe > /dev/dsp & ; cat pipe | devdisplay 240 240 2
which could equally well be:
tcpdump -s 0 -w - | tee /dev/dsp | devdisplay 240 240 2
tcpflow -i eth0 // dumps reconstruction/tcpfollowed also with -C or -cg
shell//scripting
-
zsh number substitution
scp images_2/p10508{06..14}.* katier@192.168.1.12:/home/katier/Desktop/udk/ -
sort in numerical:
ls xyz*([0-9]*).jpg | nawk -F'xyz' '{print $NF, $0}' | sort -n | cut -d ' ' -f2- -
one liner:
for file in `ls *.jpeg`; do gocr $file done > ghost_out
- fix for new lines:
#!/bin/sh
tmpIFS=$IFS
IFS=$'\n'
for file in `ls *.mp3`
do
new=`basename $file .wav`
sox $file ${new}.wav
done
IFS=$tmpIFS
-
one-liner
while true; do mplayer /root/dump/test.wav -ao jack done
- rawify
#!/bin/sh
for file in `ls *.wav`
do
new=`basename $file .wav`
sox $file -r 8000 -u -b -c 1 ${new}.raw
done
- shuffle
#!/bin/sh
for file in `ls`
do
new=$RANDOM.${file}
mv $file $new
done
-
and to use to cutup audio:
./rawify.sh // convert to raw (8000 samples p/s)
split -a 4 -d -b 8000 ../full_exq.raw // split into 1 second fragments pref in new dir
./shuffle.sh // shuffle these
cat * > fulllll // cat these
sox -t raw -r 8000 -u -b -c 1 fulllll full.wav // back to wav
- evp-shell
#!/bin/sh
for file in `ls *.wav`
do
new=`basename $file .wav`
sox $file -r 44100 -u -b -c 1 trans${new}.raw
cat trans${new}.raw | evp 8 32 400000 0 > evp${new}.raw
sox -r 44100 -u -b -c 1 -v 0.5 evp${new}.raw evp${new}.wav
rm *.raw
done
- speaks files from list
#!/bin/sh cat test_sed2 | while read line do flite $line done
- rotate all images:
#!/bin/bash for img in `ls *.jpg` do convert -rotate -90 $img rr$img done
-
concatenate wav files
sox *.wav (or list) concat.wav
sed/awk
-
adding up wordcounts:
awk '{sum+=$1} END{printf("%d\n",sum)}' testwc
other/tbd
extract one gps track from gpx:
1] open in gpsman (running as xxxxx)
2] import gpx
3] got to data/track/export/gpx/select
learning python
own example code:
potential projects -
mode+v:
natural language:
scapy: sniffeur.py
M-; - comment/uncomment region
emacs/gnus/mew/org-mode
mew
- now using mew instead of gnus:
- in .emacs
(autoload 'mew "mew" nil t)
(autoload 'mew-send "mew" nil t)
;; Optional setup (e.g. C-xm for sending a message):
(autoload 'mew-user-agent-compose "mew" nil t)
(if (boundp 'mail-user-agent)
(setq mail-user-agent 'mew-user-agent))
(if (fboundp 'define-mail-user-agent)
(define-mail-user-agent
'mew-user-agent
'mew-user-agent-compose
'mew-draft-send-message
'mew-draft-kill
'mew-send-hook))
(setq mew-use-master-passwd t)
(autoload 'bbdb-insinuate-mew "bbdb-mew" "Hook BBDB into Mew")
(add-hook 'mew-init-hook 'bbdb-insinuate-mew)
(setq bbdb-send-mail-style 'mew)
(setq sc-auto-fill-region-p t)
(setq mew-smtp-user "user@domain")
(setq mew-smtp-server "server")
(setq mew-smtp-auth-list '("LOGIN")) ; "CRAM-MD5", "PLAIN", and "LOGIN" can be used
and customize mew-field-completion-switch: ("To:" bbdb-complete-name)
-
to send an attachment/ make a multipart message:
C-c C-a
and then c to copy file in
-
to read an attachment:
n and then C-c C-e
org2hpda
comment out loading twit.el in .emacs and then run (from ~/buff/hip)
make -f org2hpda
registers
C-x r s reg - copy region to register reg
C-x r i reg - insert region from register reg
also numbers in registers (handy for keyboard macros):
C-u num C-x r n reg - store number in register
C-x r + reg - increment
C-x r g reg - insert
twit.el
(load "~/buff/twit.el") (twit-show-recent-tweets) (twit-follow-recent-tweets)
org-mode/org-babel
C-c C-c on headline to add tags
C-c \ C-c / m
Create a sparse tree with all headlines matching a tags search. With a C-u prefix argument, ignore headlines that are not a TODO line.
LaTex, org-mode and pdfjam/pdfnup
- how to prepare a 2x2 A0 PDF using org-mode and pdfnup
- prepare tex using org-mode:
# Local Variables: # org-export-latex-append-header: "\ # \\usepackage{geometry} # \\geometry{verbose,a2paper} # " # End:is placed at the end of the org-mode file and we use:
M-x normal-mode
to re-read the local variables
then export C-c C-e to PDF as usual.
-
now we have A2 PDF which we can place four sheets on one page with:
pdfnup island_forpdf.pdf --nup 2x2
- which gives us an A2 PDF also but with a grid of 2x2 pages on each page.
- enlarge to A0 using acroread, print to file and custom size
and to embed fonts:
# Local Variables:
# org-export-latex-append-header: "\
# \\usepackage{geometry}
# \\usepackage{times}
# \\usepackage{pslatex}
# \\geometry{verbose,a2paper}
# "
# End:
and see also:
latex embed pdf etc notes
- how to embed bmp images
NOT! - convert to pdf/png
- how to make page breaks
embed:
\begin{test} \pagebreak \end{test} - how to embed other pdfs
#+ATTR_LaTeX: page=4,width=5cm [[file:stegsx.pdf]]
or
with
\\usepackage{pdfpages}\includepdf[pages=1-8]{/root/projects/magnetometer/protonmagnetometer.pdf}
notes for org-mode and agendas
for use with agenda - C-c a - can have several org-mode files into agenda
eg.
C-c . - add date as below and it takes title from:
C-c a n - whole year
- other commands
-
Shift-arrows to change date elements
M-S RET - insert TODO item
C-c C-d - insert deadline
C-c [ - add file to agenda list
C-c ] - remove file
C-c C-t - toggle status of TODO
-
Shift-arrows to change date elements
- commands
v - view mode (eg. week, month, year, insert diary entries)
RET - goto relevant org file
ange-ft format
/newlife@ftp.1010.co.uk:/user/htdocs/1010/
jack.el notes
- fixed and uploaded new jack.el
(jack-start)
run also: jack_simple_client as fake and disconnect all
while true; do mplayer /root/dump/test.wav -ao jack:port=simple,name=monk done
to prevent straight connection mplayer
(jack-list)
(jack-ports "monk")
(jack-get-port-connections "monk" 0) ????
bibtex, bibliography and org-mode
\bibliographystyle{plain}
\bibliography{notes}
… is at the end of the document
We also need the following in .emacs:
(defun org-mode-reftex-setup ()
(load-library "reftex")
(and (buffer-file-name)
(file-exists-p (buffer-file-name))
(reftex-parse-all))
(define-key org-mode-map (kbd "C-c )") 'reftex-citation)
)
(add-hook 'org-mode-hook 'org-mode-reftex-setup)
(require 'org-exp-bibtex)
(require 'org-latex)
(setq org-export-latex-classes
(cons '("article"
"\\documentclass{article}
\\usepackage{amsmath}
\\usepackage{amssymb}
\\usepackage{longtable}
\\usepackage{float}
\\usepackage{wrapfig}
\\usepackage{soul}
\\usepackage{hyperref}"
("\\section{%s}" . "\\section*{%s}")
("\\subsection{%s}" . "\\subsection*{%s}")
("\\subsubsection{%s}" . "\\subsubsection*{%s}")
("\\paragraph{%s}" . "\\paragraph*{%s}")
("\\subparagraph{%s}" . "\\subparagraph*{%s}"))
org-export-latex-classes))
(setq org-latex-to-pdf-process
'("pdflatex -interaction nonstopmode %b"
"bibtex %b"
"pdflatex -interaction nonstopmode %b"
"pdflatex -interaction nonstopmode %b"))
An example from notes.bib:
@Book{pynchon1966,
author = {Pynchon, Thomas},
title = {The Crying of Lot 49},
publisher = {Lippincott},
year = {1966},
address = {Philadelphia},
isbn = {0397004184}
}
which we can cite with: C-c C-)
rest notes
#+LaTeX: \setlength\parskip{5mm} // for spacing between paragraphs
C-u 0 C-l - puts line to top of screen
C-x C-f /ftp:newlife@1010.co.uk:/
(make-comint "sniff" "/root/sniffeur.py")
M-x image-dired-dired-display-image
C-x C- - = - smaller and larger fonts
Gnus: T T - turn off threading
C-c C-s C-d - gnus summary sort by date
flush the agent cache M-x gnus-agent-flush-cache RET M-x gnus-agent-expire[-group] RET
avr
avrdude -c usbasp -p m168 -U lfuse:w:0xE2:m -U hfuse:w:0xDF:m -U flash:w:sd-reader.hex
avrdude -c usbasp -p m128 -U lfuse:w:0xFD:m -U hfuse:w:0x99:m -U efuse:w:0xFF:m -U flash:w:serialtest.hex
set up latest avr-gcc
- later than avr-libc-1.6.3 has
:clock_prescale_set(clock_div_1);
- see: http://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&t=42631&postdays=0&postorder=asc
for the scripts to download and patch:
sudo apt-get install build-essential texinfo texi2html libcwidget-dev tcl8.4-dev tk8.4-dev libncurses5-dev libx11-dev binutils-dev bison flex libusb-0.1-4 libusb-dev libmpfr-dev libexpat1-dev libbfd-dev
./getfiles.sh
./get-patches.sh
./buildavr-no-insight.sh
and in .zshrc:
# User specific environment and startup programs PREFIX=/usr/local/avr export PREFIX PATH=$PATH:$HOME/bin:$PREFIX/bin export PATH
avr notes
(0 << [anything]) is always 0. T
The usual way to reset invidual bits in a control register is actually along the lines of:
USBCON &= ~(1 << [bit_name]);
deeper AVR
compile and linking of assembly to elf
avr-gcc -Os -mmcu=atmega8 -Wa,-gstabs -I/usr/lib/avr/include/avr/ -o test.elf test.S
elf to hex:
avr-objcopy -j .text -j .data -O ihex test.elf test.hex
disassembly (use this to get linked full assembly!):
avr-objdump -S test.elf
(if we compile with -g // debugging // and not -Os (for size optimisation)??)
avr-gcc -g -mmcu=atmega8 -I/usr/lib/avr/include/avr/ memtest.c -o memtest.elf
also to note:
avr-gcc -g -mmcu=atmega8 -Wl,-Map,demo.map -o demo.elf demo.o
__exit->endless loop.
26c: ff cf rjmp .-2 ; 0x26c <__stop_program>
flash/rom sections
- The .text Section
The .text section contains the actual machine instructions which make up your program. Includes:
- The .initN Sections
init code
- The .finiN Sections
exit code
- The .finiN Sections
- The .data Section
This section contains static data which was defined in your code.
- The .bss Section
Uninitialized global or static variables end up in the .bss section. Includes:
- The .noinit Section
- The .noinit Section
- The .eeprom Section
- avr-size
The avr-size program (part of binutils), coming from a Unix background, doesn't account for the .data initialization space added to the .text section, so in order to know how much flash the final program will consume, one needs to add the values for both, .text and .data (but not .bss), while the amount of pre-allocated SRAM is the sum of .data and .bss.
- malloc?
The variables __malloc_heap_start and __malloc_heap_end can be used to restrict the malloc() function to a certain memory region. These variables are statically initialized to point to __heap_start and __heap_end, respectively, where __heap_start is filled in by the linker to point just beyond .bss, and __heap_end is set to 0 which makes malloc() assume the heap is below the stack.
- what is the heap?
The standard RAM layout is to place .data variables first, from the beginning of the internal RAM, followed by .bss. The stack is started from the top of internal RAM, growing downwards. The so-called "heap" available for the dynamic memory allocator will be placed beyond the end of .bss.
- note from scrying makefile:
EXTERNAL_RAM = -Wl,-Tdata=0x801100,–defsym=__heap_end=0x80ffff
and we use memory pointer directly from 1100 - how do we avoid writing over variables (in serialtest.c case).
- TODO test serialtest code in scrying
in new code - also PORTE is set strangely (for gplog to 0x00 , for main log to 0xff)
same in noise2.c where we write to 1100+ and don't set PORTE
possible answer as using:
avr-size noise2.o
we see:
text data bss dec hex filename 8336 4 10 8350 209e noise2.o
how can we see what is in data and bss (-s switch)?
avr-objdump -sh -S noise2.o
gives:
0000 0ad7233c
but in the case of serialtest.o we have 621 bytes of data which is all text messages (for help and so on) which we know doesn't get overwritten???
only conclusion is that data segment is not moved by Makefile (or possibility that as it is stored in ROM/FLASH????)
- what is the heap?
registers
scrying
use serial board with diode bypassed for charging
Remember to delay before we switch Trimble Lassen SQ to NMEA
Ref also: http://www.picbasic.co.uk/forum/archive/index.php/t-1260.html
mercurial
hg ci - commit
hg clone - clone external repo
-
other commands
hg diff - show changes
hg log - show all revisions
hg diff -r 335 -r 338 - diffs between revisions
hg export 338 337 336 > exportage - export patch
kernel
kernel config
make-kpkg clean
fakeroot make-kpkg --revision=custom.1.0 kernel_image
dpkg -i kernel-image-2.6.8.1_custom.1.0_i386.deb
update-initramfs -c -k 2.6.30 -t
cd /boot/grub/
uname -r for running kernel version
add latest initrd to menu.lst
uml [user mode linux]
apt-get install user-mode-linux uml-utilities
linux rootfstype=hostfs rw init=/bin/zsh
custom kernel
make mrproper
make mrproper ARCH=um
make defconfig ARCH=um
make menuconfig ARCH=um
make ARCH=um
or
export ARCH=um
dvd
-
kino - capture, export as dvd-video dual pass (dvd video directory)
mkisofs -dvd-video -o juego.iso juego
mplayer/gstreamer
mencoder input.avi -idx -ovc copy -oac copy -o output.avi // fix broken indexing
seek to 1000 (seconds?) and convert 10 frames:
mplayer -ss 1000 -frames 10 -vo jpeg:outdir=/tmp:quality=75 test.avi -ao null
-
raw:
gst-launch-0.10 filesrc location=/root/pipe ! videoparse ! xvimagesink
-
or in mplayer:
mplayer -rawvideo w=720:h=576 -demuxer rawvideo /dev/sda
gst-launch-0.10 v4l2src device=/dev/video1 ! queue ! ffmpegcolorspace ! theoraenc quality=1 ! queue ! oggmux name=mux alsasrc ! audio/x-raw-int,rate=8000,channels=1,depth=8 ! queue ! audioconvert ! vorbisenc ! queue ! mux. mux. ! queue ! shout2send ip=giss.tv port=8000 username=source password=ry92b mount=/micro.ogg
mencoder mf://"@list.txt" -mf w=800:h=600:fps=10:type=jpg -ovc lavc \ -lavcopts vcodec=mpeg4:mbd=2:trell -oac copy -o output.avi
mencoder input.avi -idx -ovc copy -oac copy -o output.avi // fix broken indexing
gst-launch-0.10 filesrc location=/root/pipe ! videoparse ! xvimagesink
mplayer -rawvideo w=720:h=576 -demuxer rawvideo /dev/sda
-
record stream:
mplayer -dumpstream -cache 8000 mms://streaming-26c3-wmv.fem-net.de/saal3
data carving
-
using foremost to extract:
foremost -v /dev/sdc1
config file is in: /usr/local/etc/foremost.conf
paper sizes ref
cm //inches
ISO A0 84.09 x 118.92 33.11 x 46.82
ISO A1 59.46 x 84.09 23.41 x 33.11
ISO A2 42.04 x 59.46 16.55 x 23.41
playing with images in octave
rough notes/example code
imshow(0,gray) # to set grayscale???
x=getpgm("../page1_trith_003.pgm");
q = 6 ./ hilb(16) + 26
y = jpeg(x, q); # from jpegtools
imagesc(y, 2);
saveimage ("my_output.ps",y,ps);
myfile = fopen("../diana.txt", "r");
al = fread(myfile,[8,8],'uchar')'; # read as 8x8 matrix
QTx = quant(x, al);
diana = imread('../diana.pgm');
function [Stego, Extracted] = LSBHide(Cover, Hidden, n)
Stego = uint8(bitor(bitand(Cover, bitcmp(2^n - 1, 8)) , bitshift(Hidden, n - 8)));
Extracted = uint8(bitand(255, bitshift(Stego, 8 - n)));
endfunction
[Stego, Extracted] = LSBHide(xxx, xxxxx, n);
shell scripting with octave
- for rough image analysis (white vs. black pixels):
- image_an.m
filename=argv();
pkg load image;
#disp(filename{1});
xx=imread(filename{1});
img = rgb2gray(xx);
ibw = img;
m=128;
disp(numel(ibw (ibw < m )))
- analyse.sh
#!/bin/bash for file in `ls *.jpg` do octave -qf image_an.m $file done
notes for (island2) gallery setup
avoid screen blanking
xset s off
and edit /etc/X11/xorg.conf and restart X:
Section "ServerFlags" Option "BlankTime" "0" Option "StandbyTime" "0" Option "SuspendTime" "0" Option "OffTime" "0" EndSection
startx on boot without any login
- edit /etc/inittab with:
id:5:initdefault: [...] x:5:once:/bin/su PREFERED_USER -l -c "/bin/bash --login -c /usr/bin/startx >/dev/null 2>&1"
misc
- .xinitrc example: machine 1
xset s off xmodmap /root/.Xmodmap exec awesome & exec xterm -maximized -exec watch tail /var/log/syslog & sleep 4s exec xterm -exec top & exec xterm -exec /root/test.sh
machine 1 is now running minicom… (usb serial must be plugged in before booting)
- .xinitrc example: machine 2
killall -9 evilwm xset s off exec evilwm & exec wireshark -i eth5 -f "icmp" -k & sleep 20s exec xterm -geometry 80x20+0+0 -exec minicom
- open an xterm with dmesg showing but not closing - sleep for 1000 days
#!/bin/bash dmesg sleep 1000d
- edit /etc/rc.local for other post-boot options
/etc/network/interfaces
- for dhcp
# The loopback network interface auto lo iface lo inet loopback # The primary network interface - use DHCP to find our address auto eth0 iface eth0 inet dhcp
- for static
# The loopback network interface auto lo iface lo inet loopback # The primary network interface auto eth0 iface eth0 inet static address 192.168.1.90 gateway 192.168.1.1 netmask 255.255.255.0 network 192.168.1.0 broadcast 192.168.1.255
arpspoof
with address of switch:
arpspoof -i eth0 192.168.1.1
tcpdump
tcpdump -s 0 -w - icmp> /dev/dsp
both in /etc/rc.local
wireshark with ringbuffer
wireshark -i eth5 -f "icmp" -k -w test -b files:10 -b duration:10
mini-scry filesystem for SD cards
mkfs.vfat -F 16 /dev/mmcblk0p1
gnuplot tricks
-
multiple plots and colours
set multiplot set style line 1 linecolor rgb "green" plot "whitenoise06022010.log" w lines ls 1
fixing a hard drive
with errors
sudo e2fsck -b 32768 /dev/sdb1
sudo mount -t ext3 -o sb=131072 /dev/sdb1 /mnt
avrdude and efuse on atmega32u4
change avrdude.conf:
memory "efuse"
size = 1;
write = "1 0 1 0 1 1 0 0 1 0 1 0 0 1 0 0",
"x x x x x x x x i i i i i i i i";
read = "0 1 0 1 0 0 0 0 0 0 0 0 1 0 0 0",
"x x x x x x x x o o o o o o o o";
min_write_delay = 9000;
max_write_delay = 9000;
;
code rocks
- five acts USE OLD KERNEL
own software:
- older
jekyll-
i_am-
/dev/mem | strings | espeak --stdout | ./i_am 4 2 1 > /dev/dsp
- more recent
evp-
cat /dev/dsp | ./evp 1 32 8000 1 > ~/pipe play -t raw -r 8000 -u -b -c 1 pipe
self-
commandline
-
tee:
tcpdump -s 0 -w - | tee /dev/dsp | devdisplay 240 240 2
-
turn off swap
swapoff -a
-
play a pipe
play -t raw -r 44100 -u -b -c 1 pipe
for example from:
nice -n -10 top -d.1 | tee pipe
[for top always use 44100]
top commands:
A,M,N,P,T - alt display, sort by memory, PID, CPU, time
k - prompt to kill a PID
-
espeak:
cat /dev/mem | strings | espeak --stdout > /dev/dsp
or for correct speech:
cat /dev/mem | strings | espeak --stdout > ~/pipe play -t raw -r 22050 -u -1 -c 1 pipe
maybe insert evp process in there
-
dev/mem// use of tee for multiple processes
cat /dev/mem | tee >(devdisplay 240 240 1) | strings | espeak --stdout | ./jekyll 2 3 > /
rock
stty -F /dev/ttyUSB0 115200
set list
START: stty, swapoff, old kernel
swapoff -a stty -F /dev/ttyUSB0 115200
5 acts:
1- process table and xxxx….sh yyyyy….sh
nice -n -10 top -d.1 | tee pipe play -t raw -r 44100 -u -b -c 1 pipe
also with: A,M,N,P,T - alt display, sort by memory, PID, CPU, time (and G for group)
2- evp/i_am/speech somehow
cat /dev/mem | strings | espeak --stdout > /dev/dsp play -t raw -r 44100 -u -b -c 1 pipe
3- self
./self > /dev/dsp
4- code rocks
cat /dev/mem > /dev/ttyUSB0 cat /dev/ttyUSB0 > /dev/dsp
5- rock off:
cat /dev/mem > /dev/ttyUSB0 cat /dev/ttyUSB0 | tee /dev/dsp > /dev/mem
Date: 2010-07-23 17:17:01 BST
HTML generated by org-mode 6.31trans in emacs 23